1 /*
2  *_________________________________________________________________________*
3  *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
4  *      DESCRIPTION: SEE READ-ME                                           *
5  *      FILE NAME: mat3x3.h                                                *
6  *      AUTHORS: See Author List                                           *
7  *      GRANTS: See Grants List                                            *
8  *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
9  *      LICENSE: Please see License Agreement                              *
10  *      DOWNLOAD: Free at www.rpi.edu/~anderk5                             *
11  *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
12  *                     Computational Dynamics Lab                          *
13  *                     Rensselaer Polytechnic Institute                    *
14  *                     110 8th St. Troy NY 12180                           *
15  *      CONTACT:        anderk5@rpi.edu                                    *
16  *_________________________________________________________________________*/
17 
18 #ifndef MAT3X3_H
19 #define MAT3X3_H
20 
21 #include "virtualmatrix.h"
22 
23 
24 class Vect3;
25 class Mat6x6;
26 class Matrix;
27 class ColMatrix;
28 
29 class Mat3x3 : public VirtualMatrix  {
30   double elements[3][3];
31 public:
32   Mat3x3();
33   ~Mat3x3();
34   Mat3x3(const Mat3x3& A);  // copy constructor
35   Mat3x3(const VirtualMatrix& A);  // copy constructor
36 
37   double& operator_2int (int i, int j); // array access
38   double Get_2int(int i, int j) const;
39   void Set_2int(int i, int j, double value);
40   double BasicGet_2int(int i, int j) const;
41   void BasicSet_2int(int i, int j, double value);
42   void BasicIncrement_2int(int i, int j, double value);
43 
44   void Const(double value);
45   MatrixType GetType() const;
46   std::istream& ReadData(std::istream& c); // input
47   std::ostream& WriteData(std::ostream& c) const; // output
48 
49   void AssignVM(const VirtualMatrix& A);
50   Mat3x3& operator=(const Mat3x3& A); // assignment operator
51   Mat3x3& operator=(const VirtualMatrix& A); // overloaded =
52   Mat3x3& operator*=(double b);
53 
54   Mat3x3& Identity();
55 
56   friend Mat3x3 T(const Mat3x3& A);  // a wasteful transpose
57   friend Mat3x3 CrossMat(Vect3& a);  // a wasteful cross matrix implementation
58 
59   friend void FastSimpleRotation(Vect3& v, double q, Mat3x3& d);
60   friend void FastQuaternions(ColMatrix& q, Mat3x3& C);
61   friend void FastInvQuaternions(Mat3x3& C, ColMatrix& q);
62   friend void FastLU(Mat3x3& A, Mat3x3& LU, int *indx);
63   friend void FastLUSubs(Mat3x3& LU, Mat3x3& B, Mat3x3& C, int *indx);
64   friend void FastMult(Mat3x3& A, Vect3& B, Vect3& C);
65   friend void FastTMult(Mat3x3& A, Vect3& B, Vect3& C);
66   friend void FastNegMult(Mat3x3& A, Vect3& B, Vect3& C);
67   friend void FastNegTMult(Mat3x3& A, Vect3& B, Vect3& C);
68   friend void FastMult(Mat3x3& A, Mat3x3& B, Mat3x3& C);
69   friend void FastMultT(Mat3x3& A, Mat3x3& B, Mat3x3& C);
70   friend void FastAssignT(Mat3x3& A, Mat3x3& C);
71   friend void FastMult(Mat3x3& A, Vect3& B, ColMatrix& C);
72 
73   friend void OnPopulateSC(Vect3& gamma, Mat3x3& C, Mat6x6& SC);
74   friend void OnPopulateSI(Mat3x3& inertia, double mass, Mat6x6& sI);
75 
76   friend void FastMult(Mat3x3& A, ColMatrix& B, Vect3& C);
77 
78   friend void EP_Transformation(ColMatrix& q, Mat3x3& C);
79   friend void EP_FromTransformation(ColMatrix& q, Mat3x3& C);
80 
81 };
82 
83 #endif
84