File: math_Vector.hxx

package info (click to toggle)
opencascade 6.2-7
  • links: PTS
  • area: non-free
  • in suites: lenny
  • size: 444,652 kB
  • ctags: 256,750
  • sloc: cpp: 1,150,123; ansic: 225,762; tcl: 30,130; makefile: 12,619; sh: 7,958; xml: 3,981; lisp: 283; java: 212; csh: 203; perl: 15
file content (349 lines) | stat: -rw-r--r-- 11,589 bytes parent folder | download | duplicates (2)
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
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
// File generated by CPPExt (Value)
//
//                     Copyright (C) 1991 - 2000 by  
//                      Matra Datavision SA.  All rights reserved.
//  
//                     Copyright (C) 2001 - 2004 by
//                     Open CASCADE SA.  All rights reserved.
// 
// This file is part of the Open CASCADE Technology software.
//
// This software may be distributed and/or modified under the terms and
// conditions of the Open CASCADE Public License as defined by Open CASCADE SA
// and appearing in the file LICENSE included in the packaging of this file.
//  
// This software is distributed on an "AS IS" basis, without warranty of any
// kind, and Open CASCADE SA hereby disclaims all such warranties,
// including without limitation, any warranties of merchantability, fitness
// for a particular purpose or non-infringement. Please see the License for
// the specific terms and conditions governing rights and limitations under the
// License.

#ifndef _math_Vector_HeaderFile
#define _math_Vector_HeaderFile

#ifndef _Standard_Integer_HeaderFile
#include <Standard_Integer.hxx>
#endif
#ifndef _math_SingleTabOfReal_HeaderFile
#include <math_SingleTabOfReal.hxx>
#endif
#ifndef _Standard_Real_HeaderFile
#include <Standard_Real.hxx>
#endif
#ifndef _Standard_Address_HeaderFile
#include <Standard_Address.hxx>
#endif
#ifndef _Standard_OStream_HeaderFile
#include <Standard_OStream.hxx>
#endif
class Standard_DimensionError;
class Standard_DivideByZero;
class Standard_RangeError;
class Standard_NullValue;
class math_Matrix;


#ifndef _Standard_HeaderFile
#include <Standard.hxx>
#endif
#ifndef _Standard_Macro_HeaderFile
#include <Standard_Macro.hxx>
#endif


//! This class implements the real vector abstract data type. <br>
//! Vectors can have an arbitrary range which must be defined at <br>
//! the declaration and cannot be changed after this declaration. <br>
//!    math_Vector V1(-3, 5); // a vector with range [-3..5] <br>
class math_Vector  {

public:

