STK++ 1.0

STK::Array1D< Real > Class Template Reference

Specialization of the templated class Array1D for Real. More...

#include <STK_Vector.h>

Inheritance diagram for STK::Array1D< Real >:

List of all members.

Public Member Functions

 Array1D (Range const &I=Range())
 Default constructor : first_ =1 and last_ =0.
 Array1D (Range const &I, Real const &v)
 Misc constructor with beg and end, initialization with a constant.
 Array1D (const Array1D &T, bool ref=false)
 Copy constructor.
 Array1D (Array1D const &T, Range const &I)
 constructor by reference, ref_=1.
 Array1D (Real *q, Range const &I, Integer const &index=0)
 Wrapper constructor : the container is a reference.
 Array1D (const _IArrayBaseType &T, Range const &I, Integer const &index)
 constructor by reference, ref_=1.
virtual ~Array1D ()
 Virtual destructor: allocated memory is liberated by IArrayBase base class.
Realelt (Integer const &pos)
 access to one element.
Real const & elt (Integer const &pos) const
 access to one element const.
Array1D elt (Range const &J) const
 access to many elements.
Array1Doperator= (Array1D const &T)
 operator = : overwrite the Array1D with T.
Array1Doperator= (Real const &v)
 operator= : set the container to a constant value.
Array1Doperator+= (Real const &v)
 operator+= Adding a constant.
Array1Doperator-= (Real const &v)
 operator -= decreasing a constant.
Array1Doperator/= (Real const &v)
 operator /= Dividing a constant.
Array1Doperator*= (Real const &v)
 operator *= Multiplying a constant.
template<class LEAF >
Array1Doperator= (const ITContainer1D< Real, LEAF > &T)
 operator = : overwrite the Array1D with the container T.
template<class Exp >
Array1Doperator= (const Exp &rhs)
 operator = overwriting a Array1D with An Expression.
template<class Exp >
Array1Doperator+= (const Exp &rhs)
 operator += Adding an Expression.
template<class Exp >
Array1Doperator-= (const Exp &rhs)
 operator -= decreasing an Expression.
template<class Exp >
Array1Doperator/= (const Exp &rhs)
 operator /= Dividing an Expression.
template<class Exp >
Array1Doperator*= (const Exp &rhs)
 operator *= Multiplying an Expression.

Private Types

typedef IArrayBase< Real * > _IArrayBaseType
 Type for the Base reference Class.
typedef RecursiveArray1D< Real,
Array1D< Real > > 
_IArray1DType
 Type for the IArray1DBase Class.

Detailed Description

template<>
class STK::Array1D< Real >

Specialization of the templated class Array1D for Real.

A Vector is a final Array1D class. It is a vertical (column) container.

Definition at line 61 of file STK_Vector.h.


Member Typedef Documentation

typedef IArrayBase<Real*> STK::Array1D< Real >::_IArrayBaseType [private]

Type for the Base reference Class.

Reimplemented from STK::RecursiveArray1D< Real, Array1D< Real > >.

Definition at line 64 of file STK_Vector.h.

Type for the IArray1DBase Class.

Reimplemented from STK::RecursiveArray1D< Real, Array1D< Real > >.

Definition at line 66 of file STK_Vector.h.


Constructor & Destructor Documentation

STK::Array1D< Real >::Array1D ( Range const &  I = Range()) [inline]

Default constructor : first_ =1 and last_ =0.

Parameters:
Irange of the container

Definition at line 72 of file STK_Vector.h.

          : _IArray1DType(I)
    { ;}
STK::Array1D< Real >::Array1D ( Range const &  I,
Real const &  v 
) [inline]

Misc constructor with beg and end, initialization with a constant.

Parameters:
Irange of the container
vinitial value of the container

Definition at line 80 of file STK_Vector.h.

References STK::ITContainer1D< TYPE, Array1D< TYPE > >::first(), STK::ITContainer1D< TYPE, Array1D< TYPE > >::last(), and STK::IArrayBase< TYPE >::setData().

           : _IArray1DType(I)
    {
      for (Integer i=first(); i<=last(); i++)
        setData(i, v);
    }
