Open CASCADE Technology  7.1.0.beta
Public Member Functions | Protected Member Functions | Friends
math_Vector Class 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_Vector.hxx>

Public Member Functions

 math_Vector (const Standard_Integer theLower, const Standard_Integer theUpper)
 Contructs 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. More...
 
 math_Vector (const Standard_Integer theLower, const Standard_Integer theUpper, const Standard_Real theInitialValue)
 Contructs a vector in the range [theLower..theUpper] whose values are all initialized with the value "theInitialValue". More...
 
 math_Vector (const Standard_Address theTab, const Standard_Integer theLower, const Standard_Integer theUpper)
 Constructs a vector in the range [theLower..theUpper] with the "c array" theTab. More...
 
 math_Vector (const gp_XY &Other)
 Constructor for converting gp_XY to math_Vector. More...
 
 math_Vector (const gp_XYZ &Other)
 Constructor for converting gp_XYZ to math_Vector. More...
 
void Init (const Standard_Real theInitialValue)
 Initialize all the elements of a vector with "theInitialValue". More...
 
 math_Vector (const math_Vector &theOther)
 Constructs a copy for initialization. An exception is raised if the lengths of the vectors are different. More...
 
Standard_Integer Length () const
 Returns the length of a vector. More...
 
Standard_Integer Lower () const
 Returns the value of the theLower index of a vector. More...
 
Standard_Integer Upper () const
 Returns the value of the theUpper index of a vector. More...
 
Standard_Real Norm () const
 Returns the value or the square of the norm of this vector. More...
 
Standard_Real Norm2 () const
 Returns the value of the square of the norm of a vector. More...
 
Standard_Integer Max () const
 Returns the value of the "Index" of the maximum element of a vector. More...
 
Standard_Integer Min () const
 Returns the value of the "Index" of the minimum element of a vector. More...
 
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(). More...
 
math_Vector 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(). More...
 
void Invert ()
 Inverts this vector and assigns the result to this vector. More...
 
math_Vector Inverse () const
 Inverts this vector and creates a new vector. More...
 
void Set (const Standard_Integer theI1, const Standard_Integer theI2, const math_Vector &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". More...
 
math_Vector 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.) More...
 
void Multiply (const Standard_Real theRight)
 returns the product of a vector and a real value. More...
 
void operator*= (const Standard_Real theRight)
 
math_Vector Multiplied (const Standard_Real theRight) const
 returns the product of a vector and a real value. More...
 
math_Vector operator* (const Standard_Real theRight) const
 
math_Vector TMultiplied (const Standard_Real theRight) const
 returns the product of a vector and a real value. More...
 
void Divide (const Standard_Real theRight)
 divides a vector by the value "theRight". An exception is raised if "theRight" = 0. More...
 
void operator/= (const Standard_Real theRight)
 
math_Vector Divided (const Standard_Real theRight) const
 divides a vector by the value "theRight". An exception is raised if "theRight" = 0. More...
 
math_Vector operator/ (const Standard_Real theRight) const
 
