0027961: Visualization - remove unused and no more working OpenGl_AVIWriter
[occt.git] / src / math / math_Matrix.cxx
1 // Copyright (c) 1997-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15
16 #include <math_Gauss.hxx>
17 #include <math_Matrix.hxx>
18 #include <math_NotSquare.hxx>
19 #include <math_SingularMatrix.hxx>
20 #include <math_Vector.hxx>
21 #include <Standard_DimensionError.hxx>
22 #include <Standard_DivideByZero.hxx>
23 #include <Standard_RangeError.hxx>
24
25 void math_Matrix::SetLowerRow(const Standard_Integer LowerRow) {
26   
27   Array.SetLowerRow(LowerRow);
28   Standard_Integer Rows = RowNumber();
29   LowerRowIndex = LowerRow;
30   UpperRowIndex = LowerRowIndex + Rows - 1;
31 }
32
33 void math_Matrix::SetLowerCol(const Standard_Integer LowerCol) {
34   
35   Array.SetLowerCol(LowerCol);
36   Standard_Integer Cols = ColNumber();
37   LowerColIndex = LowerCol;
38   UpperColIndex = LowerColIndex + Cols - 1;
39 }
40
41 math_Matrix::math_Matrix (const Standard_Integer LowerRow,
42                           const Standard_Integer UpperRow,
43                           const Standard_Integer LowerCol,
44                           const Standard_Integer UpperCol): 
45                           
46                           LowerRowIndex(LowerRow),
47                           UpperRowIndex(UpperRow),
48                           LowerColIndex(LowerCol),
49                           UpperColIndex(UpperCol),
50                           Array(LowerRow, UpperRow,
51                                 LowerCol, UpperCol) 
52 {
53   
54   Standard_RangeError_Raise_if((LowerRow > UpperRow) ||
55                                (LowerCol > UpperCol), "");
56 }
57
58 math_Matrix::math_Matrix (const Standard_Integer LowerRow,
59                           const Standard_Integer UpperRow,
60                           const Standard_Integer LowerCol,
61                           const Standard_Integer UpperCol,
62                           const Standard_Real InitialValue): 
63                           
64                           LowerRowIndex(LowerRow),
65                           UpperRowIndex(UpperRow),
66                           LowerColIndex(LowerCol),
67                           UpperColIndex(UpperCol),
68                           Array(LowerRow, UpperRow,
69                                 LowerCol, UpperCol) 
70 {
71   
72   Standard_RangeError_Raise_if((LowerRow > UpperRow) ||
73                                (LowerCol > UpperCol), "");
74   Array.Init(InitialValue);
75 }
76
77 math_Matrix::math_Matrix (const Standard_Address Tab,
78                           const Standard_Integer LowerRow,
79                           const Standard_Integer UpperRow,
80                           const Standard_Integer LowerCol,
81                           const Standard_Integer UpperCol) :
82                           
83                           LowerRowIndex(LowerRow),
84                           UpperRowIndex(UpperRow),
85                           LowerColIndex(LowerCol),
86                           UpperColIndex(UpperCol),
87                           Array(Tab, LowerRow, UpperRow, LowerCol, UpperCol) 
88
89   
90   Standard_RangeError_Raise_if((LowerRow > UpperRow) ||
91                                (LowerCol > UpperCol), "");
92 }
93
94 void math_Matrix::Init(const Standard_Real InitialValue) 
95 {
96   Array.Init(InitialValue);
97 }
98
99 math_Matrix::math_Matrix (const math_Matrix& Other): 
100
101 LowerRowIndex(Other.LowerRow()),
102 UpperRowIndex(Other.UpperRow()),
103 LowerColIndex(Other.LowerCol()),
104 UpperColIndex(Other.UpperCol()),
105 Array(Other.Array) 
106 {
107 }
108
109
110
111 math_Matrix math_Matrix::Divided (const Standard_Real Right) const 
112 {
113   Standard_DivideByZero_Raise_if(Abs(Right) <= RealEpsilon(), "");
114   math_Matrix temp = Multiplied(1./Right);
115   return temp;
116 }
117
118
119 Standard_Real math_Matrix::Determinant() const 
120
121   math_Gauss Sol(*this);
122   
123   if(Sol.IsDone()) {
124     return Sol.Determinant();
125   }
126   else {
127     return 0.0;
128   }
129 }
130
131 void math_Matrix::Transpose() 
132
133   math_NotSquare_Raise_if(RowNumber() != ColNumber(), "");
134   
135   Standard_Integer Row = LowerRowIndex;
136   Standard_Integer Col = LowerColIndex;
137   SetLowerCol(LowerRowIndex);
138   Standard_Real Temp;
139   for(Standard_Integer I = LowerRowIndex; I <= UpperRowIndex; I++) {
140     for(Standard_Integer J = I; J <= UpperColIndex; J++) {
141       Temp = Array(I, J);
142       Array(I, J) = Array(J, I);
143       Array(J, I) = Temp;
144     }
145   }
146   SetLowerRow(Col);
147   SetLowerCol(Row);
148 }
149
150 math_Matrix math_Matrix::Transposed() const 
151
152   math_Matrix Result(LowerColIndex, UpperColIndex,
153                      LowerRowIndex, UpperRowIndex);
154   
155   for(Standard_Integer I = LowerRowIndex; I <= UpperRowIndex; I++) {
156     for(Standard_Integer J = LowerColIndex; J <= UpperColIndex; J++) {
157       Result.Array(J, I) = Array(I, J);
158     }
159   }
160   return Result;
161 }
162
163 void math_Matrix::Invert() 
164
165   math_NotSquare_Raise_if(RowNumber() != ColNumber(), "");
166   
167   math_Gauss Sol(*this);
168   if(Sol.IsDone()) {
169     Sol.Invert(*this);
170   }
171   else {
172     math_SingularMatrix::Raise(); // SingularMatrix Exception;
173   }
174 }
175
176 math_Matrix math_Matrix::Inverse() const 
177 {
178   
179   math_Matrix Result = *this;
180   Result.Invert();
181   return Result;
182 }
183
184 void math_Matrix::Multiply (const Standard_Real Right) 
185
186   for(Standard_Integer I = LowerRowIndex; I <= UpperRowIndex; I++) {
187     for(Standard_Integer J = LowerColIndex; J <= UpperColIndex; J++) {
188       Array(I, J) = Array(I, J) * Right;
189     }
190   }
191 }
192
193 math_Matrix math_Matrix::Multiplied (const Standard_Real Right) const
194
195   math_Matrix Result(LowerRowIndex, UpperRowIndex, 
196                      LowerColIndex, UpperColIndex);
197   for(Standard_Integer I = LowerRowIndex; I <= UpperRowIndex; I++) {
198     for(Standard_Integer J = LowerColIndex; J <= UpperColIndex; J++) {
199       Result.Array(I, J) = Array(I, J) * Right;
200     }
201   }
202   return Result;
203 }
204
205 math_Matrix math_Matrix::TMultiplied (const Standard_Real Right) const
206
207   math_Matrix Result(LowerRowIndex, UpperRowIndex, 
208                      LowerColIndex, UpperColIndex);
209   for(Standard_Integer I = LowerRowIndex; I <= UpperRowIndex; I++) {
210     for(Standard_Integer J = LowerColIndex; J <= UpperColIndex; J++) {
211       Result.Array(I, J) = Array(I, J) * Right;
212     }
213   }
214   return Result;
215 }
216
217
218
219 void math_Matrix::Divide (const Standard_Real Right) 
220
221   Standard_DivideByZero_Raise_if(Abs(Right) <= RealEpsilon(), "");
222   
223   for(Standard_Integer I = LowerRowIndex; I <= UpperRowIndex; I++) {
224     for(Standard_Integer J = LowerColIndex; J <= UpperColIndex; J++) {
225       Array(I, J) = Array(I, J) / Right;
226     }
227   }
228 }
229
230 void math_Matrix::Add (const math_Matrix& Right) 
231 {
232   Standard_DimensionError_Raise_if((RowNumber() != Right.RowNumber()) ||
233                                    (ColNumber() != Right.ColNumber()),
234                                    "");
235   
236   Standard_Integer I2 = Right.LowerRowIndex;
237   for(Standard_Integer I = LowerRowIndex; I <= UpperRowIndex; I++) {
238     Standard_Integer J2 = Right.LowerColIndex;
239     for(Standard_Integer J = LowerColIndex; J <= UpperColIndex; J++) {
240       Array(I, J) = Array(I, J) + Right.Array(I2, J2);
241       J2++;
242     }
243     I2++;
244   }
245 }
246
247 void math_Matrix::Subtract (const math_Matrix& Right) 
248
249   Standard_DimensionError_Raise_if((RowNumber() != Right.RowNumber()) ||
250                                    (ColNumber() != Right.ColNumber()),
251                                    "");
252   
253   Standard_Integer I2 = Right.LowerRowIndex;
254   for(Standard_Integer I = LowerRowIndex; I <= UpperRowIndex; I++) {
255     Standard_Integer J2 = Right.LowerColIndex;
256     for(Standard_Integer J = LowerColIndex; J <= UpperColIndex; J++) {
257       Array(I, J) = Array(I, J) - Right.Array(I2, J2);
258       J2++;
259     }
260     I2++;
261   }
262 }
263
264 void math_Matrix::Set(const Standard_Integer I1,const Standard_Integer I2,
265                       const Standard_Integer J1,const Standard_Integer J2,
266                       const math_Matrix& M) 
267 {
268   
269   Standard_DimensionError_Raise_if((I1 < LowerRowIndex)       || 
270                                    (I2 > UpperRowIndex)       ||
271                                    (J1 < LowerColIndex)       ||
272                                    (J2 > UpperColIndex)       ||
273                                    (I1 > I2) || (J1 > J2)     ||
274                                    (I2-I1+1 != M.RowNumber()) ||
275                                    (J2-J1+1 != M.ColNumber()), "");
276   
277   Standard_Integer II = M.LowerRow();
278   for(Standard_Integer I = I1; I <= I2; I++) {
279     Standard_Integer JJ = M.LowerCol();
280     for(Standard_Integer J = J1; J <= J2; J++) {
281       Array(I, J) = M.Array(II, JJ);
282       JJ++;
283     }
284     II++;
285   }
286 }         
287
288 void math_Matrix::SetRow (const Standard_Integer Row,
289                           const math_Vector& V) 
290
291   
292   Standard_RangeError_Raise_if((Row < LowerRowIndex) ||
293                                (Row > UpperRowIndex) , "");
294   
295   Standard_DimensionError_Raise_if(ColNumber() != V.Length(), "");
296   
297   Standard_Integer I = V.LowerIndex;
298   for(Standard_Integer Index = LowerColIndex; Index <= UpperColIndex; Index++) {
299     Array(Row, Index) = V.Array(I);
300     I++;
301   }
302 }
303
304 void math_Matrix::SetCol (const Standard_Integer Col,
305                           const math_Vector& V) 
306
307   
308   Standard_RangeError_Raise_if((Col < LowerColIndex) ||
309                                (Col > UpperColIndex) , "");
310   
311   Standard_DimensionError_Raise_if(RowNumber() != V.Length(), "");
312   
313   Standard_Integer I = V.LowerIndex;
314   for(Standard_Integer Index = LowerRowIndex; Index <= UpperRowIndex; Index++) {
315     Array(Index, Col) = V.Array(I);
316     I++;
317   }
318 }
319
320 void math_Matrix::SetDiag(const Standard_Real Value)
321
322   
323   math_NotSquare_Raise_if(RowNumber() != ColNumber(), "");
324   
325   for(Standard_Integer I = LowerRowIndex; I <= UpperRowIndex; I++) {
326     Array(I, I) = Value;
327   }
328 }
329 math_Vector math_Matrix::Row (const Standard_Integer Row)  const 
330
331   
332   math_Vector Result(LowerColIndex, UpperColIndex);
333   
334   for(Standard_Integer Index = LowerColIndex; Index <= UpperColIndex; Index++) {
335     Result.Array(Index) = Array(Row, Index);
336   }
337   return Result;
338 }
339
340 math_Vector math_Matrix::Col (const Standard_Integer Col) const 
341
342   
343   math_Vector Result(LowerRowIndex, UpperRowIndex);
344   
345   for(Standard_Integer Index = LowerRowIndex; Index <= UpperRowIndex; Index++) {
346     Result.Array(Index) = Array(Index, Col);
347   }
348   return Result;
349 }
350
351 void math_Matrix::SwapRow(const Standard_Integer Row1,
352                           const Standard_Integer Row2) 
353 {
354   
355   Standard_RangeError_Raise_if((Row1 < LowerRowIndex) ||
356                                (Row1 > UpperRowIndex) ||
357                                (Row2 < LowerRowIndex) ||
358                                (Row2 > UpperRowIndex), "");
359   
360   math_Vector V1 = Row(Row1);
361   math_Vector V2 = Row(Row2);
362   SetRow(Row1,V2);
363   SetRow(Row2,V1);
364 }
365
366 void math_Matrix::SwapCol(const Standard_Integer Col1,
367                           const Standard_Integer Col2) 
368 {
369   
370   Standard_RangeError_Raise_if((Col1 < LowerColIndex) ||
371                                (Col1 > UpperColIndex) ||
372                                (Col2 < LowerColIndex) ||
373                                (Col2 > UpperColIndex), "");
374   
375   math_Vector V1 = Col(Col1);
376   math_Vector V2 = Col(Col2);
377   SetCol(Col1,V2);
378   SetCol(Col2,V1);
379 }
380
381
382
383 math_Matrix  math_Matrix::Multiplied (const math_Matrix& Right) const 
384
385   
386   Standard_DimensionError_Raise_if(ColNumber() != Right.RowNumber(), "");
387   
388   math_Matrix Result(LowerRowIndex,       UpperRowIndex,
389                      Right.LowerColIndex, Right.UpperColIndex);
390   
391   Standard_Real Som;
392   for(Standard_Integer I = LowerRowIndex; I <= UpperRowIndex; I++) {
393     for(Standard_Integer J2 = Right.LowerColIndex; J2 <= Right.UpperColIndex; J2++) {
394       Som = 0.0;
395       Standard_Integer I2 = Right.LowerRowIndex;
396       for(Standard_Integer J = LowerColIndex; J <= UpperColIndex; J++) {
397         Som = Som + Array(I, J) * Right.Array(I2, J2);
398         I2++;
399       }
400       Result.Array(I, J2) = Som;
401     }
402   }
403   return Result;
404 }
405
406 math_Matrix  math_Matrix::TMultiply (const math_Matrix& Right) const 
407
408   
409   Standard_DimensionError_Raise_if(RowNumber() != Right.RowNumber(), "");
410   
411   math_Matrix Result(LowerColIndex,       UpperColIndex,
412                      Right.LowerColIndex, Right.UpperColIndex);
413   
414   Standard_Real Som;
415   for(Standard_Integer I = LowerColIndex; I <= UpperColIndex; I++) {
416     for(Standard_Integer J2 = Right.LowerColIndex; J2 <= Right.UpperColIndex; J2++) {
417       Som = 0.0;
418       Standard_Integer I2 = Right.LowerRowIndex;
419       for(Standard_Integer J = LowerRowIndex; J <= UpperRowIndex; J++) {
420         Som = Som + Array(J, I) * Right.Array(I2, J2);
421         I2++;
422       }
423       Result.Array(I, J2) = Som;
424     }
425   }
426   return Result;
427 }
428
429 math_Matrix  math_Matrix::Added (const math_Matrix& Right) const 
430
431   
432   Standard_DimensionError_Raise_if((RowNumber() != Right.RowNumber()) ||
433                                    (ColNumber() != Right.ColNumber()),
434                                    "");
435   
436   math_Matrix Result(LowerRowIndex, UpperRowIndex, 
437                      LowerColIndex, UpperColIndex);
438   
439   Standard_Integer I2 = Right.LowerRowIndex;
440   for(Standard_Integer I = LowerRowIndex; I <= UpperRowIndex; I++) {
441     Standard_Integer J2 = Right.LowerColIndex;
442     for(Standard_Integer J = LowerColIndex; J <= UpperColIndex; J++) {
443       Result.Array(I, J) = Array(I, J) + Right.Array(I2, J2);
444       J2++;
445     }
446     I2++;
447   }
448   return Result;
449 }
450
451 math_Matrix  math_Matrix::Opposite () 
452
453   
454   math_Matrix Result(LowerRowIndex, UpperRowIndex, 
455                      LowerColIndex, UpperColIndex);
456   
457   for(Standard_Integer I = LowerRowIndex; I <= UpperRowIndex; I++) {
458     for(Standard_Integer J = LowerColIndex; J <= UpperColIndex; J++) {
459       Result.Array(I, J) = - Array(I, J);
460     }
461   }
462   return Result;
463 }
464
465 math_Matrix  math_Matrix::Subtracted (const math_Matrix& Right) const 
466
467   
468   Standard_DimensionError_Raise_if((RowNumber() != Right.RowNumber()) ||
469                                    (ColNumber() != Right.ColNumber()),
470                                    "");
471   
472   math_Matrix Result(LowerRowIndex, UpperRowIndex, 
473                      LowerColIndex, UpperColIndex);
474   
475   Standard_Integer I2 = Right.LowerRowIndex;
476   for(Standard_Integer I = LowerRowIndex; I <= UpperRowIndex; I++) {
477     Standard_Integer J2 = Right.LowerColIndex;
478     for(Standard_Integer J = LowerColIndex; J <= UpperColIndex; J++) {
479       Result.Array(I, J) = Array(I, J) - Right.Array(I2, J2);
480       J2++;
481     }
482     I2++;
483   }
484   return Result;
485 }
486
487 void  math_Matrix::Multiply(const math_Vector&  Left, 
488                             const math_Vector&  Right) 
489 {
490   
491   Standard_DimensionError_Raise_if((RowNumber() != Left.Length()) ||
492                                    (ColNumber() != Right.Length()),
493                                    "");
494   
495   for(Standard_Integer I = LowerRowIndex; I <= UpperRowIndex; I++) {
496     for(Standard_Integer J = LowerColIndex; J <= UpperColIndex; J++) {
497       Array(I, J) = Left.Array(I) * Right.Array(J);
498     }
499   }
500 }
501
502 void  math_Matrix::Multiply(const math_Matrix&  Left, 
503                             const math_Matrix&  Right) 
504 {
505   
506   Standard_DimensionError_Raise_if((Left.ColNumber() != Right.RowNumber()) ||
507                                    (RowNumber() != Left.RowNumber()) ||
508                                    (ColNumber() != Right.ColNumber()),
509                                    "");
510   
511   Standard_Real Som;
512   Standard_Integer I1 = Left.LowerRowIndex;
513   for(Standard_Integer I = LowerRowIndex; I <= UpperRowIndex; I++) {
514     Standard_Integer J2 = Right.LowerColIndex;  
515     for(Standard_Integer J = LowerColIndex; J <= UpperColIndex; J++) {
516       Som = 0.0;
517       Standard_Integer J1 = Left.LowerColIndex;
518       Standard_Integer I2 = Right.LowerRowIndex;
519       for(Standard_Integer K = Left.LowerColIndex; K <= Left.UpperColIndex; K++) {
520         Som = Som + Left.Array(I1, J1) * Right.Array(I2, J2);
521         J1++;
522         I2++;
523       }
524       Array(I, J) = Som;
525       J2++;
526     }
527     I1++;
528   }
529 }
530
531 void math_Matrix::TMultiply(const math_Matrix& TLeft, 
532                             const math_Matrix&  Right) 
533 {
534   
535   Standard_DimensionError_Raise_if((TLeft.RowNumber() != Right.RowNumber()) ||
536                                    (RowNumber() != TLeft.ColNumber()) ||
537                                    (ColNumber() != Right.ColNumber()),
538                                    "");
539   
540   Standard_Real Som;
541   Standard_Integer I1 = TLeft.LowerColIndex;
542   for(Standard_Integer I = LowerRowIndex; I <= UpperRowIndex; I++) {
543     Standard_Integer J2 = Right.LowerColIndex;  
544     for(Standard_Integer J = LowerColIndex; J <= UpperColIndex; J++) {
545       Som = 0.0;
546       Standard_Integer J1 = TLeft.LowerRowIndex;
547       Standard_Integer I2 = Right.LowerRowIndex;
548       for(Standard_Integer K = TLeft.LowerRowIndex; K <= TLeft.UpperRowIndex; K++) {
549         Som = Som + TLeft.Array(J1, I1) * Right.Array(I2, J2);
550         J1++;
551         I2++;
552       }
553       Array(I, J) = Som;
554       J2++;
555     }
556     I1++;
557   }
558 }
559
560 void  math_Matrix::Add (const math_Matrix&  Left, 
561                         const math_Matrix&  Right) 
562 {
563   
564   Standard_DimensionError_Raise_if((RowNumber() != Right.RowNumber()) ||
565                                    (ColNumber() != Right.ColNumber()) ||
566                                    (Right.RowNumber() != Left.RowNumber()) ||
567                                    (Right.ColNumber() != Left.ColNumber()),
568                                    "");
569   
570   Standard_Integer I1 = Left.LowerRowIndex;
571   Standard_Integer I2 = Right.LowerRowIndex;
572   for(Standard_Integer I = LowerRowIndex; I <= UpperRowIndex; I++) {
573     Standard_Integer J1 = Left.LowerColIndex;
574     Standard_Integer J2 = Right.LowerColIndex;
575     for(Standard_Integer J = LowerColIndex; J <= UpperColIndex; J++) {
576       Array(I, J) = Left.Array(I1, J1) + Right.Array(I2, J2);
577       J1++;
578       J2++;
579     }
580     I1++;
581     I2++;
582   }
583 }
584
585 void  math_Matrix::Subtract(const math_Matrix&  Left,
586                             const math_Matrix&  Right) 
587 {
588   
589   Standard_DimensionError_Raise_if((RowNumber() != Right.RowNumber()) ||
590                                    (ColNumber() != Right.ColNumber()) ||
591                                    (Right.RowNumber() != Left.RowNumber()) ||
592                                    (Right.ColNumber() != Left.ColNumber()),
593                                    "");
594   
595   Standard_Integer I1 = Left.LowerRowIndex;
596   Standard_Integer I2 = Right.LowerRowIndex;
597   for(Standard_Integer I = LowerRowIndex; I <= UpperRowIndex; I++) {
598     Standard_Integer J1 = Left.LowerColIndex;
599     Standard_Integer J2 = Right.LowerColIndex;
600     for(Standard_Integer J = LowerColIndex; J <= UpperColIndex; J++) {
601       Array(I, J) = Left.Array(I1, J1) - Right.Array(I2, J2);
602       J1++;
603       J2++;
604     }
605     I1++;
606     I2++;
607   }
608 }
609
610
611 void math_Matrix::Multiply(const math_Matrix& Right) 
612 {
613   
614   Standard_DimensionError_Raise_if(ColNumber() != Right.RowNumber(), "");
615   
616   Standard_Real Som;
617   for(Standard_Integer I = LowerRowIndex; I <= UpperRowIndex; I++) {
618     for(Standard_Integer J2 = Right.LowerColIndex; J2 <= Right.UpperColIndex; J2++) {
619       Som = 0.0;
620       Standard_Integer I2 = Right.LowerRowIndex;
621       for(Standard_Integer J = LowerColIndex; J <= UpperColIndex; J++) {
622         Som = Som + Array(I, J) * Right.Array(I2, J2);
623         I2++;
624       }
625       Array(I, J2) = Som;
626     }
627   }
628 }
629
630
631
632 math_Vector math_Matrix::Multiplied(const math_Vector& Right)const
633 {
634   
635   Standard_DimensionError_Raise_if(ColNumber() != Right.Length(), "");
636   
637   math_Vector Result(LowerRowIndex, UpperRowIndex);
638   
639   for(Standard_Integer I = LowerRowIndex; I <= UpperRowIndex; I++) {
640     Result.Array(I) = 0.0;
641     Standard_Integer II = Right.LowerIndex;
642     for(Standard_Integer J = LowerColIndex; J <= UpperColIndex; J++) {
643       Result.Array(I) = Result.Array(I) + Array(I, J) * Right.Array(II);
644       II++;
645     }
646   }
647   return Result;
648 }
649
650 math_Matrix& math_Matrix::Initialized(const math_Matrix& Other) 
651 {
652   
653   Standard_DimensionError_Raise_if((RowNumber() != Other.RowNumber()) ||
654                                    (ColNumber() != Other.ColNumber()), "");
655   
656   (Other.Array).Copy(Array);
657   return *this;
658 }
659
660
661
662
663 void math_Matrix::Dump(Standard_OStream& o)const
664
665 {
666   o << "math_Matrix of RowNumber = " << RowNumber();
667   o << " and ColNumber = " << ColNumber() << "\n";
668   
669   for(Standard_Integer I = LowerRowIndex; I <= UpperRowIndex; I++) {
670     for(Standard_Integer J = LowerColIndex; J <= UpperColIndex; J++) {
671       o << "math_Matrix ( " << I << ", " << J << " ) = ";
672       o << Array(I, J) << "\n";
673     }
674   }
675 }
676