00001 // Wild Magic Source Code 00002 // David Eberly 00003 // http://www.geometrictools.com 00004 // Copyright (c) 1998-2007 00005 // 00006 // This library is free software; you can redistribute it and/or modify it 00007 // under the terms of the GNU Lesser General Public License as published by 00008 // the Free Software Foundation; either version 2.1 of the License, or (at 00009 // your option) any later version. The license is available for reading at 00010 // either of the locations: 00011 // http://www.gnu.org/copyleft/lgpl.html 00012 // http://www.geometrictools.com/License/WildMagicLicense.pdf 00013 // The license applies to versions 0 through 4 of Wild Magic. 00014 // 00015 // Version: 4.0.0 (2006/06/28) 00016 00017 #ifndef WM4BANDEDMATRIX_H 00018 #define WM4BANDEDMATRIX_H 00019 00020 #include "Wm4FoundationLIB.h" 00021 #include "Wm4System.h" 00022 00023 namespace Wm4 00024 { 00025 00026 template <class Real> 00027 class BandedMatrix 00028 { 00029 public: 00030 BandedMatrix (int iSize, int iLBands, int iUBands); 00031 BandedMatrix (const BandedMatrix& rkM); 00032 ~BandedMatrix (); 00033 00034 BandedMatrix& operator= (const BandedMatrix& rkM); 00035 00036 int GetSize () const; 00037 int GetLBands () const; 00038 int GetUBands () const; 00039 00040 Real* GetDBand (); 00041 const Real* GetDBand () const; 00042 00043 int GetLBandMax (int i) const; // LBand(i): 0 <= index < LBandMax 00044 Real* GetLBand (int i); 00045 const Real* GetLBand (int i) const; 00046 00047 int GetUBandMax (int i) const; // UBand(i): 0 <= index < UBandMax 00048 Real* GetUBand (int i); 00049 const Real* GetUBand (int i) const; 00050 00051 Real& operator() (int iRow, int iCol); 00052 Real operator() (int iRow, int iCol) const; 00053 00054 void SetZero (); 00055 void SetIdentity (); 00056 00057 private: 00058 void Allocate (); 00059 void Deallocate (); 00060 00061 int m_iSize, m_iLBands, m_iUBands; 00062 Real* m_afDBand; 00063 Real** m_aafLBand; 00064 Real** m_aafUBand; 00065 }; 00066 00067 } 00068 00069 #include "Wm4BandedMatrix.inl" 00070 00071 namespace Wm4 00072 { 00073 typedef BandedMatrix<float> BandedMatrixf; 00074 typedef BandedMatrix<double> BandedMatrixd; 00075 } 00076 00077 #endif