00001 /// \file CATMatrix.h 00002 /// \brief Simple class for matrix operations 00003 /// \ingroup CAT 00004 /// 00005 /// Copyright (c) 2002-2008 by Michael Ellison. 00006 /// See COPYING.txt for the \ref gaslicense License (MIT License). 00007 /// 00008 // $Author: mikeellison $ 00009 // $Date: 2008-01-19 19:19:35 -0600 (Sat, 19 Jan 2008) $ 00010 // $Revision: $ 00011 // $NoKeywords: $ 00012 00013 #ifndef _CRMATRIX_H 00014 #define _CRMATRIX_H 00015 00016 #include "CATInternal.h" 00017 #include <math.h> 00018 00019 /// \class CATMatrix 00020 /// \brief Simple class for matrix operations 00021 /// \ingroup CAT 00022 class CATMatrix 00023 { 00024 public: 00025 // Generate a matrix of width and height 00026 CATMatrix(CATUInt32 w, CATUInt32 h); 00027 CATMatrix(const CATMatrix& matrix); 00028 virtual ~CATMatrix(); 00029 00030 CATFloat64& Val(CATUInt32 x, CATUInt32 y); 00031 00032 CATFloat64 cVal(CATUInt32 x, CATUInt32 y) const; 00033 00034 CATUInt32 Width() const {return fWidth;} 00035 CATUInt32 Height() const {return fHeight;} 00036 00037 bool operator== (const CATMatrix& matrix) const; 00038 CATMatrix operator* (const CATMatrix& matrix) const; 00039 CATMatrix operator* (const CATFloat64 scalar) const; 00040 CATMatrix operator+ (const CATMatrix& matrix) const; 00041 CATMatrix operator- (const CATMatrix& matrix) const; 00042 00043 /// Get the determinant of a matrix 00044 CATFloat64 GetDeterminant() const; 00045 00046 /// Get the inversion of the matrix 00047 CATMatrix GetInverted() const; 00048 00049 /// Get the pseudo-inverse of a matrix 00050 CATMatrix GetPseudoInverse() const; 00051 00052 /// Get the transposed matrix 00053 CATMatrix GetTransposed() const; 00054 00055 /// Set to special matricies 00056 void SetToIdentity(); 00057 void ZeroMatrix(); 00058 00059 /// Check for special matricies 00060 bool IsNullMatrix() const; 00061 bool IsIdentityMatrix() const; 00062 00063 /// Can the matricies be multiplied? 00064 bool IsConformable(const CATMatrix& matrix) const; 00065 00066 00067 /// Check for same order between to matricies 00068 bool SameOrder(const CATMatrix& matrix) const; 00069 00070 /// Debug 00071 void DebugDump() const; 00072 protected: 00073 CATFloat64 *fMatrix; 00074 CATUInt32 fWidth; 00075 CATUInt32 fHeight; 00076 }; 00077 #endif _CRMATRIX_H