8 const CLHEP::HepVector & vector,
12 static_cast<double> (matrix.num_row ()) ;
13 std::vector<int> holes ;
15 for (
int row = 0 ; row < matrix.num_row () ; ++row)
18 for (
int col = 0 ;
col < matrix.num_col () ; ++
col)
19 sumAbs += fabs (matrix[row][
col]) ;
20 if (sumAbs < threshold) holes.push_back (row) ;
23 int dim = matrix.num_col () - holes.size () ;
25 if (holes.size () == 0)
27 for (
int i = 0 ;
i < result.num_row () ; ++
i)
32 CLHEP::HepMatrix solution (dim, dim, 0) ;
33 CLHEP::HepVector
input (dim, 0) ;
34 shrink (matrix, solution, vector, input, holes) ;
35 CLHEP::HepVector
output = solve (solution,input) ;
36 pour (result, output, holes) ;
38 return holes.size () ;
47 CLHEP::HepMatrix & solution,
48 const CLHEP::HepVector &
result,
49 CLHEP::HepVector &
input,
50 const std::vector<int> & where)
54 std::vector<int>::const_iterator whereRows = where.begin () ;
56 for (
int row = 0 ; row < matrix.num_row () ; ++row)
58 if (row == *whereRows)
65 input[row-offsetRow] = result[row] ;
67 std::vector<int>::const_iterator whereCols = where.begin () ;
69 for (
int col = 0 ;
col < matrix.num_col () ; ++
col)
71 if (
col == *whereCols)
77 solution[row-offsetRow][
col-offsetCol] = matrix[row][
col] ;
89 const CLHEP::HepVector &
output,
90 const std::vector<int> & where)
92 std::vector<int>::const_iterator whereCols = where.begin () ;
93 int readingIndex = 0 ;
95 for (
int xtal = 0 ; xtal < result.num_row () ; ++xtal)
97 if (xtal == *whereCols)
104 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)
return(e1-e2)*(e1-e2)+dp *dp
void pour(CLHEP::HepVector &result, const CLHEP::HepVector &output, const std::vector< int > &where)
pour results in bigger vector