Vector3D is the object that effeciently stores the objective function Hessian each entry is a Matrix3D object (i.e. a vertex Hessian). More...
#include <MsqHessian.hpp>
Public Member Functions | |
MsqHessian () | |
~MsqHessian () | |
void | initialize (PatchData &pd, MsqError &err) |
creates a sparse structure for a Hessian, based on the connectivity information contained in the PatchData. Only the upper triangular part of the Hessian is stored. More... | |
void | zero_out () |
size_t | size () |
void | get_diagonal_blocks (msq_std::vector< Matrix3D > &diag, MsqError &err) |
returns the diagonal blocks, memory must be allocated before call. More... | |
Matrix3D * | get_block (size_t i, size_t j) |
void | accumulate_entries (PatchData &pd, const size_t &elem_index, Matrix3D *const &mat3d_array, MsqError &err) |
void | compute_preconditioner (MsqError &err) |
void | apply_preconditioner (Vector3D zloc[], Vector3D rloc[], MsqError &err) |
void | cg_solver (Vector3D x[], Vector3D b[], MsqError &err) |
MsqHessian () | |
~MsqHessian () | |
void | initialize (PatchData &pd, MsqError &err) |
void | zero_out () |
size_t | size () |
void | get_diagonal_blocks (msq_std::vector< Matrix3D > &diag, MsqError &err) |
returns the diagonal blocks, memory must be allocated before call. More... | |
Matrix3D * | get_block (size_t i, size_t j) |
void | accumulate_entries (PatchData &pd, const size_t &elem_index, Matrix3D *const &mat3d_array, MsqError &err) |
void | compute_preconditioner (MsqError &err) |
void | apply_preconditioner (Vector3D zloc[], Vector3D rloc[], MsqError &err) |
void | cg_solver (Vector3D x[], Vector3D b[], MsqError &err) |
Protected Attributes | |
PatchData * | origin_pd |
MsqMeshEntity * | patchElemArray |
stored once during initialization for More... | |
Matrix3D * | mEntries |
CSR block entries. size: nb of nonzero blocks, i.e. mRowStart[mSize] . More... | |
size_t * | mRowStart |
start of each row in mEntries. size: nb of vertices (mSize). More... | |
size_t * | mColIndex |
CSR block structure: column indexes of the row entries. More... | |
int * | mAccumulation |
accumulation pattern instructions More... | |
size_t * | mAccumElemStart |
Starting index in mAccumulation for element i, i=1,... More... | |
size_t | mSize |
number of rows (or number of columns, this is a square matrix). More... | |
Matrix3D * | mPreconditioner |
size_t | precondArraySize |
Vector3D * | mR |
array used in the CG solver More... | |
Vector3D * | mZ |
array used in the CG solver More... | |
Vector3D * | mP |
array used in the CG solver More... | |
Vector3D * | mW |
array used in the CG solver More... | |
size_t | cgArraySizes |
size of arrays allocated in the CG solver. More... | |
size_t | maxCGiter |
max nb of iterations of the CG solver. More... | |
Friends | |
class | ObjectiveFunction |
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). More... | |
msq_stdio::ostream & | operator<< (msq_stdio::ostream &, const MsqHessian &) |
Prints out the MsqHessian blocks. More... | |
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). More... | |
msq_stdio::ostream & | operator<< (msq_stdio::ostream &, const MsqHessian &) |
Prints out the MsqHessian blocks. More... | |
Vector3D is the object that effeciently stores the objective function Hessian each entry is a Matrix3D object (i.e. a vertex Hessian).
Definition at line 75 of file includeLinks/MsqHessian.hpp.
MsqHessian | ( | ) |
Definition at line 62 of file Misc/MsqHessian.cpp.
~MsqHessian | ( | ) |
Definition at line 70 of file Misc/MsqHessian.cpp.
References MsqHessian::mAccumElemStart, MsqHessian::mAccumulation, MsqHessian::mColIndex, MsqHessian::mEntries, MsqHessian::mP, MsqHessian::mPreconditioner, MsqHessian::mR, MsqHessian::mRowStart, MsqHessian::mW, and MsqHessian::mZ.
MsqHessian | ( | ) |
~MsqHessian | ( | ) |
|
inline |
Accumulates entries of an element hessian into an objective function hessian. Make sure to use zero_out() before starting the accumulation process.
pd,: | PatchData in that contains the element which Hessian we are accumulating in the Hessian matrix. This must be the same PatchData that was used in MsqHessian::initialize(). |
elem_index,: | index of the element in the PatchData. |
mat3d_array,: | This is the upper triangular part of the element Hessian for all nodes, including fixed nodes, for which the entries must be null Matrix3Ds. |
nb_mat3d. | The size of the mat3d_array: (n+1)n/2, where n is the number of nodes in the element. |
Definition at line 153 of file includeLinks/MsqHessian.hpp.
References PatchData::get_element_array(), i, MsqError::INVALID_ARG, j, MsqHessian::mAccumElemStart, MsqHessian::mAccumulation, MsqHessian::mEntries, MSQ_SETERR, MsqHessian::origin_pd, Matrix3D::plus_transpose_equal(), and MsqMeshEntity::vertex_count().
Referenced by LPtoPTemplate::compute_analytical_hessian().
|
inline |
Computes .
Definition at line 240 of file includeLinks/MsqHessian.hpp.
References MsqHessian::mPreconditioner, and MsqHessian::mSize.
Referenced by MsqHessian::cg_solver().
uses the preconditionned conjugate gradient algebraic solver to find d in .
x | : the solution, usually the descent direction d. |
b | : -b will be the right hand side. Usually b is the gradient. |
Definition at line 440 of file Misc/MsqHessian.cpp.
References MsqHessian::apply_preconditioner(), MsqHessian::axpy, MsqHessian::cgArraySizes, MsqHessian::compute_preconditioner(), i, Mesquite::inner(), Mesquite::length(), MsqHessian::maxCGiter, MsqHessian::mP, MsqHessian::mR, MsqHessian::mSize, MSQ_CHKERR, MSQ_FUNCTION_TIMER, MsqHessian::mW, and MsqHessian::mZ.
Referenced by FeasibleNewton::optimize_vertex_positions().
void compute_preconditioner | ( | MsqError & | err | ) |
void compute_preconditioner | ( | MsqError & | err | ) |
compute a preconditioner used in the preconditioned conjugate gradient algebraic solver. In fact, this computes .
Definition at line 358 of file Misc/MsqHessian.cpp.
References MsqHessian::mEntries, MsqHessian::mPreconditioner, MsqHessian::mRowStart, MsqHessian::mSize, and MsqHessian::precondArraySize.
Referenced by MsqHessian::cg_solver().
|
inline |
Returns a pointer to the Matrix3D block at position i,j if it exist. Returns the NULL pointer if position i,j (0-based) is a NULL entry. Note that block i,j must be in the upper triangular part of the (symetric) hessian.
Definition at line 276 of file includeLinks/MsqHessian.hpp.
References MsqHessian::mColIndex, MsqHessian::mEntries, MsqHessian::mRowStart, and MsqHessian::mSize.
Matrix3D* get_block | ( | size_t | i, |
size_t | j | ||
) |
returns the diagonal blocks, memory must be allocated before call.
diag | is an STL vector of size MsqHessian::size() . |
Definition at line 341 of file Misc/MsqHessian.cpp.
References i, MsqHessian::mEntries, MsqHessian::mRowStart, and MsqHessian::size().
returns the diagonal blocks, memory must be allocated before call.
creates a sparse structure for a Hessian, based on the connectivity information contained in the PatchData. Only the upper triangular part of the Hessian is stored.
Definition at line 91 of file Misc/MsqHessian.cpp.
References PatchData::get_element_array(), MsqMeshEntity::get_vertex_index_array(), i, MsqError::INVALID_ARG, j, MsqHessian::mAccumElemStart, MsqHessian::mAccumulation, MsqHessian::mColIndex, MsqHessian::mEntries, MsqHessian::mRowStart, MsqHessian::mSize, MSQ_CHKERR, MSQ_FUNCTION_TIMER, MSQ_SETERR, PatchData::num_elements(), PatchData::num_vertices(), MsqHessian::origin_pd, MsqHessian::patchElemArray, rs(), and MsqMeshEntity::vertex_count().
Referenced by FeasibleNewton::optimize_vertex_positions().
|
inline |
Definition at line 107 of file src/Misc/MsqHessian.hpp.
References MsqHessian::mSize.
|
inline |
Definition at line 107 of file includeLinks/MsqHessian.hpp.
References MsqHessian::mSize.
Referenced by MsqHessian::get_diagonal_blocks().
|
inline |
|
inline |
Sets all Hessian entries to zero. This is usually used before starting to accumulate elements hessian in the objective function hessian.
Definition at line 129 of file includeLinks/MsqHessian.hpp.
References i, MsqHessian::mEntries, MsqHessian::mRowStart, MsqHessian::mSize, and Matrix3D::zero().
Referenced by LPtoPTemplate::compute_analytical_hessian().
|
friend |
Hessian - vector product, summed with a second vector (optional).
res,: | array of Vector3D in which the result is stored. |
size_r,: | size of the res array. |
x,: | vector multiplied by the Hessian. |
size_x,: | size of the x array. |
y,: | vector added to the Hessian vector product. Set to 0 (NULL) if not needed. |
size_y,: | size of the y array. Set to 0 if not needed. |
Definition at line 187 of file includeLinks/MsqHessian.hpp.
Referenced by MsqHessian::cg_solver().
|
friend |
Hessian - vector product, summed with a second vector (optional).
res,: | array of Vector3D in which the result is stored. |
size_r,: | size of the res array. |
x,: | vector multiplied by the Hessian. |
size_x,: | size of the x array. |
y,: | vector added to the Hessian vector product. Set to 0 (NULL) if not needed. |
size_y,: | size of the y array. Set to 0 if not needed. |
Definition at line 187 of file includeLinks/MsqHessian.hpp.
|
friend |
Definition at line 121 of file includeLinks/MsqHessian.hpp.
|
friend |
Prints out the MsqHessian blocks.
|
friend |
Prints out the MsqHessian blocks.
|
protected |
size of arrays allocated in the CG solver.
Definition at line 98 of file includeLinks/MsqHessian.hpp.
Referenced by MsqHessian::cg_solver().
|
protected |
Starting index in mAccumulation for element i, i=1,...
Definition at line 87 of file includeLinks/MsqHessian.hpp.
Referenced by MsqHessian::accumulate_entries(), MsqHessian::initialize(), and MsqHessian::~MsqHessian().
|
protected |
accumulation pattern instructions
Definition at line 86 of file includeLinks/MsqHessian.hpp.
Referenced by MsqHessian::accumulate_entries(), MsqHessian::initialize(), and MsqHessian::~MsqHessian().
|
protected |
max nb of iterations of the CG solver.
Definition at line 99 of file includeLinks/MsqHessian.hpp.
Referenced by MsqHessian::cg_solver().
|
protected |
CSR block structure: column indexes of the row entries.
Definition at line 84 of file includeLinks/MsqHessian.hpp.
Referenced by Mesquite::axpy(), MsqHessian::get_block(), MsqHessian::initialize(), Mesquite::operator<<(), and MsqHessian::~MsqHessian().
|
protected |
CSR block entries. size: nb of nonzero blocks, i.e. mRowStart[mSize] .
Definition at line 82 of file includeLinks/MsqHessian.hpp.
Referenced by MsqHessian::accumulate_entries(), Mesquite::axpy(), MsqHessian::compute_preconditioner(), MsqHessian::get_block(), MsqHessian::get_diagonal_blocks(), MsqHessian::initialize(), Mesquite::operator<<(), MsqHessian::zero_out(), and MsqHessian::~MsqHessian().
|
protected |
array used in the CG solver
Definition at line 96 of file includeLinks/MsqHessian.hpp.
Referenced by MsqHessian::cg_solver(), and MsqHessian::~MsqHessian().
|
protected |
Definition at line 91 of file includeLinks/MsqHessian.hpp.
Referenced by MsqHessian::apply_preconditioner(), MsqHessian::compute_preconditioner(), and MsqHessian::~MsqHessian().
|
protected |
array used in the CG solver
Definition at line 94 of file includeLinks/MsqHessian.hpp.
Referenced by MsqHessian::cg_solver(), and MsqHessian::~MsqHessian().
|
protected |
start of each row in mEntries. size: nb of vertices (mSize).
Definition at line 83 of file includeLinks/MsqHessian.hpp.
Referenced by Mesquite::axpy(), MsqHessian::compute_preconditioner(), MsqHessian::get_block(), MsqHessian::get_diagonal_blocks(), MsqHessian::initialize(), Mesquite::operator<<(), MsqHessian::zero_out(), and MsqHessian::~MsqHessian().
|
protected |
number of rows (or number of columns, this is a square matrix).
Definition at line 89 of file includeLinks/MsqHessian.hpp.
Referenced by MsqHessian::apply_preconditioner(), Mesquite::axpy(), MsqHessian::cg_solver(), MsqHessian::compute_preconditioner(), MsqHessian::get_block(), MsqHessian::initialize(), Mesquite::operator<<(), MsqHessian::size(), and MsqHessian::zero_out().
|
protected |
array used in the CG solver
Definition at line 97 of file includeLinks/MsqHessian.hpp.
Referenced by MsqHessian::cg_solver(), and MsqHessian::~MsqHessian().
|
protected |
array used in the CG solver
Definition at line 95 of file includeLinks/MsqHessian.hpp.
Referenced by MsqHessian::cg_solver(), and MsqHessian::~MsqHessian().
|
protected |
Definition at line 78 of file includeLinks/MsqHessian.hpp.
Referenced by MsqHessian::accumulate_entries(), and MsqHessian::initialize().
|
protected |
stored once during initialization for
fast access.
Definition at line 79 of file includeLinks/MsqHessian.hpp.
Referenced by MsqHessian::initialize().
|
protected |
Definition at line 92 of file includeLinks/MsqHessian.hpp.
Referenced by MsqHessian::compute_preconditioner().