#include <Calibration/EcalCalibAlgos/interface/BlockSolver.h>
Public Member Functions | |
int | operator() (const CLHEP::HepMatrix &matrix, const CLHEP::HepVector &vector, CLHEP::HepVector &result) |
| |
Private Member Functions | |
void | pour (CLHEP::HepVector &result, const CLHEP::HepVector &output, const std::vector< int > &where) |
pour results in bigger vector | |
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 |
Definition at line 25 of file BlockSolver.h.
int BlockSolver::operator() | ( | const CLHEP::HepMatrix & | matrix, | |
const CLHEP::HepVector & | vector, | |||
CLHEP::HepVector & | result | |||
) |
Definition at line 11 of file BlockSolver.cc.
References parsecf::pyparsing::col(), i, iggi_31X_cfg::input, output(), pour(), row, shrink(), solve(), and dimuonsSequences_cff::threshold.
00014 { 00015 double threshold = matrix.trace () / 00016 static_cast<double> (matrix.num_row ()) ; 00017 std::vector<int> holes ; 00018 // loop over the matrix rows 00019 for (int row = 0 ; row < matrix.num_row () ; ++row) 00020 { 00021 double sumAbs = 0. ; 00022 for (int col = 0 ; col < matrix.num_col () ; ++col) 00023 sumAbs += fabs (matrix[row][col]) ; 00024 if (sumAbs < threshold) holes.push_back (row) ; 00025 } // loop over the matrix rows 00026 00027 int dim = matrix.num_col () - holes.size () ; 00028 00029 if (holes.size () == 0) //PG exceptional case! 00030 { 00031 for (int i = 0 ; i < result.num_row () ; ++i) 00032 result[i] = 1. ; 00033 } 00034 else if (dim > 0) 00035 { 00036 CLHEP::HepMatrix solution (dim, dim, 0) ; 00037 CLHEP::HepVector input (dim, 0) ; 00038 shrink (matrix, solution, vector, input, holes) ; 00039 CLHEP::HepVector output = solve (solution,input) ; 00040 pour (result, output, holes) ; 00041 } 00042 return holes.size () ; 00043 }
void BlockSolver::pour | ( | CLHEP::HepVector & | result, | |
const CLHEP::HepVector & | output, | |||
const std::vector< int > & | where | |||
) | [private] |
pour results in bigger vector
Definition at line 92 of file BlockSolver.cc.
Referenced by operator()().
00095 { 00096 std::vector<int>::const_iterator whereCols = where.begin () ; 00097 int readingIndex = 0 ; 00098 //PG loop over the output crystals 00099 for (int xtal = 0 ; xtal < result.num_row () ; ++xtal) 00100 { 00101 if (xtal == *whereCols) 00102 { 00103 result[xtal] = 1. ; 00104 ++whereCols ; 00105 } 00106 else 00107 { 00108 result[xtal] = output[readingIndex] ; 00109 ++readingIndex ; 00110 } 00111 } //PG loop over the output crystals 00112 00113 return ; 00114 }
void BlockSolver::shrink | ( | const CLHEP::HepMatrix & | matrix, | |
CLHEP::HepMatrix & | solution, | |||
const CLHEP::HepVector & | result, | |||
CLHEP::HepVector & | input, | |||
const std::vector< int > & | where | |||
) | [private] |
eliminate empty columns and rows
Definition at line 50 of file BlockSolver.cc.
References parsecf::pyparsing::col(), lat::endl(), and row.
Referenced by operator()().
00055 { 00056 00057 int offsetRow = 0 ; 00058 std::vector<int>::const_iterator whereRows = where.begin () ; 00059 // loop over rows 00060 for (int row = 0 ; row < matrix.num_row () ; ++row) 00061 { 00062 if (row == *whereRows) 00063 { 00064 edm::LogWarning ("solving")<<"shrinking"<< *whereRows << std::endl ; 00065 ++offsetRow ; 00066 ++whereRows ; 00067 continue ; 00068 } 00069 input[row-offsetRow] = result[row] ; 00070 int offsetCol = 0 ; 00071 std::vector<int>::const_iterator whereCols = where.begin () ; 00072 // loop over columns 00073 for (int col = 0 ; col < matrix.num_col () ; ++col) 00074 { 00075 if (col == *whereCols) 00076 { 00077 ++offsetCol ; 00078 ++whereCols ; 00079 continue ; 00080 } 00081 solution[row-offsetRow][col-offsetCol] = matrix[row][col] ; 00082 } 00083 } // loop over rows 00084 return ; 00085 }