44 : _size(0), _nrrows(0), _nrcol(0), _matrix(0), _columns(0), _rows(0),
45 _nothing(0),_verb(
false)
50 : _size(rows * nonzero_col),
54 _matrix =
new double[_size];
55 _rows =
new int[_size];
56 _columns =
new int[_size];
57 for (
int i=0; i<_size;i++)
63 _nothing =
new double;
70 : _size(rows * nonzero_col),
74 _matrix =
new double[_size];
75 _rows =
new int[_size];
76 _columns =
new int[_size];
77 for (
int i=0; i<_size;i++)
83 _nothing =
new double;
95 _matrix =
new double[_size];
96 _rows =
new int[_size];
97 _columns =
new int[_size];
98 _nothing =
m1._nothing;
101 for (
long int i=0;i<_size;i++)
103 _matrix[i] =
m1._matrix[i];
104 _rows[i] =
m1._rows[i];
105 _columns[i] =
m1._columns[i];
141 long int found =
find(
row, col );
147 std::cout <<
"EmcLSSMatrix:: ERROR "
148 <<
"EmcLSSMatrix: matrix element not found !!" << endl
149 <<
"EmcLSSMatrix: Return zero !" << endl;
155 return (*(_matrix+found));
183 double* matr_row_max;
185 if (larger < 0 || larger > _nrrows || smaller < 0 || smaller > _nrrows )
188 std::cout <<
"EmcLSSMatrix::ERROR"
189 <<
"!!! ERROR in bound check of EmcLSSMatrix !!!"
190 <<
"!!! Return zero !!!"
197 col_p = (_columns + (larger * _nrcol));
198 row_p = (_rows + (larger * _nrcol));
199 matr_p = (_matrix + (larger * _nrcol));
200 matr_row_max = (matr_p + _nrcol);
202 while ( matr_p < matr_row_max ) {
205 std::cout <<
"EmcLSSMatrix::VERBOSE"
206 <<
"C: " << larger <<
" " << smaller <<
" "
207 << col_p <<
" " << *col_p <<
" "
208 << matr_p <<
" " << *matr_p <<
" "
209 << (_matrix+(matr_p-_matrix)) <<
" "
210 << *(_matrix+(matr_p-_matrix)) << endl;
219 if ( matr_p == (matr_row_max-1) )
222 std::cout <<
"EmcLSSMatrix::WARNING "
223 <<
"!! WARNING: Reached maximum number of columns "
224 <<
"in LSSMatrix when searching for row "
225 << larger <<
" column " << smaller <<
" !!"
227 <<
"!! Return zero pointer !! " << endl;
234 if ( *col_p == smaller )
240 if ( (*matr_p == 0.) )
262 long int diff = matr_p-_matrix;
277 if (rowind < _nrrows)
279 here = (_matrix+(rowind*_nrcol));
284 std::cout <<
"EmcLSSMatrix::ERROR "
285 <<
"EmcLSSMatrix::matrix: Error "
286 <<
"- larger row index than existing requested !"
299 if (rowind < _nrrows)
301 here = (_columns+(rowind*_nrcol));
307 std::cout <<
"EmcLSSMatrix::ERROR "
308 <<
"EmcLSSMatrix.column: Error "
309 <<
"- larger row index than existing requested !"
320 double * search_i = _matrix + (
row * _nrcol );
321 double * max_i = search_i + _nrcol;
324 while ( (*search_i != 0.) && (search_i < max_i) )
336 for (
long int i=0; i<_size; i++ )
338 if ( (_matrix[i] != 0.) && (_columns[i] == col) )
351 int* col_p = _columns;
352 double* ele_p = _matrix;
353 double* mat_max_p = (_matrix + _size);
356 while ( ele_p < mat_max_p )
358 if ( *ele_p != 0.) nrele++;
372 for (
int i=0; i<_size;i++)
384 bool successful =
true;
389 long int _newIndx = 0;
392 for (
long int _arrayIndx = 0;
393 _arrayIndx < _size; _arrayIndx++)
399 if ( _matrix[_arrayIndx] > 0. )
402 if ( (xRef_list[(_rows[_arrayIndx])]) >= 0
403 && (xRef_list[(_columns[_arrayIndx])]) >= 0 )
405 _matrix[_newIndx] = _matrix[_arrayIndx];
406 _rows[_newIndx] = ((xRef_list[(_rows[_arrayIndx])])+1);
407 _columns[_newIndx] = ((xRef_list[(_columns[_arrayIndx])])+1);
414 if (xRef_list[(_rows[_arrayIndx])] < 0 )
417 std::cout <<
"EmcLSSMatrix::ERROR "
418 <<
"EmcLSSMatrix: Xtal index "
420 <<
" appears in matrix, "
421 <<
"but not in vector !!! "
422 << _rows[_arrayIndx] <<
" "
423 << _columns[_arrayIndx]
431 std::cout <<
"EmcLSSMatrix::ERROR "
432 <<
"EmcLSSMatrix: Xtal index "
433 << _columns[_arrayIndx]
434 <<
" appears in matrix, "
435 <<
"but not in vector !!! "
436 << _rows[_arrayIndx] <<
" "
437 << _columns[_arrayIndx]
449 std::cout <<
"EmcLSSMatrix::DEBUG "
450 <<
"Reduced LSSMatrix !!! Number of non zeros: "
462 int* col_p = _columns;
464 double* ele_p = _matrix;
465 double* mat_max_p = (_matrix + _size);
471 std::cout <<
"EmcLSSMatrix::DEBUG "
472 <<
"List of nonzero Matrix elements (Matrix size: "
473 << _size <<
" ) : " << endl;
476 while ( ele_p < mat_max_p )
482 std::cout <<
"EmcLSSMatrix::DEBUG "
484 <<
" M( " << *row_p <<
" , " << *col_p
486 <<
" array index: " << wo << endl;
507 int* col_p = _columns+(_nrcol*rownr);
508 int* row_p = _rows+(_nrcol*rownr);
509 double* ele_p = _matrix+(_nrcol*rownr);
510 double* mat_max_p = (ele_p + _nrcol);
515 std::cout <<
"EmcLSSMatrix::DEBUG "
518 while ( ele_p < mat_max_p )
524 std::cout <<
"EmcLSSMatrix::DEBUG "
526 <<
" M( " << *row_p <<
" , " << *col_p
528 <<
" array index: " << wo << endl;
548 int* col_p = _columns;
550 double* ele_p = _matrix;
551 double* mat_max_p = (_matrix + _size);
557 while ( ele_p < mat_max_p )
571 std::cout <<
"EmcLSSMatrix::DEBUG "
573 <<
" non zero matrix elements to file !!!" << endl;
586 cout<<
"nonz="<<nonz<<endl;
594 for (
long int i=0; i<nonz; i++ )
596 In >> theRow >> theCol >> theEle;
597 index =
find (theRow,theCol);
605 _matrix[index] += theEle;
608 if ( i < 50 || i > (nonz-10) )
611 std::cout <<
"EmcLSSMatrix::DEBUG "
612 <<
"M: " << _rows[index] <<
" " << _columns[index]
613 <<
" " << _matrix[index] <<
" " << index << endl;
623 std::cout <<
"EmcLSSMatrix::DEBUG "
624 <<
"Have read in " << nonz
625 <<
" non zero matrix elements from file !!!" << endl;
int num_filled_cols(const int row) const
bool reduce_Matrix(int *xRef_list)
long int find(int row, int col)
void print_row(int rownr)
int * column(const int &rowind=0) const
void writeOut(ostream &Out)
double & operator()(int row, int col)
double * matrix(const int &rowind=0) const
int num_filled_rows(const int col) const