blitz/mstruct.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  * blitz/mstruct.h      Matrix structure classes
00003  *
00004  * $Id: mstruct.h,v 1.4 2003/12/11 03:44:22 julianc Exp $
00005  *
00006  * Copyright (C) 1997-2001 Todd Veldhuizen <tveldhui@oonumerics.org>
00007  *
00008  * This program is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU General Public License
00010  * as published by the Free Software Foundation; either version 2
00011  * of the License, or (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  *
00019  * Suggestions:          blitz-dev@oonumerics.org
00020  * Bugs:                 blitz-bugs@oonumerics.org
00021  *
00022  * For more information, please see the Blitz++ Home Page:
00023  *    http://oonumerics.org/blitz/
00024  *
00025  ***************************************************************************/
00026 
00027 #ifndef BZ_MSTRUCT_H
00028 #define BZ_MSTRUCT_H
00029 
00030 #ifndef BZ_BLITZ_H
00031  #include <blitz/blitz.h>
00032 #endif
00033 
00034 #ifndef BZ_ZERO_H
00035  #include <blitz/zero.h>
00036 #endif
00037 
00038 /*
00039  * Each matrix structure class encapsulates a storage format for matrix
00040  * data.  It is responsible for:
00041  * - Storing the size of the matrix
00042  * - Calculating how many unique elements the matrix will have
00043  * - Mapping indices (i,j) onto memory locations
00044  * - Performing any sign reversals or conjugations when matrix
00045  *   elements are retrieved (e.g. in a Hermitian or Skew symmetric
00046  *   matrix)
00047  *
00048  * Every matrix structure class must provide these methods:
00049  *
00050  * ctor()
00051  * ctor(unsigned rows, unsigned cols)
00052  * unsigned columns() const;
00053  * unsigned cols()    const;
00054  * unsigned firstInRow() const;
00055  * unsigned firstInCol() const;
00056  * template<typename T> T& get(T* data, unsigned i, unsigned j);
00057  * template<typename T> T  get(const T* data, unsigned i, unsigned j) const;
00058  * bool inRange(unsigned i, unsigned j) const
00059  * unsigned lastInRow() const;
00060  * unsigned lastInCol() const;
00061  * unsigned numElements() const;
00062  * void resize(unsigned rows, unsigned cols);
00063  * unsigned rows()    const;
00064  *
00065  * Each matrix structure class must declare a public type
00066  * T_iterator which is an iterator to scan through the unique
00067  * entries of the matrix.  The iterator class must provide
00068  * these methods:
00069  *
00070  * ctor(unsigned rows, unsigned cols)
00071  * unsigned offset() const
00072  * operator bool() const
00073  * unsigned row() const
00074  * unsigned col() const
00075  */
00076 
00077 BZ_NAMESPACE(blitz)
00078 
00079 class MatrixStructure { };
00080 
00081 class AsymmetricMatrix : public MatrixStructure {
00082 public:
00083     AsymmetricMatrix()
00084         : rows_(0), cols_(0)
00085     { }
00086 
00087     AsymmetricMatrix(unsigned rows, unsigned cols)
00088         : rows_(rows), cols_(cols)
00089     { }
00090 
00091     unsigned columns() const { return cols_; }
00092 
00093     unsigned cols() const { return cols_; }
00094 
00095     bool inRange(const unsigned i,const unsigned j) const {
00096         return (i<rows_) && (j<cols_);
00097     }
00098 
00099     void resize(unsigned rows, unsigned cols) {
00100         rows_ = rows;
00101         cols_ = cols;
00102     }
00103 
00104     unsigned rows() const { return rows_; }
00105 
00106 protected:
00107     unsigned rows_, cols_;
00108 };
00109 
00110 // Still to be implemented:
00111 // SkewSymmetric
00112 // Hermitian
00113 // Tridiagonal
00114 // Banded<L,H>
00115 // Upper bidiagonal
00116 // Lower bidiagonal
00117 // Upper Hessenberg
00118 // Lower Hessenberg
00119 
00120 BZ_NAMESPACE_END
00121 
00122 #include <blitz/matgen.h>         // RowMajor and ColumnMajor general matrices
00123 #include <blitz/matsymm.h>        // Symmetric
00124 #include <blitz/matdiag.h>        // Diagonal
00125 #include <blitz/mattoep.h>        // Toeplitz
00126 #include <blitz/matltri.h>        // Lower triangular
00127 #include <blitz/matutri.h>        // Upper triangular
00128 
00129 #endif // BZ_MSTRUCT_H

Generated on Mon Oct 22 09:27:56 2007 for blitz by  doxygen 1.4.7