BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | Friends
BDSThreeVector< T > Class Template Reference

Simple three vector that's templated so the right type can be used. More...

#include <BDSThreeVector.hh>

Collaboration diagram for BDSThreeVector< T >:
Collaboration graph

Public Member Functions

 BDSThreeVector ()
 Default constructor.
 
 BDSThreeVector (T xIn, T yIn, T zIn)
 Alternate constructor.
 
 BDSThreeVector (const BDSThreeVector &other)
 Copy constructor.
 
BDSThreeVectoroperator= (const BDSThreeVector &rhs)
 Assignment operator.
 
T & operator[] (const G4int index)
 Access / set a single element.
 
const T & operator[] (const G4int index) const
 Access a single element.
 
dot (const BDSThreeVector &b) const
 
mag () const
 Get the magnitude of it.
 
BDSThreeVectoroperator*= (G4double a)
 
const T & x () const
 Accessor by name.
 
const T & y () const
 Accessor by name.
 
const T & z () const
 Accessor by name.
 

Private Attributes

values [3]
 Member data - x,y,z.
 

Friends

std::ostream & operator<< (std::ostream &out, BDSThreeVector const &v)
 Output stream.
 
BDSThreeVector operator* (const BDSThreeVector &a, const double &b)
 Multiplication.
 
BDSThreeVector operator* (const double &b, const BDSThreeVector &a)
 Multiplication.
 
operator* (const BDSThreeVector &a, const BDSThreeVector &b)
 Multiplication.
 
BDSThreeVector operator+ (const BDSThreeVector &a, const G4double &b)
 Addition, subtraction.
 
BDSThreeVector operator+ (const BDSThreeVector &a, const BDSThreeVector &b)
 Addition, subtraction.
 
BDSThreeVector operator- (const BDSThreeVector &a, const G4double &b)
 Addition, subtraction.
 
BDSThreeVector operator- (const BDSThreeVector &a, const BDSThreeVector &b)
 Addition, subtraction.
 

Detailed Description

template<typename T>
class BDSThreeVector< T >

Simple three vector that's templated so the right type can be used.

The G4ThreeVector(HEP::ThreeVector) is much better, but this only uses a double. Here, a simple three vector that's templated allows the possibility of using float or double precision, which could make a significant difference to the memory usage - very important for large arrays of this class.

Should more complex features be required - it's best to use an actual G4ThreeVector - constructed from this - and then translated back.

Author
Laurie Nevay

Definition at line 44 of file BDSThreeVector.hh.

Constructor & Destructor Documentation

◆ BDSThreeVector() [1/3]

template<typename T >
BDSThreeVector< T >::BDSThreeVector ( )
inline

Default constructor.

Definition at line 48 of file BDSThreeVector.hh.

References BDSThreeVector< T >::values.

◆ BDSThreeVector() [2/3]

template<typename T >
BDSThreeVector< T >::BDSThreeVector ( xIn,
yIn,
zIn 
)
inline

Alternate constructor.

Definition at line 52 of file BDSThreeVector.hh.

References BDSThreeVector< T >::values.

◆ BDSThreeVector() [3/3]

template<typename T >
BDSThreeVector< T >::BDSThreeVector ( const BDSThreeVector< T > &  other)
inline

Copy constructor.

Definition at line 56 of file BDSThreeVector.hh.

References BDSThreeVector< T >::values.

Member Function Documentation

◆ dot()

template<typename T >
T BDSThreeVector< T >::dot ( const BDSThreeVector< T > &  b) const
inline

Definition at line 99 of file BDSThreeVector.hh.

◆ mag()

template<typename T >
T BDSThreeVector< T >::mag ( ) const
inline

Get the magnitude of it.

Definition at line 103 of file BDSThreeVector.hh.

References BDSThreeVector< T >::values.

Referenced by BDS::mag().

Here is the caller graph for this function:

◆ operator*=()

template<typename T >
BDSThreeVector & BDSThreeVector< T >::operator*= ( G4double  a)
inline

Definition at line 125 of file BDSThreeVector.hh.

◆ operator=()

template<typename T >
BDSThreeVector & BDSThreeVector< T >::operator= ( const BDSThreeVector< T > &  rhs)
inline

Assignment operator.

Definition at line 63 of file BDSThreeVector.hh.

References BDSThreeVector< T >::values.

◆ operator[]() [1/2]

template<typename T >
T & BDSThreeVector< T >::operator[] ( const G4int  index)
inline

Access / set a single element.

Definition at line 74 of file BDSThreeVector.hh.

References BDSThreeVector< T >::values.

◆ operator[]() [2/2]

template<typename T >
const T & BDSThreeVector< T >::operator[] ( const G4int  index) const
inline

Access a single element.

Definition at line 82 of file BDSThreeVector.hh.

References BDSThreeVector< T >::values.

◆ x()

template<typename T >
const T & BDSThreeVector< T >::x ( ) const
inline

◆ y()

template<typename T >
const T & BDSThreeVector< T >::y ( ) const
inline

◆ z()

template<typename T >
const T & BDSThreeVector< T >::z ( ) const
inline

Friends And Related Function Documentation

◆ operator* [1/3]

template<typename T >
T operator* ( const BDSThreeVector< T > &  a,
const BDSThreeVector< T > &  b 
)
friend

Multiplication.

Definition at line 110 of file BDSThreeVector.hh.

◆ operator* [2/3]

template<typename T >
BDSThreeVector operator* ( const BDSThreeVector< T > &  a,
const double &  b 
)
friend

Multiplication.

Definition at line 106 of file BDSThreeVector.hh.

◆ operator* [3/3]

template<typename T >
BDSThreeVector operator* ( const double &  b,
const BDSThreeVector< T > &  a 
)
friend

Multiplication.

Definition at line 108 of file BDSThreeVector.hh.

◆ operator+ [1/2]

template<typename T >
BDSThreeVector operator+ ( const BDSThreeVector< T > &  a,
const BDSThreeVector< T > &  b 
)
friend

Addition, subtraction.

Definition at line 117 of file BDSThreeVector.hh.

◆ operator+ [2/2]

template<typename T >
BDSThreeVector operator+ ( const BDSThreeVector< T > &  a,
const G4double &  b 
)
friend

Addition, subtraction.

Definition at line 115 of file BDSThreeVector.hh.

◆ operator- [1/2]

template<typename T >
BDSThreeVector operator- ( const BDSThreeVector< T > &  a,
const BDSThreeVector< T > &  b 
)
friend

Addition, subtraction.

Definition at line 121 of file BDSThreeVector.hh.

◆ operator- [2/2]

template<typename T >
BDSThreeVector operator- ( const BDSThreeVector< T > &  a,
const G4double &  b 
)
friend

Addition, subtraction.

Definition at line 119 of file BDSThreeVector.hh.

◆ operator<<

template<typename T >
std::ostream & operator<< ( std::ostream &  out,
BDSThreeVector< T > const &  v 
)
friend

Output stream.

Definition at line 96 of file BDSThreeVector.hh.

Field Documentation

◆ values

template<typename T >
T BDSThreeVector< T >::values[3]
private

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