#include <matpackI.h>
Public Member Functions | |
Vector () | |
Default constructor. | |
Vector (Index n) | |
Constructor setting size. | |
Vector (Index n, Numeric fill) | |
Constructor setting size and filling with constant value. | |
Vector (Numeric start, Index extent, Numeric stride) | |
Constructor filling with values. | |
Vector (const ConstVectorView &v) | |
Copy constructor from VectorView. | |
Vector (const Vector &v) | |
Copy constructor from Vector. | |
Vector & | operator= (const Vector &v) |
Assignment from another Vector. | |
Vector & | operator= (const Array< Numeric > &v) |
Assignment operator from Array<Numeric>. | |
Vector & | operator= (Numeric x) |
Assignment operator from scalar. | |
void | resize (Index n) |
Assignment operator from VectorView. | |
~Vector () | |
Destructor for Vector. |
This is a subvector that also allocates storage automatically, and deallocates it when it is destroyed. We take all the functionality from VectorView. Additionally defined in this class are:
1. Constructors and destructors (allocating memory). 2. Assignment operator from scalar. 3. Resize function.
It seems that we need no assignment operator from VectorView or Vector, because the one of VectorView is used.
Definition at line 389 of file matpackI.h.
Vector::Vector | ( | ) | [inline] |
Vector::Vector | ( | Index | n | ) | [inline, explicit] |
Constructor setting size and filling with constant value.
Definition at line 1355 of file matpackI.h.
Constructor filling with values.
Examples:
Vector v(1,5,1); // 1, 2, 3, 4, 5 Vector v(1,5,.5); // 1, 1.5, 2, 2.5, 3 Vector v(5,5,-1); // 5, 4, 3, 2, 1
Definition at line 1373 of file matpackI.h.
Vector::Vector | ( | const ConstVectorView & | v | ) | [inline] |
Copy constructor from VectorView.
This automatically sets the size and copies the data. The vector created will have start zero and stride 1, independent on how these parameters are set for the original. So, what is copied is the data, not the shape of the selection.
Definition at line 1393 of file matpackI.h.
Vector::Vector | ( | const Vector & | v | ) | [inline] |
Copy constructor from Vector.
This is important to override the automatically generated shallow constructor. We want deep copies!
Definition at line 1402 of file matpackI.h.
Vector::~Vector | ( | ) | [inline] |
Destructor for Vector.
This is important, since Vector uses new to allocate storage.
Definition at line 1481 of file matpackI.h.
Assignment from another Vector.
Important to avoid segmentation fault for x = Vector(n);
Reimplemented from VectorView.
Definition at line 1413 of file matpackI.h.
Assignment operator from Array<Numeric>.
This copies the data from a Array<Numeric> to this VectorView. Dimensions must agree! Resizing would destroy the selection that we might have done in this VectorView by setting its range.
Array<Numeric> can be useful to collect things in, because there is a .push_back method for it. Then, after collecting we usually have to transfer the content to a Vector. With this assignment operator that's easy.
Assignment operators are not inherited, so we have to make an explicit call to:
VectorView VectorView::operator=(const Array<Numeric>& v)
here.
Reimplemented from VectorView.
Definition at line 1439 of file matpackI.h.
Assignment operator from scalar.
Assignment operators are not inherited.
Reimplemented from VectorView.
Definition at line 1447 of file matpackI.h.
void Vector::resize | ( | Index | n | ) | [inline] |
Assignment operator from VectorView.
Assignment operators are not inherited. Resize function. If the size is already correct this function does nothing. All data is lost after resizing! The new Vector is not initialized, so it will contain random values.
Definition at line 1467 of file matpackI.h.