19 #include <Eigen/Eigen>
20 #include <Eigen/Sparse>
33 using IndexType = Eigen::SparseMatrix<double>::Index;
65 std::vector<double>
get(std::vector<IndexType>
const& indices)
const
67 std::vector<double> local_x;
68 local_x.reserve(indices.size());
70 transform(cbegin(indices), cend(indices), back_inserter(local_x),
71 [&](
auto const i) {
return vec_[i]; });
83 template <
class T_SUBVEC>
84 void add(
const std::vector<IndexType>& pos,
const T_SUBVEC& sub_vec)
86 auto const length = pos.size();
87 for (std::size_t i = 0; i < length; ++i)
89 add(pos[i], sub_vec[i]);
96 assert(u.size() == (std::size_t)
vec_.size());
97 copy_n(
vec_.data(),
vec_.size(), u.begin());
102 void write(
const std::string& filename)
const
104 std::ofstream os(filename);
Global vector based on Eigen vector.
double const & operator[](IndexType rowId) const
access entry
IndexType getRangeEnd() const
return an end index of the active data range
void copyValues(std::vector< double > &u) const
Copy vector values.
void add(IndexType rowId, double v)
add entry
double & operator[](IndexType rowId)
IndexType size() const
return a vector length
double get(IndexType rowId) const
get entry
void set(IndexType rowId, double v)
set entry
EigenVector(EigenVector const &src)=default
copy constructor
RawVectorType & getRawVector()
return a raw Eigen vector object
Eigen::VectorXd RawVectorType
EigenVector(IndexType length)
void add(const std::vector< IndexType > &pos, const T_SUBVEC &sub_vec)
add entries
const RawVectorType & getRawVector() const
return a raw Eigen vector object
Eigen::SparseMatrix< double >::Index IndexType
void write(const std::string &filename) const
printout this equation for debugging
std::vector< double > get(std::vector< IndexType > const &indices) const
get entries
static constexpr IndexType getRangeBegin()
return a start index of the active data range