void System::rhs_combined(const state_t &state, state_t & out, double time) { assert(out.size() == dim*(dim+1)); rhs(state, out, time); jac(ublas::subrange(state,0,dim), jacobian, time, dfdt); for (int i=1; i<out.size() / dim ; i++) { auto st = ublas::subrange(state,dim*i,dim*(i+1)); ublas::subrange(out, dim*i, dim*(i+1)) = ublas::prod(jacobian, st); } }
void Rossler::jac(const_it_t &state, state_t & out, double time) { assert(out.size() == dim*dim); auto it = out.begin(); it[0] = 0; it[1] = -1; it[2] = -1; it += dim; it[0] = 1; it[1] = a; it[2] = 0; it += dim; it[0] = state[2]; it[1] = 0; it[2] = state[0]-c; }
space_partition(state_t const& st, operator_t const& H, bool store_matrix_elements = true) : subspaces(st.size()), tmp_state(make_zero_state(st)) { auto size = tmp_state.size(); // Iteration over all initial basis states for (index_t i = 0; i < size; ++i) { tmp_state(i) = amplitude_t(1.0); state_t final_state = H(tmp_state); // Iterate over non-zero final amplitudes foreach(final_state, [&](index_t f, amplitude_t amplitude) { if (triqs::utility::is_zero(amplitude)) return; auto i_subspace = subspaces.find_set(i); auto f_subspace = subspaces.find_set(f); if (i_subspace != f_subspace) subspaces.link(i_subspace, f_subspace); if (store_matrix_elements) matrix_elements[std::make_pair(i, f)] = amplitude; }); tmp_state(i) = amplitude_t(0.); } _update_index(); }
float f(const state_t& x) { f_eval_count ++; return x.squaredNorm() / static_cast<float>(x.size()); }