VectorView Class Reference

The VectorView class. More...

#include <matpackI.h>

Inheritance diagram for VectorView:

Inheritance graph
[legend]
Collaboration diagram for VectorView:

Collaboration graph
[legend]

List of all members.

Public Types

typedef Iterator1D iterator

Public Member Functions

 VectorView (const Vector &)
 Bail out immediately if somebody tries to create a VectorView from a const Vector.
 VectorView (Vector &v)
 Create VectorView from a Vector.
Numeric operator[] (Index n) const
 Plain const index operator.
ConstVectorView operator[] (const Range &r) const
 Const index operator for subrange.
Numericoperator[] (Index n)
 Plain Index operator.
VectorView operator[] (const Range &r)
 Index operator for subrange.
ConstIterator1D begin () const
 Return const iterator to first element.
ConstIterator1D end () const
 Return const iterator behind last element.
Iterator1D begin ()
 Return iterator to first element.
Iterator1D end ()
 Return iterator behind last element.
VectorViewoperator= (const ConstVectorView &v)
 Assignment operator.
VectorViewoperator= (const VectorView &v)
 Assignment from VectorView to VectorView.
VectorViewoperator= (const Vector &v)
 Assignment from Vector.
VectorViewoperator= (const Array< Numeric > &v)
 Assignment operator from Array<Numeric>.
VectorViewoperator= (Numeric x)
 Assigning a scalar to a VectorView will set all elements to this value.
VectorView operator*= (Numeric x)
 Multiplication by scalar.
VectorView operator/= (Numeric x)
 Division by scalar.
VectorView operator+= (Numeric x)
 Addition of scalar.
VectorView operator-= (Numeric x)
 Subtraction of scalar.
VectorView operator*= (const ConstVectorView &x)
 Element-vise multiplication by another vector.
VectorView operator/= (const ConstVectorView &x)
 Element-vise division by another vector.
VectorView operator+= (const ConstVectorView &x)
 Element-vise addition of another vector.
VectorView operator-= (const ConstVectorView &x)
 Element-vise subtraction of another vector.
 operator MatrixView ()
 Conversion to 1 column matrix.
const Numericget_c_array () const
 Conversion to plain C-array.
Numericget_c_array ()
 Conversion to plain C-array.
virtual ~VectorView ()
 Destructor.
 VectorView (Numeric &a)
 A special constructor, which allows to make a VectorView from a scalar.

Protected Member Functions

 VectorView ()
 Default constructor.
 VectorView (Numeric *data, const Range &range)
 Explicit constructor.
 VectorView (Numeric *data, const Range &p, const Range &n)
 Recursive constructor.

Friends

class ConstIterator2D
class Iterator2D
class MatrixView
class Tensor3View
class Tensor4View
class Tensor5View
class Tensor6View
class Tensor7View


Detailed Description

The VectorView class.

This contains the main implementation of a vector. The class Vector is just a special case of subvector which also allocates storage.

Unfortunately, names of element functions of derived classes hide the names of the original class, even if the arguments are different. This means that we have to redefine those element functions that can have different arguments, for example the constant index operators and iterators.

Definition at line 364 of file matpackI.h.


Member Typedef Documentation

Definition at line 370 of file matpackI.h.


Constructor & Destructor Documentation

VectorView::VectorView ( const Vector  ) 

Bail out immediately if somebody tries to create a VectorView from a const Vector.

Definition at line 294 of file matpackI.cc.

VectorView::VectorView ( Vector v  ) 

Create VectorView from a Vector.

Definition at line 305 of file matpackI.cc.

References ConstVectorView::mdata, and ConstVectorView::mrange.

virtual VectorView::~VectorView (  )  [inline, virtual]

Destructor.

Definition at line 424 of file matpackI.h.

VectorView::VectorView ( Numeric a  ) 

A special constructor, which allows to make a VectorView from a scalar.

Definition at line 547 of file matpackI.cc.

VectorView::VectorView (  )  [protected]

Default constructor.

This is necessary, so that we can have a default constructor for the derived class Vector.

Definition at line 555 of file matpackI.cc.

Referenced by operator[]().

VectorView::VectorView ( Numeric data,
const Range range 
) [protected]

Explicit constructor.

