casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Protected Attributes | Friends
casa::RigidVector< T, n > Class Template Reference

Fast Vector classes with fixed (templated) length. More...

#include <RigidVector.h>

List of all members.

Public Member Functions

 RigidVector ()
 RigidVector(Int dummy) { for (Int i=0; i<n; i++) v_p[i]=T(0); } Default constructor.
 RigidVector (const T &c)
 Construct from scalar, sets all elements to c.
 RigidVector (const T &v0, const T &v1)
 Construct a 2-element vector, fails for wrong size vectors.
 RigidVector (const T &v0, const T &v1, const T &v2)
 Construct a 3-element vector, fails for wrong size vectors.
 RigidVector (const T &v0, const T &v1, const T &v2, const T &v3)
 Construct a 4-element vector, fails for wrong size vectors.
 RigidVector (const T v[n])
 Construct from a c-array (copy semantics)
 RigidVector (const Vector< T > &v)
 Construct from a Vector.
 RigidVector (const RigidVector< T, n > &v)
 Copy constructor, copy semantics.
RigidVector< T, n > & operator= (const RigidVector< T, n > &v)
 Assign from a RigidVector.
RigidVector< T, n > & operator= (const Vector< T > &v)
 Assign from a Vector.
RigidVector< T, n > & operator= (const T &c)
 Assign a scalar, sets all elements to c.
RigidVector< T, n > & operator- ()
 Negation.
RigidVector< T, n > & operator+= (const RigidVector< T, n > &v)
 Addition.
RigidVector< T, n > & operator*= (const RigidVector< T, n > &v)
RigidVector< T, n > & operator-= (const RigidVector< T, n > &v)
 Subtraction.
RigidVector< T, n > & operator*= (const T &val)
 Multiplication by scalar.
RigidVector< T, n > & operator*= (const SquareMatrix< T, n > &m)
 Multiply vector by matrix: v*=M is equivalent to v=M*v;.
T & operator() (Int i)
 Indexing by reference.
const T & operator() (Int i) const
 Indexing by const reference.
Vector< T > vector () const
 Convert to a regular Vector.
RigidVector< T, n > sqrt (const RigidVector< T, n > &v)
 Square Root.

Protected Attributes

v_p [n]
 // The following are needed for Image<RigidVector>

Friends

RigidVector< T, n > operator+ (const RigidVector< T, n > &l, const RigidVector< T, n > &r)
 Add two RigidVectors.
RigidVector< T, n > operator- (const RigidVector< T, n > &l, const RigidVector< T, n > &r)
 Subtract two RigidVectors.
operator* (const RigidVector< T, n > &l, const RigidVector< T, n > &r)
 The innerproduct of 2 RigidVectors.
RigidVector< T, n > operator* (const T &f, const RigidVector< T, n > &v)
 Multiply a RigidVector by a scalar.
RigidVector< T, n > operator* (const RigidVector< T, n > &v, const T &f)
 Multiply a RigidVector by a scalar.
ostream & operator<< (ostream &os, const RigidVector< T, n > &v)
 Write out a RigidVector using the Vector output method.
RigidVector< Complex, 4 > operator* (const SquareMatrix< Complex, 4 > &m, const RigidVector< Float, 4 > &v)
 Special matrix multiply of Complex matrix * Float vector.

Detailed Description

template<class T, Int n>
class casa::RigidVector< T, n >

Fast Vector classes with fixed (templated) length.

Intended use:

Public interface

 <h3>Review Status</h3><dl><dt>Date Reviewed:<dd>yyyy/mm/dd</dl> 

Prerequisite

Etymology

RigidVector is a vector with a size fixed at compile time, i.e. Rigid as compared to the normal Vector class.

Synopsis

RigidVector is a specialized Vector class for short (<25 elements) vectors. It has a size fixed at compile time, avoids new and delete and uses copy semantics throughout. Unlike Vectors, RigidVectors have fixed zero origin and no strides, allowing fast indexing. The more common mathematical operations are defined for RigidVector, allowing element by element arithmetic, innerproduct and matrix multiplication (by a SquareMatrix). Conversion to and from normal vectors is provided.

Example

    // Create two RigidVectors
    RigidVector<Float,3> rv1(1.0,2.0,3.0),rv2(3.0,2.0,1.0);
    // Compute sum
    RigidVector<Float,3> rv3=rv1+rv2;
    // Compute innerproduct
    Float inprod=rv1*rv2;
    // Write out results
    cout << "rv1+rv2="<< rv3 <<", rv1*rv2="<< inprod<<endl;

Motivation

The standard Vector class is rather inefficient for short vectors, this class is designed for speed and simplicity.

Template Type Argument Requirements (T)

Thrown Exceptions

To Do

Definition at line 102 of file RigidVector.h.


Constructor & Destructor Documentation

template<class T, Int n>
casa::RigidVector< T, n >::RigidVector ( ) [inline]

RigidVector(Int dummy) { for (Int i=0; i<n; i++) v_p[i]=T(0); } Default constructor.

Definition at line 147 of file RigidVector.h.

template<class T, Int n>
casa::RigidVector< T, n >::RigidVector ( const T &  c) [inline]

Construct from scalar, sets all elements to c.

Definition at line 151 of file RigidVector.h.

template<class T, Int n>
casa::RigidVector< T, n >::RigidVector ( const T &  v0,
const T &  v1 
) [inline]

Construct a 2-element vector, fails for wrong size vectors.

Definition at line 155 of file RigidVector.h.

template<class T, Int n>
casa::RigidVector< T, n >::RigidVector ( const T &  v0,
const T &  v1,
const T &  v2 
) [inline]

