Open CASCADE Technology 7.8.0
Public Member Functions | Protected Member Functions
math_VectorBase< TheItemType > Class Template Reference

This class implements the real vector abstract data type. Vectors can have an arbitrary range which must be defined at the declaration and cannot be changed after this declaration. More...

#include <math_VectorBase.hxx>

Public Member Functions

 math_VectorBase (const Standard_Integer theLower, const Standard_Integer theUpper)
 Memory allocation.
 
 math_VectorBase (const Standard_Integer theLower, const Standard_Integer theUpper, const TheItemType theInitialValue)
 Constructs a vector in the range [theLower..theUpper] whose values are all initialized with the value "theInitialValue".
 
 math_VectorBase (const TheItemType *theTab, const Standard_Integer theLower, const Standard_Integer theUpper)
 Constructs a vector in the range [theLower..theUpper] whose values are all initialized with the value "theInitialValue".
 
 math_VectorBase (const gp_XY &Other)
 Constructor for converting gp_XY to math_VectorBase.
 
 math_VectorBase (const gp_XYZ &Other)
 Constructor for converting gp_XYZ to math_VectorBase.
 
void Init (const TheItemType theInitialValue)
 Initialize all the elements of a vector with "theInitialValue".
 
 math_VectorBase (const math_VectorBase &theOther)
 Constructs a copy for initialization. An exception is raised if the lengths of the vectors are different.
 
Standard_Integer Length () const
 Returns the length of a vector.
 
Standard_Integer Lower () const
 Returns the lower index of the vector.
 
Standard_Integer Upper () const
 Returns the upper index of the vector.
 
Standard_Real Norm () const
 Returns the value or the square of the norm of this vector.
 
Standard_Real Norm2 () const
 Returns the value of the square of the norm of a vector.
 
Standard_Integer Max () const
 Returns the index of the maximum element of a vector. (first found)
 
Standard_Integer Min () const
 Returns the index of the minimum element of a vector. (first found)
 
