19#include <Eigen/Sparse>
32 using IndexType = Eigen::SparseMatrix<double>::Index;
61 std::vector<double>
get(std::vector<IndexType>
const& indices)
const
63 std::vector<double> local_x;
64 local_x.reserve(indices.size());
66 transform(cbegin(indices), cend(indices), back_inserter(local_x),
67 [&](
auto const i) {
return vec_[i]; });
79 template <
class T_SUBVEC>
80 void set(
const std::vector<IndexType>& pos,
const T_SUBVEC& sub_vec)
82 auto const length = pos.size();
83 for (std::size_t i = 0; i < length; ++i)
85 set(pos[i], sub_vec[i]);
90 template <
class T_SUBVEC>
91 void add(
const std::vector<IndexType>& pos,
const T_SUBVEC& sub_vec)
93 auto const length = pos.size();
94 for (std::size_t i = 0; i < length; ++i)
96 add(pos[i], sub_vec[i]);
107 void write(
const std::string& filename)
const;
Global vector based on Eigen vector.
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