void Add (const math_Vector &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. More...
 
void operator+= (const math_Vector &theRight)
 
math_Vector Added (const math_Vector &theRight) const
 adds the vector theRight to a vector. An exception is raised if the vectors have not the same length. An exception is raised if the lengths are not equal. More...
 
math_Vector operator+ (const math_Vector &theRight) const
 
void Multiply (const math_Vector &theLeft, const math_Matrix &theRight)
 sets a vector to the product of the vector "theLeft" with the matrix "theRight". More...
 
void Multiply (const math_Matrix &theLeft, const math_Vector &theRight)
 sets a vector to the product of the matrix "theLeft" with the vector "theRight". More...
 
void TMultiply (const math_Matrix &theTLeft, const math_Vector &theRight)
 sets a vector to the product of the transpose of the matrix "theTLeft" by the vector "theRight". More...
 
void TMultiply (const math_Vector &theLeft, const math_Matrix &theTRight)
 sets a vector to the product of the vector "theLeft" by the transpose of the matrix "theTRight". More...
 
void Add (const math_Vector &theLeft, const math_Vector &theRight)
 sets a vector to the sum of the vector "theLeft" and the vector "theRight". An exception is raised if the lengths are different. More...
 
void Subtract (const math_Vector &theLeft, const math_Vector &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. More...
 
Standard_RealValue (const Standard_Integer theNum) const
 accesses (in read or write mode) the value of index "theNum" of a vector. More...
 
Standard_Realoperator() (const Standard_Integer theNum) const
 
math_VectorInitialized (const math_Vector &theOther)
 Initialises a vector by copying "theOther". An exception is raised if the Lengths are differents. More...
 
math_Vectoroperator= (const math_Vector &theOther)
 
Standard_Real Multiplied (const math_Vector &theRight) const
 returns the inner product of 2 vectors. An exception is raised if the lengths are not equal. More...
 
Standard_Real operator* (const math_Vector &theRight) const
 
math_Vector Multiplied (const math_Matrix &theRight) const
 returns the product of a vector by a matrix. More...
 
math_Vector operator* (const math_Matrix &theRight) const
 
math_Vector Opposite ()
 returns the opposite of a vector. More...
 
math_Vector operator- ()
 
void Subtract (const math_Vector &theRight)
 returns the subtraction of "theRight" from "me". An exception is raised if the vectors have not the same length. More...
 
void operator-= (const math_Vector &theRight)
 
math_Vector Subtracted (const math_Vector &theRight) const
 returns the subtraction of "theRight" from "me". An exception is raised if the vectors have not the same length. More...
 
math_Vector operator- (const math_Vector &theRight) const
 
void Multiply (const Standard_Real theLeft, const math_Vector &theRight)
 returns the multiplication of a real by a vector. "me" = "theLeft" * "theRight" More...
 
void Dump (Standard_OStream &theO) const
 Prints information on the current state of the object. Is used to redefine the operator <<. More...
 

Protected Member Functions

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

Friends

math_Vector operator* (const Standard_Real theLeft, const math_Vector &theRight)
 
Standard_OStreamoperator<< (Standard_OStream &theO, const math_Vector &theVec)
 

Detailed Description

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_Vector V1(-3, 5); // a vector with range [-3..5]

Vector are copied through assignement :

math_Vector V2( 1, 9);
....
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 :

math_Vector V3(1, 2);
V3 = V1; // --> will raise DimensionError;
V1.Add(V3) // --> will raise DimensionError;

Constructor & Destructor Documentation

math_Vector::math_Vector ( const Standard_Integer  theLower,
const Standard_Integer  theUpper 
)

Contructs 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_Vector::math_Vector ( const Standard_Integer  theLower,
const Standard_Integer  theUpper,
const Standard_Real  theInitialValue 
)

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

math_Vector::math_Vector ( const Standard_Address  theTab,
const Standard_Integer  theLower,
const Standard_Integer  theUpper 
)

Constructs a vector in the range [theLower..theUpper] with the "c array" theTab.

math_Vector::math_Vector ( const gp_XY Other)

Constructor for converting gp_XY to math_Vector.

math_Vector::math_Vector ( const gp_XYZ Other)

Constructor for converting gp_XYZ to math_Vector.

math_Vector::math_Vector ( const math_Vector theOther)

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

Member Function Documentation

void math_Vector::Add ( const math_Vector 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 math_Vector::Add ( const math_Vector theLeft,
const math_Vector theRight 
)

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

math_Vector math_Vector::Added ( const math_Vector theRight) const

adds the vector theRight to a vector. An exception is raised if the vectors have not the same length. An exception is raised if the lengths are not equal.

void math_Vector::Divide ( const Standard_Real  theRight)

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

math_Vector math_Vector::Divided ( const Standard_Real  theRight) const

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

void math_Vector::Dump ( Standard_OStream theO) const

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

void math_Vector::Init ( const Standard_Real  theInitialValue)

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

math_Vector& math_Vector::Initialized ( const math_Vector theOther)

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

math_Vector math_Vector::Inverse ( ) const

Inverts this vector and creates a new vector.

void math_Vector::Invert ( )

Inverts this vector and assigns the result to this vector.

Standard_Integer math_Vector::Length ( void  ) const
inline

Returns the length of a vector.

Standard_Integer math_Vector::Lower ( void  ) const
inline

Returns the value of the theLower index of a vector.

Standard_Integer math_Vector::Max ( ) const

Returns the value of the "Index" of the maximum element of a vector.

Standard_Integer math_Vector::Min ( ) const

Returns the value of the "Index" of the minimum element of a vector.

math_Vector math_Vector::Multiplied ( const Standard_Real  theRight) const

returns the product of a vector and a real value.

Standard_Real math_Vector::Multiplied ( const math_Vector theRight) const

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

math_Vector math_Vector::Multiplied ( const math_Matrix theRight) const

returns the product of a vector by a matrix.

void math_Vector::Multiply ( const Standard_Real  theRight)

returns the product of a vector and a real value.

void math_Vector::Multiply ( const math_Vector theLeft,
const math_Matrix theRight 
)

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

void math_Vector::Multiply ( const math_Matrix theLeft,
const math_Vector theRight 
)

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

void math_Vector::Multiply ( const Standard_Real  theLeft,
const math_Vector theRight 
)

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

Standard_Real math_Vector::Norm ( ) const

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

Standard_Real math_Vector::Norm2 ( ) const

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

void math_Vector::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_Vector math_Vector::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().

Standard_Real& math_Vector::operator() ( const Standard_Integer  theNum) const
inline
math_Vector math_Vector::operator* ( const Standard_Real  theRight) const
inline
Standard_Real math_Vector::operator* ( const math_Vector theRight) const
inline
math_Vector math_Vector::operator* ( const math_Matrix theRight) const
inline
void math_Vector::operator*= ( const Standard_Real  theRight)
inline
math_Vector math_Vector::operator+ ( const math_Vector theRight) const
inline
void math_Vector::operator+= ( const math_Vector theRight)
inline
math_Vector math_Vector::operator- ( )
inline
math_Vector math_Vector::operator- ( const math_Vector theRight) const
inline
void math_Vector::operator-= ( const math_Vector theRight)
inline
math_Vector math_Vector::operator/ ( const Standard_Real  theRight) const
inline
void math_Vector::operator/= ( const Standard_Real  theRight)
inline
math_Vector& math_Vector::operator= ( const math_Vector theOther)
inline
math_Vector math_Vector::Opposite ( )

returns the opposite of a vector.

void math_Vector::Set ( const Standard_Integer  theI1,
const Standard_Integer  theI2,
const math_Vector 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".

void math_Vector::SetLower ( const Standard_Integer  theLower)
protected

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

math_Vector math_Vector::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 math_Vector::Subtract ( const math_Vector theLeft,
const math_Vector 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.

void math_Vector::Subtract ( const math_Vector theRight)

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

math_Vector math_Vector::Subtracted ( const math_Vector theRight) const

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

math_Vector math_Vector::TMultiplied ( const Standard_Real  theRight) const

returns the product of a vector and a real value.

void math_Vector::TMultiply ( const math_Matrix theTLeft,
const math_Vector theRight 
)

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

void math_Vector::TMultiply ( const math_Vector theLeft,
const math_Matrix theTRight 
)

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

Standard_Integer math_Vector::Upper ( void  ) const
inline

Returns the value of the theUpper index of a vector.

Standard_Real& math_Vector::Value ( const Standard_Integer  theNum) const
inline

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

Friends And Related Function Documentation

math_Vector operator* ( const Standard_Real  theLeft,
const math_Vector theRight 
)
friend
Standard_OStream& operator<< ( Standard_OStream theO,
const math_Vector theVec 
)
friend

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