void Normalize ()
 Normalizes this vector (the norm of the result is equal to 1.0) and assigns the result to this vector Exceptions Standard_NullValue if this vector is null (i.e. if its norm is less than or equal to Standard_Real::RealEpsilon().
 
math_VectorBase Normalized () const
 Normalizes this vector (the norm of the result is equal to 1.0) and creates a new vector Exceptions Standard_NullValue if this vector is null (i.e. if its norm is less than or equal to Standard_Real::RealEpsilon().
 
void Invert ()
 Inverts this vector and assigns the result to this vector.
 
math_VectorBase Inverse () const
 Inverts this vector and creates a new vector.
 
void Set (const Standard_Integer theI1, const Standard_Integer theI2, const math_VectorBase &theV)
 sets a vector from "theI1" to "theI2" to the vector "theV"; An exception is raised if "theI1" is less than "LowerIndex" or "theI2" is greater than "UpperIndex" or "theI1" is greater than "theI2". An exception is raised if "theI2-theI1+1" is different from the "Length" of "theV".
 
math_VectorBase Slice (const Standard_Integer theI1, const Standard_Integer theI2) const
 Creates a new vector by inverting the values of this vector between indexes "theI1" and "theI2". If the values of this vector were (1., 2., 3., 4.,5., 6.), by slicing it between indexes 2 and 5 the values of the resulting vector are (1., 5., 4., 3., 2., 6.)
 
void Multiply (const TheItemType theRight)
 Updates current vector by multiplying each element on current value.
 
void operator*= (const TheItemType theRight)
 
math_VectorBase Multiplied (const TheItemType theRight) const
 returns the product of a vector and a real value.
 
math_VectorBase operator* (const TheItemType theRight) const
 
math_VectorBase TMultiplied (const TheItemType theRight) const
 returns the product of a vector and a real value.
 
void Divide (const TheItemType theRight)
 divides a vector by the value "theRight". An exception is raised if "theRight" = 0.
 
void operator/= (const TheItemType theRight)
 
math_VectorBase Divided (const TheItemType theRight) const
 Returns new vector as dividing current vector with the value "theRight". An exception is raised if "theRight" = 0.
 
math_VectorBase operator/ (const TheItemType theRight) const
 
void Add (const math_VectorBase &theRight)
 adds the vector "theRight" to a vector. An exception is raised if the vectors have not the same length. Warning In order to avoid time-consuming copying of vectors, it is preferable to use operator += or the function Add whenever possible.
 
void operator+= (const math_VectorBase &theRight)
 
math_VectorBase Added (const math_VectorBase &theRight) const
 Returns new vector as adding curent vector with the value "theRight". An exception is raised if the vectors have not the same length. An exception is raised if the lengths are not equal.
 
math_VectorBase operator+ (const math_VectorBase &theRight) const
 
void Multiply (const math_VectorBase &theLeft, const math_Matrix &theRight)
 sets a vector to the product of the vector "theLeft" with the matrix "theRight".
 
void Multiply (const math_Matrix &theLeft, const math_VectorBase &theRight)
 sets a vector to the product of the matrix "theLeft" with the vector "theRight".
 
void TMultiply (const math_Matrix &theTLeft, const math_VectorBase &theRight)
 sets a vector to the product of the transpose of the matrix "theTLeft" by the vector "theRight".
 
void TMultiply (const math_VectorBase &theLeft, const math_Matrix &theTRight)
 sets a vector to the product of the vector "theLeft" by the transpose of the matrix "theTRight".
 
void Add (const math_VectorBase &theLeft, const math_VectorBase &theRight)
 sets a vector to the sum of the vector "theLeft" and the vector "theRight". An exception is raised if the lengths are different.
 
void Subtract (const math_VectorBase &theLeft, const math_VectorBase &theRight)
 sets a vector to the Subtraction of the vector theRight from the vector theLeft. An exception is raised if the vectors have not the same length. Warning In order to avoid time-consuming copying of vectors, it is preferable to use operator -= or the function Subtract whenever possible.
 
const TheItemTypeValue (const Standard_Integer theNum) const
 accesses the value of index "theNum" of a vector.
 
TheItemTypeValue (const Standard_Integer theNum)
 accesses (in read or write mode) the value of index "theNum" of a vector.
 
const TheItemTypeoperator() (const Standard_Integer theNum) const
 
TheItemTypeoperator() (const Standard_Integer theNum)
 
math_VectorBaseInitialized (const math_VectorBase &theOther)
 Initialises a vector by copying "theOther". An exception is raised if the Lengths are different.
 
math_VectorBaseoperator= (const math_VectorBase &theOther)
 
TheItemType Multiplied (const math_VectorBase &theRight) const
 returns the inner product of 2 vectors. An exception is raised if the lengths are not equal.
 
TheItemType operator* (const math_VectorBase &theRight) const
 
math_VectorBase Multiplied (const math_Matrix &theRight) const
 returns the product of a vector by a matrix.
 
math_VectorBase operator* (const math_Matrix &theRight) const
 
math_VectorBase Opposite ()
 returns the opposite of a vector.
 
math_VectorBase operator- ()
 
void Subtract (const math_VectorBase &theRight)
 returns the subtraction of "theRight" from "me". An exception is raised if the vectors have not the same length.
 
void operator-= (const math_VectorBase &theRight)
 
math_VectorBase Subtracted (const math_VectorBase &theRight) const
 returns the subtraction of "theRight" from "me". An exception is raised if the vectors have not the same length.
 
math_VectorBase operator- (const math_VectorBase &theRight) const
 
void Multiply (const TheItemType theLeft, const math_VectorBase &theRight)
 returns the multiplication of a real by a vector. "me" = "theLeft" * "theRight"
 
void Dump (Standard_OStream &theO) const
 Prints information on the current state of the object. Is used to redefine the operator <<.
 

Protected Member Functions

void SetLower (const Standard_Integer theLower)
 Is used internally to set the "theLower" value of the vector.
 

Detailed Description

template<typename TheItemType>
class math_VectorBase< TheItemType >

This class implements the real vector abstract data type. Vectors can have an arbitrary range which must be defined at the declaration and cannot be changed after this declaration.

math_VectorBase<TheItemType> V1(-3, 5); // a vector with range [-3..5]
Definition NCollection_UBTree.hxx:64

Vector are copied through assignment:

....
V2 = V1;
V1(1) = 2.0; // the vector V2 will not be modified.

The Exception RangeError is raised when trying to access outside the range of a vector :

V1(11) = 0.0 // --> will raise RangeError;

The Exception DimensionError is raised when the dimensions of two vectors are not compatible :

V3 = V1; // --> will raise DimensionError;
V1.Add(V3) // --> will raise DimensionError;

Constructor & Destructor Documentation

◆ math_VectorBase() [1/6]

Memory allocation.

Constructs a non-initialized vector in the range [theLower..theUpper] "theLower" and "theUpper" are the indexes of the lower and upper bounds of the constructed vector.

◆ math_VectorBase() [2/6]

template<typename TheItemType >
math_VectorBase< TheItemType >::math_VectorBase ( const Standard_Integer  theLower,
const Standard_Integer  theUpper,
const TheItemType  theInitialValue 
)
inline

Constructs a vector in the range [theLower..theUpper] whose values are all initialized with the value "theInitialValue".

◆ math_VectorBase() [3/6]

Constructs a vector in the range [theLower..theUpper] whose values are all initialized with the value "theInitialValue".

◆ math_VectorBase() [4/6]

Constructor for converting gp_XY to math_VectorBase.

◆ math_VectorBase() [5/6]

Constructor for converting gp_XYZ to math_VectorBase.

◆ math_VectorBase() [6/6]

Constructs a copy for initialization. An exception is raised if the lengths of the vectors are different.

Member Function Documentation

◆ Add() [1/2]

template<typename TheItemType >
void math_VectorBase< TheItemType >::Add ( const math_VectorBase< TheItemType > &  theLeft,
const math_VectorBase< TheItemType > &  theRight 
)
inline

sets a vector to the sum of the vector "theLeft" and the vector "theRight". An exception is raised if the lengths are different.

◆ Add() [2/2]

template<typename TheItemType >
void math_VectorBase< TheItemType >::Add ( const math_VectorBase< TheItemType > &  theRight)
inline

adds the vector "theRight" to a vector. An exception is raised if the vectors have not the same length. Warning In order to avoid time-consuming copying of vectors, it is preferable to use operator += or the function Add whenever possible.

◆ Added()

template<typename TheItemType >
math_VectorBase math_VectorBase< TheItemType >::Added ( const math_VectorBase< TheItemType > &  theRight) const
inline

Returns new vector as adding curent vector with the value "theRight". An exception is raised if the vectors have not the same length. An exception is raised if the lengths are not equal.

◆ Divide()

template<typename TheItemType >
void math_VectorBase< TheItemType >::Divide ( const TheItemType  theRight)
inline

divides a vector by the value "theRight". An exception is raised if "theRight" = 0.

◆ Divided()

template<typename TheItemType >
math_VectorBase math_VectorBase< TheItemType >::Divided ( const TheItemType  theRight) const
inline

Returns new vector as dividing current vector with the value "theRight". An exception is raised if "theRight" = 0.

◆ Dump()

template<typename TheItemType >
void math_VectorBase< TheItemType >::Dump ( Standard_OStream theO) const
inline

Prints information on the current state of the object. Is used to redefine the operator <<.

◆ Init()

template<typename TheItemType >
void math_VectorBase< TheItemType >::Init ( const TheItemType  theInitialValue)

Initialize all the elements of a vector with "theInitialValue".

◆ Initialized()

template<typename TheItemType >
math_VectorBase & math_VectorBase< TheItemType >::Initialized ( const math_VectorBase< TheItemType > &  theOther)
inline

Initialises a vector by copying "theOther". An exception is raised if the Lengths are different.

◆ Inverse()

template<typename TheItemType >
math_VectorBase math_VectorBase< TheItemType >::Inverse ( ) const
inline

Inverts this vector and creates a new vector.

◆ Invert()

template<typename TheItemType >
void math_VectorBase< TheItemType >::Invert ( )
inline

Inverts this vector and assigns the result to this vector.

◆ Length()

template<typename TheItemType >
Standard_Integer math_VectorBase< TheItemType >::Length ( ) const
inline

Returns the length of a vector.

◆ Lower()

template<typename TheItemType >
Standard_Integer math_VectorBase< TheItemType >::Lower ( ) const
inline

Returns the lower index of the vector.

◆ Max()

template<typename TheItemType >
Standard_Integer math_VectorBase< TheItemType >::Max ( ) const
inline

Returns the index of the maximum element of a vector. (first found)

◆ Min()

template<typename TheItemType >
Standard_Integer math_VectorBase< TheItemType >::Min ( ) const
inline

Returns the index of the minimum element of a vector. (first found)

◆ Multiplied() [1/3]

template<typename TheItemType >
math_VectorBase math_VectorBase< TheItemType >::Multiplied ( const math_Matrix theRight) const
inline

returns the product of a vector by a matrix.

◆ Multiplied() [2/3]

template<typename TheItemType >
TheItemType math_VectorBase< TheItemType >::Multiplied ( const math_VectorBase< TheItemType > &  theRight) const
inline

returns the inner product of 2 vectors. An exception is raised if the lengths are not equal.

◆ Multiplied() [3/3]

template<typename TheItemType >
math_VectorBase math_VectorBase< TheItemType >::Multiplied ( const TheItemType  theRight) const
inline

returns the product of a vector and a real value.

◆ Multiply() [1/4]

template<typename TheItemType >
void math_VectorBase< TheItemType >::Multiply ( const math_Matrix theLeft,
const math_VectorBase< TheItemType > &  theRight 
)
inline

sets a vector to the product of the matrix "theLeft" with the vector "theRight".

◆ Multiply() [2/4]

template<typename TheItemType >
void math_VectorBase< TheItemType >::Multiply ( const math_VectorBase< TheItemType > &  theLeft,
const math_Matrix theRight 
)
inline

sets a vector to the product of the vector "theLeft" with the matrix "theRight".

◆ Multiply() [3/4]

template<typename TheItemType >
void math_VectorBase< TheItemType >::Multiply ( const TheItemType  theLeft,
const math_VectorBase< TheItemType > &  theRight 
)
inline

returns the multiplication of a real by a vector. "me" = "theLeft" * "theRight"

◆ Multiply() [4/4]

template<typename TheItemType >
void math_VectorBase< TheItemType >::Multiply ( const TheItemType  theRight)
inline

Updates current vector by multiplying each element on current value.

◆ Norm()

template<typename TheItemType >
Standard_Real math_VectorBase< TheItemType >::Norm ( ) const
inline

Returns the value or the square of the norm of this vector.

◆ Norm2()

template<typename TheItemType >
Standard_Real math_VectorBase< TheItemType >::Norm2 ( ) const
inline

Returns the value of the square of the norm of a vector.

◆ Normalize()

template<typename TheItemType >
void math_VectorBase< TheItemType >::Normalize ( )
inline

Normalizes this vector (the norm of the result is equal to 1.0) and assigns the result to this vector Exceptions Standard_NullValue if this vector is null (i.e. if its norm is less than or equal to Standard_Real::RealEpsilon().

◆ Normalized()

template<typename TheItemType >
math_VectorBase math_VectorBase< TheItemType >::Normalized ( ) const
inline

Normalizes this vector (the norm of the result is equal to 1.0) and creates a new vector Exceptions Standard_NullValue if this vector is null (i.e. if its norm is less than or equal to Standard_Real::RealEpsilon().

◆ operator()() [1/2]

◆ operator()() [2/2]

◆ operator*() [1/3]

◆ operator*() [2/3]

◆ operator*() [3/3]

◆ operator*=()

template<typename TheItemType >
void math_VectorBase< TheItemType >::operator*= ( const TheItemType  theRight)
inline

◆ operator+()

◆ operator+=()

◆ operator-() [1/2]

◆ operator-() [2/2]

◆ operator-=()

◆ operator/()

◆ operator/=()

template<typename TheItemType >
void math_VectorBase< TheItemType >::operator/= ( const TheItemType  theRight)
inline

◆ operator=()

◆ Opposite()

template<typename TheItemType >
math_VectorBase math_VectorBase< TheItemType >::Opposite ( )
inline

returns the opposite of a vector.

◆ Set()

template<typename TheItemType >
void math_VectorBase< TheItemType >::Set ( const Standard_Integer  theI1,
const Standard_Integer  theI2,
const math_VectorBase< TheItemType > &  theV 
)
inline

sets a vector from "theI1" to "theI2" to the vector "theV"; An exception is raised if "theI1" is less than "LowerIndex" or "theI2" is greater than "UpperIndex" or "theI1" is greater than "theI2". An exception is raised if "theI2-theI1+1" is different from the "Length" of "theV".

◆ SetLower()

template<typename TheItemType >
void math_VectorBase< TheItemType >::SetLower ( const Standard_Integer  theLower)
inlineprotected

Is used internally to set the "theLower" value of the vector.

◆ Slice()

Creates a new vector by inverting the values of this vector between indexes "theI1" and "theI2". If the values of this vector were (1., 2., 3., 4.,5., 6.), by slicing it between indexes 2 and 5 the values of the resulting vector are (1., 5., 4., 3., 2., 6.)

◆ Subtract() [1/2]

template<typename TheItemType >
void math_VectorBase< TheItemType >::Subtract ( const math_VectorBase< TheItemType > &  theLeft,
const math_VectorBase< TheItemType > &  theRight 
)
inline

sets a vector to the Subtraction of the vector theRight from the vector theLeft. An exception is raised if the vectors have not the same length. Warning In order to avoid time-consuming copying of vectors, it is preferable to use operator -= or the function Subtract whenever possible.

◆ Subtract() [2/2]

template<typename TheItemType >
void math_VectorBase< TheItemType >::Subtract ( const math_VectorBase< TheItemType > &  theRight)
inline

returns the subtraction of "theRight" from "me". An exception is raised if the vectors have not the same length.

◆ Subtracted()

template<typename TheItemType >
math_VectorBase math_VectorBase< TheItemType >::Subtracted ( const math_VectorBase< TheItemType > &  theRight) const
inline

returns the subtraction of "theRight" from "me". An exception is raised if the vectors have not the same length.

◆ TMultiplied()

template<typename TheItemType >
math_VectorBase math_VectorBase< TheItemType >::TMultiplied ( const TheItemType  theRight) const
inline

returns the product of a vector and a real value.

◆ TMultiply() [1/2]

template<typename TheItemType >
void math_VectorBase< TheItemType >::TMultiply ( const math_Matrix theTLeft,
const math_VectorBase< TheItemType > &  theRight 
)
inline

sets a vector to the product of the transpose of the matrix "theTLeft" by the vector "theRight".

◆ TMultiply() [2/2]

template<typename TheItemType >
void math_VectorBase< TheItemType >::TMultiply ( const math_VectorBase< TheItemType > &  theLeft,
const math_Matrix theTRight 
)
inline

sets a vector to the product of the vector "theLeft" by the transpose of the matrix "theTRight".

◆ Upper()

template<typename TheItemType >
Standard_Integer math_VectorBase< TheItemType >::Upper ( ) const
inline

Returns the upper index of the vector.

◆ Value() [1/2]

accesses (in read or write mode) the value of index "theNum" of a vector.

◆ Value() [2/2]

template<typename TheItemType >
const TheItemType & math_VectorBase< TheItemType >::Value ( const Standard_Integer  theNum) const
inline

accesses the value of index "theNum" of a vector.


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