#ifndef __JTOOLS__JHESSEMATRIX__ #define __JTOOLS__JHESSEMATRIX__ #include "JTools/JTable2D.hh" #include "JTools/JResult.hh" /** * \author mdejong */ namespace JTOOLS {} namespace JPP { using namespace JTOOLS; } namespace JTOOLS { /** * Hessian matrix. */ template struct JHesseMatrix : public JTable2D { /** * Default constructor. */ JHesseMatrix() {} /** * Constructor. * * \param result Hesse result */ template JHesseMatrix(const JResultHesse& result) { set(result); } /** * Set matrix according given result. * * \param result Hesse result */ template void set(const JResultHesse& result) { set(0, result); for (unsigned int i = 1; i != N; ++i) { for (unsigned int j = 0; j != i; ++j) { this->data[i][j] = this->data[j][i]; } } } private: /** * Set final element. * * \param pivot pivot * \param result Hesse result */ void set(unsigned int pivot, const JResultHesse& result) { this->data[pivot][pivot] = result.fpp; } /** * Set final element. * * \param row row * \param col col * \param result Hesse result */ void set(unsigned int row, unsigned int col, const JResultHesse& result) { this->data[row][col] = result.fp; } /** * Recursivaly set elements. * * \param pivot pivot * \param result Hesse result */ template void set(unsigned int pivot, const JResultHesse& result) { this->data[pivot][pivot] = get_value(result.fpp); set(pivot, pivot + 1, result.fp); set(pivot + 1, result.f); } /** * Recursivaly set elements. * * \param row row * \param col col * \param result Hesse result */ template void set(unsigned int row, unsigned int col, const JResultHesse& result) { this->data[row][col] = get_value(result.fp); set(row, col + 1, result.f); } }; } #endif