GOAT (Geometrical optics application tool) 0.1
Loading...
Searching...
No Matches
GOAT::maths::Vector< T > Class Template Reference

Template class for threedimensional vectors. More...

#include <vector.h>

Public Member Functions

void binRead (std::ifstream &is)
void binWrite (std::ofstream &os)
bool operator!= (const Vector &r)
 Inequality operator: Two vectors are inequal if at least one component is not equal.
Vectoroperator*= (T r)
 Multiplication with scalar.
Vectoroperator+= (const Vector &r)
 Addition operator.
Vector operator- ()
Vectoroperator-= (const Vector &r)
 Subtraction operator.
Vectoroperator/= (T r)
 Division by scalar.
Vectoroperator= (const Vector &r)
 Assignment operator.
Vectoroperator= (T r[3])
 Assignment operator (with an ordinary threedimensional array.
bool operator== (const Vector &r)
 Comparison operators: two vectors are equal if their components are (exactly) the same.
T & operator[] (int i)
 Bracket operator, gives access to the i-th component of the vector (as for a usual array).
const T & operator[] (int i) const
 Bracket operator, gives access to the i-th component of the vector (as for a usual array).
 Vector ()
 Standard constructor (all components are initialized with 0)
 Vector (const Vector &r)
 Vector (T x, T y, T z)
 Constructor with the three components as parameters.

Public Attributes

data [3]

Friends

Vector ediv (const Vector &r1, const Vector &r2)
 Component-wise division of two vectors.
Vector ediv (T s, const Vector &r)
 Component-wise division, scalar (s) by vector (r)
Vector emult (const Vector &r1, const Vector &r2)
 Component-wise multiplication of two vectors.
Vector exp (const Vector &r)
 exponential function of a vector (x,y,z), defined by exp((x,y,z)) \(\rightarrow (e^x,e^y,e^z)\)
bool operator!= (const Vector &A, const Vector &B)
Vector operator% (const Vector &r1, const Vector &r2)
 cross product between two vectors.
operator* (const Vector &a, const Vector &b)
Vector operator* (const Vector &r, T x)
 Multiplication of a vector with a scalar.
Vector operator* (T x, const Vector &r)
 Multiplication of a scalar with a vector.
Vector operator+ (const Vector &r1, const Vector &r2)
 Addition of two vectors.
Vector operator- (const Vector &r1, const Vector &r2)
 Subtraction of two vectors.
Vector operator/ (const Vector &r, T x)
 Division of a vector by a scalar.
bool operator== (const Vector &A, const Vector &B)
Vector sqrt (const Vector &r)
 calculates the square root of a vector: result: sqrt((x,y,z)) \( \rightarrow (\sqrt{x},\sqrt{y},\sqrt{z}) \)

Detailed Description

template<class T>
class GOAT::maths::Vector< T >

Template class for threedimensional vectors.

This class provides standard operations and functions for threedimensional vectors. It is intended for use with int, double and complex<double> based vectors. Also, operators with mixed types are given (e.g. operators for double and complex vectors).

Definition at line 56 of file vector.h.

Constructor & Destructor Documentation

◆ Vector() [1/3]

template<class T>
GOAT::maths::Vector< T >::Vector ( )
inline

Standard constructor (all components are initialized with 0)

Definition at line 77 of file vector.h.

◆ Vector() [2/3]

template<class T>
GOAT::maths::Vector< T >::Vector ( T x,
T y,
T z )
inline

Constructor with the three components as parameters.

Parameters
xfirst component
ysecond component
zthird component

Definition at line 91 of file vector.h.

◆ Vector() [3/3]

template<class T>
GOAT::maths::Vector< T >::Vector ( const Vector< T > & r)
inline

Copy constructor

Definition at line 99 of file vector.h.

Member Function Documentation

◆ binRead()

template<class T>
void GOAT::maths::Vector< T >::binRead ( std::ifstream & is)
inline
Parameters
isreads vector from binary file, represented by the input stream is

Definition at line 68 of file vector.h.

◆ binWrite()

template<class T>
void GOAT::maths::Vector< T >::binWrite ( std::ofstream & os)
inline
Parameters
oswrites vector to a binary file, represented by the output stream os

Definition at line 61 of file vector.h.

◆ operator!=()

template<class T>
bool GOAT::maths::Vector< T >::operator!= ( const Vector< T > & r)
inline

Inequality operator: Two vectors are inequal if at least one component is not equal.

Definition at line 241 of file vector.h.

◆ operator*=()

template<class T>
Vector & GOAT::maths::Vector< T >::operator*= ( T r)
inline

Multiplication with scalar.

Definition at line 265 of file vector.h.

◆ operator+=()

template<class T>
Vector & GOAT::maths::Vector< T >::operator+= ( const Vector< T > & r)
inline

Addition operator.

Definition at line 249 of file vector.h.

◆ operator-()

template<class T>
Vector GOAT::maths::Vector< T >::operator- ( )
inline

sign minus

Definition at line 122 of file vector.h.

◆ operator-=()

template<class T>
Vector & GOAT::maths::Vector< T >::operator-= ( const Vector< T > & r)
inline

Subtraction operator.

Definition at line 257 of file vector.h.

◆ operator/=()

template<class T>
Vector & GOAT::maths::Vector< T >::operator/= ( T r)
inline

Division by scalar.

Definition at line 273 of file vector.h.

◆ operator=() [1/2]

template<class T>
Vector & GOAT::maths::Vector< T >::operator= ( const Vector< T > & r)
inline

Assignment operator.

Definition at line 215 of file vector.h.

◆ operator=() [2/2]

template<class T>
Vector & GOAT::maths::Vector< T >::operator= ( T r[3])
inline

Assignment operator (with an ordinary threedimensional array.

Definition at line 225 of file vector.h.

◆ operator==()

template<class T>
bool GOAT::maths::Vector< T >::operator== ( const Vector< T > & r)
inline

Comparison operators: two vectors are equal if their components are (exactly) the same.

Definition at line 233 of file vector.h.

◆ operator[]() [1/2]

template<class T>
T & GOAT::maths::Vector< T >::operator[] ( int i)
inline

Bracket operator, gives access to the i-th component of the vector (as for a usual array).

Parameters
iIndex of the component
Returns
content of the i-th component

Definition at line 354 of file vector.h.

◆ operator[]() [2/2]

template<class T>
const T & GOAT::maths::Vector< T >::operator[] ( int i) const
inline

Bracket operator, gives access to the i-th component of the vector (as for a usual array).

Parameters
iIndex of the component
Returns
content of the i-th component

Definition at line 361 of file vector.h.

◆ ediv [1/2]

template<class T>
Vector ediv ( const Vector< T > & r1,
const Vector< T > & r2 )
friend

Component-wise division of two vectors.

Definition at line 190 of file vector.h.

◆ ediv [2/2]

template<class T>
Vector ediv ( T s,
const Vector< T > & r )
friend

Component-wise division, scalar (s) by vector (r)

Parameters
sScalar
rVector
Returns
Vector with components: (s/r[0],s/r[1],s/r[2])

Definition at line 205 of file vector.h.

◆ emult

template<class T>
Vector emult ( const Vector< T > & r1,
const Vector< T > & r2 )
friend

Component-wise multiplication of two vectors.

Definition at line 181 of file vector.h.

◆ exp

template<class T>
Vector exp ( const Vector< T > & r)
friend

exponential function of a vector (x,y,z), defined by exp((x,y,z)) \(\rightarrow (e^x,e^y,e^z)\)

Definition at line 175 of file vector.h.

◆ operator!=

template<class T>
bool operator!= ( const Vector< T > & A,
const Vector< T > & B )
friend
Parameters
BInequality operator. Two vectors are unequal if they differ in at least one component.

Definition at line 286 of file vector.h.

◆ operator%

template<class T>
Vector operator% ( const Vector< T > & r1,
const Vector< T > & r2 )
friend

cross product between two vectors.

Parameters
r1first vector
r2second vector
Returns
cross product

Definition at line 154 of file vector.h.

◆ operator* [1/3]

template<class T>
T operator* ( const Vector< T > & a,
const Vector< T > & b )
friend
Parameters
bScalar product between two vectors

Definition at line 293 of file vector.h.

◆ operator* [2/3]

template<class T>
Vector operator* ( const Vector< T > & r,
T x )
friend

Multiplication of a vector with a scalar.

Parameters
rvector
xscalar

Definition at line 324 of file vector.h.

◆ operator* [3/3]

template<class T>
Vector operator* ( T x,
const Vector< T > & r )
friend

Multiplication of a scalar with a vector.

Parameters
xscalar
rvector

Definition at line 309 of file vector.h.

◆ operator+

template<class T>
Vector operator+ ( const Vector< T > & r1,
const Vector< T > & r2 )
friend

Addition of two vectors.

Parameters
r1first summand
r2second summand
Returns
sum of r1 and r2

Definition at line 112 of file vector.h.

◆ operator-

template<class T>
Vector operator- ( const Vector< T > & r1,
const Vector< T > & r2 )
friend

Subtraction of two vectors.

Parameters
r1minuend
r2subtrahend
Returns

Definition at line 137 of file vector.h.

◆ operator/

template<class T>
Vector operator/ ( const Vector< T > & r,
T x )
friend

Division of a vector by a scalar.

Parameters
rvector
xscalar

Definition at line 340 of file vector.h.

◆ operator==

template<class T>
bool operator== ( const Vector< T > & A,
const Vector< T > & B )
friend
Parameters
BComparison operator. Two vectors are equal if all components are the same

Definition at line 281 of file vector.h.

◆ sqrt

template<class T>
Vector sqrt ( const Vector< T > & r)
friend

calculates the square root of a vector: result: sqrt((x,y,z)) \( \rightarrow (\sqrt{x},\sqrt{y},\sqrt{z}) \)

Definition at line 167 of file vector.h.

Member Data Documentation

◆ data

template<class T>
T GOAT::maths::Vector< T >::data[3]

Definition at line 362 of file vector.h.


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