Vector Class Reference

The Vector class. More...

#include <matpackI.h>

Inheritance diagram for Vector:

VectorView ConstVectorView MakeVector

List of all members.

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.
Vectoroperator= (const Vector &v)
 Assignment from another Vector.
Vectoroperator= (const Array< Numeric > &v)
 Assignment operator from Array<Numeric>.
Vectoroperator= (Numeric x)
 Assignment operator from scalar.
void resize (Index n)
 Assignment operator from VectorView.
 ~Vector ()
 Destructor for Vector.


Detailed Description

The Vector class.

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.


Constructor & Destructor Documentation

Vector::Vector (  )  [inline]

Default constructor.

Definition at line 1341 of file matpackI.h.

Vector::Vector ( Index  n  )  [inline, explicit]

Constructor setting size.

Definition at line 1347 of file matpackI.h.

Vector::Vector ( Index  n,
Numeric  fill 
) [inline]

Constructor setting size and filling with constant value.

Definition at line 1355 of file matpackI.h.

Vector::Vector ( Numeric  start,
Index  extent,
Numeric  stride 
) [inline]

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.


Member Function Documentation

Vector & Vector::operator= ( const Vector v  )  [inline]

Assignment from another Vector.

Important to avoid segmentation fault for x = Vector(n);

Reimplemented from VectorView.

Definition at line 1413 of file matpackI.h.

Vector & Vector::operator= ( const Array< Numeric > &  x  )  [inline]

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.

Vector & Vector::operator= ( Numeric  x  )  [inline]

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.


The documentation for this class was generated from the following file:

Generated on Wed Feb 4 08:17:40 2009 for ARTS by  doxygen 1.5.6