This one is used by Vector to initialize its own VectorView part.

Definition at line 563 of file matpackI.cc.

VectorView::VectorView ( Numeric data,
const Range p,
const Range n 
) [protected]

Recursive constructor.

This is used to construct sub ranges from sub ranges. That means that the new range has to be interpreted relative to the original range. The new range may contain -1 for the extent which acts as a joker. However, the used Range constructor converts this to an explicit range, consistent with the original Range.

Parameters:
*data The actual data.
p Previous range.
n New Range.

Definition at line 580 of file matpackI.cc.


Member Function Documentation

Numeric VectorView::operator[] ( Index  n  )  const [inline]

Plain const index operator.

Has to be redifined here, because the one from ConstVectorView is hidden.

Reimplemented from ConstVectorView.

Definition at line 375 of file matpackI.h.

References ConstVectorView::operator[]().

Referenced by MakeVector::MakeVector().

ConstVectorView VectorView::operator[] ( const Range r  )  const

Const index operator for subrange.

We have to also account for the case, that *this is already a subrange of a Vector. This allows correct recursive behavior. Has to be redifined here, because the one from ConstVectorView is hidden.

Reimplemented from ConstVectorView.

Definition at line 315 of file matpackI.cc.

References ConstVectorView::operator[]().

Numeric& VectorView::operator[] ( Index  n  )  [inline]

Plain Index operator.

Definition at line 381 of file matpackI.h.

References ConstVectorView::mdata, Range::mextent, ConstVectorView::mrange, Range::mstart, and Range::mstride.

VectorView VectorView::operator[] ( const Range r  ) 

Index operator for subrange.

We have to also account for the case, that *this is already a subrange of a Vector. This allows correct recursive behavior.

Definition at line 323 of file matpackI.cc.

References ConstVectorView::mdata, ConstVectorView::mrange, and VectorView().

ConstIterator1D VectorView::begin (  )  const

Return const iterator to first element.

Has to be redefined here, since it is hiden by the non-const operator of the derived class.

Reimplemented from ConstVectorView.

Definition at line 331 of file matpackI.cc.

References ConstVectorView::begin().

Referenced by operator*=(), operator+=(), operator-=(), operator/=(), Vector::operator=(), operator=(), test03(), test1(), transform(), and Vector::Vector().

ConstIterator1D VectorView::end (  )  const

Return const iterator behind last element.

Has to be redefined here, since it is hiden by the non-const operator of the derived class.

Reimplemented from ConstVectorView.

Definition at line 339 of file matpackI.cc.

References ConstVectorView::end().

Referenced by operator*=(), operator+=(), operator-=(), operator/=(), Vector::operator=(), operator=(), test03(), and Vector::Vector().

Iterator1D VectorView::begin (  ) 

Return iterator to first element.

Definition at line 345 of file matpackI.cc.

References ConstVectorView::mdata, ConstVectorView::mrange, Range::mstart, and Range::mstride.

Iterator1D VectorView::end (  ) 

Return iterator behind last element.

Definition at line 351 of file matpackI.cc.

References ConstVectorView::mdata, Range::mextent, ConstVectorView::mrange, Range::mstart, and Range::mstride.

VectorView & VectorView::operator= ( const ConstVectorView v  ) 

Assignment operator.

This copies the data from another VectorView to this VectorView. Dimensions must agree! Resizing would destroy the selection that we might have done in this VectorView by setting its range.

Definition at line 363 of file matpackI.cc.

References begin(), ConstVectorView::begin(), copy(), ConstVectorView::end(), Range::mextent, and ConstVectorView::mrange.

Referenced by Vector::operator=().

VectorView & VectorView::operator= ( const VectorView v  ) 

Assignment from VectorView to VectorView.

This is a tricky one. The problem is that since VectorView is derived from ConstVectorView, a default = operator is generated by the compiler, which does not do what we want. So we need this one to override the default.

Definition at line 380 of file matpackI.cc.

References begin(), copy(), end(), Range::mextent, and ConstVectorView::mrange.

VectorView & VectorView::operator= ( const Vector v  ) 

Assignment from Vector.

This is important to avoid a bug when assigning a Vector to a VectorView.

Reimplemented in Vector.

Definition at line 394 of file matpackI.cc.

