Loading...
Searching...
No Matches
gpr::field Namespace Reference

Functions

template<typename Derived>
void appendRows (Eigen::PlainObjectBase< Derived > &mat, const Eigen::PlainObjectBase< Derived > &other)
template<typename Derived>
void appendRow (Eigen::PlainObjectBase< Derived > &mat, const Eigen::PlainObjectBase< Derived > &other, Eigen::Index i)
template<typename Derived>
void appendScalarAsRow (Eigen::PlainObjectBase< Derived > &mat, typename Derived::Scalar value)
template<typename Derived>
void deleteRow (Eigen::PlainObjectBase< Derived > &mat, Eigen::Index i)
template<typename Derived>
void deleteColumn (Eigen::PlainObjectBase< Derived > &mat, Eigen::Index j)
template<typename Derived>
void appendVector (Eigen::PlainObjectBase< Derived > &mat, const Eigen::VectorXd &vec)
template<typename DerivedA, typename DerivedB>
double flatDot (const Eigen::MatrixBase< DerivedA > &a, const Eigen::MatrixBase< DerivedB > &b)

Function Documentation

◆ appendRow()

template<typename Derived>
void gpr::field::appendRow ( Eigen::PlainObjectBase< Derived > & mat,
const Eigen::PlainObjectBase< Derived > & other,
Eigen::Index i )
inline

Definition at line 31 of file EigenHelpers.h.

34{
35 if (mat.size() == 0) {
36 mat.resize(1, other.cols());
37 mat.row(0) = other.row(i);
38 return;
39 }
40 const Eigen::Index oldRows = mat.rows();
41 mat.conservativeResize(oldRows + 1, mat.cols());
42 mat.row(oldRows) = other.row(i);
43}

◆ appendRows()

template<typename Derived>
void gpr::field::appendRows ( Eigen::PlainObjectBase< Derived > & mat,
const Eigen::PlainObjectBase< Derived > & other )
inline

Definition at line 17 of file EigenHelpers.h.

19{
20 if (other.rows() == 0) return;
21 if (mat.size() == 0) {
22 mat = other;
23 return;
24 }
25 const Eigen::Index oldRows = mat.rows();
26 mat.conservativeResize(oldRows + other.rows(), mat.cols());
27 mat.bottomRows(other.rows()) = other;
28}

◆ appendScalarAsRow()

template<typename Derived>
void gpr::field::appendScalarAsRow ( Eigen::PlainObjectBase< Derived > & mat,
typename Derived::Scalar value )
inline

Definition at line 46 of file EigenHelpers.h.

48{
49 const Eigen::Index oldRows = mat.rows();
50 mat.conservativeResize(oldRows + 1, mat.cols());
51 mat.row(oldRows).setConstant(value);
52}

◆ appendVector()

template<typename Derived>
void gpr::field::appendVector ( Eigen::PlainObjectBase< Derived > & mat,
const Eigen::VectorXd & vec )
inline

Definition at line 81 of file EigenHelpers.h.

83{
84 if (mat.size() == 0) {
85 mat.resize(1, vec.size());
86 for (Eigen::Index n = 0; n < vec.size(); ++n)
87 mat(0, n) = vec(n);
88 return;
89 }
90 const Eigen::Index oldRows = mat.rows();
91 mat.conservativeResize(oldRows + 1, mat.cols());
92 for (Eigen::Index n = 0; n < mat.cols(); ++n)
93 mat(oldRows, n) = vec(n);
94}

◆ deleteColumn()

template<typename Derived>
void gpr::field::deleteColumn ( Eigen::PlainObjectBase< Derived > & mat,
Eigen::Index j )
inline

Definition at line 68 of file EigenHelpers.h.

69{
70 if (mat.cols() == 0) return;
71 const Eigen::Index rows = mat.rows();
72 const Eigen::Index cols = mat.cols();
73 if (j < cols - 1) {
74 mat.block(0, j, rows, cols - j - 1) =
75 mat.block(0, j + 1, rows, cols - j - 1);
76 }
77 mat.conservativeResize(rows, cols - 1);
78}

◆ deleteRow()

template<typename Derived>
void gpr::field::deleteRow ( Eigen::PlainObjectBase< Derived > & mat,
Eigen::Index i )
inline

Definition at line 55 of file EigenHelpers.h.

56{
57 if (mat.rows() == 0) return;
58 const Eigen::Index rows = mat.rows();
59 const Eigen::Index cols = mat.cols();
60 if (i < rows - 1) {
61 mat.block(i, 0, rows - i - 1, cols) =
62 mat.block(i + 1, 0, rows - i - 1, cols);
63 }
64 mat.conservativeResize(rows - 1, cols);
65}

◆ flatDot()

template<typename DerivedA, typename DerivedB>
double gpr::field::flatDot ( const Eigen::MatrixBase< DerivedA > & a,
const Eigen::MatrixBase< DerivedB > & b )
inline

Flat dot product: treat a FieldMatrixd as a 1-D vector and compute dot(a, b).

Definition at line 99 of file EigenHelpers.h.

101{
102 return Eigen::Map<const Eigen::VectorXd>(a.derived().data(), a.size())
103 .dot(Eigen::Map<const Eigen::VectorXd>(b.derived().data(), b.size()));
104}