STK::Array1D< Real >::Array1D ( const Array1D< Real > &  T,
bool  ref = false 
) [inline]

Copy constructor.

Parameters:
Tthe container to copy
reftrue if T is wrapped

Definition at line 91 of file STK_Vector.h.

References STK::IArrayBase< DATA >::data(), STK::ITContainer1D< TYPE, Array1D< TYPE > >::first(), STK::ITContainer1D< TYPE, Array1D< TYPE > >::last(), and STK::IArrayBase< TYPE >::setData().

           : _IArray1DType(T, ref)
    {
      // check if we want just a reference
      if (!ref)
      {
        for (Integer j=first(); j<=last(); j++)
          setData(j, T.data(j));
      }
    }
STK::Array1D< Real >::Array1D ( Array1D< Real > const &  T,
Range const &  I 
) [inline]

constructor by reference, ref_=1.

Parameters:
Tthe container to copy
Irange of the data to wrap

Definition at line 106 of file STK_Vector.h.

           : _IArray1DType(T, I)
    { ;}
STK::Array1D< Real >::Array1D ( Real q,
Range const &  I,
Integer const &  index = 0 
) [inline]

Wrapper constructor : the container is a reference.

Parameters:
qpointer on data
Irange of the data
indexindex (row or col) of the data

Definition at line 115 of file STK_Vector.h.

           : _IArray1DType(q, I, index)
    { ;}
STK::Array1D< Real >::Array1D ( const _IArrayBaseType T,
Range const &  I,
Integer const &  index 
) [inline]

constructor by reference, ref_=1.

Parameters:
Tthe container to wrap
Ithe range of the data to wrap
indexthe index of the column to wrap

Definition at line 124 of file STK_Vector.h.

            : _IArray1DType(T.data(index), I, index)
    { ;}
virtual STK::Array1D< Real >::~Array1D ( ) [inline, virtual]

Virtual destructor: allocated memory is liberated by IArrayBase base class.

Definition at line 131 of file STK_Vector.h.

{ ;}

Member Function Documentation

Real& STK::Array1D< Real >::elt ( Integer const &  pos) [inline]

access to one element.

Parameters:
posindex of the element

Reimplemented from STK::ITContainer1D< Real, Array1D< Real > >.

Definition at line 136 of file STK_Vector.h.

References STK::IArrayBase< TYPE >::data().

    { return this->data(pos);}
Real const& STK::Array1D< Real >::elt ( Integer const &  pos) const [inline]

access to one element const.

Parameters:
posindex of the const element

Reimplemented from STK::ITContainer1D< Real, Array1D< Real > >.

Definition at line 142 of file STK_Vector.h.

References STK::IArrayBase< TYPE >::data().

    { return this->data(pos);}
Array1D STK::Array1D< Real >::elt ( Range const &  J) const [inline]

access to many elements.

Parameters:
Jthe range of the elements

Reimplemented from STK::ITContainer1D< Real, Array1D< Real > >.

Definition at line 148 of file STK_Vector.h.

References STK::Array1D< TYPE >::Array1D(), STK::ITContainer1D< TYPE, Array1D< TYPE > >::first(), STK::Range::first(), STK::ITContainer1D< TYPE, Array1D< TYPE > >::last(), and STK::Range::last().

    {
#ifdef STK_BOUNDS_CHECK
      if ((J.first()<this->first()))
      { throw std::out_of_range("Array1D::elt(J) "
                                "J.first()<this->first()");
      }
      if ((J.last()>this->last()))
      { throw std::out_of_range("Array1D::elt(J) "
                                "J.last()>this->last()");
      }
#endif
      return Array1D(*this, J);
    }
Array1D& STK::Array1D< Real >::operator= ( Array1D< Real > const &  T) [inline]

operator = : overwrite the Array1D with T.

We resize the object if this and T does not have the same size but if they have the same size, we don't modify the range of the object.

Parameters:
Tthe container to copy

