preCICE
v3.1.2
Loading...
Searching...
No Matches
src
utils
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
8
#include "
EigenHelperFunctions.hpp
"
9
10
namespace
precice::utils
{
11
12
void
shiftSetFirst
(
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
22
void
appendFront
(
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
38
void
removeColumnFromMatrix
(
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
48
void
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
EigenHelperFunctions.hpp
PRECICE_ASSERT
#define PRECICE_ASSERT(...)
Definition
assertion.hpp:87
precice::utils
contains precice-related utilities.
Definition
PointToPointCommunicationTest.cpp:23
precice::utils::removeColumnFromMatrix
void removeColumnFromMatrix(Eigen::MatrixXd &A, int col)
Definition
EigenHelperFunctions.cpp:38
precice::utils::appendFront
void appendFront(Eigen::MatrixXd &A, Eigen::VectorXd &v)
Definition
EigenHelperFunctions.cpp:22
precice::utils::append
void append(Eigen::VectorXd &v, double value)
Definition
EigenHelperFunctions.cpp:48
precice::utils::shiftSetFirst
void shiftSetFirst(Eigen::MatrixXd &A, const Eigen::VectorXd &v)
Definition
EigenHelperFunctions.cpp:12