49 #ifndef MsqHessian_hpp
50 #define MsqHessian_hpp
54 #include "PatchData.hpp"
59 #ifdef MSQ_USE_OLD_IO_HEADERS
68 class ObjectiveFunction;
105 void initialize(PatchData &pd, MsqError &err);
131 if (
mSize==0)
return;
154 Matrix3D*
const &mat3d_array, MsqError &err)
158 "Cannot accumulate elements from a different patch. "
159 "Use MsqHessian::initialize first.",
164 size_t nve = pd.get_element_array(err)[elem_index].vertex_count();
165 const size_t nb_mat3d = (nve+1)*nve/2;
170 for (i = 0; i < nb_mat3d; ++
i) {
188 const MsqHessian &H,
const Vector3D x[],
size_t size_x,
189 const Vector3D y[],
size_t size_y, MsqError &)
191 if ((size_r != H.mSize) || (size_x != H.mSize) ||
192 (size_y != H.mSize && size_y != 0)) {
197 size_t* col = H.mColIndex;
198 const size_t nn = H.mSize;
206 for (i = 0; i < nn; ++
i) {
211 for (i = 0; i < nn; ++
i) {
217 for (i = 0; i < nn; ++
i) {
218 rl = H.mRowStart[i+1] - H.mRowStart[
i];
223 eqAx(tmpm, H.mEntries[el], tmpx);
227 for (j = 1; j < rl; ++
j) {
230 plusEqAx(tmpm, H.mEntries[el], x[c]);
246 for (m=0; m<
mSize; ++m) {
247 #ifdef DIAGONAL_PRECONDITIONER
254 zloc[m][0] = rloc[m][0];
264 zloc[m][2] = zloc[m][2];
283 for (c=mRowStart[i]; c<mRowStart[i+1]; ++c) {
295 msq_stdio::ostream&
operator<<(msq_stdio::ostream &
s,
const MsqHessian &h);
299 #endif // MsqHessian_hpp
void accumulate_entries(PatchData &pd, const size_t &elem_index, Matrix3D *const &mat3d_array, MsqError &err)
void zero()
Sets all entries to zero (more efficient than assignement).
void int int REAL REAL * y
Used to hold the error state and return it to the application.
void apply_preconditioner(Vector3D zloc[], Vector3D rloc[], MsqError &err)
void plusEqAx(Vector3D &v, const Matrix3D &A, const Vector3D &x)
void axpy(Vector3D res[], size_t size_r, const MsqHessian &H, const Vector3D x[], size_t size_x, const Vector3D y[], size_t size_y, MsqError &)
size_t * mAccumElemStart
Starting index in mAccumulation for element i, i=1,...
void plusEqTransAx(Vector3D &v, const Matrix3D &A, const Vector3D &x)
Vector3D is the object that effeciently stores information about about three-deminsional vectors...
void compute_preconditioner(MsqError &err)
Vector3D is the object that effeciently stores the objective function Hessian each entry is a Matrix3...
Vector3D * mZ
array used in the CG solver
size_t maxCGiter
max nb of iterations of the CG solver.
invalid function argument passed
void plus_transpose_equal(const Matrix3D &B)
NVec< 3, double > Vector3D
size_t mSize
number of rows (or number of columns, this is a square matrix).
3*3 Matric class, row-oriented, 0-based [i][j] indexing.
void cg_solver(Vector3D x[], Vector3D b[], MsqError &err)
#define MSQ_SETERR(err)
Macro to set error - use err.clear() to clear.
Vector3D * mR
array used in the CG solver
friend void axpy(Vector3D res[], size_t size_r, const MsqHessian &H, const Vector3D x[], size_t size_x, const Vector3D y[], size_t size_y, MsqError &err)
Hessian - vector product, summed with a second vector (optional).
Vector3D * mW
array used in the CG solver
size_t * mColIndex
CSR block structure: column indexes of the row entries.
Matrix3D * mEntries
CSR block entries. size: nb of nonzero blocks, i.e. mRowStart[mSize] .
MsqMeshEntity * patchElemArray
stored once during initialization for
void initialize(PatchData &pd, MsqError &err)
creates a sparse structure for a Hessian, based on the connectivity information contained in the Patc...
msq_stdio::ostream & operator<<(msq_stdio::ostream &s, const Matrix3D &A)
friend msq_stdio::ostream & operator<<(msq_stdio::ostream &, const MsqHessian &)
Prints out the MsqHessian blocks.
size_t * mRowStart
start of each row in mEntries. size: nb of vertices (mSize).
void get_diagonal_blocks(msq_std::vector< Matrix3D > &diag, MsqError &err)
returns the diagonal blocks, memory must be allocated before call.
Matrix3D * mPreconditioner
Base class for concrete Objective Functions ObjectiveFunction contains a pointer to a QualityMetric...
Matrix3D * get_block(size_t i, size_t j)
size_t cgArraySizes
size of arrays allocated in the CG solver.
int * mAccumulation
accumulation pattern instructions
Vector3D * mP
array used in the CG solver
void eqAx(Vector3D &v, const Matrix3D &A, const Vector3D &x)