Definition at line 169 of file STK_Vector.h.

References STK::IArrayBase< DATA >::data(), STK::ITContainer1D< TYPE, TContainer1D >::first(), STK::ITContainer1D< TYPE, Array1D< TYPE > >::first(), STK::ITContainer1D< TYPE, Array1D< TYPE > >::last(), STK::ITContainer1D< TYPE, TContainer1D >::last(), STK::ITContainer1D< TYPE, TContainer1D >::range(), STK::IContainer1D::resize(), STK::IArrayBase< TYPE >::setData(), STK::ITContainer1D< TYPE, TContainer1D >::size(), and STK::ITContainer1D< TYPE, Array1D< TYPE > >::size().

    {
      // check size
      if (size()!=T.size()) resize(T.range());
      // copy without ovelapping.
      if (first() < T.first())
      { for (Integer i=first(), j=T.first(); j<=T.last(); i++, j++)
          setData(i, T.data(j));
      }
      else
      { for (Integer i=last(), j=T.last(); j>=T.first(); i--, j--)
          setData(i, T.data(j));
      }
      return *this;
    }
Array1D& STK::Array1D< Real >::operator= ( Real const &  v) [inline]

operator= : set the container to a constant value.

Parameters:
vthe value to set

Definition at line 188 of file STK_Vector.h.

References STK::ITContainer1D< TYPE, Array1D< TYPE > >::first(), STK::ITContainer1D< TYPE, Array1D< TYPE > >::last(), and STK::IArrayBase< TYPE >::setData().

    {
      for (Integer i=first(); i<=last(); i++)
        setData(i, v);
      return *this;
    }
Array1D& STK::Array1D< Real >::operator+= ( Real const &  v) [inline]

operator+= Adding a constant.

Parameters:
vthe value to add

Definition at line 198 of file STK_Vector.h.

References STK::Array1D< TYPE >::elt(), STK::ITContainer1D< TYPE, Array1D< TYPE > >::first(), and STK::ITContainer1D< TYPE, Array1D< TYPE > >::last().

    {
      for (Integer i=first(); i<=last(); i++)
        elt(i) += v;
      return *this;
    }
Array1D& STK::Array1D< Real >::operator-= ( Real const &  v) [inline]

operator -= decreasing a constant.

Parameters:
vthe value to decrease

Definition at line 208 of file STK_Vector.h.

References STK::Array1D< TYPE >::elt(), STK::ITContainer1D< TYPE, Array1D< TYPE > >::first(), and STK::ITContainer1D< TYPE, Array1D< TYPE > >::last().

    {
      for (Integer i=first(); i<=last(); i++)
        elt(i) -= v;
      return *this;
    }
Array1D& STK::Array1D< Real >::operator/= ( Real const &  v) [inline]

operator /= Dividing a constant.

Parameters:
vthe value to divide

Definition at line 218 of file STK_Vector.h.

References STK::Array1D< TYPE >::elt(), STK::ITContainer1D< TYPE, Array1D< TYPE > >::first(), and STK::ITContainer1D< TYPE, Array1D< TYPE > >::last().

    {
      for (Integer i=first(); i<=last(); i++)
        elt(i) /= v;
      return *this;
    }
Array1D& STK::Array1D< Real >::operator*= ( Real const &  v) [inline]

operator *= Multiplying a constant.

Parameters:
vthe value to multiply

Definition at line 228 of file STK_Vector.h.

References STK::Array1D< TYPE >::elt(), STK::ITContainer1D< TYPE, Array1D< TYPE > >::first(), and STK::ITContainer1D< TYPE, Array1D< TYPE > >::last().

    {
      for (Integer i=first(); i<=last(); i++)
        elt(i) *= v;
      return *this;
    }
template<class LEAF >
Array1D& STK::Array1D< Real >::operator= ( const ITContainer1D< Real, LEAF > &  T) [inline]

operator = : overwrite the Array1D with the container T.

We resize the object if this and T does not have the same size but if they have the same size, we don't modify the range of the object.

Parameters:
Tthe container to copy