    void* operator new(size_t,void* anAddress) 
      {
        return anAddress;
      }
    void* operator new(size_t size) 
      { 
        return Standard::Allocate(size); 
      }
    void  operator delete(void *anAddress) 
      { 
        if (anAddress) Standard::Free((Standard_Address&)anAddress); 
      }
 // Methods PUBLIC
 // 

//! Contructs a non-initialized vector in the range [Lower..Upper] <br>
//! Lower and Upper are the indexes of the lower and upper <br>
//! bounds of the constructed vector. <br>
Standard_EXPORT math_Vector(const Standard_Integer Lower,const Standard_Integer Upper);

//! Contructs a vector in the range [Lower..Upper] <br>
//!         whose values are all initialized with the value   InitialValue.. <br>
Standard_EXPORT math_Vector(const Standard_Integer Lower,const Standard_Integer Upper,const Standard_Real InitialValue);

//! Constructs a vector in the range [Lower..Upper] <br>
//!          with the "c array" Tab. <br>
Standard_EXPORT math_Vector(const Standard_Address Tab,const Standard_Integer Lower,const Standard_Integer Upper);

//! Initialize all the elements of a vector with InitialValue. <br>
Standard_EXPORT   void Init(const Standard_Real InitialValue) ;

//! Constructs a copy for initialization. <br>
//!          An exception is raised if the lengths of the vectors are <br>
//!          different. <br>
Standard_EXPORT math_Vector(const math_Vector& Other);
//! Returns the length of a vector <br>
  Standard_Integer Length() const;
//! Returns the value of the Lower index of a vector. <br>
  Standard_Integer Lower() const;
//! Returns the value of the Upper index of a vector. <br>
  Standard_Integer Upper() const;

//! Returns the value or the square  of the norm of this vector. <br>
Standard_EXPORT   Standard_Real Norm() const;

//! Returns the value of the square of the norm of a vector. <br>
Standard_EXPORT   Standard_Real Norm2() const;

//! Returns the value of the Index of the maximum element of a vector. <br>
Standard_EXPORT   Standard_Integer Max() const;

//! Returns the value of the Index of the minimum element  of a vector. <br>
Standard_EXPORT   Standard_Integer Min() const;

//! Normalizes this vector (the norm of the result <br>
//! is equal to 1.0) and assigns the result to this vector <br>
//!   Exceptions <br>
//! Standard_NullValue if this vector is null (i.e. if its norm is <br>
//! less than or equal to Standard_Real::RealEpsilon(). <br>
Standard_EXPORT   void Normalize() ;

//! Normalizes this vector (the norm of the result <br>
//! is equal to 1.0) and creates a new vector <br>
//!   Exceptions <br>
//! Standard_NullValue if this vector is null (i.e. if its norm is <br>
//! less than or equal to Standard_Real::RealEpsilon(). <br>
Standard_EXPORT   math_Vector Normalized() const;

//! Inverts this vector and assigns the result to this vector. <br>
Standard_EXPORT   void Invert() ;

//! Inverts this vector and creates a new vector. <br>
Standard_EXPORT   math_Vector Inverse() const;

//! sets a vector from <I1> to <I2> to the vector <V>; <br>
//! An exception is raised if I1<LowerIndex or I2>UpperIndex or I1>I2. <br>
//! An exception is raised if I2-I1+1 is different from the Length of V. <br>
Standard_EXPORT   void Set(const Standard_Integer I1,const Standard_Integer I2,const math_Vector& V) ;

//!Creates a new vector by inverting the values of this vector <br>
//!  between indexes I1 and I2. <br>
//! If the values of this vector were (1., 2., 3., 4., <br>
//! 5., 6.), by slicing it between indexes 2 and 5 the <br>
//! values of the resulting vector are (1., 5., 4., 3., 2., 6.) <br>
Standard_EXPORT   math_Vector Slice(const Standard_Integer I1,const Standard_Integer I2) const;

//! returns the product of a vector and a real value. <br>
Standard_EXPORT   void Multiply(const Standard_Real Right) ;
  void operator *=(const Standard_Real Right) 
{
  Multiply(Right);
}


//! returns the product of a vector and a real value. <br>
Standard_EXPORT   math_Vector Multiplied(const Standard_Real Right) const;
  math_Vector operator*(const Standard_Real Right) const
{
  return Multiplied(Right);
}


//! returns the product of a vector and a real value. <br>
Standard_EXPORT   math_Vector TMultiplied(const Standard_Real Right) const;
friend math_Vector operator *(const Standard_Real Left,const math_Vector& Right);

//! divides a vector by the value <Right>. <br>
//! An exception is raised if <Right> = 0. <br>
Standard_EXPORT   void Divide(const Standard_Real Right) ;
  void operator /=(const Standard_Real Right) 
{
  Divide(Right);
}


//! divides a vector by the value <Right>. <br>
//! An exception is raised if <Right> = 0. <br>
Standard_EXPORT   math_Vector Divided(const Standard_Real Right) const;
  math_Vector operator/(const Standard_Real Right) const
{
  return Divided(Right);
}


//! adds the vector <Right> to a vector. <br>
//! An exception is raised if the vectors have not the same length. <br>
//! Warning <br>
//! In order to avoid time-consuming copying of vectors, it <br>
//! is preferable to use operator += or the function Add whenever possible. <br>
Standard_EXPORT   void Add(const math_Vector& Right) ;
  void operator +=(const math_Vector& Right) 
{
  Add(Right);
}


//! adds the vector <Right> to a vector. <br>
//! An exception is raised if the vectors have not the same length. <br>
//! An exception is raised if the lengths are not equal. <br>
Standard_EXPORT   math_Vector Added(const math_Vector& Right) const;
  math_Vector operator+(const math_Vector& Right) const
{
  return Added(Right);
}


//! sets a vector to the product of the vector <Left> <br>
//!          with the matrix <Right>. <br>
Standard_EXPORT   void Multiply(const math_Vector& Left,const math_Matrix& Right) ;

//!sets a vector to the product of the matrix <Left> <br>
//!         with the vector <Right>. <br>
Standard_EXPORT   void Multiply(const math_Matrix& Left,const math_Vector& Right) ;

//! sets a vector to the product of the transpose <br>
//!           of the matrix <TLeft> by the vector <Right>. <br>
Standard_EXPORT   void TMultiply(const math_Matrix& TLeft,const math_Vector& Right) ;

//! sets a vector to the product of the vector <br>
//!          <Left> by the transpose of the matrix <TRight>. <br>
Standard_EXPORT   void TMultiply(const math_Vector& Left,const math_Matrix& TRight) ;

//! sets a vector to the sum of the vector <Left> <br>
//!          and the vector <Right>. <br>
//! An exception is raised if the lengths are different. <br>
Standard_EXPORT   void Add(const math_Vector& Left,const math_Vector& Right) ;

//! sets a vector to the Subtraction of the <br>
//!           vector <Right> from the vector <Left>. <br>
//! An exception is raised if the vectors have not the same length. <br>
//!  Warning <br>
//! In order to avoid time-consuming copying of vectors, it <br>
//! is preferable to use operator -= or the function <br>
//! Subtract whenever possible. <br>
Standard_EXPORT   void Subtract(const math_Vector& Left,const math_Vector& Right) ;
//! accesses (in read or write mode) the value of index Num of <br>
//!          a vector. <br>
  Standard_Real& Value(const Standard_Integer Num) const;
  Standard_Real& operator()(const Standard_Integer Num) const
{
  return Value(Num);
}


//! Initialises a vector by copying <Other>. <br>
//!          An exception is raised if the Lengths are differents. <br>
Standard_EXPORT   math_Vector& Initialized(const math_Vector& Other) ;
  math_Vector& operator=(const math_Vector& Other) 
{
  return Initialized(Other);
}


//! returns the inner product of 2 vectors. <br>
//! An exception is raised if the lengths are not equal. <br>
Standard_EXPORT   Standard_Real Multiplied(const math_Vector& Right) const;
  Standard_Real operator*(const math_Vector& Right) const
{
  return Multiplied(Right);
}


//! returns the product of a vector by a matrix. <br>
Standard_EXPORT   math_Vector Multiplied(const math_Matrix& Right) const;
  math_Vector operator*(const math_Matrix& Right) const
{
  return Multiplied(Right);
}


//! returns the opposite of a vector. <br>
Standard_EXPORT   math_Vector Opposite() ;
  math_Vector operator-() 
{
  return Opposite();
}


//! returns the subtraction of <Right> from <me>. <br>
//! An exception is raised if the vectors have not the same length. <br>
Standard_EXPORT   void Subtract(const math_Vector& Right) ;
  void operator-=(const math_Vector& Right) 
{
  Subtract(Right);
}


//! returns the subtraction of <Right> from <me>. <br>
//! An exception is raised if the vectors have not the same length. <br>
Standard_EXPORT   math_Vector Subtracted(const math_Vector& Right) const;
  math_Vector operator-(const math_Vector& Right) const
{
  return Subtracted(Right);
}


//! returns the multiplication of a real by a vector. <br>
//!          <me> = <Left> * <Right> <br>
Standard_EXPORT   void Multiply(const Standard_Real Left,const math_Vector& Right) ;

//! Prints information on the current state of the object. <br>
//!          Is used to redefine the operator <<. <br>
Standard_EXPORT   void Dump(Standard_OStream& o) const;


friend class math_Matrix;



protected:

 // Methods PROTECTED
 // 

//! Is used internally to set the Lower value of the vector. <br>
Standard_EXPORT   void SetLower(const Standard_Integer Lower) ;


 // Fields PROTECTED
 //


private: 

 // Methods PRIVATE
 // 


 // Fields PRIVATE
 //
Standard_Integer LowerIndex;
Standard_Integer UpperIndex;
math_SingleTabOfReal Array;


};


#include <math_Vector.lxx>



// other Inline functions and methods (like "C++: function call" methods)
//


#endif