13#include <Eigen/Sparse>
26 using IndexType = Eigen::SparseMatrix<double>::Index;
55 std::vector<double>
get(std::vector<IndexType>
const& indices)
const
57 std::vector<double> local_x;
58 local_x.reserve(indices.size());
60 transform(cbegin(indices), cend(indices), back_inserter(local_x),
61 [&](
auto const i) {
return vec_[i]; });
73 template <
class T_SUBVEC>
74 void set(
const std::vector<IndexType>& pos,
const T_SUBVEC& sub_vec)
76 auto const length = pos.size();
77 for (std::size_t i = 0; i < length; ++i)
79 set(pos[i], sub_vec[i]);
84 template <
class T_SUBVEC>
85 void add(
const std::vector<IndexType>& pos,
const T_SUBVEC& sub_vec)
87 auto const length = pos.size();
88 for (std::size_t i = 0; i < length; ++i)
90 add(pos[i], sub_vec[i]);
106 void write(
const std::string& filename)
const;
IndexType getRangeEnd() const
return an end index of the active data range
void copyValues(std::vector< double > &u) const
void add(IndexType rowId, double v)
add entry
IndexType size() const
return a vector length
double get(IndexType rowId) const
get entry
void set(IndexType rowId, double v)
set entry
void set(const std::vector< IndexType > &pos, const T_SUBVEC &sub_vec)
set entries
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
double & operator[](IndexType rowId)
RawVectorType & getRawVector()
return a raw Eigen vector object
double const & operator[](IndexType rowId) const
access entry
std::vector< double > get(std::vector< IndexType > const &indices) const
get entries
Eigen::SparseMatrix< double >::Index IndexType
void write(const std::string &filename) const
write this vector to a file for debugging
static constexpr IndexType getRangeBegin()
return a start index of the active data range