24template <
typename Matrix>
26 Eigen::MatrixXd::Index rows,
27 Eigen::MatrixXd::Index cols)
29 static_assert(Matrix::IsRowMajor || Matrix::IsVectorAtCompileTime,
30 "The default storage order in OGS is row major storage for "
32 assert(Matrix::RowsAtCompileTime == Eigen::Dynamic ||
33 Matrix::RowsAtCompileTime == rows);
34 assert(Matrix::ColsAtCompileTime == Eigen::Dynamic ||
35 Matrix::ColsAtCompileTime == cols);
38 data.resize(rows * cols);
39 return {data.data(), rows, cols};
49 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>
51 Eigen::MatrixXd::Index rows,
52 Eigen::MatrixXd::Index cols)
55 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>(
64template <
typename Matrix>
65Eigen::Map<const Matrix>
toMatrix(std::vector<double>
const& data,
66 Eigen::MatrixXd::Index rows,
67 Eigen::MatrixXd::Index cols)
69 static_assert(Matrix::IsRowMajor || Matrix::IsVectorAtCompileTime,
70 "The default storage order in OGS is row major storage for "
72 assert(Matrix::RowsAtCompileTime == Eigen::Dynamic ||
73 Matrix::RowsAtCompileTime == rows);
74 assert(Matrix::ColsAtCompileTime == Eigen::Dynamic ||
75 Matrix::ColsAtCompileTime == cols);
76 assert(
static_cast<Eigen::MatrixXd::Index
>(data.size()) == rows * cols);
78 return {data.data(), rows, cols};
88 Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>
90 Eigen::MatrixXd::Index rows,
91 Eigen::MatrixXd::Index cols)
94 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>(
103template <
typename Matrix>
104Eigen::Map<Matrix>
toMatrix(std::vector<double>& data,
105 Eigen::MatrixXd::Index rows,
106 Eigen::MatrixXd::Index cols)
108 static_assert(Matrix::IsRowMajor || Matrix::IsVectorAtCompileTime,
109 "The default storage order in OGS is row major storage for "
111 assert(Matrix::RowsAtCompileTime == Eigen::Dynamic ||
112 Matrix::RowsAtCompileTime == rows);
113 assert(Matrix::ColsAtCompileTime == Eigen::Dynamic ||
114 Matrix::ColsAtCompileTime == cols);
115 assert(
static_cast<Eigen::MatrixXd::Index
>(data.size()) == rows * cols);
117 return {data.data(), rows, cols};
126 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>
128 Eigen::MatrixXd::Index rows,
129 Eigen::MatrixXd::Index cols)
132 Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>(
145template <
typename Vector>
147 Eigen::VectorXd::Index size)
149 static_assert(Vector::IsVectorAtCompileTime,
"A vector type is required.");
150 assert(Vector::SizeAtCompileTime == Eigen::Dynamic ||
151 Vector::SizeAtCompileTime == size);
152 assert(data.empty());
155 return {data.data(), size};
159template <
typename Vector>
160Eigen::Map<const Vector>
toVector(std::vector<double>
const& data,
161 Eigen::VectorXd::Index size)
163 static_assert(Vector::IsVectorAtCompileTime,
"A vector type is required.");
164 assert(Vector::SizeAtCompileTime == Eigen::Dynamic ||
165 Vector::SizeAtCompileTime == size);
166 assert(
static_cast<Eigen::VectorXd::Index
>(data.size()) == size);
168 return {data.data(), size};
172template <
typename Vector>
173Eigen::Map<Vector>
toVector(std::vector<double>& data,
174 Eigen::VectorXd::Index size)
176 static_assert(Vector::IsVectorAtCompileTime,
"A vector type is required.");
177 assert(Vector::SizeAtCompileTime == Eigen::Dynamic ||
178 Vector::SizeAtCompileTime == size);
179 assert(
static_cast<Eigen::VectorXd::Index
>(data.size()) == size);
181 return {data.data(), size};
190 std::vector<double>
const& data)
192 return {data.data(),
static_cast<Eigen::VectorXd::Index
>(data.size())};
200inline Eigen::Map<Eigen::VectorXd>
toVector(std::vector<double>& data)
202 return {data.data(),
static_cast<Eigen::VectorXd::Index
>(data.size())};
Eigen::Map< Vector > createZeroedVector(std::vector< double > &data, Eigen::VectorXd::Index size)
Eigen::Map< const Vector > toVector(std::vector< double > const &data, Eigen::VectorXd::Index size)
Creates an Eigen mapped vector from the given data vector.
Eigen::Map< Matrix > createZeroedMatrix(std::vector< double > &data, Eigen::MatrixXd::Index rows, Eigen::MatrixXd::Index cols)
Eigen::Map< const Matrix > toMatrix(std::vector< double > const &data, Eigen::MatrixXd::Index rows, Eigen::MatrixXd::Index cols)