My Project
MatrixMNTC.h
1 //
3 // MatrixMNTC.h
4 //
5 // Copyright Microsoft Corporation
6 //
7 // Microsoft Research Graphics Group
8 // Kineform Project
9 //
10 // Abstract: An mxn matrix class for Luciform / Kineform
11 //
12 // Revision History Abstract:
13 // 03Apr1999 ChuckR Initial code start
15 
16 #ifndef _129E7523_AADB_11d2_B8F2_00C04F6881C7
17 #define _129E7523_AADB_11d2_B8F2_00C04F6881C7
18 
19 #define OS_UNIX 1
20 #define OS_WINNT 2
21 
22 #ifndef WIN32
23 #define USE_UNIX
24 #endif
25 
26 #ifdef USE_UNIX
27 # define OS OS_UNIX
28 #else
29 # define OS OS_WINNT
30 #endif
31 
32 #if OS == OS_WINNT
33 #include <comdef.h>
34 #else
35 #include "comdef.h"
36 #endif
37 
38 template <class Coord> class GXMatrixMNTC {
39 
40 public:
41 
42  GXMatrixMNTC (void);
43  GXMatrixMNTC (unsigned int cRows, unsigned int cCols);
44  GXMatrixMNTC (unsigned int cRows, unsigned int cCols, const Coord& initializeTo);
45  GXMatrixMNTC (const GXMatrixMNTC<Coord>& toCopy);
46 
47  ~GXMatrixMNTC (void);
48 
49  void SetDim (unsigned int cRows, unsigned int cCols);
50  void SetDim (unsigned int cRows, unsigned int cCols, const Coord& initializeTo);
51 
52  void Init (const Coord& initializeTo);
53 
54  unsigned int Rows (void) const;
55  unsigned int Cols (void) const;
56 
57  bool IsSquare (void) const;
58  bool IsDiagonal (void) const;
59  bool IsScalar (void) const;
60  bool IsSymmetric (void) const;
61  bool IsAntiSymmetric (void) const;
62 
63  Coord* Data (void);
64 
65  const Coord& operator() (unsigned int iRow, unsigned int iCol) const;
66  Coord& operator() (unsigned int iRow, unsigned int iCol);
67 
68  const GXMatrixMNTC<Coord>& operator= (const GXMatrixMNTC<Coord>& toCopy);
69 
70  const GXMatrixMNTC<Coord>& operator+= (const GXMatrixMNTC<Coord>& toAdd);
71  const GXMatrixMNTC<Coord>& operator-= (const GXMatrixMNTC<Coord>& toAdd);
72  const GXMatrixMNTC<Coord>& operator*= (Coord s);
73  const GXMatrixMNTC<Coord>& operator/= (Coord s);
74 
75  /*
76  friend GXMatrixMNTC<Coord> operator+ (const GXMatrixMNTC<Coord>& A,
77  const GXMatrixMNTC<Coord>& B);
78  friend GXMatrixMNTC<Coord> operator- (const GXMatrixMNTC<Coord>& A,
79  const GXMatrixMNTC<Coord>& B);
80  friend GXMatrixMNTC<Coord> operator* (const GXMatrixMNTC<Coord>& A,
81  const GXMatrixMNTC<Coord>& B);
82  friend GXMatrixMNTC<Coord> operator* (const GXMatrixMNTC<Coord>& M, Coord s);
83  friend GXMatrixMNTC<Coord> operator* (Coord s, const GXMatrixMNTC<Coord>& M);
84  friend GXMatrixMNTC<Coord> operator/ (const GXMatrixMNTC<Coord>& M, Coord s);
85 
86  friend GXMatrixMNTC<Coord> operator+ (const GXMatrixMNTC<Coord>& M);
87  friend GXMatrixMNTC<Coord> operator- (const GXMatrixMNTC<Coord>& M);
88 
89  friend bool operator == (const GXMatrixMNTC<Coord>& A,
90  const GXMatrixMNTC<Coord>& B);
91  friend bool operator != (const GXMatrixMNTC<Coord>& A,
92  const GXMatrixMNTC<Coord>& B);
93 
94  friend const GXMatrixMNTC<Coord> Transpose (const GXMatrixMNTC<Coord>& M);
95  friend const GXMatrixMNTC<Coord> Identity (unsigned int cOrder);
96  friend const GXMatrixMNTC<Coord> ScalarMatrix (unsigned int cOrder, Coord s);
97  */
98 
99 protected:
100 
101  Coord* m_pElements;
102  unsigned int m_cRows,
103  m_cCols;
104 
105 private:
106 
107  const Coord& Get (unsigned int i, unsigned int j) const;
108 
109 };
110 
111 template <class Coord>
112 GXMatrixMNTC<Coord> operator+ (const GXMatrixMNTC<Coord>& A,const GXMatrixMNTC<Coord>& B);
113 template <class Coord>
114 GXMatrixMNTC<Coord> operator- (const GXMatrixMNTC<Coord>& A,const GXMatrixMNTC<Coord>& B);
115 template <class Coord>
116 GXMatrixMNTC<Coord> operator* (const GXMatrixMNTC<Coord>& A,const GXMatrixMNTC<Coord>& B);
117 template <class Coord>
118 GXMatrixMNTC<Coord> operator* (const GXMatrixMNTC<Coord>& M, Coord s);
119 template <class Coord>
120 GXMatrixMNTC<Coord> operator* (Coord s, const GXMatrixMNTC<Coord>& M);
121 template <class Coord>
122 GXMatrixMNTC<Coord> operator/ (const GXMatrixMNTC<Coord>& M, Coord s);
123 template <class Coord>
124 GXMatrixMNTC<Coord> operator+ (const GXMatrixMNTC<Coord>& M);
125 template <class Coord>
126 GXMatrixMNTC<Coord> operator- (const GXMatrixMNTC<Coord>& M);
127 template <class Coord>
128 bool operator == (const GXMatrixMNTC<Coord>& A,const GXMatrixMNTC<Coord>& B);
129 template <class Coord>
130 bool operator != (const GXMatrixMNTC<Coord>& A,const GXMatrixMNTC<Coord>& B);
131 template <class Coord>
132 const GXMatrixMNTC<Coord> Transpose (const GXMatrixMNTC<Coord>& M);
133 template <class Coord>
134 const GXMatrixMNTC<Coord> Identity (unsigned int cOrder);
135 template <class Coord>
136 const GXMatrixMNTC<Coord> ScalarMatrix (unsigned int cOrder, Coord s);
137 
138 
141 
142 #include "MatrixMNTC.inl"
143 
144 
145 #endif //_129E7523_AADB_11d2_B8F2_00C04F6881C7
146 
Definition: MatrixMNTC.h:38