20#include <Eigen/Sparse>
33 using IndexType = Eigen::SparseMatrix<double>::Index;
62 std::vector<double>
get(std::vector<IndexType>
const& indices)
const
64 std::vector<double> local_x;
65 local_x.reserve(indices.size());
67 transform(cbegin(indices), cend(indices), back_inserter(local_x),
68 [&](
auto const i) {
return vec_[i]; });
62 std::vector<double>
get(std::vector<IndexType>
const& indices)
const {
…}
80 template <
class T_SUBVEC>
81 void set(
const std::vector<IndexType>& pos,
const T_SUBVEC& sub_vec)
83 auto const length = pos.size();
84 for (std::size_t i = 0; i < length; ++i)
86 set(pos[i], sub_vec[i]);
81 void set(
const std::vector<IndexType>& pos,
const T_SUBVEC& sub_vec) {
…}
91 template <
class T_SUBVEC>
92 void add(
const std::vector<IndexType>& pos,
const T_SUBVEC& sub_vec)
94 auto const length = pos.size();
95 for (std::size_t i = 0; i < length; ++i)
97 add(pos[i], sub_vec[i]);
92 void add(
const std::vector<IndexType>& pos,
const T_SUBVEC& sub_vec) {
…}
113 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