Mercurial > forge
comparison main/fixed/src/fixedCMatrix.cc @ 9481:d84d2fea3c90 octave-forge
Re-enable compilation of fixed package
author | jordigh |
---|---|
date | Wed, 22 Feb 2012 22:07:33 +0000 |
parents | 52f21a12e35b |
children |
comparison
equal
deleted
inserted
replaced
9480:954f2f00d782 | 9481:d84d2fea3c90 |
---|---|
44 | 44 |
45 #include "fixed-inline.cc" | 45 #include "fixed-inline.cc" |
46 | 46 |
47 // Fixed Point Complex Matrix class. | 47 // Fixed Point Complex Matrix class. |
48 | 48 |
49 FixedComplexMatrix::FixedComplexMatrix (const MArray2<int> &is, | 49 FixedComplexMatrix::FixedComplexMatrix (const MArray<int> &is, |
50 const MArray2<int> &ds) | 50 const MArray<int> &ds) |
51 : MArray2<FixedPointComplex> (is.rows(), is.cols()) | 51 : MArray<FixedPointComplex> (dim_vector (is.rows(), is.cols())) |
52 { | 52 { |
53 if ((rows() != ds.rows()) || (cols() != ds.cols())) { | 53 if ((rows() != ds.rows()) || (cols() != ds.cols())) { |
54 (*current_liboctave_error_handler) ("matrix size mismatch"); | 54 (*current_liboctave_error_handler) ("matrix size mismatch"); |
55 return; | 55 return; |
56 } | 56 } |
60 elem (i, j) = FixedPointComplex((unsigned int)is(i,j), | 60 elem (i, j) = FixedPointComplex((unsigned int)is(i,j), |
61 (unsigned int)ds(i,j)); | 61 (unsigned int)ds(i,j)); |
62 } | 62 } |
63 | 63 |
64 FixedComplexMatrix::FixedComplexMatrix (const Matrix &is, const Matrix &ds) | 64 FixedComplexMatrix::FixedComplexMatrix (const Matrix &is, const Matrix &ds) |
65 : MArray2<FixedPointComplex> (is.rows(), is.cols()) | 65 : MArray<FixedPointComplex> (dim_vector (is.rows(), is.cols())) |
66 { | 66 { |
67 if ((rows() != ds.rows()) || (cols() != ds.cols())) { | 67 if ((rows() != ds.rows()) || (cols() != ds.cols())) { |
68 (*current_liboctave_error_handler) ("matrix size mismatch"); | 68 (*current_liboctave_error_handler) ("matrix size mismatch"); |
69 return; | 69 return; |
70 } | 70 } |
75 (unsigned int)ds(i,j)); | 75 (unsigned int)ds(i,j)); |
76 } | 76 } |
77 | 77 |
78 FixedComplexMatrix::FixedComplexMatrix (const ComplexMatrix &is, | 78 FixedComplexMatrix::FixedComplexMatrix (const ComplexMatrix &is, |
79 const ComplexMatrix &ds) | 79 const ComplexMatrix &ds) |
80 : MArray2<FixedPointComplex> (is.rows(), is.cols()) | 80 : MArray<FixedPointComplex> (dim_vector (is.rows(), is.cols())) |
81 { | 81 { |
82 if ((rows() != ds.rows()) || (cols() != ds.cols())) { | 82 if ((rows() != ds.rows()) || (cols() != ds.cols())) { |
83 (*current_liboctave_error_handler) ("matrix size mismatch"); | 83 (*current_liboctave_error_handler) ("matrix size mismatch"); |
84 return; | 84 return; |
85 } | 85 } |
89 elem (i, j) = FixedPointComplex( is(i,j), ds(i,j)); | 89 elem (i, j) = FixedPointComplex( is(i,j), ds(i,j)); |
90 } | 90 } |
91 | 91 |
92 FixedComplexMatrix::FixedComplexMatrix (unsigned int is, unsigned int ds, | 92 FixedComplexMatrix::FixedComplexMatrix (unsigned int is, unsigned int ds, |
93 const FixedComplexMatrix& a) | 93 const FixedComplexMatrix& a) |
94 : MArray2<FixedPointComplex> (a.rows(), a.cols()) | 94 : MArray<FixedPointComplex> (dim_vector (a.rows(), a.cols())) |
95 { | 95 { |
96 for (int j = 0; j < cols (); j++) | 96 for (int j = 0; j < cols (); j++) |
97 for (int i = 0; i < rows (); i++) | 97 for (int i = 0; i < rows (); i++) |
98 elem (i, j) = FixedPointComplex(is, ds, a.elem (i, j)); | 98 elem (i, j) = FixedPointComplex(is, ds, a.elem (i, j)); |
99 } | 99 } |
100 | 100 |
101 FixedComplexMatrix::FixedComplexMatrix (Complex is, Complex ds, | 101 FixedComplexMatrix::FixedComplexMatrix (Complex is, Complex ds, |
102 const FixedComplexMatrix& a) | 102 const FixedComplexMatrix& a) |
103 : MArray2<FixedPointComplex> (a.rows(), a.cols()) | 103 : MArray<FixedPointComplex> (dim_vector (a.rows(), a.cols())) |
104 { | 104 { |
105 for (int j = 0; j < cols (); j++) | 105 for (int j = 0; j < cols (); j++) |
106 for (int i = 0; i < rows (); i++) | 106 for (int i = 0; i < rows (); i++) |
107 elem (i, j) = FixedPointComplex(is, ds, a.elem (i, j)); | 107 elem (i, j) = FixedPointComplex(is, ds, a.elem (i, j)); |
108 } | 108 } |
109 | 109 |
110 FixedComplexMatrix::FixedComplexMatrix (const MArray2<int> &is, | 110 FixedComplexMatrix::FixedComplexMatrix (const MArray<int> &is, |
111 const MArray2<int> &ds, const FixedComplexMatrix& a) | 111 const MArray<int> &ds, const FixedComplexMatrix& a) |
112 : MArray2<FixedPointComplex> (a.rows(), a.cols()) | 112 : MArray<FixedPointComplex> (dim_vector (a.rows(), a.cols())) |
113 { | 113 { |
114 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) | 114 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) |
115 || (cols() != ds.cols())) { | 115 || (cols() != ds.cols())) { |
116 (*current_liboctave_error_handler) ("matrix size mismatch"); | 116 (*current_liboctave_error_handler) ("matrix size mismatch"); |
117 return; | 117 return; |
123 (unsigned int)ds(i,j), a.elem (i, j)); | 123 (unsigned int)ds(i,j), a.elem (i, j)); |
124 } | 124 } |
125 | 125 |
126 FixedComplexMatrix::FixedComplexMatrix (const Matrix &is, const Matrix &ds, | 126 FixedComplexMatrix::FixedComplexMatrix (const Matrix &is, const Matrix &ds, |
127 const FixedComplexMatrix& a) | 127 const FixedComplexMatrix& a) |
128 : MArray2<FixedPointComplex> (a.rows(), a.cols()) | 128 : MArray<FixedPointComplex> (dim_vector (a.rows(), a.cols())) |
129 { | 129 { |
130 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) | 130 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) |
131 || (cols() != ds.cols())) { | 131 || (cols() != ds.cols())) { |
132 (*current_liboctave_error_handler) ("matrix size mismatch"); | 132 (*current_liboctave_error_handler) ("matrix size mismatch"); |
133 return; | 133 return; |
139 (unsigned int)ds(i,j), a.elem (i, j)); | 139 (unsigned int)ds(i,j), a.elem (i, j)); |
140 } | 140 } |
141 | 141 |
142 FixedComplexMatrix::FixedComplexMatrix (const ComplexMatrix &is, | 142 FixedComplexMatrix::FixedComplexMatrix (const ComplexMatrix &is, |
143 const ComplexMatrix &ds, const FixedComplexMatrix& a) | 143 const ComplexMatrix &ds, const FixedComplexMatrix& a) |
144 : MArray2<FixedPointComplex> (a.rows(), a.cols()) | 144 : MArray<FixedPointComplex> (dim_vector (a.rows(), a.cols())) |
145 { | 145 { |
146 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) | 146 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) |
147 || (cols() != ds.cols())) { | 147 || (cols() != ds.cols())) { |
148 (*current_liboctave_error_handler) ("matrix size mismatch"); | 148 (*current_liboctave_error_handler) ("matrix size mismatch"); |
149 return; | 149 return; |
154 elem (i, j) = FixedPointComplex( is(i,j), ds(i,j), a.elem (i, j)); | 154 elem (i, j) = FixedPointComplex( is(i,j), ds(i,j), a.elem (i, j)); |
155 } | 155 } |
156 | 156 |
157 FixedComplexMatrix::FixedComplexMatrix (unsigned int is, unsigned int ds, | 157 FixedComplexMatrix::FixedComplexMatrix (unsigned int is, unsigned int ds, |
158 const FixedMatrix& a) | 158 const FixedMatrix& a) |
159 : MArray2<FixedPointComplex> (a.rows(), a.cols()) | 159 : MArray<FixedPointComplex> (dim_vector (a.rows(), a.cols())) |
160 { | 160 { |
161 for (int j = 0; j < cols (); j++) | 161 for (int j = 0; j < cols (); j++) |
162 for (int i = 0; i < rows (); i++) | 162 for (int i = 0; i < rows (); i++) |
163 elem (i, j) = FixedPointComplex(is, ds, a.elem (i, j)); | 163 elem (i, j) = FixedPointComplex(is, ds, a.elem (i, j)); |
164 } | 164 } |
165 | 165 |
166 FixedComplexMatrix::FixedComplexMatrix (Complex is, Complex ds, | 166 FixedComplexMatrix::FixedComplexMatrix (Complex is, Complex ds, |
167 const FixedMatrix& a) | 167 const FixedMatrix& a) |
168 : MArray2<FixedPointComplex> (a.rows(), a.cols()) | 168 : MArray<FixedPointComplex> (dim_vector (a.rows(), a.cols())) |
169 { | 169 { |
170 for (int j = 0; j < cols (); j++) | 170 for (int j = 0; j < cols (); j++) |
171 for (int i = 0; i < rows (); i++) | 171 for (int i = 0; i < rows (); i++) |
172 elem (i, j) = FixedPointComplex(is, ds, FixedPointComplex(a.elem (i, j))); | 172 elem (i, j) = FixedPointComplex(is, ds, FixedPointComplex(a.elem (i, j))); |
173 } | 173 } |
174 | 174 |
175 FixedComplexMatrix::FixedComplexMatrix (const MArray2<int> &is, | 175 FixedComplexMatrix::FixedComplexMatrix (const MArray<int> &is, |
176 const MArray2<int> &ds, const FixedMatrix& a) | 176 const MArray<int> &ds, const FixedMatrix& a) |
177 : MArray2<FixedPointComplex> (a.rows(), a.cols()) | 177 : MArray<FixedPointComplex> (dim_vector (a.rows(), a.cols())) |
178 { | 178 { |
179 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) | 179 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) |
180 || (cols() != ds.cols())) { | 180 || (cols() != ds.cols())) { |
181 (*current_liboctave_error_handler) ("matrix size mismatch"); | 181 (*current_liboctave_error_handler) ("matrix size mismatch"); |
182 return; | 182 return; |
188 (unsigned int)ds(i,j), a.elem (i, j)); | 188 (unsigned int)ds(i,j), a.elem (i, j)); |
189 } | 189 } |
190 | 190 |
191 FixedComplexMatrix::FixedComplexMatrix (const Matrix &is, const Matrix &ds, | 191 FixedComplexMatrix::FixedComplexMatrix (const Matrix &is, const Matrix &ds, |
192 const FixedMatrix& a) | 192 const FixedMatrix& a) |
193 : MArray2<FixedPointComplex> (a.rows(), a.cols()) | 193 : MArray<FixedPointComplex> (dim_vector (a.rows(), a.cols())) |
194 { | 194 { |
195 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) | 195 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) |
196 || (cols() != ds.cols())) { | 196 || (cols() != ds.cols())) { |
197 (*current_liboctave_error_handler) ("matrix size mismatch"); | 197 (*current_liboctave_error_handler) ("matrix size mismatch"); |
198 return; | 198 return; |
204 (unsigned int)ds(i,j), a.elem (i, j)); | 204 (unsigned int)ds(i,j), a.elem (i, j)); |
205 } | 205 } |
206 | 206 |
207 FixedComplexMatrix::FixedComplexMatrix (const ComplexMatrix &is, | 207 FixedComplexMatrix::FixedComplexMatrix (const ComplexMatrix &is, |
208 const ComplexMatrix &ds, const FixedMatrix& a) | 208 const ComplexMatrix &ds, const FixedMatrix& a) |
209 : MArray2<FixedPointComplex> (a.rows(), a.cols()) | 209 : MArray<FixedPointComplex> (dim_vector (a.rows(), a.cols())) |
210 { | 210 { |
211 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) | 211 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) |
212 || (cols() != ds.cols())) { | 212 || (cols() != ds.cols())) { |
213 (*current_liboctave_error_handler) ("matrix size mismatch"); | 213 (*current_liboctave_error_handler) ("matrix size mismatch"); |
214 return; | 214 return; |
219 elem (i, j) = FixedPointComplex( is(i,j), ds(i,j), FixedPointComplex(a.elem (i, j))); | 219 elem (i, j) = FixedPointComplex( is(i,j), ds(i,j), FixedPointComplex(a.elem (i, j))); |
220 } | 220 } |
221 | 221 |
222 FixedComplexMatrix::FixedComplexMatrix (unsigned int is, unsigned int ds, | 222 FixedComplexMatrix::FixedComplexMatrix (unsigned int is, unsigned int ds, |
223 const ComplexMatrix& a) | 223 const ComplexMatrix& a) |
224 : MArray2<FixedPointComplex> (a.rows(), a.cols()) | 224 : MArray<FixedPointComplex> (dim_vector (a.rows(), a.cols())) |
225 { | 225 { |
226 for (int j = 0; j < cols (); j++) | 226 for (int j = 0; j < cols (); j++) |
227 for (int i = 0; i < rows (); i++) | 227 for (int i = 0; i < rows (); i++) |
228 elem (i, j) = FixedPointComplex(is, ds, a.elem (i, j)); | 228 elem (i, j) = FixedPointComplex(is, ds, a.elem (i, j)); |
229 } | 229 } |
230 | 230 |
231 FixedComplexMatrix::FixedComplexMatrix (Complex is, Complex ds, | 231 FixedComplexMatrix::FixedComplexMatrix (Complex is, Complex ds, |
232 const ComplexMatrix& a) | 232 const ComplexMatrix& a) |
233 : MArray2<FixedPointComplex> (a.rows(), a.cols()) | 233 : MArray<FixedPointComplex> (dim_vector (a.rows(), a.cols())) |
234 { | 234 { |
235 for (int j = 0; j < cols (); j++) | 235 for (int j = 0; j < cols (); j++) |
236 for (int i = 0; i < rows (); i++) | 236 for (int i = 0; i < rows (); i++) |
237 elem (i, j) = FixedPointComplex(is, ds, a.elem (i, j)); | 237 elem (i, j) = FixedPointComplex(is, ds, a.elem (i, j)); |
238 } | 238 } |
239 | 239 |
240 FixedComplexMatrix::FixedComplexMatrix (const MArray2<int> &is, | 240 FixedComplexMatrix::FixedComplexMatrix (const MArray<int> &is, |
241 const MArray2<int> &ds, const ComplexMatrix& a) | 241 const MArray<int> &ds, const ComplexMatrix& a) |
242 : MArray2<FixedPointComplex> (a.rows(), a.cols()) | 242 : MArray<FixedPointComplex> (dim_vector (a.rows(), a.cols())) |
243 { | 243 { |
244 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) | 244 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) |
245 || (cols() != ds.cols())) { | 245 || (cols() != ds.cols())) { |
246 (*current_liboctave_error_handler) ("matrix size mismatch"); | 246 (*current_liboctave_error_handler) ("matrix size mismatch"); |
247 return; | 247 return; |
253 (unsigned int)ds(i,j), a.elem (i, j)); | 253 (unsigned int)ds(i,j), a.elem (i, j)); |
254 } | 254 } |
255 | 255 |
256 FixedComplexMatrix::FixedComplexMatrix (const Matrix &is, const Matrix &ds, | 256 FixedComplexMatrix::FixedComplexMatrix (const Matrix &is, const Matrix &ds, |
257 const ComplexMatrix& a) | 257 const ComplexMatrix& a) |
258 : MArray2<FixedPointComplex> (a.rows(), a.cols()) | 258 : MArray<FixedPointComplex> (dim_vector (a.rows(), a.cols())) |
259 { | 259 { |
260 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) | 260 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) |
261 || (cols() != ds.cols())) { | 261 || (cols() != ds.cols())) { |
262 (*current_liboctave_error_handler) ("matrix size mismatch"); | 262 (*current_liboctave_error_handler) ("matrix size mismatch"); |
263 return; | 263 return; |
269 (unsigned int)ds(i,j), a.elem (i, j)); | 269 (unsigned int)ds(i,j), a.elem (i, j)); |
270 } | 270 } |
271 | 271 |
272 FixedComplexMatrix::FixedComplexMatrix (const ComplexMatrix &is, | 272 FixedComplexMatrix::FixedComplexMatrix (const ComplexMatrix &is, |
273 const ComplexMatrix &ds, const ComplexMatrix& a) | 273 const ComplexMatrix &ds, const ComplexMatrix& a) |
274 : MArray2<FixedPointComplex> (a.rows(), a.cols()) | 274 : MArray<FixedPointComplex> (dim_vector (a.rows(), a.cols())) |
275 { | 275 { |
276 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) | 276 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) |
277 || (cols() != ds.cols())) { | 277 || (cols() != ds.cols())) { |
278 (*current_liboctave_error_handler) ("matrix size mismatch"); | 278 (*current_liboctave_error_handler) ("matrix size mismatch"); |
279 return; | 279 return; |
284 elem (i, j) = FixedPointComplex(is(i,j), ds(i,j), a.elem (i, j)); | 284 elem (i, j) = FixedPointComplex(is(i,j), ds(i,j), a.elem (i, j)); |
285 } | 285 } |
286 | 286 |
287 FixedComplexMatrix::FixedComplexMatrix (unsigned int is, unsigned int ds, | 287 FixedComplexMatrix::FixedComplexMatrix (unsigned int is, unsigned int ds, |
288 const Matrix& a) | 288 const Matrix& a) |
289 : MArray2<FixedPointComplex> (a.rows(), a.cols()) | 289 : MArray<FixedPointComplex> (dim_vector (a.rows(), a.cols())) |
290 { | 290 { |
291 for (int j = 0; j < cols (); j++) | 291 for (int j = 0; j < cols (); j++) |
292 for (int i = 0; i < rows (); i++) | 292 for (int i = 0; i < rows (); i++) |
293 elem (i, j) = FixedPointComplex(is, ds, a.elem (i, j)); | 293 elem (i, j) = FixedPointComplex(is, ds, a.elem (i, j)); |
294 } | 294 } |
295 | 295 |
296 FixedComplexMatrix::FixedComplexMatrix (Complex is, Complex ds, | 296 FixedComplexMatrix::FixedComplexMatrix (Complex is, Complex ds, |
297 const Matrix& a) | 297 const Matrix& a) |
298 : MArray2<FixedPointComplex> (a.rows(), a.cols()) | 298 : MArray<FixedPointComplex> (dim_vector (a.rows(), a.cols())) |
299 { | 299 { |
300 for (int j = 0; j < cols (); j++) | 300 for (int j = 0; j < cols (); j++) |
301 for (int i = 0; i < rows (); i++) | 301 for (int i = 0; i < rows (); i++) |
302 elem (i, j) = FixedPointComplex(is, ds, a.elem (i, j)); | 302 elem (i, j) = FixedPointComplex(is, ds, a.elem (i, j)); |
303 } | 303 } |
304 | 304 |
305 FixedComplexMatrix::FixedComplexMatrix (const MArray2<int> &is, | 305 FixedComplexMatrix::FixedComplexMatrix (const MArray<int> &is, |
306 const MArray2<int> &ds, const Matrix& a) | 306 const MArray<int> &ds, const Matrix& a) |
307 : MArray2<FixedPointComplex> (a.rows(), a.cols()) | 307 : MArray<FixedPointComplex> (dim_vector (a.rows(), a.cols())) |
308 { | 308 { |
309 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) | 309 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) |
310 || (cols() != ds.cols())) { | 310 || (cols() != ds.cols())) { |
311 (*current_liboctave_error_handler) ("matrix size mismatch"); | 311 (*current_liboctave_error_handler) ("matrix size mismatch"); |
312 return; | 312 return; |
318 (unsigned int)ds(i,j), a.elem (i, j)); | 318 (unsigned int)ds(i,j), a.elem (i, j)); |
319 } | 319 } |
320 | 320 |
321 FixedComplexMatrix::FixedComplexMatrix (const Matrix &is, const Matrix &ds, | 321 FixedComplexMatrix::FixedComplexMatrix (const Matrix &is, const Matrix &ds, |
322 const Matrix& a) | 322 const Matrix& a) |
323 : MArray2<FixedPointComplex> (a.rows(), a.cols()) | 323 : MArray<FixedPointComplex> (dim_vector (a.rows(), a.cols())) |
324 { | 324 { |
325 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) | 325 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) |
326 || (cols() != ds.cols())) { | 326 || (cols() != ds.cols())) { |
327 (*current_liboctave_error_handler) ("matrix size mismatch"); | 327 (*current_liboctave_error_handler) ("matrix size mismatch"); |
328 return; | 328 return; |
334 (unsigned int)ds(i,j), a.elem (i, j)); | 334 (unsigned int)ds(i,j), a.elem (i, j)); |
335 } | 335 } |
336 | 336 |
337 FixedComplexMatrix::FixedComplexMatrix (const ComplexMatrix &is, | 337 FixedComplexMatrix::FixedComplexMatrix (const ComplexMatrix &is, |
338 const ComplexMatrix &ds, const Matrix& a) | 338 const ComplexMatrix &ds, const Matrix& a) |
339 : MArray2<FixedPointComplex> (a.rows(), a.cols()) | 339 : MArray<FixedPointComplex> (dim_vector (a.rows(), a.cols())) |
340 { | 340 { |
341 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) | 341 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) |
342 || (cols() != ds.cols())) { | 342 || (cols() != ds.cols())) { |
343 (*current_liboctave_error_handler) ("matrix size mismatch"); | 343 (*current_liboctave_error_handler) ("matrix size mismatch"); |
344 return; | 344 return; |
350 } | 350 } |
351 | 351 |
352 | 352 |
353 FixedComplexMatrix::FixedComplexMatrix (unsigned int is, unsigned int ds, | 353 FixedComplexMatrix::FixedComplexMatrix (unsigned int is, unsigned int ds, |
354 const ComplexMatrix& a, const ComplexMatrix& b) | 354 const ComplexMatrix& a, const ComplexMatrix& b) |
355 : MArray2<FixedPointComplex> (a.rows(), a.cols()) | 355 : MArray<FixedPointComplex> (dim_vector (a.rows(), a.cols())) |
356 { | 356 { |
357 if ((rows() != b.rows()) || (cols() != b.cols())) { | 357 if ((rows() != b.rows()) || (cols() != b.cols())) { |
358 (*current_liboctave_error_handler) ("matrix size mismatch"); | 358 (*current_liboctave_error_handler) ("matrix size mismatch"); |
359 return; | 359 return; |
360 } | 360 } |
364 elem (i, j) = FixedPointComplex(is, ds, a.elem (i, j), b.elem(i,j)); | 364 elem (i, j) = FixedPointComplex(is, ds, a.elem (i, j), b.elem(i,j)); |
365 } | 365 } |
366 | 366 |
367 FixedComplexMatrix::FixedComplexMatrix (Complex is, Complex ds, | 367 FixedComplexMatrix::FixedComplexMatrix (Complex is, Complex ds, |
368 const ComplexMatrix& a, const ComplexMatrix& b) | 368 const ComplexMatrix& a, const ComplexMatrix& b) |
369 : MArray2<FixedPointComplex> (a.rows(), a.cols()) | 369 : MArray<FixedPointComplex> (dim_vector (a.rows(), a.cols())) |
370 { | 370 { |
371 if ((rows() != b.rows()) || (cols() != b.cols())) { | 371 if ((rows() != b.rows()) || (cols() != b.cols())) { |
372 (*current_liboctave_error_handler) ("matrix size mismatch"); | 372 (*current_liboctave_error_handler) ("matrix size mismatch"); |
373 return; | 373 return; |
374 } | 374 } |
376 for (int j = 0; j < cols (); j++) | 376 for (int j = 0; j < cols (); j++) |
377 for (int i = 0; i < rows (); i++) | 377 for (int i = 0; i < rows (); i++) |
378 elem (i, j) = FixedPointComplex(is, ds, a.elem (i, j), b.elem(i,j)); | 378 elem (i, j) = FixedPointComplex(is, ds, a.elem (i, j), b.elem(i,j)); |
379 } | 379 } |
380 | 380 |
381 FixedComplexMatrix::FixedComplexMatrix (const MArray2<int> &is, | 381 FixedComplexMatrix::FixedComplexMatrix (const MArray<int> &is, |
382 const MArray2<int> &ds, const ComplexMatrix& a, | 382 const MArray<int> &ds, const ComplexMatrix& a, |
383 const ComplexMatrix& b) | 383 const ComplexMatrix& b) |
384 : MArray2<FixedPointComplex> (a.rows(), a.cols()) | 384 : MArray<FixedPointComplex> (dim_vector (a.rows(), a.cols())) |
385 { | 385 { |
386 if ((rows() != b.rows()) || (cols() != b.cols()) || (rows() != is.rows()) | 386 if ((rows() != b.rows()) || (cols() != b.cols()) || (rows() != is.rows()) |
387 || (cols() != is.cols()) || (rows() != ds.rows()) | 387 || (cols() != is.cols()) || (rows() != ds.rows()) |
388 || (cols() != ds.cols())) { | 388 || (cols() != ds.cols())) { |
389 (*current_liboctave_error_handler) ("matrix size mismatch"); | 389 (*current_liboctave_error_handler) ("matrix size mismatch"); |
396 b.elem(i,j)); | 396 b.elem(i,j)); |
397 } | 397 } |
398 | 398 |
399 FixedComplexMatrix::FixedComplexMatrix (const Matrix &is, const Matrix &ds, | 399 FixedComplexMatrix::FixedComplexMatrix (const Matrix &is, const Matrix &ds, |
400 const ComplexMatrix& a, const ComplexMatrix& b) | 400 const ComplexMatrix& a, const ComplexMatrix& b) |
401 : MArray2<FixedPointComplex> (a.rows(), a.cols()) | 401 : MArray<FixedPointComplex> (dim_vector (a.rows(), a.cols())) |
402 { | 402 { |
403 if ((rows() != b.rows()) || (cols() != b.cols()) || (rows() != is.rows()) | 403 if ((rows() != b.rows()) || (cols() != b.cols()) || (rows() != is.rows()) |
404 || (cols() != is.cols()) || (rows() != ds.rows()) | 404 || (cols() != is.cols()) || (rows() != ds.rows()) |
405 || (cols() != ds.cols())) { | 405 || (cols() != ds.cols())) { |
406 (*current_liboctave_error_handler) ("matrix size mismatch"); | 406 (*current_liboctave_error_handler) ("matrix size mismatch"); |
414 } | 414 } |
415 | 415 |
416 FixedComplexMatrix::FixedComplexMatrix (const ComplexMatrix &is, | 416 FixedComplexMatrix::FixedComplexMatrix (const ComplexMatrix &is, |
417 const ComplexMatrix &ds, const ComplexMatrix& a, | 417 const ComplexMatrix &ds, const ComplexMatrix& a, |
418 const ComplexMatrix& b) | 418 const ComplexMatrix& b) |
419 : MArray2<FixedPointComplex> (a.rows(), a.cols()) | 419 : MArray<FixedPointComplex> (dim_vector (a.rows(), a.cols())) |
420 { | 420 { |
421 if ((rows() != b.rows()) || (cols() != b.cols()) || (rows() != is.rows()) | 421 if ((rows() != b.rows()) || (cols() != b.cols()) || (rows() != is.rows()) |
422 || (cols() != is.cols()) || (rows() != ds.rows()) | 422 || (cols() != is.cols()) || (rows() != ds.rows()) |
423 || (cols() != ds.cols())) { | 423 || (cols() != ds.cols())) { |
424 (*current_liboctave_error_handler) ("matrix size mismatch"); | 424 (*current_liboctave_error_handler) ("matrix size mismatch"); |
430 elem (i, j) = FixedPointComplex(is(i, j), ds(i, j), a.elem (i, j), | 430 elem (i, j) = FixedPointComplex(is(i, j), ds(i, j), a.elem (i, j), |
431 b.elem(i,j)); | 431 b.elem(i,j)); |
432 } | 432 } |
433 | 433 |
434 FixedComplexMatrix::FixedComplexMatrix (const FixedComplexRowVector& rv) | 434 FixedComplexMatrix::FixedComplexMatrix (const FixedComplexRowVector& rv) |
435 : MArray2<FixedPointComplex> (1, rv.length (), FixedPointComplex()) | 435 : MArray<FixedPointComplex> (dim_vector (1, rv.length ()), FixedPointComplex()) |
436 { | 436 { |
437 for (int i = 0; i < rv.length (); i++) | 437 for (int i = 0; i < rv.length (); i++) |
438 elem (0, i) = rv.elem (i); | 438 elem (0, i) = rv.elem (i); |
439 } | 439 } |
440 | 440 |
441 FixedComplexMatrix::FixedComplexMatrix (const FixedRowVector& rv) | 441 FixedComplexMatrix::FixedComplexMatrix (const FixedRowVector& rv) |
442 : MArray2<FixedPointComplex> (1, rv.length (), FixedPointComplex()) | 442 : MArray<FixedPointComplex> (dim_vector (1, rv.length ()), FixedPointComplex()) |
443 { | 443 { |
444 for (int i = 0; i < rv.length (); i++) | 444 for (int i = 0; i < rv.length (); i++) |
445 elem (0, i) = FixedPointComplex(rv.elem (i)); | 445 elem (0, i) = FixedPointComplex(rv.elem (i)); |
446 } | 446 } |
447 | 447 |
448 FixedComplexMatrix::FixedComplexMatrix (const FixedComplexColumnVector& cv) | 448 FixedComplexMatrix::FixedComplexMatrix (const FixedComplexColumnVector& cv) |
449 : MArray2<FixedPointComplex> (cv.length (), 1, FixedPointComplex()) | 449 : MArray<FixedPointComplex> (dim_vector (cv.length (), 1), FixedPointComplex()) |
450 { | 450 { |
451 for (int i = 0; i < cv.length (); i++) | 451 for (int i = 0; i < cv.length (); i++) |
452 elem (i, 0) = cv.elem (i); | 452 elem (i, 0) = cv.elem (i); |
453 } | 453 } |
454 | 454 |
455 FixedComplexMatrix::FixedComplexMatrix (const FixedColumnVector& cv) | 455 FixedComplexMatrix::FixedComplexMatrix (const FixedColumnVector& cv) |
456 : MArray2<FixedPointComplex> (cv.length (), 1, FixedPointComplex()) | 456 : MArray<FixedPointComplex> (dim_vector (cv.length (), 1), FixedPointComplex()) |
457 { | 457 { |
458 for (int i = 0; i < cv.length (); i++) | 458 for (int i = 0; i < cv.length (); i++) |
459 elem (i, 0) = FixedPointComplex(cv.elem (i)); | 459 elem (i, 0) = FixedPointComplex(cv.elem (i)); |
460 } | 460 } |
461 | 461 |
462 FixedComplexMatrix::FixedComplexMatrix (const FixedMatrix& m) | 462 FixedComplexMatrix::FixedComplexMatrix (const FixedMatrix& m) |
463 : MArray2<FixedPointComplex> (m.rows (), m.cols (), FixedPointComplex()) | 463 : MArray<FixedPointComplex> (dim_vector (m.rows (), m.cols ()), FixedPointComplex()) |
464 { | 464 { |
465 for (int j = 0; j < m.cols (); j++) | 465 for (int j = 0; j < m.cols (); j++) |
466 for (int i = 0; i < m.rows (); i++) | 466 for (int i = 0; i < m.rows (); i++) |
467 elem (i, j) = FixedPointComplex(m.elem (i,j)); | 467 elem (i, j) = FixedPointComplex(m.elem (i,j)); |
468 } | 468 } |
469 | 469 |
470 FixedComplexMatrix::FixedComplexMatrix (const FixedMatrix& a, | 470 FixedComplexMatrix::FixedComplexMatrix (const FixedMatrix& a, |
471 const FixedMatrix& b) | 471 const FixedMatrix& b) |
472 : MArray2<FixedPointComplex> (a.rows (), a.cols (), FixedPointComplex()) | 472 : MArray<FixedPointComplex> (dim_vector (a.rows (), a.cols ()), FixedPointComplex()) |
473 { | 473 { |
474 if ((rows() != b.rows()) || (cols() != b.cols())) { | 474 if ((rows() != b.rows()) || (cols() != b.cols())) { |
475 (*current_liboctave_error_handler) ("matrix size mismatch"); | 475 (*current_liboctave_error_handler) ("matrix size mismatch"); |
476 return; | 476 return; |
477 } | 477 } |
663 } | 663 } |
664 | 664 |
665 FixedComplexMatrix& | 665 FixedComplexMatrix& |
666 FixedComplexMatrix::insert (const FixedComplexMatrix& a, int r, int c) | 666 FixedComplexMatrix::insert (const FixedComplexMatrix& a, int r, int c) |
667 { | 667 { |
668 Array2<FixedPointComplex>::insert (a, r, c); | 668 Array<FixedPointComplex>::insert (a, r, c); |
669 return *this; | 669 return *this; |
670 } | 670 } |
671 | 671 |
672 FixedComplexMatrix& | 672 FixedComplexMatrix& |
673 FixedComplexMatrix::insert (const FixedComplexRowVector& a, int r, int c) | 673 FixedComplexMatrix::insert (const FixedComplexRowVector& a, int r, int c) |
1006 | 1006 |
1007 if (len != 0) | 1007 if (len != 0) |
1008 { | 1008 { |
1009 int a_len = a.length (); | 1009 int a_len = a.length (); |
1010 | 1010 |
1011 retval.resize (len, a_len); | 1011 retval.resize (dim_vector (len, a_len)); |
1012 | 1012 |
1013 for (int i = 0; i < len; i++) | 1013 for (int i = 0; i < len; i++) |
1014 for (int j = 0; j < a_len; j++) | 1014 for (int j = 0; j < a_len; j++) |
1015 retval.elem(j,i) = v.elem(i) * a.elem(j); | 1015 retval.elem(j,i) = v.elem(i) * a.elem(j); |
1016 } | 1016 } |
1039 } | 1039 } |
1040 | 1040 |
1041 boolMatrix | 1041 boolMatrix |
1042 FixedComplexMatrix::all (int dim) const | 1042 FixedComplexMatrix::all (int dim) const |
1043 { | 1043 { |
1044 return do_mx_red_op<boolMatrix> (*this, dim, mx_inline_all); | 1044 return do_mx_red_op<bool, FixedPointComplex> (*this, dim, mx_inline_all); |
1045 } | 1045 } |
1046 | 1046 |
1047 boolMatrix | 1047 boolMatrix |
1048 FixedComplexMatrix::any (int dim) const | 1048 FixedComplexMatrix::any (int dim) const |
1049 { | 1049 { |
1050 return do_mx_red_op<boolMatrix> (*this, dim, mx_inline_any); | 1050 return do_mx_red_op<bool, FixedPointComplex> (*this, dim, mx_inline_any); |
1051 } | 1051 } |
1052 | 1052 |
1053 FixedComplexMatrix | 1053 FixedComplexMatrix |
1054 FixedComplexMatrix::cumprod (int dim) const | 1054 FixedComplexMatrix::cumprod (int dim) const |
1055 { | 1055 { |
1056 return do_mx_cum_op<FixedComplexMatrix> (*this, dim, mx_inline_cumprod); | 1056 return do_mx_cum_op<FixedPointComplex, FixedPointComplex> (*this, dim, mx_inline_cumprod); |
1057 } | 1057 } |
1058 | 1058 |
1059 FixedComplexMatrix | 1059 FixedComplexMatrix |
1060 FixedComplexMatrix::cumsum (int dim) const | 1060 FixedComplexMatrix::cumsum (int dim) const |
1061 { | 1061 { |
1062 return do_mx_cum_op<FixedComplexMatrix> (*this, dim, mx_inline_cumsum); | 1062 return do_mx_cum_op<FixedPointComplex, FixedPointComplex> (*this, dim, mx_inline_cumsum); |
1063 } | 1063 } |
1064 | 1064 |
1065 FixedComplexMatrix | 1065 FixedComplexMatrix |
1066 FixedComplexMatrix::prod (int dim) const | 1066 FixedComplexMatrix::prod (int dim) const |
1067 { | 1067 { |
1068 return do_mx_red_op<FixedComplexMatrix> (*this, dim, mx_inline_prod); | 1068 return do_mx_red_op<FixedPointComplex, FixedPointComplex> (*this, dim, mx_inline_prod); |
1069 } | 1069 } |
1070 | 1070 |
1071 FixedComplexMatrix | 1071 FixedComplexMatrix |
1072 FixedComplexMatrix::sum (int dim) const | 1072 FixedComplexMatrix::sum (int dim) const |
1073 { | 1073 { |
1074 return do_mx_red_op<FixedComplexMatrix> (*this, dim, mx_inline_sum); | 1074 return do_mx_red_op<FixedPointComplex, FixedPointComplex> (*this, dim, mx_inline_sum); |
1075 } | 1075 } |
1076 | 1076 |
1077 FixedComplexMatrix | 1077 FixedComplexMatrix |
1078 FixedComplexMatrix::sumsq (int dim) const | 1078 FixedComplexMatrix::sumsq (int dim) const |
1079 { | 1079 { |
1080 return do_mx_red_op<FixedMatrix> (*this, dim, mx_inline_sumsq); | 1080 return do_mx_red_op<FixedPointComplex, FixedPointComplex> (*this, dim, mx_inline_sumsq); |
1081 } | 1081 } |
1082 | 1082 |
1083 FixedComplexMatrix | 1083 FixedComplexMatrix |
1084 FixedComplexMatrix::abs (void) const | 1084 FixedComplexMatrix::abs (void) const |
1085 { | 1085 { |
1157 int nc = cols (); | 1157 int nc = cols (); |
1158 | 1158 |
1159 if (nr > 0 && nc > 0) | 1159 if (nr > 0 && nc > 0) |
1160 { | 1160 { |
1161 result.resize (nr); | 1161 result.resize (nr); |
1162 index.resize (nr); | 1162 index.resize (dim_vector (nr, 1)); |
1163 | 1163 |
1164 for (int i = 0; i < nr; i++) | 1164 for (int i = 0; i < nr; i++) |
1165 { | 1165 { |
1166 int idx_j = 0; | 1166 int idx_j = 0; |
1167 | 1167 |
1204 int nc = cols (); | 1204 int nc = cols (); |
1205 | 1205 |
1206 if (nr > 0 && nc > 0) | 1206 if (nr > 0 && nc > 0) |
1207 { | 1207 { |
1208 result.resize (nr); | 1208 result.resize (nr); |
1209 index.resize (nr); | 1209 index.resize (dim_vector (nr, 1)); |
1210 | 1210 |
1211 for (int i = 0; i < nr; i++) | 1211 for (int i = 0; i < nr; i++) |
1212 { | 1212 { |
1213 int idx_j = 0; | 1213 int idx_j = 0; |
1214 | 1214 |
1251 int nc = cols (); | 1251 int nc = cols (); |
1252 | 1252 |
1253 if (nr > 0 && nc > 0) | 1253 if (nr > 0 && nc > 0) |
1254 { | 1254 { |
1255 result.resize (nc); | 1255 result.resize (nc); |
1256 index.resize (nc); | 1256 index.resize (dim_vector (1, nc)); |
1257 | 1257 |
1258 for (int j = 0; j < nc; j++) | 1258 for (int j = 0; j < nc; j++) |
1259 { | 1259 { |
1260 int idx_i = 0; | 1260 int idx_i = 0; |
1261 | 1261 |
1298 int nc = cols (); | 1298 int nc = cols (); |
1299 | 1299 |
1300 if (nr > 0 && nc > 0) | 1300 if (nr > 0 && nc > 0) |
1301 { | 1301 { |
1302 result.resize (nc); | 1302 result.resize (nc); |
1303 index.resize (nc); | 1303 index.resize (dim_vector (1, nc)); |
1304 | 1304 |
1305 for (int j = 0; j < nc; j++) | 1305 for (int j = 0; j < nc; j++) |
1306 { | 1306 { |
1307 int idx_i = 0; | 1307 int idx_i = 0; |
1308 | 1308 |
1383 int b_nr = b.rows (); | 1383 int b_nr = b.rows (); |
1384 int b_nc = b.cols (); | 1384 int b_nc = b.cols (); |
1385 | 1385 |
1386 if (a_nr == 1 && a_nc == 1) | 1386 if (a_nr == 1 && a_nc == 1) |
1387 { | 1387 { |
1388 retval.resize(b_nr,b_nc); | 1388 retval.resize(dim_vector (b_nr,b_nc)); |
1389 FixedPointComplex ad = a(0,0); | 1389 FixedPointComplex ad = a(0,0); |
1390 for (int j = 0; j < b_nc; j++) | 1390 for (int j = 0; j < b_nc; j++) |
1391 for (int i = 0; i < b_nr; i++) | 1391 for (int i = 0; i < b_nr; i++) |
1392 retval(i,j) = pow(ad, b(i,j)); | 1392 retval(i,j) = pow(ad, b(i,j)); |
1393 } | 1393 } |
1394 else if (b_nr == 1 && b_nc == 1) | 1394 else if (b_nr == 1 && b_nc == 1) |
1395 { | 1395 { |
1396 retval.resize(a_nr,a_nc); | 1396 retval.resize(dim_vector (a_nr,a_nc)); |
1397 FixedPointComplex bd = b(0,0); | 1397 FixedPointComplex bd = b(0,0); |
1398 for (int j = 0; j < a_nc; j++) | 1398 for (int j = 0; j < a_nc; j++) |
1399 for (int i = 0; i < a_nr; i++) | 1399 for (int i = 0; i < a_nr; i++) |
1400 retval(i,j) = pow(a(i,j), bd); | 1400 retval(i,j) = pow(a(i,j), bd); |
1401 } | 1401 } |
1402 else if ((a_nr == b_nr) && (a_nc == b_nc)) | 1402 else if ((a_nr == b_nr) && (a_nc == b_nc)) |
1403 { | 1403 { |
1404 retval.resize(a_nr,a_nc); | 1404 retval.resize(dim_vector (a_nr,a_nc)); |
1405 for (int j = 0; j < a_nc; j++) | 1405 for (int j = 0; j < a_nc; j++) |
1406 for (int i = 0; i < a_nr; i++) | 1406 for (int i = 0; i < a_nr; i++) |
1407 retval(i,j) = pow(a(i,j), b(i,j)); | 1407 retval(i,j) = pow(a(i,j), b(i,j)); |
1408 } | 1408 } |
1409 else | 1409 else |
1546 int nr = rows (); | 1546 int nr = rows (); |
1547 int nc = cols (); | 1547 int nc = cols (); |
1548 FixedComplexMatrix result; | 1548 FixedComplexMatrix result; |
1549 if (length () > 0) | 1549 if (length () > 0) |
1550 { | 1550 { |
1551 result.resize (nc, nr); | 1551 result.resize (dim_vector (nc, nr)); |
1552 for (int j = 0; j < nc; j++) | 1552 for (int j = 0; j < nc; j++) |
1553 for (int i = 0; i < nr; i++) | 1553 for (int i = 0; i < nr; i++) |
1554 result.elem (j, i) = conj (elem (i, j)); | 1554 result.elem (j, i) = conj (elem (i, j)); |
1555 } | 1555 } |
1556 return result; | 1556 return result; |
1610 | 1610 |
1611 if (a_nc != b_nr) | 1611 if (a_nc != b_nr) |
1612 gripe_nonconformant ("operator *", a_nr, a_nc, b_nr, b_nc); | 1612 gripe_nonconformant ("operator *", a_nr, a_nc, b_nr, b_nc); |
1613 else | 1613 else |
1614 { | 1614 { |
1615 retval.resize (a_nr, b_nc, FixedPointComplex()); | 1615 retval.resize (dim_vector (a_nr, b_nc), FixedPointComplex()); |
1616 if (a_nr != 0 && a_nc != 0 && b_nc != 0) | 1616 if (a_nr != 0 && a_nc != 0 && b_nc != 0) |
1617 { | 1617 { |
1618 for (int j = 0; j < b_nr; j++) | 1618 for (int j = 0; j < b_nr; j++) |
1619 for (int i = 0; i < b_nc; i++) { | 1619 for (int i = 0; i < b_nc; i++) { |
1620 FixedPointComplex tmp = b.elem(j,i); | 1620 FixedPointComplex tmp = b.elem(j,i); |
1771 } | 1771 } |
1772 | 1772 |
1773 return result; | 1773 return result; |
1774 } | 1774 } |
1775 | 1775 |
1776 MS_CMP_OPS(FixedComplexMatrix, real, FixedPointComplex, real) | 1776 MS_CMP_OPS(FixedComplexMatrix, FixedPointComplex) |
1777 MS_BOOL_OPS(FixedComplexMatrix, FixedPointComplex, FixedPointComplex()) | 1777 MS_BOOL_OPS(FixedComplexMatrix, FixedPointComplex) |
1778 | 1778 |
1779 SM_CMP_OPS(FixedPointComplex, real, FixedComplexMatrix, real) | 1779 SM_CMP_OPS(FixedPointComplex, FixedComplexMatrix) |
1780 SM_BOOL_OPS(FixedPointComplex, FixedComplexMatrix, FixedPointComplex()) | 1780 SM_BOOL_OPS(FixedPointComplex, FixedComplexMatrix) |
1781 | 1781 |
1782 MM_CMP_OPS(FixedComplexMatrix, real, FixedComplexMatrix, real) | 1782 MM_CMP_OPS(FixedComplexMatrix, FixedComplexMatrix) |
1783 MM_BOOL_OPS(FixedComplexMatrix, FixedComplexMatrix, FixedPointComplex()) | 1783 MM_BOOL_OPS(FixedComplexMatrix, FixedComplexMatrix) |
1784 | 1784 |
1785 /* | 1785 /* |
1786 ;;; Local Variables: *** | 1786 ;;; Local Variables: *** |
1787 ;;; mode: C++ *** | 1787 ;;; mode: C++ *** |
1788 ;;; End: *** | 1788 ;;; End: *** |