Construct a 3-element vector, fails for wrong size vectors.

Definition at line 160 of file RigidVector.h.

template<class T, Int n>
casa::RigidVector< T, n >::RigidVector ( const T &  v0,
const T &  v1,
const T &  v2,
const T &  v3 
) [inline]

Construct a 4-element vector, fails for wrong size vectors.

Definition at line 165 of file RigidVector.h.

template<class T, Int n>
casa::RigidVector< T, n >::RigidVector ( const T  v[n]) [inline]

Construct from a c-array (copy semantics)

Definition at line 170 of file RigidVector.h.

template<class T, Int n>
casa::RigidVector< T, n >::RigidVector ( const Vector< T > &  v) [inline]

Construct from a Vector.

Definition at line 174 of file RigidVector.h.

template<class T, Int n>
casa::RigidVector< T, n >::RigidVector ( const RigidVector< T, n > &  v) [inline]

Copy constructor, copy semantics.

Definition at line 178 of file RigidVector.h.


Member Function Documentation

template<class T, Int n>
T& casa::RigidVector< T, n >::operator() ( Int  i) [inline]

Indexing by reference.

Definition at line 224 of file RigidVector.h.

template<class T, Int n>
const T& casa::RigidVector< T, n >::operator() ( Int  i) const [inline]

Indexing by const reference.

Definition at line 226 of file RigidVector.h.

template<class T, Int n>
RigidVector<T,n>& casa::RigidVector< T, n >::operator*= ( const RigidVector< T, n > &  v) [inline]

Definition at line 206 of file RigidVector.h.

template<class T, Int n>
RigidVector<T,n>& casa::RigidVector< T, n >::operator*= ( const T &  val) [inline]

Multiplication by scalar.

Definition at line 216 of file RigidVector.h.

template<class T, Int n>
RigidVector<T,n>& casa::RigidVector< T, n >::operator*= ( const SquareMatrix< T, n > &  m)

Multiply vector by matrix: v*=M is equivalent to v=M*v;.

template<class T, Int n>
RigidVector<T,n>& casa::RigidVector< T, n >::operator+= ( const RigidVector< T, n > &  v) [inline]

Addition.

Definition at line 202 of file RigidVector.h.

template<class T, Int n>
RigidVector<T,n>& casa::RigidVector< T, n >::operator- ( ) [inline]

Negation.

Reimplemented in casa::StokesVector, and casa::CStokesVector.

Definition at line 197 of file RigidVector.h.

template<class T, Int n>
RigidVector<T,n>& casa::RigidVector< T, n >::operator-= ( const RigidVector< T, n > &  v) [inline]

Subtraction.

Definition at line 211 of file RigidVector.h.

template<class T, Int n>
RigidVector<T,n>& casa::RigidVector< T, n >::operator= ( const RigidVector< T, n > &  v) [inline]

Assign from a RigidVector.

Definition at line 182 of file RigidVector.h.

template<class T, Int n>
RigidVector<T,n>& casa::RigidVector< T, n >::operator= ( const Vector< T > &  v) [inline]

Assign from a Vector.

Reimplemented in casa::StokesVector, and casa::CStokesVector.

Definition at line 187 of file RigidVector.h.

template<class T, Int n>
RigidVector<T,n>& casa::RigidVector< T, n >::operator= ( const T &  c) [inline]

Assign a scalar, sets all elements to c.

Reimplemented in casa::CStokesVector.

Definition at line 192 of file RigidVector.h.

template<class T, Int n>
RigidVector<T,n> casa::RigidVector< T, n >::sqrt ( const RigidVector< T, n > &  v)

Square Root.

template<class T, Int n>
Vector<T> casa::RigidVector< T, n >::vector ( ) const [inline]

Convert to a regular Vector.

Definition at line 230 of file RigidVector.h.


Friends And Related Function Documentation

template<class T, Int n>
T operator* ( const RigidVector< T, n > &  l,
const RigidVector< T, n > &  r 
) [friend]

The innerproduct of 2 RigidVectors.

Definition at line 118 of file RigidVector.h.

template<class T, Int n>
RigidVector<T,n> operator* ( const T &  f,
const RigidVector< T, n > &  v 
) [friend]

Multiply a RigidVector by a scalar.

Definition at line 125 of file RigidVector.h.

template<class T, Int n>
RigidVector<T,n> operator* ( const RigidVector< T, n > &  v,
const T &  f 
) [friend]

Multiply a RigidVector by a scalar.

Definition at line 130 of file RigidVector.h.

template<class T, Int n>
RigidVector<Complex,4> operator* ( const SquareMatrix< Complex, 4 > &  m,
const RigidVector< Float, 4 > &  v 
) [friend]

Special matrix multiply of Complex matrix * Float vector.

template<class T, Int n>
RigidVector<T,n> operator+ ( const RigidVector< T, n > &  l,
const RigidVector< T, n > &  r 
) [friend]

Add two RigidVectors.

Definition at line 106 of file RigidVector.h.

template<class T, Int n>
RigidVector<T,n> operator- ( const RigidVector< T, n > &  l,
const RigidVector< T, n > &  r 
) [friend]

Subtract two RigidVectors.

Definition at line 112 of file RigidVector.h.

template<class T, Int n>
ostream& operator<< ( ostream &  os,
const RigidVector< T, n > &  v 
) [friend]

Write out a RigidVector using the Vector output method.

Definition at line 135 of file RigidVector.h.


Member Data Documentation

template<class T, Int n>
T casa::RigidVector< T, n >::v_p[n] [protected]

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