[221] | 1 | /***************************************************************************
|
---|
| 2 | * blitz/mstruct.h Matrix structure classes
|
---|
| 3 | *
|
---|
| 4 | * $Id: mstruct.h,v 1.1.1.1 1999-04-09 17:59:00 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.5 1998/03/14 00:04:47 tveldhui
|
---|
| 28 | * 0.2-alpha-05
|
---|
| 29 | *
|
---|
| 30 | * Revision 1.4 1997/07/16 14:51:20 tveldhui
|
---|
| 31 | * Update: Alpha release 0.2 (Arrays)
|
---|
| 32 | *
|
---|
| 33 | * Revision 1.3 1997/01/24 14:42:00 tveldhui
|
---|
| 34 | * Periodic RCS update
|
---|
| 35 | *
|
---|
| 36 | * Revision 1.2 1997/01/13 22:19:58 tveldhui
|
---|
| 37 | * Periodic RCS update
|
---|
| 38 | *
|
---|
| 39 | *
|
---|
| 40 | */
|
---|
| 41 |
|
---|
| 42 | #ifndef BZ_MSTRUCT_H
|
---|
| 43 | #define BZ_MSTRUCT_H
|
---|
| 44 |
|
---|
| 45 | #ifndef BZ_BLITZ_H
|
---|
| 46 | #include <blitz/blitz.h>
|
---|
| 47 | #endif
|
---|
| 48 |
|
---|
| 49 | #ifndef BZ_ZERO_H
|
---|
| 50 | #include <blitz/zero.h>
|
---|
| 51 | #endif
|
---|
| 52 |
|
---|
| 53 | /*
|
---|
| 54 | * Each matrix structure class encapsulates a storage format for matrix
|
---|
| 55 | * data. It is responsible for:
|
---|
| 56 | * - Storing the size of the matrix
|
---|
| 57 | * - Calculating how many unique elements the matrix will have
|
---|
| 58 | * - Mapping indices (i,j) onto memory locations
|
---|
| 59 | * - Performing any sign reversals or conjugations when matrix
|
---|
| 60 | * elements are retrieved (e.g. in a Hermitian or Skew symmetric
|
---|
| 61 | * matrix)
|
---|
| 62 | *
|
---|
| 63 | * Every matrix structure class must provide these methods:
|
---|
| 64 | *
|
---|
| 65 | * ctor()
|
---|
| 66 | * ctor(unsigned rows, unsigned cols)
|
---|
| 67 | * unsigned columns() const;
|
---|
| 68 | * unsigned cols() const;
|
---|
| 69 | * unsigned firstInRow() const;
|
---|
| 70 | * unsigned firstInCol() const;
|
---|
| 71 | * template<class T> T& get(T* data, unsigned i, unsigned j);
|
---|
| 72 | * template<class T> T get(const T* data, unsigned i, unsigned j) const;
|
---|
| 73 | * bool inRange(unsigned i, unsigned j) const
|
---|
| 74 | * unsigned lastInRow() const;
|
---|
| 75 | * unsigned lastInCol() const;
|
---|
| 76 | * unsigned numElements() const;
|
---|
| 77 | * void resize(unsigned rows, unsigned cols);
|
---|
| 78 | * unsigned rows() const;
|
---|
| 79 | *
|
---|
| 80 | * Each matrix structure class must declare a public type
|
---|
| 81 | * T_iterator which is an iterator to scan through the unique
|
---|
| 82 | * entries of the matrix. The iterator class must provide
|
---|
| 83 | * these methods:
|
---|
| 84 | *
|
---|
| 85 | * ctor(unsigned rows, unsigned cols)
|
---|
| 86 | * unsigned offset() const
|
---|
| 87 | * operator bool() const
|
---|
| 88 | * unsigned row() const
|
---|
| 89 | * unsigned col() const
|
---|
| 90 | */
|
---|
| 91 |
|
---|
| 92 | BZ_NAMESPACE(blitz)
|
---|
| 93 |
|
---|
| 94 | class MatrixStructure { };
|
---|
| 95 |
|
---|
| 96 | class AsymmetricMatrix : public MatrixStructure {
|
---|
| 97 | public:
|
---|
| 98 | AsymmetricMatrix()
|
---|
| 99 | : rows_(0), cols_(0)
|
---|
| 100 | { }
|
---|
| 101 |
|
---|
| 102 | AsymmetricMatrix(unsigned rows, unsigned cols)
|
---|
| 103 | : rows_(rows), cols_(cols)
|
---|
| 104 | { }
|
---|
| 105 |
|
---|
| 106 | unsigned columns() const
|
---|
| 107 | { return cols_; }
|
---|
| 108 |
|
---|
| 109 | unsigned cols() const
|
---|
| 110 | { return cols_; }
|
---|
| 111 |
|
---|
| 112 | _bz_bool inRange(unsigned i, unsigned j) const
|
---|
| 113 | {
|
---|
| 114 | return (i < rows_) && (j < cols_);
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | void resize(unsigned rows, unsigned cols)
|
---|
| 118 | {
|
---|
| 119 | rows_ = rows;
|
---|
| 120 | cols_ = cols;
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 | unsigned rows() const
|
---|
| 124 | { return rows_; }
|
---|
| 125 |
|
---|
| 126 | protected:
|
---|
| 127 | unsigned rows_, cols_;
|
---|
| 128 | };
|
---|
| 129 |
|
---|
| 130 | // Still to be implemented:
|
---|
| 131 | // SkewSymmetric
|
---|
| 132 | // Hermitian
|
---|
| 133 | // Tridiagonal
|
---|
| 134 | // Banded<L,H>
|
---|
| 135 | // Upper bidiagonal
|
---|
| 136 | // Lower bidiagonal
|
---|
| 137 | // Upper Hessenberg
|
---|
| 138 | // Lower Hessenberg
|
---|
| 139 |
|
---|
| 140 | BZ_NAMESPACE_END
|
---|
| 141 |
|
---|
| 142 | #include <blitz/matgen.h> // RowMajor and ColumnMajor general matrices
|
---|
| 143 | #include <blitz/matsymm.h> // Symmetric
|
---|
| 144 | #include <blitz/matdiag.h> // Diagonal
|
---|
| 145 | #include <blitz/mattoep.h> // Toeplitz
|
---|
| 146 | #include <blitz/matltri.h> // Lower triangular
|
---|
| 147 | #include <blitz/matutri.h> // Upper triangular
|
---|
| 148 |
|
---|
| 149 | #endif // BZ_MSTRUCT_H
|
---|