Assignments
Assignments
MatrixMNTC.h
Go to the documentation of this file.
1
2//
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 USE_MK_EXCEPTIONS
20
21#define OS_UNIX 1
22#define OS_WINNT 2
23
24#ifdef WIN32
25# define OS OS_WINNT
26#else
27# define OS OS_UNIX
28#endif
29
30#ifdef USE_MK_EXCEPTIONS
31#include <exception>
32#include <string>
33class MatrixMNTCException : public std::exception
34{
35 std::string _message;
36public:
37 MatrixMNTCException( const char *message ) : _message(message) {}
38 const char *what( void ) const noexcept { return _message.c_str(); }
39};
40#else // !USE_MK_EXCEPTIONS
41#if OS == OS_WINNT
42#include <comdef.h>
43#else
44#include "comdef.h"
45#endif
46#endif // USE_MK_EXCEPTIONS
47
48template <class Coord> class GXMatrixMNTC {
49
50public:
51
52 GXMatrixMNTC (void);
53 GXMatrixMNTC (unsigned int cRows, unsigned int cCols);
54 GXMatrixMNTC (unsigned int cRows, unsigned int cCols, const Coord& initializeTo);
55 GXMatrixMNTC (const GXMatrixMNTC<Coord>& toCopy);
56
57 ~GXMatrixMNTC (void);
58
59 void SetDim (unsigned int cRows, unsigned int cCols);
60 void SetDim (unsigned int cRows, unsigned int cCols, const Coord& initializeTo);
61
62 void Init (const Coord& initializeTo);
63
64 unsigned int Rows (void) const;
65 unsigned int Cols (void) const;
66
67 bool IsSquare (void) const;
68 bool IsDiagonal (void) const;
69 bool IsScalar (void) const;
70 bool IsSymmetric (void) const;
71 bool IsAntiSymmetric (void) const;
72
73 Coord* Data (void);
74
75 const Coord& operator() (unsigned int iRow, unsigned int iCol) const;
76 Coord& operator() (unsigned int iRow, unsigned int iCol);
77
79
82 const GXMatrixMNTC<Coord>& operator*= (Coord s);
83 const GXMatrixMNTC<Coord>& operator/= (Coord s);
84
85 /*
86 friend GXMatrixMNTC<Coord> operator+ (const GXMatrixMNTC<Coord>& A,
87 const GXMatrixMNTC<Coord>& B);
88 friend GXMatrixMNTC<Coord> operator- (const GXMatrixMNTC<Coord>& A,
89 const GXMatrixMNTC<Coord>& B);
90 friend GXMatrixMNTC<Coord> operator* (const GXMatrixMNTC<Coord>& A,
91 const GXMatrixMNTC<Coord>& B);
92 friend GXMatrixMNTC<Coord> operator* (const GXMatrixMNTC<Coord>& M, Coord s);
93 friend GXMatrixMNTC<Coord> operator* (Coord s, const GXMatrixMNTC<Coord>& M);
94 friend GXMatrixMNTC<Coord> operator/ (const GXMatrixMNTC<Coord>& M, Coord s);
95
96 friend GXMatrixMNTC<Coord> operator+ (const GXMatrixMNTC<Coord>& M);
97 friend GXMatrixMNTC<Coord> operator- (const GXMatrixMNTC<Coord>& M);
98
99 friend bool operator == (const GXMatrixMNTC<Coord>& A,
100 const GXMatrixMNTC<Coord>& B);
101 friend bool operator != (const GXMatrixMNTC<Coord>& A,
102 const GXMatrixMNTC<Coord>& B);
103
104 friend const GXMatrixMNTC<Coord> Transpose (const GXMatrixMNTC<Coord>& M);
105 friend const GXMatrixMNTC<Coord> Identity (unsigned int cOrder);
106 friend const GXMatrixMNTC<Coord> ScalarMatrix (unsigned int cOrder, Coord s);
107 */
108
109protected:
110
112 unsigned int m_cRows,
114
115private:
116
117 const Coord& Get (unsigned int i, unsigned int j) const;
118
119};
120
121template <class Coord>
123template <class Coord>
125template <class Coord>
127template <class Coord>
129template <class Coord>
131template <class Coord>
133template <class Coord>
135template <class Coord>
137template <class Coord>
139template <class Coord>
141template <class Coord>
143template <class Coord>
144const GXMatrixMNTC<Coord> Identity (unsigned int cOrder);
145template <class Coord>
146const GXMatrixMNTC<Coord> ScalarMatrix (unsigned int cOrder, Coord s);
147
148
151
152#include "MatrixMNTC.inl"
153
154
155#endif //_129E7523_AADB_11d2_B8F2_00C04F6881C7
156
bool operator==(const GXMatrixMNTC< Coord > &A, const GXMatrixMNTC< Coord > &B)
Definition: MatrixMNTC.inl:379
GXMatrixMNTC< Coord > operator-(const GXMatrixMNTC< Coord > &A, const GXMatrixMNTC< Coord > &B)
Definition: MatrixMNTC.inl:429
GXMatrixMNTC< float > GXMatrixMNf
Definition: MatrixMNTC.h:149
const GXMatrixMNTC< Coord > ScalarMatrix(unsigned int cOrder, Coord s)
Definition: MatrixMNTC.inl:563
const GXMatrixMNTC< Coord > Identity(unsigned int cOrder)
GXMatrixMNTC< Coord > operator+(const GXMatrixMNTC< Coord > &A, const GXMatrixMNTC< Coord > &B)
Definition: MatrixMNTC.inl:409
bool operator!=(const GXMatrixMNTC< Coord > &A, const GXMatrixMNTC< Coord > &B)
Definition: MatrixMNTC.inl:394
GXMatrixMNTC< Coord > operator/(const GXMatrixMNTC< Coord > &M, Coord s)
Definition: MatrixMNTC.inl:505
GXMatrixMNTC< double > GXMatrixMNd
Definition: MatrixMNTC.h:150
const GXMatrixMNTC< Coord > Transpose(const GXMatrixMNTC< Coord > &M)
Definition: MatrixMNTC.inl:581
GXMatrixMNTC< Coord > operator*(const GXMatrixMNTC< Coord > &A, const GXMatrixMNTC< Coord > &B)
Definition: MatrixMNTC.inl:449
Definition: MatrixMNTC.h:48
const Coord & Get(unsigned int i, unsigned int j) const
Definition: MatrixMNTC.inl:112
unsigned int m_cRows
Definition: MatrixMNTC.h:112
bool IsDiagonal(void) const
Definition: MatrixMNTC.inl:141
void SetDim(unsigned int cRows, unsigned int cCols)
Definition: MatrixMNTC.inl:199
unsigned int m_cCols
Definition: MatrixMNTC.h:113
unsigned int Cols(void) const
Definition: MatrixMNTC.inl:100
const Coord & operator()(unsigned int iRow, unsigned int iCol) const
Definition: MatrixMNTC.inl:351
const GXMatrixMNTC< Coord > & operator=(const GXMatrixMNTC< Coord > &toCopy)
Definition: MatrixMNTC.inl:260
Coord * m_pElements
Definition: MatrixMNTC.h:111
const GXMatrixMNTC< Coord > & operator/=(Coord s)
Definition: MatrixMNTC.inl:335
bool IsSquare(void) const
Definition: MatrixMNTC.inl:173
const GXMatrixMNTC< Coord > & operator+=(const GXMatrixMNTC< Coord > &toAdd)
Definition: MatrixMNTC.inl:294
void Init(const Coord &initializeTo)
Definition: MatrixMNTC.inl:118
Coord * Data(void)
Definition: MatrixMNTC.inl:106
~GXMatrixMNTC(void)
Definition: MatrixMNTC.inl:93
unsigned int Rows(void) const
Definition: MatrixMNTC.inl:193
bool IsAntiSymmetric(void) const
Definition: MatrixMNTC.inl:125
GXMatrixMNTC(void)
Definition: MatrixMNTC.inl:17
const GXMatrixMNTC< Coord > & operator-=(const GXMatrixMNTC< Coord > &toAdd)
Definition: MatrixMNTC.inl:310
const GXMatrixMNTC< Coord > & operator*=(Coord s)
Definition: MatrixMNTC.inl:326
bool IsSymmetric(void) const
Definition: MatrixMNTC.inl:179
bool IsScalar(void) const
Definition: MatrixMNTC.inl:155
Definition: MatrixMNTC.h:34
MatrixMNTCException(const char *message)
Definition: MatrixMNTC.h:37
const char * what(void) const noexcept
Definition: MatrixMNTC.h:38
std::string _message
Definition: MatrixMNTC.h:35