Mantid
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
Mantid::Kernel::VMDBase< TYPE > Class Template Reference

Simple vector class for multiple dimensions (i.e. More...

#include <VMD.h>

Public Member Functions

TYPE angle (const VMDBase &v) const
 Return the angle between this and another vector. More...
 
VMDBase cross_prod (const VMDBase &v) const
 Cross product of two vectors. More...
 
const TYPEgetBareArray () const
 
size_t getNumDims () const
 
TYPE length () const
 
TYPE norm () const
 
TYPE norm2 () const
 
TYPE normalize ()
 Normalize this vector to unity length. More...
 
bool operator!= (const VMDBase &v) const
 Not-equals operator with tolerance factor. More...
 
VMDBase operator* (const double scalar) const
 Multiply by a scalar. More...
 
VMDBase operator* (const VMDBase &v) const
 Inner product of two vectors (element-by-element) More...
 
VMDBaseoperator*= (const double scalar)
 Multiply by a scalar. More...
 
VMDBaseoperator*= (const VMDBase &v)
 Inner product of two vectors (element-by-element) More...
 
VMDBase operator+ (const VMDBase &v) const
 Add two vectors together. More...
 
VMDBaseoperator+= (const VMDBase &v)
 Add two vectors together. More...
 
VMDBase operator- (const VMDBase &v) const
 Subtract two vectors. More...
 
VMDBaseoperator-= (const VMDBase &v)
 Subtract two vectors. More...
 
VMDBase operator/ (const double scalar) const
 Divide by a scalar. More...
 
VMDBase operator/ (const VMDBase &v) const
 Inner division of two vectors (element-by-element) More...
 
VMDBaseoperator/= (const double scalar)
 Divide by a scalar. More...
 
VMDBaseoperator/= (const VMDBase &v)
 Inner division of two vectors (element-by-element) More...
 
VMDBaseoperator= (const VMDBase &other)
 Assignment operator. More...
 
VMDBaseoperator= (VMDBase &&other) noexcept
 Move assignment. More...
 
bool operator== (const VMDBase &v) const
 Equals operator with tolerance factor. More...
 
TYPEoperator[] (const size_t index)
 
const TYPEoperator[] (const size_t index) const
 
TYPE scalar_prod (const VMDBase &v) const
 Scalar product of two vectors. More...
 
size_t size () const
 
std::string toString (const std::string &separator=" ") const
 Return a simple string representation of the vector. More...
 
 VMDBase ()
 Default constructor, build with 1 dimension. More...
 
 VMDBase (const std::string &str)
 Constructor from string. More...
 
 VMDBase (const std::vector< double > &vector)
 Constructor. More...
 
 VMDBase (const std::vector< float > &vector)
 Constructor. More...
 
 VMDBase (const V3D &vector)
 Constructor. More...
 
 VMDBase (const VMDBase &other)
 Copy constructor. More...
 
 VMDBase (double val0, double val1)
 2D Constructor More...
 
 VMDBase (double val0, double val1, double val2)
 3D Constructor More...
 
 VMDBase (double val0, double val1, double val2, double val3)
 4D Constructor More...
 
 VMDBase (double val0, double val1, double val2, double val3, double val4)
 5D Constructor More...
 
 VMDBase (double val0, double val1, double val2, double val3, double val4, double val5)
 6D Constructor More...
 
 VMDBase (size_t nd)
 Constructor. More...
 
 VMDBase (size_t nd, const double *bareData)
 Constructor. More...
 
 VMDBase (size_t nd, const float *bareData)
 Constructor. More...
 
 VMDBase (VMDBase &&other) noexcept
 Move constructor. More...
 
 ~VMDBase ()
 Destructor. More...
 

Static Public Member Functions

static VMDBase getNormalVector (const std::vector< VMDBase > &vectors)
 Given N-1 vectors defining a N-1 dimensional hyperplane in N dimensions, returns a vector that is normal (perpendicular) to all the input vectors. More...
 
static std::vector< VMDBasemakeVectorsOrthogonal (std::vector< VMDBase > &vectors)
 Make an orthogonal system with 2 input 3D vectors. More...
 

Protected Attributes

TYPEdata
 Data, an array of size nd. More...
 
size_t nd
 Number of dimensions. More...
 

Detailed Description

template<typename TYPE = double>
class Mantid::Kernel::VMDBase< TYPE >

Simple vector class for multiple dimensions (i.e.

> 3).

Author
Janik Zikovsky
Date
2011-08-30

Definition at line 22 of file VMD.h.

Constructor & Destructor Documentation

◆ VMDBase() [1/15]

template<typename TYPE >
Mantid::Kernel::VMDBase< TYPE >::VMDBase

Default constructor, build with 1 dimension.

Definition at line 26 of file VMD.cpp.

◆ VMDBase() [2/15]

template<typename TYPE >
Mantid::Kernel::VMDBase< TYPE >::VMDBase ( size_t  nd)

Constructor.

Parameters
nd:: number of dimensions

Definition at line 34 of file VMD.cpp.

◆ VMDBase() [3/15]

template<typename TYPE >
Mantid::Kernel::VMDBase< TYPE >::VMDBase ( double  val0,
double  val1 
)

2D Constructor

Parameters
val0:: value at first dimension
val1:: value at second dimension

Definition at line 46 of file VMD.cpp.

◆ VMDBase() [4/15]

template<typename TYPE >
Mantid::Kernel::VMDBase< TYPE >::VMDBase ( double  val0,
double  val1,
double  val2 
)

3D Constructor

Parameters
val0:: value at first dimension
val1:: value at second dimension
val2:: value at third dimension

Definition at line 57 of file VMD.cpp.

◆ VMDBase() [5/15]

template<typename TYPE >
Mantid::Kernel::VMDBase< TYPE >::VMDBase ( double  val0,
double  val1,
double  val2,
double  val3 
)

4D Constructor

Parameters
val0:: value at first dimension
val1:: value at second dimension
val2:: value at third dimension
val3:: value at fourth dimension

Definition at line 70 of file VMD.cpp.

◆ VMDBase() [6/15]

template<typename TYPE >
Mantid::Kernel::VMDBase< TYPE >::VMDBase ( double  val0,
double  val1,
double  val2,
double  val3,
double  val4 
)

5D Constructor

Parameters
val0:: value at first dimension
val1:: value at second dimension
val2:: value at third dimension
val3:: value at fourth dimension
val4:: value at fifth dimension

Definition at line 86 of file VMD.cpp.

References Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.

◆ VMDBase() [7/15]

template<typename TYPE >
Mantid::Kernel::VMDBase< TYPE >::VMDBase ( double  val0,
double  val1,
double  val2,
double  val3,
double  val4,
double  val5 
)

6D Constructor

Parameters
val0:: value at first dimension
val1:: value at second dimension
val2:: value at third dimension
val3:: value at fourth dimension
val4:: value at fifth dimension
val5:: value at sixth dimension

Definition at line 104 of file VMD.cpp.

References Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.

◆ VMDBase() [8/15]

template<typename TYPE >
Mantid::Kernel::VMDBase< TYPE >::VMDBase ( const VMDBase< TYPE > &  other)

Copy constructor.

Parameters
other:: other to copy

Definition at line 116 of file VMD.cpp.

References Mantid::Geometry::d, Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.

◆ VMDBase() [9/15]

template<typename TYPE >
Mantid::Kernel::VMDBase< TYPE >::VMDBase ( VMDBase< TYPE > &&  other)
noexcept

Move constructor.

Parameters
other:: move into this

Definition at line 141 of file VMD.cpp.

◆ VMDBase() [10/15]

template<typename TYPE >
Mantid::Kernel::VMDBase< TYPE >::VMDBase ( size_t  nd,
const double *  bareData 
)

Constructor.

Parameters
nd:: number of dimensions
bareData:: pointer to a nd-sized bare data array

Definition at line 163 of file VMD.cpp.

References Mantid::Geometry::d, Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.

◆ VMDBase() [11/15]

template<typename TYPE >
Mantid::Kernel::VMDBase< TYPE >::VMDBase ( size_t  nd,
const float *  bareData 
)

Constructor.

Parameters
nd:: number of dimensions
bareData:: pointer to a nd-sized bare data array

Definition at line 174 of file VMD.cpp.

References Mantid::Geometry::d, Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.

◆ VMDBase() [12/15]

template<typename TYPE >
Mantid::Kernel::VMDBase< TYPE >::VMDBase ( const V3D vector)

Constructor.

Parameters
vector:: V3D

Definition at line 184 of file VMD.cpp.

References Mantid::Geometry::d, Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.

◆ VMDBase() [13/15]

template<typename TYPE >
Mantid::Kernel::VMDBase< TYPE >::VMDBase ( const std::vector< double > &  vector)

Constructor.

Parameters
vector:: vector of doubles

Definition at line 192 of file VMD.cpp.

References Mantid::Geometry::d, Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.

◆ VMDBase() [14/15]

template<typename TYPE >
Mantid::Kernel::VMDBase< TYPE >::VMDBase ( const std::vector< float > &  vector)

Constructor.

Parameters
vector:: vector of floats

Definition at line 202 of file VMD.cpp.

References Mantid::Geometry::d, Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.

◆ VMDBase() [15/15]

template<typename TYPE >
Mantid::Kernel::VMDBase< TYPE >::VMDBase ( const std::string &  str)

Constructor from string.

Parameters
str:: string of comma or space-separated numbers for each component

Definition at line 213 of file VMD.cpp.

References Mantid::Kernel::StringTokenizer::cbegin(), Mantid::Kernel::StringTokenizer::cend(), and Mantid::Kernel::StringTokenizer::TOK_IGNORE_EMPTY.

◆ ~VMDBase()

template<typename TYPE >
Mantid::Kernel::VMDBase< TYPE >::~VMDBase

Destructor.

Definition at line 233 of file VMD.cpp.

Member Function Documentation

◆ angle()

template<typename TYPE >
TYPE Mantid::Kernel::VMDBase< TYPE >::angle ( const VMDBase< TYPE > &  v) const

Return the angle between this and another vector.

Parameters
v:: The other vector
Returns
The angle between the vectors in radians (0 < theta < pi)

Definition at line 438 of file VMD.cpp.

References Mantid::Kernel::VMDBase< TYPE >::norm().

◆ cross_prod()

template<typename TYPE >
VMDBase< TYPE > Mantid::Kernel::VMDBase< TYPE >::cross_prod ( const VMDBase< TYPE > &  v) const

Cross product of two vectors.

Only works in 3D

Parameters
v:: other vector, also 3D

Definition at line 403 of file VMD.cpp.

References Mantid::Kernel::V3D::cross_prod(), Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.

◆ getBareArray()

template<typename TYPE >
const TYPE * Mantid::Kernel::VMDBase< TYPE >::getBareArray

◆ getNormalVector()

template<typename TYPE = double>
VMDBase< TYPE > Mantid::Kernel::VMDBase< TYPE >::getNormalVector ( const std::vector< VMDBase< TYPE > > &  vectors)
static

Given N-1 vectors defining a N-1 dimensional hyperplane in N dimensions, returns a vector that is normal (perpendicular) to all the input vectors.

Given planar vectors a, b, c, ... Build a NxN matrix of this style: x1 x2 x3 x4 a1 a2 a4 a4 b1 b2 b4 b4 c1 c2 c4 c4

Where xn = the basis unit vector of the space, e.g. x1 = x, x2 = y, etc.

The determinant of the matrix gives the normal vector. This is analogous to the determinant method of finding the cross product of 2 3D vectors.

It can be shown that the resulting vector n is such that: n . a = 0; n . b = 0 etc. ... meaning that all the in-plane vectors are perpendicular to the normal, which is what we wanted!

(I've worked it out in 4D and its a long proof (not shown here) I'm assuming it holds for higher dimensions, I'll let a mathematician prove this :) )

Parameters
vectors:: vector of N-1 vectors with N dimensions.
Exceptions
ifthe vectors are collinear
Returns
the normal vector

Definition at line 494 of file VMD.cpp.

References Mantid::Geometry::d, Mantid::Kernel::Matrix< T >::determinant(), and Mantid::Kernel::VMDBase< TYPE >::normalize().

◆ getNumDims()

template<typename TYPE >
size_t Mantid::Kernel::VMDBase< TYPE >::getNumDims

◆ length()

template<typename TYPE >
TYPE Mantid::Kernel::VMDBase< TYPE >::length
Returns
the length of this vector

Definition at line 417 of file VMD.cpp.

◆ makeVectorsOrthogonal()

template<typename TYPE >
std::vector< VMDBase< TYPE > > Mantid::Kernel::VMDBase< TYPE >::makeVectorsOrthogonal ( std::vector< VMDBase< TYPE > > &  vectors)
static

Make an orthogonal system with 2 input 3D vectors.

Currently only works in 3D!

Parameters
vectors:: list of 2 vectors with 3D
Returns
list of 3 vectors

Definition at line 450 of file VMD.cpp.

References Mantid::Kernel::V3D::makeVectorsOrthogonal().

◆ norm()

template<typename TYPE >
TYPE Mantid::Kernel::VMDBase< TYPE >::norm

◆ norm2()

template<typename TYPE >
TYPE Mantid::Kernel::VMDBase< TYPE >::norm2
Returns
the length of this vector

Definition at line 423 of file VMD.cpp.

◆ normalize()

template<typename TYPE >
TYPE Mantid::Kernel::VMDBase< TYPE >::normalize

◆ operator!=()

template<typename TYPE >
bool Mantid::Kernel::VMDBase< TYPE >::operator!= ( const VMDBase< TYPE > &  v) const

Not-equals operator with tolerance factor.

Parameters
v:: VMDBase for comparison
Returns
true if the items are equal

Definition at line 278 of file VMD.cpp.

References Mantid::Kernel::operator==().

◆ operator*() [1/2]

template<typename TYPE >
VMDBase< TYPE > Mantid::Kernel::VMDBase< TYPE >::operator* ( const double  scalar) const

Multiply by a scalar.

Parameters
scalar:: double scalar to multiply each element

Definition at line 359 of file VMD.cpp.

◆ operator*() [2/2]

template<typename TYPE >
VMDBase< TYPE > Mantid::Kernel::VMDBase< TYPE >::operator* ( const VMDBase< TYPE > &  v) const

Inner product of two vectors (element-by-element)

Parameters
v:: other vector, must match number of dimensions

Definition at line 321 of file VMD.cpp.

◆ operator*=() [1/2]

template<typename TYPE >
VMDBase< TYPE > & Mantid::Kernel::VMDBase< TYPE >::operator*= ( const double  scalar)

Multiply by a scalar.

Parameters
scalar:: double scalar to multiply each element

Definition at line 367 of file VMD.cpp.

References Mantid::Geometry::d.

◆ operator*=() [2/2]

template<typename TYPE >
VMDBase< TYPE > & Mantid::Kernel::VMDBase< TYPE >::operator*= ( const VMDBase< TYPE > &  v)

Inner product of two vectors (element-by-element)

Parameters
v:: other vector, must match number of dimensions

Definition at line 329 of file VMD.cpp.

References Mantid::Geometry::d, Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.

◆ operator+()

template<typename TYPE >
VMDBase< TYPE > Mantid::Kernel::VMDBase< TYPE >::operator+ ( const VMDBase< TYPE > &  v) const

Add two vectors together.

Parameters
v:: other vector, must match number of dimensions

Definition at line 282 of file VMD.cpp.

◆ operator+=()

template<typename TYPE >
VMDBase< TYPE > & Mantid::Kernel::VMDBase< TYPE >::operator+= ( const VMDBase< TYPE > &  v)

Add two vectors together.

Parameters
v:: other vector, must match number of dimensions

Definition at line 290 of file VMD.cpp.

References Mantid::Geometry::d, Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.

◆ operator-()

template<typename TYPE >
VMDBase< TYPE > Mantid::Kernel::VMDBase< TYPE >::operator- ( const VMDBase< TYPE > &  v) const

Subtract two vectors.

Parameters
v:: other vector, must match number of dimensions

Definition at line 302 of file VMD.cpp.

◆ operator-=()

template<typename TYPE >
VMDBase< TYPE > & Mantid::Kernel::VMDBase< TYPE >::operator-= ( const VMDBase< TYPE > &  v)

Subtract two vectors.

Parameters
v:: other vector, must match number of dimensions

Definition at line 310 of file VMD.cpp.

References Mantid::Geometry::d, Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.

◆ operator/() [1/2]

template<typename TYPE >
VMDBase< TYPE > Mantid::Kernel::VMDBase< TYPE >::operator/ ( const double  scalar) const

Divide by a scalar.

Parameters
scalar:: double scalar to Divide each element

Definition at line 375 of file VMD.cpp.

◆ operator/() [2/2]

template<typename TYPE >
VMDBase< TYPE > Mantid::Kernel::VMDBase< TYPE >::operator/ ( const VMDBase< TYPE > &  v) const

Inner division of two vectors (element-by-element)

Parameters
v:: other vector, must match number of dimensions

Definition at line 340 of file VMD.cpp.

◆ operator/=() [1/2]

template<typename TYPE >
VMDBase< TYPE > & Mantid::Kernel::VMDBase< TYPE >::operator/= ( const double  scalar)

Divide by a scalar.

Parameters
scalar:: double scalar to Divide each element

Definition at line 383 of file VMD.cpp.

References Mantid::Geometry::d.

◆ operator/=() [2/2]

template<typename TYPE >
VMDBase< TYPE > & Mantid::Kernel::VMDBase< TYPE >::operator/= ( const VMDBase< TYPE > &  v)

Inner division of two vectors (element-by-element)

Parameters
v:: other vector, must match number of dimensions

Definition at line 348 of file VMD.cpp.

References Mantid::Geometry::d, Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.

◆ operator=() [1/2]

template<typename TYPE >
VMDBase< TYPE > & Mantid::Kernel::VMDBase< TYPE >::operator= ( const VMDBase< TYPE > &  other)

Assignment operator.

Parameters
other:: copy into this

Definition at line 127 of file VMD.cpp.

References Mantid::Geometry::d.

◆ operator=() [2/2]

template<typename TYPE >
VMDBase< TYPE > & Mantid::Kernel::VMDBase< TYPE >::operator= ( VMDBase< TYPE > &&  other)
noexcept

Move assignment.

Parameters
other:: move into this

Definition at line 149 of file VMD.cpp.

◆ operator==()

template<typename TYPE >
bool Mantid::Kernel::VMDBase< TYPE >::operator== ( const VMDBase< TYPE > &  v) const

Equals operator with tolerance factor.

Parameters
v:: VMDBase for comparison
Returns
true if the items are equal

Definition at line 265 of file VMD.cpp.

References Mantid::Geometry::d, Mantid::Kernel::VMDBase< TYPE >::data, Mantid::Kernel::VMDBase< TYPE >::nd, and Mantid::Kernel::Tolerance.

◆ operator[]() [1/2]

template<typename TYPE >
TYPE & Mantid::Kernel::VMDBase< TYPE >::operator[] ( const size_t  index)
Returns
the value at the index

Definition at line 245 of file VMD.cpp.

References index.

◆ operator[]() [2/2]

template<typename TYPE >
const TYPE & Mantid::Kernel::VMDBase< TYPE >::operator[] ( const size_t  index) const
Returns
the value at the index

Definition at line 242 of file VMD.cpp.

References index.

◆ scalar_prod()

template<typename TYPE >
TYPE Mantid::Kernel::VMDBase< TYPE >::scalar_prod ( const VMDBase< TYPE > &  v) const

Scalar product of two vectors.

Parameters
v:: other vector, must match number of dimensions

Definition at line 391 of file VMD.cpp.

References Mantid::Geometry::d, Mantid::Kernel::VMDBase< TYPE >::data, and Mantid::Kernel::VMDBase< TYPE >::nd.

Referenced by Mantid::MDAlgorithms::SlicingAlgorithm::isProjectingOnFrame().

◆ size()

template<typename TYPE >
size_t Mantid::Kernel::VMDBase< TYPE >::size

◆ toString()

template<typename TYPE >
std::string Mantid::Kernel::VMDBase< TYPE >::toString ( const std::string &  separator = " ") const

Return a simple string representation of the vector.

Parameters
separator:: string to place between values, one space is the default

Definition at line 254 of file VMD.cpp.

References Mantid::Geometry::d.

Referenced by Mantid::Kernel::operator<<().

Member Data Documentation

◆ data

template<typename TYPE = double>
TYPE* Mantid::Kernel::VMDBase< TYPE >::data
protected

◆ nd

template<typename TYPE = double>
size_t Mantid::Kernel::VMDBase< TYPE >::nd
protected

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