/usr/include/oce/math_Vector.hxx is in liboce-foundation-dev 0.17.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | // Copyright (c) 1997-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _math_Vector_HeaderFile
#define _math_Vector_HeaderFile
#include <math_SingleTab.hxx>
class Standard_DimensionError;
class Standard_DivideByZero;
class Standard_RangeError;
class Standard_NullValue;
class math_Matrix;
//! 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.
//! @code
//! math_Vector V1(-3, 5); // a vector with range [-3..5]
//! @endcode
//!
//! Vector are copied through assignement :
//! @code
//! math_Vector V2( 1, 9);
//! ....
//! V2 = V1;
//! V1(1) = 2.0; // the vector V2 will not be modified.
//! @endcode
//!
//! The Exception RangeError is raised when trying to access outside
//! the range of a vector :
//! @code
//! V1(11) = 0.0 // --> will raise RangeError;
//! @endcode
//!
//! The Exception DimensionError is raised when the dimensions of two
//! vectors are not compatible :
//! @code
//! math_Vector V3(1, 2);
//! V3 = V1; // --> will raise DimensionError;
//! V1.Add(V3) // --> will raise DimensionError;
//! @endcode
class math_Vector
{
public:
DEFINE_STANDARD_ALLOC
//! 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.
Standard_EXPORT math_Vector(const Standard_Integer theLower, const Standard_Integer theUpper);
//! Contructs a vector in the range [theLower..theUpper]
//! whose values are all initialized with the value "theInitialValue"
Standard_EXPORT math_Vector(const Standard_Integer theLower, const Standard_Integer theUpper, const Standard_Real theInitialValue);
//! Constructs a vector in the range [theLower..theUpper]
//! with the "c array" theTab.
Standard_EXPORT math_Vector(const Standard_Address theTab, const Standard_Integer theLower, const Standard_Integer theUpper);
//! Initialize all the elements of a vector with "theInitialValue".
Standard_EXPORT void Init(const Standard_Real theInitialValue);
//! Constructs a copy for initialization.
//! An exception is raised if the lengths of the vectors are different.
Standard_EXPORT math_Vector(const math_Vector& theOther);
//! Returns the length of a vector
inline Standard_Integer Length() const
{
return UpperIndex - LowerIndex +1;
}
//! Returns the value of the theLower index of a vector.
inline Standard_Integer Lower() const
{
return LowerIndex;
}
//! Returns the value of the theUpper index of a vector.
inline Standard_Integer Upper() const
{
return UpperIndex;
}
//! Returns the value or the square of the norm of this vector.
Standard_EXPORT Standard_Real Norm() const;
//! Returns the value of the square of the norm of a vector.
Standard_EXPORT Standard_Real Norm2() const;
//! Returns the value of the "Index" of the maximum element of a vector.
Standard_EXPORT Standard_Integer Max() const;
//! Returns the value of the "Index" of the minimum element of a vector.
Standard_EXPORT Standard_Integer Min() const;
//! 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().
Standard_EXPORT void Normalize();
//! 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_EXPORT math_Vector Normalized() const;
//! Inverts this vector and assigns the result to this vector.
Standard_EXPORT void Invert();
//! Inverts this vector and creates a new vector.
Standard_EXPORT math_Vector Inverse() const;
//! 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".
Standard_EXPORT void Set(const Standard_Integer theI1, const Standard_Integer theI2, const math_Vector& theV);
//!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.)
Standard_EXPORT math_Vector Slice(const Standard_Integer theI1, const Standard_Integer theI2) const;
//! returns the product of a vector and a real value.
Standard_EXPORT void Multiply(const Standard_Real theRight);
void operator *=(const Standard_Real theRight)
{
Multiply(theRight);
}
//! returns the product of a vector and a real value.
Standard_EXPORT math_Vector Multiplied(const Standard_Real theRight) const;
math_Vector operator*(const Standard_Real theRight) const
{
return Multiplied(theRight);
}
//! returns the product of a vector and a real value.
Standard_EXPORT math_Vector TMultiplied(const Standard_Real theRight) const;
friend inline math_Vector operator* (const Standard_Real theLeft, const math_Vector& theRight)
{
return theRight.Multiplied(theLeft);
}
//! divides a vector by the value "theRight".
//! An exception is raised if "theRight" = 0.
Standard_EXPORT void Divide(const Standard_Real theRight);
void operator /=(const Standard_Real theRight)
{
Divide(theRight);
}
//! divides a vector by the value "theRight".
//! An exception is raised if "theRight" = 0.
Standard_EXPORT math_Vector Divided(const Standard_Real theRight) const;
math_Vector operator/(const Standard_Real theRight) const
{
return Divided(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.
Standard_EXPORT void Add(const math_Vector& theRight);
void operator +=(const math_Vector& theRight)
{
Add(theRight);
}
//! 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.
Standard_EXPORT math_Vector Added(const math_Vector& theRight) const;
math_Vector operator+(const math_Vector& theRight) const
{
return Added(theRight);
}
//! sets a vector to the product of the vector "theLeft"
//! with the matrix "theRight".
Standard_EXPORT void Multiply(const math_Vector& theLeft, const math_Matrix& theRight);
//!sets a vector to the product of the matrix "theLeft"
//! with the vector "theRight".
Standard_EXPORT void Multiply(const math_Matrix& theLeft, const math_Vector& theRight);
//! sets a vector to the product of the transpose
//! of the matrix "theTLeft" by the vector "theRight".
Standard_EXPORT void TMultiply(const math_Matrix& theTLeft, const math_Vector& theRight);
//! sets a vector to the product of the vector
//! "theLeft" by the transpose of the matrix "theTRight".
Standard_EXPORT void TMultiply(const math_Vector& theLeft, const math_Matrix& theTRight);
//! sets a vector to the sum of the vector "theLeft"
//! and the vector "theRight".
//! An exception is raised if the lengths are different.
Standard_EXPORT void Add(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.
Standard_EXPORT void Subtract(const math_Vector& theLeft,const math_Vector& theRight);
//! accesses (in read or write mode) the value of index "theNum" of a vector.
inline Standard_Real& Value(const Standard_Integer theNum) const
{
Standard_RangeError_Raise_if(theNum < LowerIndex || theNum > UpperIndex, " ");
return Array(theNum);
}
Standard_Real& operator()(const Standard_Integer theNum) const
{
return Value(theNum);
}
//! Initialises a vector by copying "theOther".
//! An exception is raised if the Lengths are differents.
Standard_EXPORT math_Vector& Initialized(const math_Vector& theOther);
math_Vector& operator=(const math_Vector& theOther)
{
return Initialized(theOther);
}
//! returns the inner product of 2 vectors.
//! An exception is raised if the lengths are not equal.
Standard_EXPORT Standard_Real Multiplied(const math_Vector& theRight) const;
Standard_Real operator*(const math_Vector& theRight) const
{
return Multiplied(theRight);
}
//! returns the product of a vector by a matrix.
Standard_EXPORT math_Vector Multiplied(const math_Matrix& theRight) const;
math_Vector operator*(const math_Matrix& theRight) const
{
return Multiplied(theRight);
}
//! returns the opposite of a vector.
Standard_EXPORT math_Vector Opposite();
math_Vector operator-()
{
return Opposite();
}
//! returns the subtraction of "theRight" from "me".
//! An exception is raised if the vectors have not the same length.
Standard_EXPORT void Subtract(const math_Vector& theRight);
void operator-=(const math_Vector& theRight)
{
Subtract(theRight);
}
//! returns the subtraction of "theRight" from "me".
//! An exception is raised if the vectors have not the same length.
Standard_EXPORT math_Vector Subtracted(const math_Vector& theRight) const;
math_Vector operator-(const math_Vector& theRight) const
{
return Subtracted(theRight);
}
//! returns the multiplication of a real by a vector.
//! "me" = "theLeft" * "theRight"
Standard_EXPORT void Multiply(const Standard_Real theLeft,const math_Vector& theRight);
//! Prints information on the current state of the object.
//! Is used to redefine the operator <<.
Standard_EXPORT void Dump(Standard_OStream& theO) const;
friend inline Standard_OStream& operator<<(Standard_OStream& theO, const math_Vector& theVec)
{
theVec.Dump(theO);
return theO;
}
friend class math_Matrix;
protected:
//! Is used internally to set the "theLower" value of the vector.
void SetLower(const Standard_Integer theLower);
private:
Standard_Integer LowerIndex;
Standard_Integer UpperIndex;
math_SingleTab<Standard_Real> Array;
};
#endif
|