References begin(), copy(), end(), Range::mextent, and ConstVectorView::mrange.

VectorView & VectorView::operator= ( const Array< Numeric > &  v  ) 

Assignment operator from Array<Numeric>.

This copies the data from an 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.

Reimplemented in Vector.

Definition at line 1892 of file matpackI.cc.

References begin(), Range::mextent, ConstVectorView::mrange, and Array< base >::nelem().

VectorView & VectorView::operator= ( Numeric  x  ) 

Assigning a scalar to a VectorView will set all elements to this value.

Reimplemented in Vector.

Definition at line 408 of file matpackI.cc.

References begin(), copy(), and end().

VectorView VectorView::operator*= ( Numeric  x  ) 

Multiplication by scalar.

Definition at line 415 of file matpackI.cc.

References begin(), and end().

VectorView VectorView::operator/= ( Numeric  x  ) 

Division by scalar.

Definition at line 424 of file matpackI.cc.

References begin(), and end().

VectorView VectorView::operator+= ( Numeric  x  ) 

Addition of scalar.

Definition at line 433 of file matpackI.cc.

References begin(), and end().

VectorView VectorView::operator-= ( Numeric  x  ) 

Subtraction of scalar.

Definition at line 442 of file matpackI.cc.

References begin(), and end().

VectorView VectorView::operator*= ( const ConstVectorView x  ) 

Element-vise multiplication by another vector.

Definition at line 451 of file matpackI.cc.

References begin(), ConstVectorView::begin(), end(), and ConstVectorView::nelem().

VectorView VectorView::operator/= ( const ConstVectorView x  ) 

Element-vise division by another vector.

Definition at line 466 of file matpackI.cc.

References begin(), ConstVectorView::begin(), end(), and ConstVectorView::nelem().

VectorView VectorView::operator+= ( const ConstVectorView x  ) 

Element-vise addition of another vector.

Definition at line 481 of file matpackI.cc.

References begin(), ConstVectorView::begin(), end(), and ConstVectorView::nelem().

VectorView VectorView::operator-= ( const ConstVectorView x  ) 

Element-vise subtraction of another vector.

Definition at line 496 of file matpackI.cc.

References begin(), ConstVectorView::begin(), end(), and ConstVectorView::nelem().

VectorView::operator MatrixView (  ) 

Conversion to 1 column matrix.

Definition at line 511 of file matpackI.cc.

References MatrixView, ConstVectorView::mdata, ConstVectorView::mrange, and Range::mstart.

const Numeric * VectorView::get_c_array (  )  const

Conversion to plain C-array.

This function returns a pointer to the raw data. It fails if the VectorView is not pointing to the beginning of a Vector or the stride is not 1 because the caller expects to get a C array with continuous data.

Definition at line 522 of file matpackI.cc.

References ConstVectorView::mdata, ConstVectorView::mrange, Range::mstart, and Range::mstride.

Referenced by nc_read_from_file(), nc_write_to_file(), and test38().

Numeric * VectorView::get_c_array (  ) 

Conversion to plain C-array.

This function returns a pointer to the raw data. It fails if the VectorView is not pointing to the beginning of a Vector or the stride is not 1 because the caller expects to get a C array with continuous data.

Definition at line 536 of file matpackI.cc.

References ConstVectorView::mdata, ConstVectorView::mrange, Range::mstart, and Range::mstride.


Friends And Related Function Documentation

friend class ConstIterator2D [friend]

Reimplemented from ConstVectorView.

Definition at line 424 of file matpackI.h.

friend class Iterator2D [friend]

Definition at line 428 of file matpackI.h.

friend class MatrixView [friend]

Definition at line 429 of file matpackI.h.

Referenced by operator MatrixView().

friend class Tensor3View [friend]

Definition at line 430 of file matpackI.h.

friend class Tensor4View [friend]

Definition at line 431 of file matpackI.h.

friend class Tensor5View [friend]

Definition at line 432 of file matpackI.h.

friend class Tensor6View [friend]

Definition at line 433 of file matpackI.h.

friend class Tensor7View [friend]

Definition at line 434 of file matpackI.h.


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

Generated on Mon Mar 23 14:07:06 2009 for ARTS by  doxygen 1.5.6