source: Sophya/trunk/Poubelle/DPC:FitsIOServer/Blitz/blitz/mattoep.h@ 658

Last change on this file since 658 was 658, checked in by ansari, 26 years ago

no message

File size: 3.8 KB
RevLine 
[658]1/***************************************************************************
2 * blitz/mattoep.h Declarations for Toeplitz matrices
3 *
4 * $Id: mattoep.h,v 1.1.1.1 1999-11-26 16:37:03 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 * Suggestions: blitz-suggest@cybervision.com
19 * Bugs: blitz-bugs@cybervision.com
20 *
21 * For more information, please see the Blitz++ Home Page:
22 * http://seurat.uwaterloo.ca/blitz/
23 *
24 ***************************************************************************
25 * $Log: not supported by cvs2svn $
26 * Revision 1.1.1.1 1999/04/09 17:59:00 ansari
27 * Creation module DPC/Blitz (blitz 0.4) Reza 09/04/99
28 *
29 * Revision 1.3 1998/03/14 00:04:47 tveldhui
30 * 0.2-alpha-05
31 *
32 * Revision 1.2 1997/01/24 14:42:00 tveldhui
33 * Periodic RCS update
34 *
35 * Revision 1.1 1997/01/13 22:19:58 tveldhui
36 * Periodic RCS update
37 *
38 *
39 */
40
41#ifndef BZ_MATTOEP_H
42#define BZ_MATTOEP_H
43
44#ifndef BZ_MSTRUCT_H
45 #error <blitz/mattoep.h> must be included via <blitz/mstruct.h>
46#endif
47
48BZ_NAMESPACE(blitz)
49
50// Toeplitz matrix
51// [ 0 1 2 3 ]
52// [ 1 2 3 4 ]
53// [ 2 3 4 5 ]
54// [ 3 4 5 6 ]
55
56class ToeplitzIterator {
57public:
58 ToeplitzIterator(unsigned rows, unsigned cols)
59 {
60 rows_ = rows;
61 cols_ = cols;
62 i_ = 0;
63 j_ = 0;
64 good_ = true;
65 offset_ = 0;
66 }
67
68 operator _bz_bool() const
69 {
70 return good_;
71 }
72
73 void operator++()
74 {
75 ++offset_;
76 if (i_ < rows_ - 1)
77 ++i_;
78 else if (j_ < cols_ - 1)
79 ++j_;
80 else
81 good_ = false;
82 }
83
84 unsigned row() const
85 { return i_; }
86
87 unsigned col() const
88 { return j_; }
89
90 unsigned offset() const
91 { return offset_; }
92
93protected:
94 unsigned offset_;
95 unsigned i_, j_;
96 unsigned rows_, cols_;
97 _bz_bool good_;
98};
99
100class Toeplitz : public GeneralMatrix {
101
102public:
103 typedef ToeplitzIterator T_iterator;
104
105 Toeplitz()
106 : rows_(0), cols_(0)
107 { }
108
109 Toeplitz(unsigned rows, unsigned cols)
110 : rows_(rows), cols_(cols)
111 { }
112
113 unsigned columns() const
114 { return cols_; }
115
116 unsigned coordToOffset(unsigned i, unsigned j) const
117 {
118 BZPRECONDITION(inRange(i,j));
119 return i + j;
120 }
121
122 unsigned firstInRow(unsigned i) const
123 { return 0; }
124
125 template<class T_numtype>
126 T_numtype get(const T_numtype * _bz_restrict data,
127 unsigned i, unsigned j) const
128 {
129 BZPRECONDITION(inRange(i,j));
130 return data[coordToOffset(i,j)];
131 }
132
133 template<class T_numtype>
134 T_numtype& get(T_numtype * _bz_restrict data, unsigned i, unsigned j)
135 {
136 BZPRECONDITION(inRange(i,j));
137 return data[coordToOffset(i,j)];
138 }
139
140 unsigned lastInRow(unsigned i) const
141 { return cols_ - 1; }
142
143 unsigned firstInCol(unsigned j) const
144 { return 0; }
145
146 unsigned lastInCol(unsigned j) const
147 { return rows_ - 1; }
148
149 _bz_bool inRange(unsigned i, unsigned j) const
150 {
151 return (i < rows_) && (j < cols_);
152 }
153
154 unsigned numElements() const
155 { return rows_ + cols_ - 1; }
156
157 unsigned rows() const
158 { return rows_; }
159
160 void resize(unsigned rows, unsigned cols)
161 {
162 rows_ = rows;
163 cols_ = cols;
164 }
165
166private:
167 unsigned rows_, cols_;
168};
169
170BZ_NAMESPACE_END
171
172#endif // BZ_MATSYMM_H
173
Note: See TracBrowser for help on using the repository browser.