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

Functions

Eigen::Vector3d at (const FieldMatrixd &mat, Index_t i)
Eigen::Vector3d at (const FieldMatrixd &mat, Index_t row, Index_t col)
void set (FieldMatrixd &mat, Index_t i, const Eigen::Vector3d &vec)
void set (FieldMatrixd &mat, Index_t row, Index_t col, const Eigen::Vector3d &vec)
Index_t numPoints (const FieldMatrixd &mat)
void appendVector3D (FieldMatrixd &mat, const Eigen::Vector3d &vec)
void deleteColumnAt (FieldMatrixd &mat, Index_t j)
void normalizeRow (FieldMatrixd &mat, Index_t i)

Function Documentation

◆ appendVector3D()

void gpr::coord::appendVector3D ( FieldMatrixd & mat,
const Eigen::Vector3d & vec )
inline

Definition at line 151 of file EigenHelpers.h.

152{
153 Eigen::Index oldCols = mat.cols();
154 Eigen::Index ni = mat.rows() > 0 ? mat.rows() : 1;
155 Eigen::Index nj = oldCols + 3;
156
157 FieldMatrixd tmp = mat;
158 mat.resize(ni, nj);
159 mat.setZero();
160
161 // Copy old data
162 if (tmp.size() > 0) {
163 mat.block(0, 0, tmp.rows(), tmp.cols()) = tmp;
164 }
165
166 // Write new vector for each row
167 for (Eigen::Index i = 0; i < ni; ++i) {
168 set(mat, static_cast<Index_t>(i), static_cast<Index_t>(oldCols / 3),
169 vec);
170 }
171}
void set(FieldMatrixd &mat, Index_t i, const Eigen::Vector3d &vec)
uint32_t Index_t
Definition Macros.h:17
Eigen::Matrix< double, EigenDynamic, EigenDynamic, FieldMatrixStorage > FieldMatrixd
Definition Macros.h:25

◆ at() [1/2]

Eigen::Vector3d gpr::coord::at ( const FieldMatrixd & mat,
Index_t i )
inline

Definition at line 113 of file EigenHelpers.h.

114{
115 const double* p = mat.data() + 3 * static_cast<Eigen::Index>(i);
116 return Eigen::Vector3d(p[0], p[1], p[2]);
117}

◆ at() [2/2]

Eigen::Vector3d gpr::coord::at ( const FieldMatrixd & mat,
Index_t row,
Index_t col )
inline

Definition at line 119 of file EigenHelpers.h.

120{
121 Eigen::Index idx = 3 * static_cast<Eigen::Index>(col) +
122 mat.cols() * static_cast<Eigen::Index>(row);
123 const double* p = mat.data() + idx;
124 return Eigen::Vector3d(p[0], p[1], p[2]);
125}

◆ deleteColumnAt()

void gpr::coord::deleteColumnAt ( FieldMatrixd & mat,
Index_t j )
inline

Definition at line 173 of file EigenHelpers.h.

174{
175 field::deleteColumn(mat, 3 * static_cast<Eigen::Index>(j) + 2);
176 field::deleteColumn(mat, 3 * static_cast<Eigen::Index>(j) + 1);
177 field::deleteColumn(mat, 3 * static_cast<Eigen::Index>(j));
178}
void deleteColumn(Eigen::PlainObjectBase< Derived > &mat, Eigen::Index j)

◆ normalizeRow()

void gpr::coord::normalizeRow ( FieldMatrixd & mat,
Index_t i )
inline

Definition at line 180 of file EigenHelpers.h.

181{
182 double norm = 0.;
183 Index_t npts = numPoints(mat);
184 for (Index_t j = 0; j < npts; ++j) {
185 Eigen::Vector3d v = at(mat, i, j);
186 norm += v.dot(v);
187 }
188 norm = std::sqrt(norm);
189 double norm_rec = 1. / norm;
190 for (Eigen::Index n = 0; n < mat.size(); ++n) {
191 *(mat.data() + n) *= norm_rec;
192 }
193}
Eigen::Vector3d at(const FieldMatrixd &mat, Index_t i)
Index_t numPoints(const FieldMatrixd &mat)

◆ numPoints()

Index_t gpr::coord::numPoints ( const FieldMatrixd & mat)
inline

Definition at line 146 of file EigenHelpers.h.

147{
148 return static_cast<Index_t>(mat.size() / 3);
149}

◆ set() [1/2]

void gpr::coord::set ( FieldMatrixd & mat,
Index_t i,
const Eigen::Vector3d & vec )
inline

Definition at line 127 of file EigenHelpers.h.

128{
129 double* p = mat.data() + 3 * static_cast<Eigen::Index>(i);
130 p[0] = vec(0);
131 p[1] = vec(1);
132 p[2] = vec(2);
133}

◆ set() [2/2]

void gpr::coord::set ( FieldMatrixd & mat,
Index_t row,
Index_t col,
const Eigen::Vector3d & vec )
inline

Definition at line 135 of file EigenHelpers.h.

137{
138 Eigen::Index idx = 3 * static_cast<Eigen::Index>(col) +
139 mat.cols() * static_cast<Eigen::Index>(row);
140 double* p = mat.data() + idx;
141 p[0] = vec(0);
142 p[1] = vec(1);
143 p[2] = vec(2);
144}