12 const CLHEP::HepVector & vector,
16 static_cast<double> (matrix.num_row ()) ;
17 std::vector<int> holes ;
19 for (
int row = 0 ; row < matrix.num_row () ; ++row)
22 for (
int col = 0 ;
col < matrix.num_col () ; ++
col)
23 sumAbs += fabs (matrix[row][
col]) ;
24 if (sumAbs < threshold) holes.push_back (row) ;
27 int dim = matrix.num_col () - holes.size () ;
29 if (holes.size () == 0)
31 for (
int i = 0 ;
i < result.num_row () ; ++
i)
36 CLHEP::HepMatrix solution (dim, dim, 0) ;
37 CLHEP::HepVector
input (dim, 0) ;
38 shrink (matrix, solution, vector, input, holes) ;
39 CLHEP::HepVector
output = solve (solution,input) ;
40 pour (result, output, holes) ;
42 return holes.size () ;
51 CLHEP::HepMatrix & solution,
52 const CLHEP::HepVector &
result,
53 CLHEP::HepVector &
input,
54 const std::vector<int> & where)
58 std::vector<int>::const_iterator whereRows = where.begin () ;
60 for (
int row = 0 ; row < matrix.num_row () ; ++row)
62 if (row == *whereRows)
69 input[row-offsetRow] = result[row] ;
71 std::vector<int>::const_iterator whereCols = where.begin () ;
73 for (
int col = 0 ;
col < matrix.num_col () ; ++
col)
75 if (
col == *whereCols)
81 solution[row-offsetRow][
col-offsetCol] = matrix[row][
col] ;
93 const CLHEP::HepVector &
output,
94 const std::vector<int> & where)
96 std::vector<int>::const_iterator whereCols = where.begin () ;
97 int readingIndex = 0 ;
99 for (
int xtal = 0 ; xtal < result.num_row () ; ++xtal)
101 if (xtal == *whereCols)
108 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
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