Main Page   Namespace List   Compound List   File List   Namespace Members   Compound Members   File Members  

tnt_cmat.h

Go to the documentation of this file.
00001 /*
00002 *
00003 * Template Numerical Toolkit (TNT)
00004 *
00005 * Mathematical and Computational Sciences Division
00006 * National Institute of Technology,
00007 * Gaithersburg, MD USA
00008 *
00009 *
00010 * This software was developed at the National Institute of Standards and
00011 * Technology (NIST) by employees of the Federal Government in the course
00012 * of their official duties. Pursuant to title 17 Section 105 of the
00013 * United States Code, this software is not subject to copyright protection
00014 * and is in the public domain. NIST assumes no responsibility whatsoever for
00015 * its use by other parties, and makes no guarantees, expressed or implied,
00016 * about its quality, reliability, or any other characteristic.
00017 *
00018 */
00019 
00020 
00021 
00022 #ifndef TNT_CMAT_H
00023 #define TNT_CMAT_H
00024 
00025 #include "tnt_subscript.h"
00026 #include "tnt_vec.h"
00027 #include <cstdlib>
00028 #include <cassert>
00029 #include <iostream>
00030 #include <strstream>
00031 
00032 namespace TNT
00033 {
00034 
00042 
00043 template <class T>
00044 class Matrix 
00045 {
00046 
00047 
00048   public:
00049 
00050     typedef Subscript   size_type;
00051     typedef         T   value_type;
00052     typedef         T   element_type;
00053     typedef         T*  pointer;
00054     typedef         T*  iterator;
00055     typedef         T&  reference;
00056     typedef const   T*  const_iterator;
00057     typedef const   T&  const_reference;
00058 
00059     Subscript lbound() const { return 1;}
00060  
00061   protected:
00062     Subscript m_;
00063     Subscript n_;
00064     Subscript mn_;      // total size
00065     T* v_;                  
00066     T** row_;           
00067     T* vm1_ ;       // these point to the same data, but are 1-based 
00068     T** rowm1_;
00069 
00070   public:
00071 
00072     operator T**(){ return  row_; }
00073     operator T**() const { return row_; }
00074 
00075 
00076     Subscript size() const { return mn_; }
00077 
00078     // constructors
00079 
00080     Matrix();
00081 
00082     Matrix(const Matrix<T> &A);
00083 
00084     Matrix(Subscript M, Subscript N, const T& value = T());
00085 
00086     Matrix(Subscript M, Subscript N, const T* v);
00087 
00088     Matrix(Subscript M, Subscript N, const char *s);
00089 
00090     ~Matrix();
00091 
00092 
00093     Matrix<T>& newsize(Subscript M, Subscript N);
00094 
00095 
00096 
00097     Matrix<T>& operator=(const Matrix<T> &A);
00098         
00099     Matrix<T>& operator=(const T& scalar);
00100 
00101 
00102     Subscript dim(Subscript d) const ;
00103     Subscript num_rows() const { return m_; }
00104     Subscript num_cols() const { return n_; }
00105 
00106 
00107 
00108 
00109     inline T* operator[](Subscript i);
00110 
00111     inline const T* operator[](Subscript i) const;
00112 
00113     inline reference operator()(Subscript i);
00114 
00115     inline const_reference operator()(Subscript i) const;
00116 
00117 
00118     inline reference operator()(Subscript i, Subscript j);
00119 
00120 
00121     
00122     inline const_reference operator() (Subscript i, Subscript j) const;
00123 
00124 
00125 };
00126 
00127 
00128 /* ***************************  I/O  ********************************/
00129 
00130 template <class T>
00131 std::ostream& operator<<(std::ostream &s, const Matrix<T> &A);
00132 
00133 template <class T>
00134 std::istream& operator>>(std::istream &s, Matrix<T> &A);
00135 
00136 // *******************[ basic matrix algorithms ]***************************
00137 
00138 
00139 template <class T>
00140 Matrix<T> operator+(const Matrix<T> &A, const Matrix<T> &B);
00141 
00142 template <class T> 
00143 Matrix<T> operator-(const Matrix<T> &A, const Matrix<T> &B);
00144 
00145 template <class T> 
00146 Matrix<T> mult_element(const Matrix<T> &A, const Matrix<T> &B);
00147 
00148 
00149 template <class T>
00150 Matrix<T> transpose(const Matrix<T> &A);
00151 
00152 
00153     
00154 template <class T>
00155 inline Matrix<T> matmult(const Matrix<T>  &A, const Matrix<T> &B);
00156 
00157 template <class T>
00158 inline Matrix<T> operator*(const Matrix<T>  &A, const Matrix<T> &B);
00159 
00160 template <class T>
00161 inline int matmult(Matrix<T>& C, const Matrix<T>  &A, const Matrix<T> &B);
00162 
00163 
00164 template <class T>
00165 Vector<T> matmult(const Matrix<T>  &A, const Vector<T> &x);
00166 
00167 template <class T>
00168 inline Vector<T> operator*(const Matrix<T>  &A, const Vector<T> &x) ;
00169 
00170 } // namespace TNT
00171 
00172 #endif
00173 // CMAT_H

Generated at Thu Jun 26 17:26:14 2003 for Template Numerical Toolkit (TNT) by doxygen1.2.5 written by Dimitri van Heesch, © 1997-2001