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