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>
33 class MatrixMNTCException : public std::exception
34{
35 std::string _message;
36 public:
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
48 template <class Coord> class GXMatrixMNTC {
49
50 public:
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
78 const GXMatrixMNTC<Coord>& operator= (const GXMatrixMNTC<Coord>& toCopy);
79
80 const GXMatrixMNTC<Coord>& operator+= (const GXMatrixMNTC<Coord>& toAdd);
81 const GXMatrixMNTC<Coord>& operator-= (const GXMatrixMNTC<Coord>& toAdd);
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
109 protected:
110
111 Coord* m_pElements;
112 unsigned int m_cRows,
113 m_cCols;
114
115 private:
116
117 const Coord& Get (unsigned int i, unsigned int j) const;
118
119};
120
121 template <class Coord>
122 GXMatrixMNTC<Coord> operator+ (const GXMatrixMNTC<Coord>& A,const GXMatrixMNTC<Coord>& B);
123 template <class Coord>
124 GXMatrixMNTC<Coord> operator- (const GXMatrixMNTC<Coord>& A,const GXMatrixMNTC<Coord>& B);
125 template <class Coord>
126 GXMatrixMNTC<Coord> operator* (const GXMatrixMNTC<Coord>& A,const GXMatrixMNTC<Coord>& B);
127 template <class Coord>
128 GXMatrixMNTC<Coord> operator* (const GXMatrixMNTC<Coord>& M, Coord s);
129 template <class Coord>
130 GXMatrixMNTC<Coord> operator* (Coord s, const GXMatrixMNTC<Coord>& M);
131 template <class Coord>
132 GXMatrixMNTC<Coord> operator/ (const GXMatrixMNTC<Coord>& M, Coord s);
133 template <class Coord>
134 GXMatrixMNTC<Coord> operator+ (const GXMatrixMNTC<Coord>& M);
135 template <class Coord>
136 GXMatrixMNTC<Coord> operator- (const GXMatrixMNTC<Coord>& M);
137 template <class Coord>
138 bool operator == (const GXMatrixMNTC<Coord>& A,const GXMatrixMNTC<Coord>& B);
139 template <class Coord>
140 bool operator != (const GXMatrixMNTC<Coord>& A,const GXMatrixMNTC<Coord>& B);
141 template <class Coord>
142 const GXMatrixMNTC<Coord> Transpose (const GXMatrixMNTC<Coord>& M);
143 template <class Coord>
144 const GXMatrixMNTC<Coord> Identity (unsigned int cOrder);
145 template <class Coord>
146 const GXMatrixMNTC<Coord> ScalarMatrix (unsigned int cOrder, Coord s);
147
148
149 typedef GXMatrixMNTC<float> GXMatrixMNf;
150 typedef GXMatrixMNTC<double> GXMatrixMNd;
151
152#include "MatrixMNTC.inl"
153
154
155#endif //_129E7523_AADB_11d2_B8F2_00C04F6881C7
156
operator==
bool operator==(const GXMatrixMNTC< Coord > &A, const GXMatrixMNTC< Coord > &B)
Definition MatrixMNTC.inl:379
operator-
GXMatrixMNTC< Coord > operator-(const GXMatrixMNTC< Coord > &A, const GXMatrixMNTC< Coord > &B)
Definition MatrixMNTC.inl:429
GXMatrixMNf
GXMatrixMNTC< float > GXMatrixMNf
Definition MatrixMNTC.h:149
ScalarMatrix
const GXMatrixMNTC< Coord > ScalarMatrix(unsigned int cOrder, Coord s)
Definition MatrixMNTC.inl:563
Identity
const GXMatrixMNTC< Coord > Identity(unsigned int cOrder)
operator+
GXMatrixMNTC< Coord > operator+(const GXMatrixMNTC< Coord > &A, const GXMatrixMNTC< Coord > &B)
Definition MatrixMNTC.inl:409
operator!=
bool operator!=(const GXMatrixMNTC< Coord > &A, const GXMatrixMNTC< Coord > &B)
Definition MatrixMNTC.inl:394
operator/
GXMatrixMNTC< Coord > operator/(const GXMatrixMNTC< Coord > &M, Coord s)
Definition MatrixMNTC.inl:505
GXMatrixMNd
GXMatrixMNTC< double > GXMatrixMNd
Definition MatrixMNTC.h:150
Transpose
const GXMatrixMNTC< Coord > Transpose(const GXMatrixMNTC< Coord > &M)
Definition MatrixMNTC.inl:581
operator*
GXMatrixMNTC< Coord > operator*(const GXMatrixMNTC< Coord > &A, const GXMatrixMNTC< Coord > &B)
Definition MatrixMNTC.inl:449
MatrixMNTC.inl
GXMatrixMNTC
Definition MatrixMNTC.h:48
GXMatrixMNTC::GXMatrixMNTC
GXMatrixMNTC(unsigned int cRows, unsigned int cCols)
Definition MatrixMNTC.inl:24
GXMatrixMNTC::Get
const Coord & Get(unsigned int i, unsigned int j) const
Definition MatrixMNTC.inl:112
GXMatrixMNTC< float >::m_cRows
unsigned int m_cRows
Definition MatrixMNTC.h:112
GXMatrixMNTC::IsDiagonal
bool IsDiagonal(void) const
Definition MatrixMNTC.inl:141
GXMatrixMNTC::SetDim
void SetDim(unsigned int cRows, unsigned int cCols)
Definition MatrixMNTC.inl:199
GXMatrixMNTC< float >::m_cCols
unsigned int m_cCols
Definition MatrixMNTC.h:113
GXMatrixMNTC::Cols
unsigned int Cols(void) const
Definition MatrixMNTC.inl:100
GXMatrixMNTC::operator()
const Coord & operator()(unsigned int iRow, unsigned int iCol) const
Definition MatrixMNTC.inl:351
GXMatrixMNTC::operator=
const GXMatrixMNTC< Coord > & operator=(const GXMatrixMNTC< Coord > &toCopy)
Definition MatrixMNTC.inl:260
GXMatrixMNTC< float >::m_pElements
float * m_pElements
Definition MatrixMNTC.h:111
GXMatrixMNTC::operator/=
const GXMatrixMNTC< Coord > & operator/=(Coord s)
Definition MatrixMNTC.inl:335
GXMatrixMNTC::IsSquare
bool IsSquare(void) const
Definition MatrixMNTC.inl:173
GXMatrixMNTC::operator+=
const GXMatrixMNTC< Coord > & operator+=(const GXMatrixMNTC< Coord > &toAdd)
Definition MatrixMNTC.inl:294
GXMatrixMNTC::SetDim
void SetDim(unsigned int cRows, unsigned int cCols, const Coord &initializeTo)
Definition MatrixMNTC.inl:227
GXMatrixMNTC::Init
void Init(const Coord &initializeTo)
Definition MatrixMNTC.inl:118
GXMatrixMNTC::GXMatrixMNTC
GXMatrixMNTC(const GXMatrixMNTC< Coord > &toCopy)
Definition MatrixMNTC.inl:69
GXMatrixMNTC::GXMatrixMNTC
GXMatrixMNTC(unsigned int cRows, unsigned int cCols, const Coord &initializeTo)
Definition MatrixMNTC.inl:45
GXMatrixMNTC::Data
Coord * Data(void)
Definition MatrixMNTC.inl:106
GXMatrixMNTC::~GXMatrixMNTC
~GXMatrixMNTC(void)
Definition MatrixMNTC.inl:93
GXMatrixMNTC::Rows
unsigned int Rows(void) const
Definition MatrixMNTC.inl:193
GXMatrixMNTC::IsAntiSymmetric
bool IsAntiSymmetric(void) const
Definition MatrixMNTC.inl:125
GXMatrixMNTC::GXMatrixMNTC
GXMatrixMNTC(void)
Definition MatrixMNTC.inl:17
GXMatrixMNTC::operator-=
const GXMatrixMNTC< Coord > & operator-=(const GXMatrixMNTC< Coord > &toAdd)
Definition MatrixMNTC.inl:310
GXMatrixMNTC::operator*=
const GXMatrixMNTC< Coord > & operator*=(Coord s)
Definition MatrixMNTC.inl:326
GXMatrixMNTC::IsSymmetric
bool IsSymmetric(void) const
Definition MatrixMNTC.inl:179
GXMatrixMNTC::IsScalar
bool IsScalar(void) const
Definition MatrixMNTC.inl:155
MatrixMNTCException::MatrixMNTCException
MatrixMNTCException(const char *message)
Definition MatrixMNTC.h:37
MatrixMNTCException::what
const char * what(void) const noexcept
Definition MatrixMNTC.h:38
MatrixMNTCException::_message
std::string _message
Definition MatrixMNTC.h:35