21 std::vector<double>
const vals(values);
22 std::vector<PETScVector::IndexType> idcs(vals.size());
23 std::iota(idcs.begin(), idcs.end(), 0);
45 auto const rows = tmp.rows();
46 auto const cols = tmp.cols();
51 std::vector<IndexType> row_idcs(rows);
52 std::vector<IndexType> col_idcs(cols);
54 std::iota(row_idcs.begin(), row_idcs.end(), 0);
55 std::iota(col_idcs.begin(), col_idcs.end(), 0);
58 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>
61 m.
add(row_idcs, col_idcs, tmp_);
71 assert((IndexType)values.size() == rows * cols);
73 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> tmp(
76 auto it = values.begin();
77 for (IndexType
r = 0;
r < rows; ++
r)
79 for (IndexType c = 0; c < cols; ++c)
85 std::vector<IndexType> row_idcs(rows);
86 std::vector<IndexType> col_idcs(cols);
88 std::iota(row_idcs.begin(), row_idcs.end(), 0);
89 std::iota(col_idcs.begin(), col_idcs.end(), 0);
91 m.
add(row_idcs, col_idcs, tmp);
108 auto& w =
v.getRawVector();
109 assert((std::size_t)
v.size() == values.size());
110 auto it = values.begin();
111 for (std::size_t i = 0; i < values.size(); ++i)
121 v.getRawVector()[index] = value;
126 auto const rows = m.getNumberOfRows();
127 auto const cols = m.getNumberOfColumns();
130 Eigen::MatrixXd tmp(rows, cols);
132 auto it = values.begin();
141 m.getRawMatrix() = tmp.sparseView();
146 m.getRawMatrix() = tmp.sparseView();
151 auto const rows = m.getNumberOfRows();
152 auto const cols = m.getNumberOfColumns();
155 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> tmp(
158 auto it = values.begin();
167 m.getRawMatrix() += tmp.sparseView();
GlobalMatrix::IndexType GlobalIndexType
RawMatrixType::Index IndexType
Global vector based on Eigen vector.
Wrapper class for PETSc matrix routines for matrix.
PetscInt getNumberOfColumns() const
Get the number of columns.
void setZero()
Set all entries to zero.
void add(const PetscInt i, const PetscInt j, const PetscScalar value)
Add value to a single entry.
PetscInt getNumberOfRows() const
Get the number of rows.
Wrapper class for PETSc vector.
void addToMatrix(PETScMatrix &m, std::initializer_list< double > values)
void setVector(PETScVector &v, std::initializer_list< double > values)
void setMatrix(PETScMatrix &m, std::initializer_list< double > values)