#include <cfloat>
#include <cmath>
#include <cstdlib>
#include "SprMatrix.hh"
#include "SprSymMatrix.hh"
#include "SprVector.hh"
Go to the source code of this file.
Defines | |
#define | CHK_DIM_1(c1, r2, fun) |
#define | CHK_DIM_2(r1, r2, c1, c2, fun) |
#define | SIMPLE_BOP(OPER) |
#define | SIMPLE_TOP(OPER) |
#define | SIMPLE_UOP(OPER) |
Functions | |
SprMatrix | dsum (const SprMatrix &m1, const SprMatrix &m2) |
SprMatrix | operator * (const SprMatrix &m1, const SprMatrix &m2) |
SprMatrix | operator * (double t, const SprMatrix &m1) |
SprMatrix | operator * (const SprMatrix &m1, double t) |
SprMatrix | operator+ (const SprMatrix &m1, const SprMatrix &m2) |
SprMatrix | operator- (const SprMatrix &m1, const SprMatrix &m2) |
SprMatrix | operator/ (const SprMatrix &m1, double t) |
std::ostream & | operator<< (std::ostream &s, const SprMatrix &q) |
Value:
if (c1!=r2) { \ SprGenMatrix::error("Range error in Matrix function " #fun "(2)."); \ }
Definition at line 74 of file SprMatrix.cc.
Referenced by operator *(), operator+(), and operator-().
Value:
if (r1!=r2 || c1!=c2) { \ SprGenMatrix::error("Range error in Matrix function " #fun "(1)."); \ }
Definition at line 69 of file SprMatrix.cc.
Referenced by operator+(), and operator-().
#define SIMPLE_BOP | ( | OPER | ) |
#define SIMPLE_TOP | ( | OPER | ) |
Value:
register SprMatrix::mcIter a=m1.m.begin(); \ register SprMatrix::mcIter b=m2.m.begin(); \ register SprMatrix::mIter t=mret.m.begin(); \ register SprMatrix::mcIter e=m1.m.end(); \ for(;a!=e; a++, b++, t++) (*t) = (*a) OPER (*b);
Definition at line 60 of file SprMatrix.cc.
Referenced by operator+(), and operator-().
#define SIMPLE_UOP | ( | OPER | ) |
SprMatrix dsum | ( | const SprMatrix & | m1, | |
const SprMatrix & | m2 | |||
) |
Definition at line 209 of file SprMatrix.cc.
Referenced by hcaltb::HcalTBTDCUnpacker::reconstructWC().
00210 { 00211 SprMatrix mret(m1.num_row() + m2.num_row(), m1.num_col() + m2.num_col(), 00212 0); 00213 mret.sub(1,1,m1); 00214 mret.sub(m1.num_row()+1,m1.num_col()+1,m2); 00215 return mret; 00216 }
SprMatrix operator * | ( | const SprMatrix & | m1, | |
const SprMatrix & | m2 | |||
) |
Definition at line 282 of file SprMatrix.cc.
References CHK_DIM_1, i, j, and pyDBSRunClass::temp.
00283 { 00284 // initialize matrix to 0.0 00285 SprMatrix mret(m1.nrow,m2.ncol,0); 00286 CHK_DIM_1(m1.ncol,m2.nrow,*); 00287 00288 int m1cols = m1.ncol; 00289 int m2cols = m2.ncol; 00290 00291 for (int i=0; i<m1.nrow; i++) 00292 { 00293 for (int j=0; j<m1cols; j++) 00294 { 00295 register double temp = m1.m[i*m1cols+j]; 00296 register SprMatrix::mIter pt = mret.m.begin() + i*m2cols; 00297 00298 // Loop over k (the column index in matrix m2) 00299 register SprMatrix::mcIter pb = m2.m.begin() + m2cols*j; 00300 const SprMatrix::mcIter pblast = pb + m2cols; 00301 while (pb < pblast) 00302 { 00303 (*pt) += temp * (*pb); 00304 pb++; 00305 pt++; 00306 } 00307 } 00308 } 00309 00310 return mret; 00311 }
SprMatrix operator * | ( | double | t, | |
const SprMatrix & | m1 | |||
) |
SprMatrix operator * | ( | const SprMatrix & | m1, | |
double | t | |||
) |
SprMatrix operator+ | ( | const SprMatrix & | m1, | |
const SprMatrix & | m2 | |||
) |
Definition at line 234 of file SprMatrix.cc.
References CHK_DIM_2, and SIMPLE_TOP.
00235 { 00236 SprMatrix mret(m1.nrow, m1.ncol); 00237 CHK_DIM_2(m1.num_row(),m2.num_row(), m1.num_col(),m2.num_col(),+); 00238 SIMPLE_TOP(+) 00239 return mret; 00240 }
SprMatrix operator- | ( | const SprMatrix & | m1, | |
const SprMatrix & | m2 | |||
) |
Definition at line 246 of file SprMatrix.cc.
References CHK_DIM_2, and SIMPLE_TOP.
00247 { 00248 SprMatrix mret(m1.num_row(), m1.num_col()); 00249 CHK_DIM_2(m1.num_row(),m2.num_row(), 00250 m1.num_col(),m2.num_col(),-); 00251 SIMPLE_TOP(-) 00252 return mret; 00253 }
SprMatrix operator/ | ( | const SprMatrix & | m1, | |
double | t | |||
) |
std::ostream& operator<< | ( | std::ostream & | s, | |
const SprMatrix & | q | |||
) |
Definition at line 361 of file SprMatrix.cc.
References lat::endl(), icol, and width.
00362 { 00363 s << "\n"; 00364 /* Fixed format needs 3 extra characters for field, while scientific needs 7 */ 00365 int width; 00366 if(s.flags() & std::ios::fixed) 00367 width = s.precision()+3; 00368 else 00369 width = s.precision()+7; 00370 for(int irow = 1; irow<= q.num_row(); irow++) 00371 { 00372 for(int icol = 1; icol <= q.num_col(); icol++) 00373 { 00374 s.width(width); 00375 s << q(irow,icol) << " "; 00376 } 00377 s << std::endl; 00378 } 00379 return s; 00380 }