CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
gbl::VVector Class Reference

Simple Vector based on std::vector<double> More...

#include <VMatrix.h>

Public Member Functions

unsigned int getNumRows () const
 Get number of rows. More...
 
VVector getVec (unsigned int len, unsigned int start=0) const
 Get part of vector. More...
 
double & operator() (unsigned int i)
 access element (i) More...
 
double operator() (unsigned int i) const
 access element (i) More...
 
VVector operator- (const VVector &aVector) const
 Subtraction Vector-Vector. More...
 
VVectoroperator= (const VVector &aVector)
 Assignment Vector=Vector. More...
 
void print () const
 Print vector. More...
 
void putVec (const VVector &aVector, unsigned int start=0)
 Put part of vector. More...
 
void resize (const unsigned int nRows)
 Resize vector. More...
 
 VVector (const unsigned int nRows=0)
 
 VVector (const VVector &aVector)
 
virtual ~VVector ()
 

Private Attributes

unsigned int numRows
 Number of rows. More...
 
std::vector< double > theVec
 Data. More...
 

Detailed Description

Simple Vector based on std::vector<double>

Definition at line 43 of file VMatrix.h.

Constructor & Destructor Documentation

gbl::VVector::VVector ( const unsigned int  nRows = 0)

Definition at line 246 of file VMatrix.cc.

246  :
247  numRows(nRows), theVec(nRows) {
248  }
std::vector< double > theVec
Data.
Definition: VMatrix.h:59
unsigned int numRows
Number of rows.
Definition: VMatrix.h:58
gbl::VVector::VVector ( const VVector aVector)

Definition at line 250 of file VMatrix.cc.

250  :
251  numRows(aVector.numRows), theVec(aVector.theVec) {
252 
253  }
std::vector< double > theVec
Data.
Definition: VMatrix.h:59
unsigned int numRows
Number of rows.
Definition: VMatrix.h:58
gbl::VVector::~VVector ( )
virtual

Definition at line 255 of file VMatrix.cc.

255  {
256  }

Member Function Documentation

unsigned int gbl::VVector::getNumRows ( ) const

Get number of rows.

Returns
Number of rows.

Definition at line 293 of file VMatrix.cc.

References numRows.

Referenced by operator=().

293  {
294  return numRows;
295  }
unsigned int numRows
Number of rows.
Definition: VMatrix.h:58
VVector gbl::VVector::getVec ( unsigned int  len,
unsigned int  start = 0 
) const

Get part of vector.

Parameters
[in]lenLength of part.
[in]startOffset of part.
Returns
Part of vector.

Definition at line 273 of file VMatrix.cc.

References theVec.

Referenced by gbl::BorderedBandMatrix::solveAndInvertBorderedBand().

273  {
274  VVector aResult(len);
275  std::memcpy(&aResult.theVec[0], &theVec[start], sizeof(double) * len);
276  return aResult;
277  }
Definition: start.py:1
VVector(const unsigned int nRows=0)
Definition: VMatrix.cc:246
std::vector< double > theVec
Data.
Definition: VMatrix.h:59
double & gbl::VVector::operator() ( unsigned int  i)
inline

access element (i)

Definition at line 115 of file VMatrix.h.

References theVec.

115  {
116  return theVec[iRow];
117  }
std::vector< double > theVec
Data.
Definition: VMatrix.h:59
double gbl::VVector::operator() ( unsigned int  i) const
inline

access element (i)

Definition at line 120 of file VMatrix.h.

References theVec.

120  {
121  return theVec[iRow];
122  }
std::vector< double > theVec
Data.
Definition: VMatrix.h:59
VVector gbl::VVector::operator- ( const VVector aVector) const

Subtraction Vector-Vector.

Definition at line 312 of file VMatrix.cc.

References mps_fire::i, numRows, and theVec.

312  {
313  VVector aResult(numRows);
314  for (unsigned int i = 0; i < numRows; ++i) {
315  aResult(i) = theVec[i] - aVector(i);
316  }
317  return aResult;
318  }
VVector(const unsigned int nRows=0)
Definition: VMatrix.cc:246
std::vector< double > theVec
Data.
Definition: VMatrix.h:59
unsigned int numRows
Number of rows.
Definition: VMatrix.h:58
VVector & gbl::VVector::operator= ( const VVector aVector)

Assignment Vector=Vector.

Definition at line 321 of file VMatrix.cc.

References getNumRows(), mps_fire::i, numRows, and theVec.

321  {
322  if (this != &aVector) { // Gracefully handle self assignment
323  numRows = aVector.getNumRows();
324  theVec.resize(numRows);
325  for (unsigned int i = 0; i < numRows; ++i) {
326  theVec[i] = aVector(i);
327  }
328  }
329  return *this;
330  }
std::vector< double > theVec
Data.
Definition: VMatrix.h:59
unsigned int numRows
Number of rows.
Definition: VMatrix.h:58
void gbl::VVector::print ( void  ) const

Print vector.

Definition at line 298 of file VMatrix.cc.

References gather_cfg::cout, mps_fire::i, min(), numRows, and theVec.

Referenced by gbl::GblTrajectory::printTrajectory().

298  {
299  std::cout << " VVector: " << numRows << std::endl;
300  for (unsigned int i = 0; i < numRows; ++i) {
301 
302  if (i % 5 == 0) {
303  std::cout << std::endl << std::setw(4) << i << "-" << std::setw(4)
304  << std::min(i + 4, numRows) << ":";
305  }
306  std::cout << std::setw(13) << theVec[i];
307  }
308  std::cout << std::endl << std::endl;
309  }
T min(T a, T b)
Definition: MathUtil.h:58
std::vector< double > theVec
Data.
Definition: VMatrix.h:59
unsigned int numRows
Number of rows.
Definition: VMatrix.h:58
void gbl::VVector::putVec ( const VVector aVector,
unsigned int  start = 0 
)

Put part of vector.

Parameters
[in]aVectorVector with part.
[in]startOffset of part.

Definition at line 284 of file VMatrix.cc.

References numRows, and theVec.

Referenced by gbl::BorderedBandMatrix::solveAndInvertBorderedBand().

284  {
285  std::memcpy(&theVec[start], &aVector.theVec[0],
286  sizeof(double) * aVector.numRows);
287  }
Definition: start.py:1
std::vector< double > theVec
Data.
Definition: VMatrix.h:59
void gbl::VVector::resize ( const unsigned int  nRows)

Resize vector.

Parameters
[in]nRowsNumber of rows.

Definition at line 262 of file VMatrix.cc.

References numRows, and theVec.

Referenced by Vispa.Gui.TextDialog.TextDialog::__init__(), Vispa.Plugins.ConfigEditor.ToolDialog.ToolDialog::__init__(), Vispa.Main.MainWindow.MainWindow::_loadIni(), gbl::GblTrajectory::buildLinearEquationSystem(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

262  {
263  numRows = nRows;
264  theVec.resize(nRows);
265  }
std::vector< double > theVec
Data.
Definition: VMatrix.h:59
unsigned int numRows
Number of rows.
Definition: VMatrix.h:58

Member Data Documentation

unsigned int gbl::VVector::numRows
private

Number of rows.

Definition at line 58 of file VMatrix.h.

Referenced by getNumRows(), gbl::VSymMatrix::invert(), operator-(), operator=(), print(), putVec(), and resize().

std::vector<double> gbl::VVector::theVec
private