1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
/***********************************************/
/**
* @file matrixGeneratorNormalsFile.h
*
* @brief Symmetric matrix from a normal equation file.
*
* @author Torsten Mayer-Guerr
* @date 2017-09-01
*
*/
/***********************************************/
#ifndef __GROOPS_MATRIXGENERATORNORMALSFILE__
#define __GROOPS_MATRIXGENERATORNORMALSFILE__
// Latex documentation
#ifdef DOCSTRING_MatrixGenerator
static const char *docstringMatrixGeneratorNormalsFile = R"(
\subsection{Normals file}
Matrix from a \file{normal equation file}{normalEquation}. The symmetric normal matrix,
the right hand side vector, the lPl vector, or the observation count $(1\times1)$ can be selected.
)";
#endif
/***********************************************/
#include "base/import.h"
#include "files/fileNormalEquation.h"
#include "matrixGenerator.h"
/***** CLASS ***********************************/
/** @brief Symmetric matrix from a normal equation file.
* @ingroup matrixGeneratorGroup
* @see MatrixGenerator */
class MatrixGeneratorNormalsFile : public MatrixGeneratorBase
{
enum Type {MATRIX, RHS, LPL, OBSCOUNT};
Type type;
FileName fileName;
Double factor;
public:
MatrixGeneratorNormalsFile(Config &config);
void compute(Matrix &A, UInt rowsBefore, UInt columnsBefore, UInt &startRow, UInt &startCol);
};
/***********************************************/
/***** Inlines *********************************/
/***********************************************/
inline MatrixGeneratorNormalsFile::MatrixGeneratorNormalsFile(Config &config)
{
try
{
type = MATRIX;
std::string choice;
renameDeprecatedConfig(config, "inputfileNormalequation", "inputfileNormalEquation", date2time(2020, 6, 3));
readConfig(config, "inputfileNormalEquation", fileName, Config::MUSTSET, "", "");
if(readConfigChoice(config, "type", choice, Config::MUSTSET, "", ""))
{
if(readConfigChoiceElement(config, "normalMatrix", choice, "")) type = MATRIX;
if(readConfigChoiceElement(config, "rightHandSide", choice, "")) type = RHS;
if(readConfigChoiceElement(config, "lPl", choice, "")) type = LPL;
if(readConfigChoiceElement(config, "observationCount", choice, "")) type = OBSCOUNT;
endChoice(config);
}
readConfig(config, "factor", factor, Config::DEFAULT, "1.0", "");
if(isCreateSchema(config)) return;
}
catch(std::exception &e)
{
GROOPS_RETHROW(e)
}
}
/***********************************************/
inline void MatrixGeneratorNormalsFile::compute(Matrix &A, UInt /*rowsBefore*/, UInt /*columnsBefore*/, UInt &/*startRow*/, UInt &/*startCol*/)
{
try
{
Matrix n;
NormalEquationInfo info;
if(type == MATRIX)
{
readFileNormalEquation(fileName, info, A, n);
fillSymmetric(A);
}
else if(type == RHS)
{
readFileNormalEquation(fileName, info, n);
A = n;
}
else if(type == LPL)
{
readFileNormalEquation(fileName, info, n);
A = info.lPl;
}
else if(type == OBSCOUNT)
{
readFileNormalEquation(fileName, info, n);
A = Matrix(1, 1, info.observationCount);
}
A *= factor;
}
catch(std::exception &e)
{
GROOPS_RETHROW(e)
}
}
/***********************************************/
#endif
|