casacore
Public Member Functions | Protected Attributes | Friends | List of all members
casacore::RigidVector< T, n > Class Template Reference

More...

#include <RigidVector.h>

Public Member Functions

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

Protected Attributes

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

Friends

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

Detailed Description

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

Fast Vector classes with fixed (templated) length

Intended use:

Public interface

Review Status

Date Reviewed:
yyyy/mm/dd

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;
float Float
Definition: aipstype.h:54


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

◆ RigidVector() [1/10]

template<class T , Int n>
casacore::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.

References casacore::RigidVector< T, n >::v_p.

◆ RigidVector() [2/10]

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

Construct from scalar, sets all elements to c.

Definition at line 151 of file RigidVector.h.

References casacore::C::c, and casacore::RigidVector< T, n >::v_p.

◆ RigidVector() [3/10]

template<class T , Int n>
casacore::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.

References casacore::RigidVector< T, n >::v_p.

◆ RigidVector() [4/10]

template<class T , Int n>
casacore::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.

References casacore::RigidVector< T, n >::v_p.

◆ RigidVector() [5/10]

template<class T , Int n>
casacore::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.

References casacore::RigidVector< T, n >::v_p.

◆ RigidVector() [6/10]

template<class T , Int n>
casacore::RigidVector< T, n >::RigidVector ( const T &  v0,
const T &  v1,
const T &  v2,
const T &  v3,
const T &  v4 
)
inline

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

Definition at line 170 of file RigidVector.h.

References casacore::RigidVector< T, n >::v_p.

◆ RigidVector() [7/10]

template<class T , Int n>
casacore::RigidVector< T, n >::RigidVector ( const T &  v0,
const T &  v1,
const T &  v2,
const T &  v3,
const T &  v4,
const T &  v5 
)
inline

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

Definition at line 176 of file RigidVector.h.

References casacore::RigidVector< T, n >::v_p.

◆ RigidVector() [8/10]

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

Construct from a c-array (copy semantics)

Definition at line 182 of file RigidVector.h.

References casacore::RigidVector< T, n >::v_p.

◆ RigidVector() [9/10]

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

Construct from a Vector.

Definition at line 186 of file RigidVector.h.

References casacore::RigidVector< T, n >::v_p.

◆ RigidVector() [10/10]

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

Copy constructor, copy semantics.

Definition at line 190 of file RigidVector.h.

References casacore::RigidVector< T, n >::v_p.

Member Function Documentation

◆ operator()() [1/2]

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

Indexing by reference.

Definition at line 236 of file RigidVector.h.

References casacore::RigidVector< T, n >::v_p.

◆ operator()() [2/2]

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

Indexing by const reference.

Definition at line 238 of file RigidVector.h.

References casacore::RigidVector< T, n >::v_p.

◆ operator*=() [1/3]

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

Definition at line 218 of file RigidVector.h.

References casacore::RigidVector< T, n >::v_p.

◆ operator*=() [2/3]

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

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

◆ operator*=() [3/3]

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

Multiplication by scalar.

Definition at line 228 of file RigidVector.h.

References casacore::RigidVector< T, n >::v_p.

◆ operator+=()

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

Addition

Definition at line 214 of file RigidVector.h.

References casacore::RigidVector< T, n >::v_p.

◆ operator-()

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

Negation.

Definition at line 209 of file RigidVector.h.

References casacore::RigidVector< T, n >::v_p.

◆ operator-=()

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

Subtraction.

Definition at line 223 of file RigidVector.h.

References casacore::RigidVector< T, n >::v_p.

◆ operator=() [1/3]

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

Assign from a RigidVector.

Definition at line 194 of file RigidVector.h.

References casacore::RigidVector< T, n >::v_p.

◆ operator=() [2/3]

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

Assign a scalar, sets all elements to c.

Definition at line 204 of file RigidVector.h.

References casacore::C::c, and casacore::RigidVector< T, n >::v_p.

◆ operator=() [3/3]

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

Assign from a Vector.

Definition at line 199 of file RigidVector.h.

References casacore::RigidVector< T, n >::v_p.

◆ sqrt()

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

Square Root.

◆ vector()

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

Convert to a regular Vector.

Definition at line 242 of file RigidVector.h.

References casacore::RigidVector< T, n >::v_p.

Friends And Related Function Documentation

◆ operator* [1/4]

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.

◆ operator* [2/4]

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.

◆ operator* [3/4]

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.

◆ operator* [4/4]

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.

◆ operator+

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.

◆ operator-

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.

◆ operator<<

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

◆ v_p

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

// The following are needed for Image<RigidVector>

static IPosition shape() {return IPosition(1,n);}

static void* newCopyInfo (const TableRecord& record, const IPosition& sourceElementShape);

static void deleteCopyInfo (void*);

static void set (void* copyInfo, void* out, const Array<T>& in, const IPosition& shape); static void get (void* copyInfo, Array<T>& out, const void* in, const IPosition& shape);

Definition at line 267 of file RigidVector.h.

Referenced by casacore::RigidVector< T, n >::operator()(), casacore::RigidVector< T, n >::operator*=(), casacore::RigidVector< T, n >::operator+=(), casacore::RigidVector< T, n >::operator-(), casacore::RigidVector< T, n >::operator-=(), casacore::RigidVector< T, n >::operator=(), casacore::RigidVector< T, n >::RigidVector(), and casacore::RigidVector< T, n >::vector().


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