Loading...
Searching...
No Matches
casacore::RigidVector< T, n > Class Template Reference
scimath package (libcasa_scimath) » Mathematics_module

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.
| 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 &v0, const T &v1, const T &v2, const T &v3, const T &v4)
| Construct a 5-element vector, fails for wrong size vectors.
| 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.
| 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

T | 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.
T | 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 casacore::RigidVector< T, n >

Fast Vector classes with fixed (templated) length

### Intended use:

Public interface

### Review Status

Date Reviewed:
  yyyy/mm/dd

### Prerequisite

- Vector
- Complex

### 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;
casacore::RigidVector::RigidVector
RigidVector()
RigidVector(Int dummy) { for (Int i=0; i<n; i++) v_p[i]=T(0); } Default constructor.
Definition RigidVector.h:144
casacore::Float
float Float
Definition aipstype.h:52

### Motivation

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

### Template Type Argument Requirements (T)

- this class is meant for computation and assumes operators +,-,* to be defined.

### Thrown Exceptions

- no exceptions

### To Do

- not all operations defined for Vectors are defined
- default implementation of innerProduct is wrong for Complex vectors

Definition at line 99 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 144 of file RigidVector.h.

References v_p.

Referenced by operator*, operator*, operator*, operator*, operator*=(), operator*=(), operator*=(), operator+, operator+=(), operator-(), operator-, operator-=(), operator<<, operator=(), operator=(), operator=(), RigidVector(), and sqrt().

## 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 148 of file RigidVector.h.

References 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 152 of file RigidVector.h.

References 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 157 of file RigidVector.h.

References 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 162 of file RigidVector.h.

References 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 167 of file RigidVector.h.

References 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 173 of file RigidVector.h.

References 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 179 of file RigidVector.h.

References 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 183 of file RigidVector.h.

References 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 187 of file RigidVector.h.

References RigidVector(), and 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 233 of file RigidVector.h.

References 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 235 of file RigidVector.h.

References 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 215 of file RigidVector.h.

References RigidVector(), and 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;.

References RigidVector().

## 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 225 of file RigidVector.h.

References RigidVector(), and 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 211 of file RigidVector.h.

References RigidVector(), and v_p.

## operator-()

template<class T, Int n>

RigidVector< T, n > & casacore::RigidVector< T, n >::operator- | ( |  | ) |

inline

Negation.

Definition at line 206 of file RigidVector.h.

References RigidVector(), and 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 220 of file RigidVector.h.

References RigidVector(), and 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 191 of file RigidVector.h.

References RigidVector(), and 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 201 of file RigidVector.h.

References RigidVector(), and 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 196 of file RigidVector.h.

References RigidVector(), and v_p.

## sqrt()

template<class T, Int n>

RigidVector< T, n > casacore::RigidVector< T, n >::sqrt | ( | const RigidVector< T, n > & | v | ) |

Square Root.

References RigidVector().

## vector()

template<class T, Int n>

Vector< T > casacore::RigidVector< T, n >::vector | ( |  | ) | const

inline

Convert to a regular Vector.

Definition at line 239 of file RigidVector.h.

References v_p.

Referenced by operator<<.

## Friends And Related Symbol 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 115 of file RigidVector.h.

References RigidVector(), casacore::sum(), and v_p.

## 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 127 of file RigidVector.h.

References RigidVector().

## 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.

References RigidVector().

## 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 122 of file RigidVector.h.

References RigidVector().

## 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 103 of file RigidVector.h.

References RigidVector().

## 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 109 of file RigidVector.h.

References RigidVector().

## 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 132 of file RigidVector.h.

References RigidVector(), and vector().

## 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 264 of file RigidVector.h.

Referenced by operator()(), operator()(), operator*, operator*=(), operator*=(), operator+=(), operator-(), operator-=(), operator=(), operator=(), operator=(), RigidVector(), RigidVector(), RigidVector(), RigidVector(), RigidVector(), RigidVector(), RigidVector(), RigidVector(), RigidVector(), RigidVector(), and vector().

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

- scimath/Mathematics/RigidVector.h