OCCT 8.0.1
OCCT documentation

Search guides and API reference

Enter at least two characters.

    Open CASCADE Technology Reference Manual 8.0.1
    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 int theLower, const int theUpper)
     Memory allocation.
     math_VectorBase (const int theLower, const int 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 int theLower, const int 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.
     math_VectorBase (math_VectorBase &&theOther) noexcept
     Move constructor.
    int Length () const
     Returns the length of a vector.
    int Lower () const
     Returns the lower index of the vector.
    int Upper () const
     Returns the upper index of the vector.
    double Norm () const
     Returns the value or the square of the norm of this vector.
    double Norm2 () const
     Returns the value of the square of the norm of a vector.
    int Max () const
     Returns the index of the maximum element of a vector. (first found).
    int 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 double::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 double::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 int theI1, const int 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 int theI1, const int 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 current vector with the value "theRight". An exception is raised if the vectors do not have 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 TheItemType & Value (const int theNum) const
     accesses the value of index "theNum" of a vector.
    TheItemType & Value (const int theNum)
     accesses (in read or write mode) the value of index "theNum" of a vector.
    const TheItemType & operator() (const int theNum) const
    TheItemType & operator() (const int theNum)
    math_VectorBase & Initialized (const math_VectorBase &theOther)
     Initialises a vector by copying "theOther". An exception is raised if the Lengths are different.
    math_VectorBase & operator= (const math_VectorBase &theOther)
    math_VectorBase & operator= (math_VectorBase &&theOther)
     Move assignment operator.
    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 <<.
    const NCollection_Array1< TheItemType > & Array1 () const
     Returns the underlying array for interoperability with legacy APIs. Allows passing math_Vector data to functions expecting NCollection_Array1.
    void Resize (const int theSize)
     Resizes the vector to a new size, keeping the same lower bound. Existing data within the new range is preserved. The method optimizes memory usage:

    Protected Member Functions

    void SetLower (const int 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]
    math_VectorBase(const int theLower, const int theUpper)
    Memory allocation.

    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/7]

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

    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/7]

    template<typename TheItemType>
    math_VectorBase< TheItemType >::math_VectorBase ( const int theLower,
    const int 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/7]

    template<typename TheItemType>
    math_VectorBase< TheItemType >::math_VectorBase ( const TheItemType * theTab,
    const int theLower,
    const int theUpper )
    inline

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

    ◆ math_VectorBase() [4/7]

    template<typename TheItemType>
    math_VectorBase< TheItemType >::math_VectorBase ( const gp_XY & Other)
    inline

    Constructor for converting gp_XY to math_VectorBase.

    ◆ math_VectorBase() [5/7]

    template<typename TheItemType>
    math_VectorBase< TheItemType >::math_VectorBase ( const gp_XYZ & Other)
    inline

    Constructor for converting gp_XYZ to math_VectorBase.

    ◆ math_VectorBase() [6/7]

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

    Constructs a copy for initialization.

    ◆ math_VectorBase() [7/7]

    template<typename TheItemType>
    math_VectorBase< TheItemType >::math_VectorBase ( math_VectorBase< TheItemType > && theOther)
    inlinenoexcept

    Move constructor.

    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
    inlinenodiscard

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

    ◆ Array1()

    template<typename TheItemType>
    const NCollection_Array1< TheItemType > & math_VectorBase< TheItemType >::Array1 ( ) const
    inline

    Returns the underlying array for interoperability with legacy APIs. Allows passing math_Vector data to functions expecting NCollection_Array1.

    ◆ 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
    inlinenodiscard

    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>
    int math_VectorBase< TheItemType >::Length ( ) const
    inline

    Returns the length of a vector.

    ◆ Lower()

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

    Returns the lower index of the vector.

    ◆ Max()

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

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

    ◆ Min()

    template<typename TheItemType>
    int 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
    inlinenodiscard

    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
    inlinenodiscard

    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
    inlinenodiscard

    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>
    double math_VectorBase< TheItemType >::Norm ( ) const
    inline

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

    ◆ Norm2()

    template<typename TheItemType>
    double 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 double::RealEpsilon().

    ◆ Normalized()

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

    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 double::RealEpsilon().

    ◆ operator()() [1/2]

    template<typename TheItemType>
    TheItemType & math_VectorBase< TheItemType >::operator() ( const int theNum)
    inline

    ◆ operator()() [2/2]

    template<typename TheItemType>
    const TheItemType & math_VectorBase< TheItemType >::operator() ( const int theNum) const
    inline

    ◆ operator*() [1/3]

    template<typename TheItemType>
    math_VectorBase math_VectorBase< TheItemType >::operator* ( const math_Matrix & theRight) const
    inlinenodiscard

    ◆ operator*() [2/3]

    template<typename TheItemType>
    TheItemType math_VectorBase< TheItemType >::operator* ( const math_VectorBase< TheItemType > & theRight) const
    inlinenodiscard

    ◆ operator*() [3/3]

    template<typename TheItemType>
    math_VectorBase math_VectorBase< TheItemType >::operator* ( const TheItemType theRight) const
    inlinenodiscard

    ◆ operator*=()

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

    ◆ operator+()

    template<typename TheItemType>
    math_VectorBase math_VectorBase< TheItemType >::operator+ ( const math_VectorBase< TheItemType > & theRight) const
    inlinenodiscard

    ◆ operator+=()

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

    ◆ operator-() [1/2]

    template<typename TheItemType>
    math_VectorBase math_VectorBase< TheItemType >::operator- ( )
    inline

    ◆ operator-() [2/2]

    template<typename TheItemType>
    math_VectorBase math_VectorBase< TheItemType >::operator- ( const math_VectorBase< TheItemType > & theRight) const
    inlinenodiscard

    ◆ operator-=()

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

    ◆ operator/()

    template<typename TheItemType>
    math_VectorBase math_VectorBase< TheItemType >::operator/ ( const TheItemType theRight) const
    inlinenodiscard

    ◆ operator/=()

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

    ◆ operator=() [1/2]

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

    ◆ operator=() [2/2]

    template<typename TheItemType>
    math_VectorBase & math_VectorBase< TheItemType >::operator= ( math_VectorBase< TheItemType > && theOther)
    inline

    Move assignment operator.

    ◆ Opposite()

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

    returns the opposite of a vector.

    ◆ Resize()

    template<typename TheItemType>
    void math_VectorBase< TheItemType >::Resize ( const int theSize)
    inline

    Resizes the vector to a new size, keeping the same lower bound. Existing data within the new range is preserved. The method optimizes memory usage:

    • If new size fits in stack buffer (<=32), uses stack allocation
    • If new size requires heap and was already on heap, resizes in place
    • Transitions between stack and heap as needed
      Parameters
      theSizenew size of the vector

    ◆ Set()

    template<typename TheItemType>
    void math_VectorBase< TheItemType >::Set ( const int theI1,
    const int 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 int theLower)
    inlineprotected

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

    ◆ Slice()

    template<typename TheItemType>
    math_VectorBase math_VectorBase< TheItemType >::Slice ( const int theI1,
    const int theI2 ) const
    inline

    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
    inlinenodiscard

    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
    inlinenodiscard

    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>
    int math_VectorBase< TheItemType >::Upper ( ) const
    inline

    Returns the upper index of the vector.

    ◆ Value() [1/2]

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

    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 int theNum) const
    inline

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


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