preCICE v3.1.1
Loading...
Searching...
No Matches
EigenHelperFunctions.cpp
Go to the documentation of this file.
1/*
2 * EigenHelperFunctions.cpp
3 *
4 * Created on: Dec 9, 2015
5 * Author: scheufks
6 */
7
9
10namespace precice::utils {
11
13 Eigen::MatrixXd &A, const Eigen::VectorXd &v)
14{
15 PRECICE_ASSERT(v.size() == A.rows(), v.size(), A.rows());
16 // A.bottomRightCorner(n, m - 1) = A.topLeftCorner(n, m - 1);
17 for (auto i = A.cols() - 1; i > 0; i--)
18 A.col(i) = A.col(i - 1);
19 A.col(0) = v;
20}
21
23 Eigen::MatrixXd &A, Eigen::VectorXd &v)
24{
25 int n = A.rows(), m = A.cols();
26 if (n <= 0 && m <= 0) {
27 A = v;
28 } else {
29 PRECICE_ASSERT(v.size() == n, v.size(), A.rows());
30 A.conservativeResize(n, m + 1);
31 //A.topRightCorner(n, m) = A.topLeftCorner(n, m); // bad error, reason unknown!
32 for (auto i = A.cols() - 1; i > 0; i--)
33 A.col(i) = A.col(i - 1);
34 A.col(0) = v;
35 }
36}
37
39 Eigen::MatrixXd &A, int col)
40{
41 PRECICE_ASSERT(col < A.cols() && col >= 0, col, A.cols());
42 for (int j = col; j < A.cols() - 1; j++)
43 A.col(j) = A.col(j + 1);
44
45 A.conservativeResize(A.rows(), A.cols() - 1);
46}
47
48void append(
49 Eigen::VectorXd &v,
50 double value)
51{
52 int n = v.size();
53 v.conservativeResize(n + 1);
54 v(n) = value;
55}
56
57} // namespace precice::utils
#define PRECICE_ASSERT(...)
Definition assertion.hpp:87
contains precice-related utilities.
void removeColumnFromMatrix(Eigen::MatrixXd &A, int col)
void appendFront(Eigen::MatrixXd &A, Eigen::VectorXd &v)
void append(Eigen::VectorXd &v, double value)
void shiftSetFirst(Eigen::MatrixXd &A, const Eigen::VectorXd &v)