7 double threshold = matrix.trace() /
static_cast<double>(matrix.num_row());
8 std::vector<int> holes;
10 for (
int row = 0; row < matrix.num_row(); ++row) {
12 for (
int col = 0;
col < matrix.num_col(); ++
col)
13 sumAbs += fabs(matrix[row][
col]);
14 if (sumAbs < threshold)
18 int dim = matrix.num_col() - holes.size();
22 for (
int i = 0;
i < result.num_row(); ++
i)
25 CLHEP::HepMatrix solution(dim, dim, 0);
26 CLHEP::HepVector
input(dim, 0);
27 shrink(matrix, solution, vector, input, holes);
28 CLHEP::HepVector
output = solve(solution, input);
29 pour(result, output, holes);
37 CLHEP::HepMatrix& solution,
38 const CLHEP::HepVector&
result,
39 CLHEP::HepVector&
input,
40 const std::vector<int>& where) {
42 std::vector<int>::const_iterator whereRows = where.begin();
44 for (
int row = 0; row < matrix.num_row(); ++row) {
45 if (row == *whereRows) {
51 input[row - offsetRow] = result[row];
53 std::vector<int>::const_iterator whereCols = where.begin();
55 for (
int col = 0;
col < matrix.num_col(); ++
col) {
56 if (
col == *whereCols) {
61 solution[row - offsetRow][
col - offsetCol] = matrix[row][
col];
70 std::vector<int>::const_iterator whereCols = where.begin();
73 for (
int xtal = 0; xtal < result.num_row(); ++xtal) {
74 if (xtal == *whereCols) {
78 result[xtal] = output[readingIndex];
void shrink(const CLHEP::HepMatrix &matrix, CLHEP::HepMatrix &solution, const CLHEP::HepVector &result, CLHEP::HepVector &input, const std::vector< int > &where)
eliminate empty columns and rows
static std::string const input
int operator()(const CLHEP::HepMatrix &matrix, const CLHEP::HepVector &vector, CLHEP::HepVector &result)
void pour(CLHEP::HepVector &result, const CLHEP::HepVector &output, const std::vector< int > &where)
pour results in bigger vector