#include <cstring>
#include "SprVector.hh"
#include "SprMatrix.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 | |
double | dot (const SprVector &v1, const SprVector &v2) |
SprVector | dsum (const SprVector &m1, const SprVector &m2) |
SprMatrix | operator * (const SprVector &m1, const SprMatrix &m2) |
SprVector | operator * (const SprMatrix &m1, const SprVector &m2) |
SprVector | operator * (double t, const SprVector &m1) |
SprVector | operator * (const SprVector &m1, double t) |
SprVector | operator+ (const SprVector &m1, const SprVector &m2) |
SprVector | operator+ (const SprVector &m1, const SprMatrix &m2) |
SprVector | operator+ (const SprMatrix &m1, const SprVector &m2) |
SprVector | operator- (const SprVector &m1, const SprVector &m2) |
SprVector | operator- (const SprVector &m1, const SprMatrix &m2) |
SprVector | operator- (const SprMatrix &m1, const SprVector &m2) |
SprVector | operator/ (const SprVector &m1, double t) |
std::ostream & | operator<< (std::ostream &s, const SprVector &q) |
SprVector | solve (const SprMatrix &a, const SprVector &v) |
Value:
if (c1!=r2) { \ SprGenMatrix::error("Range error in Vector function " #fun "(2)."); \ }
Definition at line 69 of file SprVector.cc.
Value:
if (r1!=r2 || c1!=c2) { \ SprGenMatrix::error("Range error in Vector function " #fun "(1)."); \ }
Definition at line 64 of file SprVector.cc.
#define SIMPLE_BOP | ( | OPER | ) |
#define SIMPLE_TOP | ( | OPER | ) |
Value:
register SprGenMatrix::mcIter a=m1.m.begin(); \ register SprGenMatrix::mcIter b=m2.m.begin(); \ register SprGenMatrix::mIter t=mret.m.begin(); \ register SprGenMatrix::mcIter e=m1.m.begin()+m1.num_size(); \ for( ;a<e; a++, b++, t++) (*t) = (*a) OPER (*b);
Definition at line 57 of file SprVector.cc.
#define SIMPLE_UOP | ( | OPER | ) |
double dot | ( | const SprVector & | v1, | |
const SprVector & | v2 | |||
) |
Definition at line 434 of file SprVector.cc.
Referenced by TruncatedPyramid::createCorners(), TwoBodyDecayEstimator::estimate(), DQMStore::extract(), Trajectory::geometricalInnermostState(), Ig3DClipsCategory::makeClip(), Ig3DGridCategory::makeGrid(), Ig3DSlicersCategory::makeSlicer(), IgSoSplineTrack::midpoint(), VisTkRecTracksTwig::onNewEvent(), AlCaHOCalibProducer::produce(), SteppingHelixPropagator::refToDest(), SoftLepton::relativeEta(), and IgSoFieldPlane::updateCorners().
00435 { 00436 if(v1.num_row()!=v2.num_row()) 00437 SprGenMatrix::error("v1 and v2 need to be the same size in dot(SprVector, SprVector)"); 00438 double d= 0; 00439 SprGenMatrix::mcIter a = v1.m.begin(); 00440 SprGenMatrix::mcIter b = v2.m.begin(); 00441 SprGenMatrix::mcIter e = a + v1.num_size(); 00442 for(;a<e;) d += (*(a++)) * (*(b++)); 00443 return d; 00444 }
SprVector dsum | ( | const SprVector & | m1, | |
const SprVector & | m2 | |||
) |
Definition at line 168 of file SprVector.cc.
00170 { 00171 SprVector mret(m1.num_row() + m2.num_row(), 00172 0); 00173 mret.sub(1,m1); 00174 mret.sub(m1.num_row()+1,m2); 00175 return mret; 00176 }
SprMatrix operator * | ( | const SprVector & | m1, | |
const SprMatrix & | m2 | |||
) |
Definition at line 294 of file SprVector.cc.
References CHK_DIM_1.
00295 { 00296 SprMatrix mret(m1.num_row(),m2.num_col()); 00297 CHK_DIM_1(1,m2.num_row(),*); 00298 SprGenMatrix::mcIter m1p; 00299 SprMatrix::mcIter m2p; 00300 SprMatrix::mIter mrp=mret.m.begin(); 00301 for(m1p=m1.m.begin();m1p<m1.m.begin()+m1.num_row();m1p++) 00302 for(m2p=m2.m.begin();m2p<m2.m.begin()+m2.num_col();m2p++) 00303 *(mrp++)=*m1p*(*m2p); 00304 return mret; 00305 }
SprVector operator * | ( | const SprMatrix & | m1, | |
const SprVector & | m2 | |||
) |
Definition at line 274 of file SprVector.cc.
References CHK_DIM_1, and pyDBSRunClass::temp.
00275 { 00276 SprVector mret(m1.num_row()); 00277 CHK_DIM_1(m1.num_col(),m2.num_row(),*); 00278 SprGenMatrix::mcIter m1p,m2p,vp; 00279 SprGenMatrix::mIter m3p; 00280 double temp; 00281 m3p=mret.m.begin(); 00282 for(m1p=m1.m.begin();m1p<m1.m.begin()+m1.num_row()*m1.num_col();m1p=m2p) 00283 { 00284 temp=0; 00285 vp=m2.m.begin(); 00286 m2p=m1p; 00287 while(m2p<m1p+m1.num_col()) 00288 temp+=(*(m2p++))*(*(vp++)); 00289 *(m3p++)=temp; 00290 } 00291 return mret; 00292 }
SprVector operator * | ( | double | t, | |
const SprVector & | m1 | |||
) |
SprVector operator * | ( | const SprVector & | m1, | |
double | t | |||
) |
SprVector operator+ | ( | const SprVector & | m1, | |
const SprVector & | m2 | |||
) |
Definition at line 210 of file SprVector.cc.
References CHK_DIM_1, and SIMPLE_TOP.
00211 { 00212 SprVector mret(m1.num_row()); 00213 CHK_DIM_1(m1.num_row(),m2.num_row(),+); 00214 SIMPLE_TOP(+) 00215 return mret; 00216 }
SprVector operator+ | ( | const SprVector & | m1, | |
const SprMatrix & | m2 | |||
) |
SprVector operator+ | ( | const SprMatrix & | m1, | |
const SprVector & | m2 | |||
) |
SprVector operator- | ( | const SprVector & | m1, | |
const SprVector & | m2 | |||
) |
Definition at line 239 of file SprVector.cc.
References CHK_DIM_1, and SIMPLE_TOP.
00240 { 00241 SprVector mret(m1.num_row()); 00242 CHK_DIM_1(m1.num_row(),m2.num_row(),-); 00243 SIMPLE_TOP(-) 00244 return mret; 00245 }
SprVector operator- | ( | const SprVector & | m1, | |
const SprMatrix & | m2 | |||
) |
SprVector operator- | ( | const SprMatrix & | m1, | |
const SprVector & | m2 | |||
) |
SprVector operator/ | ( | const SprVector & | m1, | |
double | t | |||
) |
std::ostream& operator<< | ( | std::ostream & | s, | |
const SprVector & | q | |||
) |
Definition at line 410 of file SprVector.cc.
References lat::endl(), and width.
00411 { 00412 s << std::endl; 00413 /* Fixed format needs 3 extra characters for field, while scientific needs 7 */ 00414 int width; 00415 if(s.flags() & std::ios::fixed) 00416 width = s.precision()+3; 00417 else 00418 width = s.precision()+7; 00419 for(int irow = 1; irow<= q.num_row(); irow++) 00420 { 00421 s.width(width); 00422 s << q(irow) << std::endl; 00423 } 00424 return s; 00425 }
SprVector solve | ( | const SprMatrix & | a, | |
const SprVector & | v | |||
) |
Definition at line 462 of file SprVector.cc.
References error, i, j, n, s22, and te.
Referenced by align::diffRot(), CSCSegAlgoHitPruning::fitSlopes(), CSCSegAlgoTC::fitSlopes(), CSCSegAlgoSK::fitSlopes(), BlockSolver::operator()(), IMACalibBlock::solve(), CSCSegAlgoShowering::updateParameters(), and CSCSegAlgoDF::updateParameters().
00463 { 00464 SprVector vret(v); 00465 static int max_array = 20; 00466 static int *ir = new int [max_array+1]; 00467 00468 if(a.ncol != a.nrow) 00469 SprGenMatrix::error("Matrix::solve Matrix is not NxN"); 00470 if(a.ncol != v.nrow) 00471 SprGenMatrix::error("Matrix::solve Vector has wrong number of rows"); 00472 00473 int n = a.ncol; 00474 if (n > max_array) { 00475 delete [] ir; 00476 max_array = n; 00477 ir = new int [max_array+1]; 00478 } 00479 double det; 00480 SprMatrix mt(a); 00481 int i = mt.dfact_matrix(det, ir); 00482 if (i!=0) { 00483 for (i=1;i<=n;i++) vret(i) = 0; 00484 return vret; 00485 } 00486 double s21, s22; 00487 int nxch = ir[n]; 00488 if (nxch!=0) { 00489 for (int mm=1;mm<=nxch;mm++) { 00490 int ij = ir[mm]; 00491 i = ij >> 12; 00492 int j = ij%4096; 00493 double te = vret(i); 00494 vret(i) = vret(j); 00495 vret(j) = te; 00496 } 00497 } 00498 vret(1) = mt(1,1) * vret(1); 00499 if (n!=1) { 00500 for (i=2;i<=n;i++) { 00501 s21 = -vret(i); 00502 for (int j=1;j<i;j++) { 00503 s21 += mt(i,j) * vret(j); 00504 } 00505 vret(i) = -mt(i,i)*s21; 00506 } 00507 for (i=1;i<n;i++) { 00508 int nmi = n-i; 00509 s22 = -vret(nmi); 00510 for (int j=1;j<=i;j++) { 00511 s22 += mt(nmi,n-j+1) * vret(n-j+1); 00512 } 00513 vret(nmi) = -s22; 00514 } 00515 } 00516 return vret; 00517 }