test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 21 of file VMatrix.h.

Constructor & Destructor Documentation

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

Definition at line 224 of file VMatrix.cc.

224  :
225  numRows(nRows), theVec(nRows) {
226 }
std::vector< double > theVec
Data.
Definition: VMatrix.h:37
unsigned int numRows
Number of rows.
Definition: VMatrix.h:36
gbl::VVector::VVector ( const VVector aVector)

Definition at line 228 of file VMatrix.cc.

228  :
229  numRows(aVector.numRows), theVec(aVector.theVec) {
230 
231 }
std::vector< double > theVec
Data.
Definition: VMatrix.h:37
unsigned int numRows
Number of rows.
Definition: VMatrix.h:36
gbl::VVector::~VVector ( )
virtual

Definition at line 233 of file VMatrix.cc.

233  {
234 }

Member Function Documentation

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

Get number of rows.

Returns
Number of rows.

Definition at line 271 of file VMatrix.cc.

References numRows.

Referenced by operator=().

271  {
272  return numRows;
273 }
unsigned int numRows
Number of rows.
Definition: VMatrix.h:36
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 251 of file VMatrix.cc.

References theVec.

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

251  {
252  VVector aResult(len);
253  std::memcpy(&aResult.theVec[0], &theVec[start], sizeof(double) * len);
254  return aResult;
255 }
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
VVector(const unsigned int nRows=0)
Definition: VMatrix.cc:224
std::vector< double > theVec
Data.
Definition: VMatrix.h:37
double & gbl::VVector::operator() ( unsigned int  i)
inline

access element (i)

Definition at line 93 of file VMatrix.h.

References theVec.

93  {
94  return theVec[iRow];
95 }
std::vector< double > theVec
Data.
Definition: VMatrix.h:37
double gbl::VVector::operator() ( unsigned int  i) const
inline

access element (i)

Definition at line 98 of file VMatrix.h.

References theVec.

98  {
99  return theVec[iRow];
100 }
std::vector< double > theVec
Data.
Definition: VMatrix.h:37
VVector gbl::VVector::operator- ( const VVector aVector) const

Subtraction Vector-Vector.

Definition at line 290 of file VMatrix.cc.

References i, numRows, and theVec.

290  {
291  VVector aResult(numRows);
292  for (unsigned int i = 0; i < numRows; ++i) {
293  aResult(i) = theVec[i] - aVector(i);
294  }
295  return aResult;
296 }
int i
Definition: DBlmapReader.cc:9
VVector(const unsigned int nRows=0)
Definition: VMatrix.cc:224
std::vector< double > theVec
Data.
Definition: VMatrix.h:37
unsigned int numRows
Number of rows.
Definition: VMatrix.h:36
VVector & gbl::VVector::operator= ( const VVector aVector)

Assignment Vector=Vector.

Definition at line 299 of file VMatrix.cc.

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

299  {
300  if (this != &aVector) { // Gracefully handle self assignment
301  numRows = aVector.getNumRows();
302  theVec.resize(numRows);
303  for (unsigned int i = 0; i < numRows; ++i) {
304  theVec[i] = aVector(i);
305  }
306  }
307  return *this;
308 }
int i
Definition: DBlmapReader.cc:9
std::vector< double > theVec
Data.
Definition: VMatrix.h:37
unsigned int numRows
Number of rows.
Definition: VMatrix.h:36
void gbl::VVector::print ( void  ) const

Print vector.

Definition at line 276 of file VMatrix.cc.

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

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

276  {
277  std::cout << " VVector: " << numRows << std::endl;
278  for (unsigned int i = 0; i < numRows; ++i) {
279 
280  if (i % 5 == 0) {
281  std::cout << std::endl << std::setw(4) << i << "-" << std::setw(4)
282  << std::min(i + 4, numRows) << ":";
283  }
284  std::cout << std::setw(13) << theVec[i];
285  }
286  std::cout << std::endl << std::endl;
287 }
int i
Definition: DBlmapReader.cc:9
T min(T a, T b)
Definition: MathUtil.h:58
tuple cout
Definition: gather_cfg.py:145
std::vector< double > theVec
Data.
Definition: VMatrix.h:37
unsigned int numRows
Number of rows.
Definition: VMatrix.h:36
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 262 of file VMatrix.cc.

References numRows, and theVec.

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

262  {
263  std::memcpy(&theVec[start], &aVector.theVec[0],
264  sizeof(double) * aVector.numRows);
265 }
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
std::vector< double > theVec
Data.
Definition: VMatrix.h:37
void gbl::VVector::resize ( const unsigned int  nRows)

Resize vector.

Parameters
[in]nRowsNumber of rows.

Definition at line 240 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().

240  {
241  numRows = nRows;
242  theVec.resize(nRows);
243 }
std::vector< double > theVec
Data.
Definition: VMatrix.h:37
unsigned int numRows
Number of rows.
Definition: VMatrix.h:36

Member Data Documentation

unsigned int gbl::VVector::numRows
private

Number of rows.

Definition at line 36 of file VMatrix.h.

Referenced by getNumRows(), operator-(), operator=(), print(), putVec(), and resize().

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

Data.

Definition at line 37 of file VMatrix.h.

Referenced by getVec(), operator()(), operator-(), operator=(), print(), putVec(), and resize().