00001 // -*- C++ -*- 00002 // 00003 // This file is part of libgvectors. 00004 // libgvectors is a C++ library intended for visualizing mathematical vectors. 00005 // Copyright (C) 2007 Rafael Ostertag 00006 // 00007 // This program is free software; you can redistribute it and/or 00008 // modify it under the terms of the GNU General Public License 00009 // as published by the Free Software Foundation; either version 2 00010 // of the License, or (at your option) any later version. 00011 // 00012 // This program is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with this program; if not, write to the Free Software 00019 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 00020 // USA. 00021 // 00022 // $Id: matrix_8h-source.html,v 1.1 2007-09-08 19:02:36 rafi Exp $ 00023 // 00024 // File: matrix.h 00025 // Author: Rafael Ostertag 00026 // 00027 // Created on August 8, 2007, 10:57 AM 00028 // 00029 00042 #ifndef _MATRIX_H 00043 #define _MATRIX_H 00044 00045 #include <gvectortypes.h> 00046 00047 namespace GVectors { 00048 00056 class Matrix { 00057 protected: 00065 double** matrix; 00066 00067 00069 void alloc(); 00071 void free(); 00073 void copy(double** const src); 00089 inline bool valid_index(matindex_t r, matindex_t c) const { 00090 return (r<rows && c<columns); 00091 } 00092 00093 public: 00099 const matindex_t rows; 00105 const matindex_t columns; 00106 00108 Matrix(matindex_t r, matindex_t c); 00110 Matrix(const Matrix& m); 00112 const Matrix& operator=(const Matrix& m); 00114 virtual ~Matrix(); 00115 00117 void set(matindex_t r, matindex_t c, double v); 00119 double get(matindex_t r, matindex_t c) const; 00121 void fill(double v); 00122 }; 00123 } 00124 00125 #endif /* _MATRIX_H */ 00126
1.4.7