Definition at line 242 of file STK_Vector.h.

References STK::ITContainer1D< TYPE, TContainer1D >::first(), STK::ITContainer1D< TYPE, Array1D< TYPE > >::first(), STK::ITContainer1D< TYPE, Array1D< TYPE > >::last(), STK::ITContainer1D< TYPE, TContainer1D >::last(), STK::ITContainer1D< TYPE, TContainer1D >::range(), STK::IContainer1D::resize(), STK::IArrayBase< TYPE >::setData(), STK::ITContainer1D< TYPE, TContainer1D >::size(), and STK::ITContainer1D< TYPE, Array1D< TYPE > >::size().

    { // We have to resize if this and T does not have the same size
      // but if they have the same size, we don't scale the index
      if (size()!=T.size()) resize(T.range());

      // copy without ovelapping
      if (first() < T.first())
      { for (Integer j=first(), i=T.first(); i<=T.last(); j++, i++)
          setData(j, T[i]);
      }
      else
      { for (Integer j=last(), i=T.last(); i>=T.first(); j--, i--)
          setData(j, T[i]);
      }
      return *this;
    }
template<class Exp >
Array1D& STK::Array1D< Real >::operator= ( const Exp &  rhs) [inline]

operator = overwriting a Array1D with An Expression.

Parameters:
rhsthe right hand side expression

Definition at line 263 of file STK_Vector.h.

References STK::ITContainer1D< TYPE, Array1D< TYPE > >::first(), STK::ITContainer1D< TYPE, Array1D< TYPE > >::last(), and STK::IArrayBase< TYPE >::setData().

    {
      for (Integer i=first(); i<=last(); i++)
        setData(i, rhs[i]);
      return *this;
    }
template<class Exp >
Array1D& STK::Array1D< Real >::operator+= ( const Exp &  rhs) [inline]

operator += Adding an Expression.

Parameters:
rhsthe right hand side expression

Definition at line 274 of file STK_Vector.h.

References STK::Array1D< TYPE >::elt(), STK::ITContainer1D< TYPE, Array1D< TYPE > >::first(), and STK::ITContainer1D< TYPE, Array1D< TYPE > >::last().

    {
      for (Integer i=first(); i<=last(); i++)
        elt(i) += rhs[i];
      return *this;
    }
template<class Exp >
Array1D& STK::Array1D< Real >::operator-= ( const Exp &  rhs) [inline]

operator -= decreasing an Expression.

Parameters:
rhsthe right hand side expression

Definition at line 285 of file STK_Vector.h.

References STK::Array1D< TYPE >::elt(), STK::ITContainer1D< TYPE, Array1D< TYPE > >::first(), and STK::ITContainer1D< TYPE, Array1D< TYPE > >::last().

    {
      for (Integer i=first(); i<=last(); i++)
        elt(i) -= rhs[i];
      return *this;
    }
template<class Exp >
Array1D& STK::Array1D< Real >::operator/= ( const Exp &  rhs) [inline]

operator /= Dividing an Expression.

Parameters:
rhsthe right hand side expression

Definition at line 296 of file STK_Vector.h.

References STK::Array1D< TYPE >::elt(), STK::ITContainer1D< TYPE, Array1D< TYPE > >::first(), and STK::ITContainer1D< TYPE, Array1D< TYPE > >::last().

    {
      for (Integer i=first(); i<=last(); i++)
        elt(i) /= rhs[i];
      return *this;
    }
template<class Exp >
Array1D& STK::Array1D< Real >::operator*= ( const Exp &  rhs) [inline]

operator *= Multiplying an Expression.

Parameters:
rhsthe right hand side expression

Definition at line 307 of file STK_Vector.h.

References STK::Array1D< TYPE >::elt(), STK::ITContainer1D< TYPE, Array1D< TYPE > >::first(), and STK::ITContainer1D< TYPE, Array1D< TYPE > >::last().

    {
      for (Integer i=first(); i<=last(); i++)
        elt(i) *= rhs[i];
      return *this;
    }

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