File indexing completed on 2025-03-16 11:33:31
0001 /*************************************************************************** 0002 * Copyright (C) 2006 by Alan Grimes * 0003 * agrimes@speakeasy.net * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0019 ***************************************************************************/ 0020 0021 #ifndef QMATRIX_H__KTECHLAB_ 0022 #define QMATRIX_H__KTECHLAB_ 0023 0024 //#ifndef QVECTOR_H 0025 #include "qvector.h" 0026 //#endif 0027 0028 // class QuickVector; 0029 0030 class QuickMatrix 0031 { 0032 public: 0033 QuickMatrix(CUI m_in, CUI n_in); 0034 QuickMatrix(CUI m_in); 0035 QuickMatrix(const QuickMatrix *old); // ye olde copy constructor. 0036 ~QuickMatrix(); 0037 0038 // accessors 0039 // we use accessors so that we can provide range checking. 0040 // we use Smalltalk style naming conventions. 0041 double at(CUI m_a, CUI n_a) const; 0042 bool atPut(CUI m_a, CUI n_a, const double val); 0043 bool atAdd(CUI m_a, CUI n_a, const double val); // just give a negative val to subtract. =) 0044 0045 bool isSquare() const; 0046 0047 double *&operator[](const int i) 0048 { 0049 return values[i]; 0050 } 0051 const double *operator[](const int i) const 0052 { 0053 return values[i]; 0054 } 0055 0056 unsigned int size_m() const; 0057 unsigned int size_n() const; 0058 0059 // functions for some elementary row operations. 0060 // these are actually procedures because they operate on the current matrix rather than 0061 // producing a results matrix. 0062 bool partialSAF(CUI m_a, CUI m_b, CUI from, const double scalor); 0063 bool swapRows(CUI m_a, CUI m_b); 0064 0065 // utility functions: 0066 void fillWithZero(); 0067 0068 // Matrix arithmetic. 0069 QuickMatrix *operator+=(const QuickMatrix *othermat); 0070 QuickMatrix *operator*=(const double y); 0071 QuickMatrix *operator=(const double y); // sets the diagonal to a constant. 0072 // QuickMatrix *operator =(const QuickMatrix *oldmat); 0073 QuickMatrix *operator*(const QuickMatrix *operandmat) const; 0074 0075 QuickVector *operator*(const QuickVector *operandvec) const; 0076 0077 // debugging 0078 void dumpToAux() const; 0079 0080 private: 0081 // We don't have a default matrix size so therefore we lock the default constructor. 0082 QuickMatrix() {}; 0083 0084 void allocator(); 0085 0086 unsigned int m, n; 0087 double **values; 0088 }; 0089 0090 #endif