| [658] | 1 | /*************************************************************************** | 
|---|
|  | 2 | * blitz/mstruct.h      Matrix structure classes | 
|---|
|  | 3 | * | 
|---|
|  | 4 | * $Id: mstruct.h,v 1.1.1.1 1999-11-26 16:37:04 ansari Exp $ | 
|---|
|  | 5 | * | 
|---|
|  | 6 | * Copyright (C) 1997,1998 Todd Veldhuizen <tveldhui@seurat.uwaterloo.ca> | 
|---|
|  | 7 | * | 
|---|
|  | 8 | * This program is free software; you can redistribute it and/or | 
|---|
|  | 9 | * modify it under the terms of the GNU General Public License | 
|---|
|  | 10 | * as published by the Free Software Foundation; either version 2 | 
|---|
|  | 11 | * of the License, or (at your option) any later version. | 
|---|
|  | 12 | * | 
|---|
|  | 13 | * This program is distributed in the hope that it will be useful, | 
|---|
|  | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
|  | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|---|
|  | 16 | * GNU General Public License for more details. | 
|---|
|  | 17 | * | 
|---|
|  | 18 | * | 
|---|
|  | 19 | * Suggestions:          blitz-suggest@cybervision.com | 
|---|
|  | 20 | * Bugs:                 blitz-bugs@cybervision.com | 
|---|
|  | 21 | * | 
|---|
|  | 22 | * For more information, please see the Blitz++ Home Page: | 
|---|
|  | 23 | *    http://seurat.uwaterloo.ca/blitz/ | 
|---|
|  | 24 | * | 
|---|
|  | 25 | *************************************************************************** | 
|---|
|  | 26 | * $Log: not supported by cvs2svn $ | 
|---|
|  | 27 | * Revision 1.1.1.1  1999/04/09  17:59:00  ansari | 
|---|
|  | 28 | * Creation module DPC/Blitz (blitz 0.4) Reza 09/04/99 | 
|---|
|  | 29 | * | 
|---|
|  | 30 | * Revision 1.5  1998/03/14 00:04:47  tveldhui | 
|---|
|  | 31 | * 0.2-alpha-05 | 
|---|
|  | 32 | * | 
|---|
|  | 33 | * Revision 1.4  1997/07/16 14:51:20  tveldhui | 
|---|
|  | 34 | * Update: Alpha release 0.2 (Arrays) | 
|---|
|  | 35 | * | 
|---|
|  | 36 | * Revision 1.3  1997/01/24 14:42:00  tveldhui | 
|---|
|  | 37 | * Periodic RCS update | 
|---|
|  | 38 | * | 
|---|
|  | 39 | * Revision 1.2  1997/01/13 22:19:58  tveldhui | 
|---|
|  | 40 | * Periodic RCS update | 
|---|
|  | 41 | * | 
|---|
|  | 42 | * | 
|---|
|  | 43 | */ | 
|---|
|  | 44 |  | 
|---|
|  | 45 | #ifndef BZ_MSTRUCT_H | 
|---|
|  | 46 | #define BZ_MSTRUCT_H | 
|---|
|  | 47 |  | 
|---|
|  | 48 | #ifndef BZ_BLITZ_H | 
|---|
|  | 49 | #include <blitz/blitz.h> | 
|---|
|  | 50 | #endif | 
|---|
|  | 51 |  | 
|---|
|  | 52 | #ifndef BZ_ZERO_H | 
|---|
|  | 53 | #include <blitz/zero.h> | 
|---|
|  | 54 | #endif | 
|---|
|  | 55 |  | 
|---|
|  | 56 | /* | 
|---|
|  | 57 | * Each matrix structure class encapsulates a storage format for matrix | 
|---|
|  | 58 | * data.  It is responsible for: | 
|---|
|  | 59 | * - Storing the size of the matrix | 
|---|
|  | 60 | * - Calculating how many unique elements the matrix will have | 
|---|
|  | 61 | * - Mapping indices (i,j) onto memory locations | 
|---|
|  | 62 | * - Performing any sign reversals or conjugations when matrix | 
|---|
|  | 63 | *   elements are retrieved (e.g. in a Hermitian or Skew symmetric | 
|---|
|  | 64 | *   matrix) | 
|---|
|  | 65 | * | 
|---|
|  | 66 | * Every matrix structure class must provide these methods: | 
|---|
|  | 67 | * | 
|---|
|  | 68 | * ctor() | 
|---|
|  | 69 | * ctor(unsigned rows, unsigned cols) | 
|---|
|  | 70 | * unsigned columns() const; | 
|---|
|  | 71 | * unsigned cols()    const; | 
|---|
|  | 72 | * unsigned firstInRow() const; | 
|---|
|  | 73 | * unsigned firstInCol() const; | 
|---|
|  | 74 | * template<class T> T& get(T* data, unsigned i, unsigned j); | 
|---|
|  | 75 | * template<class T> T  get(const T* data, unsigned i, unsigned j) const; | 
|---|
|  | 76 | * bool inRange(unsigned i, unsigned j) const | 
|---|
|  | 77 | * unsigned lastInRow() const; | 
|---|
|  | 78 | * unsigned lastInCol() const; | 
|---|
|  | 79 | * unsigned numElements() const; | 
|---|
|  | 80 | * void resize(unsigned rows, unsigned cols); | 
|---|
|  | 81 | * unsigned rows()    const; | 
|---|
|  | 82 | * | 
|---|
|  | 83 | * Each matrix structure class must declare a public type | 
|---|
|  | 84 | * T_iterator which is an iterator to scan through the unique | 
|---|
|  | 85 | * entries of the matrix.  The iterator class must provide | 
|---|
|  | 86 | * these methods: | 
|---|
|  | 87 | * | 
|---|
|  | 88 | * ctor(unsigned rows, unsigned cols) | 
|---|
|  | 89 | * unsigned offset() const | 
|---|
|  | 90 | * operator bool() const | 
|---|
|  | 91 | * unsigned row() const | 
|---|
|  | 92 | * unsigned col() const | 
|---|
|  | 93 | */ | 
|---|
|  | 94 |  | 
|---|
|  | 95 | BZ_NAMESPACE(blitz) | 
|---|
|  | 96 |  | 
|---|
|  | 97 | class MatrixStructure { }; | 
|---|
|  | 98 |  | 
|---|
|  | 99 | class AsymmetricMatrix : public MatrixStructure { | 
|---|
|  | 100 | public: | 
|---|
|  | 101 | AsymmetricMatrix() | 
|---|
|  | 102 | : rows_(0), cols_(0) | 
|---|
|  | 103 | { } | 
|---|
|  | 104 |  | 
|---|
|  | 105 | AsymmetricMatrix(unsigned rows, unsigned cols) | 
|---|
|  | 106 | : rows_(rows), cols_(cols) | 
|---|
|  | 107 | { } | 
|---|
|  | 108 |  | 
|---|
|  | 109 | unsigned columns() const | 
|---|
|  | 110 | { return cols_; } | 
|---|
|  | 111 |  | 
|---|
|  | 112 | unsigned cols() const | 
|---|
|  | 113 | { return cols_; } | 
|---|
|  | 114 |  | 
|---|
|  | 115 | _bz_bool inRange(unsigned i, unsigned j) const | 
|---|
|  | 116 | { | 
|---|
|  | 117 | return (i < rows_) && (j < cols_); | 
|---|
|  | 118 | } | 
|---|
|  | 119 |  | 
|---|
|  | 120 | void resize(unsigned rows, unsigned cols) | 
|---|
|  | 121 | { | 
|---|
|  | 122 | rows_ = rows; | 
|---|
|  | 123 | cols_ = cols; | 
|---|
|  | 124 | } | 
|---|
|  | 125 |  | 
|---|
|  | 126 | unsigned rows() const | 
|---|
|  | 127 | { return rows_; } | 
|---|
|  | 128 |  | 
|---|
|  | 129 | protected: | 
|---|
|  | 130 | unsigned rows_, cols_; | 
|---|
|  | 131 | }; | 
|---|
|  | 132 |  | 
|---|
|  | 133 | // Still to be implemented: | 
|---|
|  | 134 | // SkewSymmetric | 
|---|
|  | 135 | // Hermitian | 
|---|
|  | 136 | // Tridiagonal | 
|---|
|  | 137 | // Banded<L,H> | 
|---|
|  | 138 | // Upper bidiagonal | 
|---|
|  | 139 | // Lower bidiagonal | 
|---|
|  | 140 | // Upper Hessenberg | 
|---|
|  | 141 | // Lower Hessenberg | 
|---|
|  | 142 |  | 
|---|
|  | 143 | BZ_NAMESPACE_END | 
|---|
|  | 144 |  | 
|---|
|  | 145 | #include <blitz/matgen.h>         // RowMajor and ColumnMajor general matrices | 
|---|
|  | 146 | #include <blitz/matsymm.h>        // Symmetric | 
|---|
|  | 147 | #include <blitz/matdiag.h>        // Diagonal | 
|---|
|  | 148 | #include <blitz/mattoep.h>        // Toeplitz | 
|---|
|  | 149 | #include <blitz/matltri.h>        // Lower triangular | 
|---|
|  | 150 | #include <blitz/matutri.h>        // Upper triangular | 
|---|
|  | 151 |  | 
|---|
|  | 152 | #endif // BZ_MSTRUCT_H | 
|---|