Mercurial > forge
annotate main/fixed/src/fixedMatrix.cc @ 9481:d84d2fea3c90 octave-forge
Re-enable compilation of fixed package
author | jordigh |
---|---|
date | Wed, 22 Feb 2012 22:07:33 +0000 |
parents | 0924c374b60d |
children |
rev | line source |
---|---|
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1 /* |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
2 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
3 Copyright (C) 2003 Motorola Inc |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
4 Copyright (C) 2003 David Bateman |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
5 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
6 This program is free software; you can redistribute it and/or modify it |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
7 under the terms of the GNU General Public License as published by the |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
8 Free Software Foundation; either version 2, or (at your option) any |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
9 later version. |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
10 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
11 This program is distributed in the hope that it will be useful, but WITHOUT |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
14 for more details. |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
15 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
16 You should have received a copy of the GNU General Public License |
4404 | 17 along with this program; see the file COPYING. If not, see |
18 <http://www.gnu.org/licenses/>. | |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
19 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
20 In addition to the terms of the GPL, you are permitted to link |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
21 this program with any Open Source program, as defined by the |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
22 Open Source Initiative (www.opensource.org) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
23 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
24 */ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
25 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
26 #include <iostream> |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
27 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
28 #include <octave/config.h> |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
29 #include <octave/lo-error.h> |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
30 #include <octave/lo-utils.h> |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
31 #include <octave/lo-error.h> |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
32 #include <octave/error.h> |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
33 #include <octave/dMatrix.h> |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
34 #include <octave/gripes.h> |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
35 #include <octave/ops.h> |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
36 #include <octave/quit.h> |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
37 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
38 #include "fixedColVector.h" |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
39 #include "fixedRowVector.h" |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
40 #include "fixedMatrix.h" |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
41 #include "fixedCMatrix.h" |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
42 |
5655
0924c374b60d
Update fixed point code for 3.1.x. Minor bug in test code still present though code seems to work fine
adb014
parents:
5248
diff
changeset
|
43 #include "fixed-inline.cc" |
0924c374b60d
Update fixed point code for 3.1.x. Minor bug in test code still present though code seems to work fine
adb014
parents:
5248
diff
changeset
|
44 |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
45 // Fixed Point Matrix class. |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
46 |
9481 | 47 FixedMatrix::FixedMatrix (const MArray<int> &is, const MArray<int> &ds) |
48 : MArray<FixedPoint> (dim_vector (is.rows(), is.cols())) | |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
49 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
50 if ((rows() != ds.rows()) || (cols() != ds.cols())) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
51 (*current_liboctave_error_handler) ("matrix size mismatch"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
52 return; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
53 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
54 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
55 for (int j = 0; j < cols (); j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
56 for (int i = 0; i < rows (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
57 elem (i, j) = FixedPoint((unsigned int)is(i,j), (unsigned int)ds(i,j)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
58 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
59 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
60 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
61 FixedMatrix::FixedMatrix (const Matrix &is, const Matrix &ds) |
9481 | 62 : MArray<FixedPoint> (dim_vector (is.rows(), is.cols())) |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
63 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
64 if ((rows() != ds.rows()) || (cols() != ds.cols())) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
65 (*current_liboctave_error_handler) ("matrix size mismatch"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
66 return; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
67 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
68 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
69 for (int j = 0; j < cols (); j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
70 for (int i = 0; i < rows (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
71 elem (i, j) = FixedPoint((unsigned int)is(i,j), (unsigned int)ds(i,j)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
72 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
73 |
9481 | 74 FixedMatrix::FixedMatrix (const MArray<int> &is, const MArray<int> &ds, |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
75 const FixedMatrix& a) |
9481 | 76 : MArray<FixedPoint> (dim_vector (a.rows(), a.cols())) |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
77 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
78 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
79 || (cols() != ds.cols())) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
80 (*current_liboctave_error_handler) ("matrix size mismatch"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
81 return; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
82 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
83 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
84 for (int j = 0; j < cols (); j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
85 for (int i = 0; i < rows (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
86 elem (i, j) = FixedPoint((unsigned int)is(i,j), (unsigned int)ds(i,j), |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
87 a.elem (i, j)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
88 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
89 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
90 FixedMatrix::FixedMatrix (const Matrix &is, const Matrix &ds, |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
91 const FixedMatrix& a) |
9481 | 92 : MArray<FixedPoint> (dim_vector (a.rows(), a.cols())) |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
93 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
94 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
95 || (cols() != ds.cols())) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
96 (*current_liboctave_error_handler) ("matrix size mismatch"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
97 return; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
98 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
99 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
100 for (int j = 0; j < cols (); j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
101 for (int i = 0; i < rows (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
102 elem (i, j) = FixedPoint((unsigned int)is(i,j), (unsigned int)ds(i,j), |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
103 a.elem (i, j)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
104 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
105 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
106 FixedMatrix::FixedMatrix (unsigned int is, unsigned int ds, |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
107 const FixedMatrix& a) |
9481 | 108 : MArray<FixedPoint> (dim_vector (a.rows(), a.cols())) |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
109 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
110 for (int j = 0; j < cols (); j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
111 for (int i = 0; i < rows (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
112 elem (i, j) = FixedPoint(is, ds, a.elem (i, j)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
113 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
114 |
9481 | 115 FixedMatrix::FixedMatrix (const MArray<int> &is, const MArray<int> &ds, |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
116 const Matrix& a) |
9481 | 117 : MArray<FixedPoint> (dim_vector (a.rows(), a.cols())) |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
118 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
119 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
120 || (cols() != ds.cols())) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
121 (*current_liboctave_error_handler) ("matrix size mismatch"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
122 return; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
123 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
124 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
125 for (int j = 0; j < cols (); j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
126 for (int i = 0; i < rows (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
127 elem (i, j) = FixedPoint((unsigned int)is(i,j), (unsigned int)ds(i,j), |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
128 a.elem (i, j)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
129 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
130 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
131 FixedMatrix::FixedMatrix (const Matrix &is, const Matrix &ds, |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
132 const Matrix& a) |
9481 | 133 : MArray<FixedPoint> (dim_vector (a.rows(), a.cols())) |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
134 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
135 if ((rows() != is.rows()) || (cols() != is.cols()) || (rows() != ds.rows()) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
136 || (cols() != ds.cols())) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
137 (*current_liboctave_error_handler) ("matrix size mismatch"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
138 return; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
139 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
140 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
141 for (int j = 0; j < cols (); j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
142 for (int i = 0; i < rows (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
143 elem (i, j) = FixedPoint((unsigned int)is(i,j), (unsigned int)ds(i,j), |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
144 a.elem (i, j)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
145 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
146 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
147 FixedMatrix::FixedMatrix (unsigned int is, unsigned int ds, const Matrix& a) |
9481 | 148 : MArray<FixedPoint> (dim_vector (a.rows(), a.cols())) |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
149 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
150 for (int j = 0; j < cols (); j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
151 for (int i = 0; i < rows (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
152 elem (i, j) = FixedPoint(is, ds, a.elem (i, j)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
153 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
154 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
155 FixedMatrix::FixedMatrix (unsigned int is, unsigned int ds, const Matrix& a, |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
156 const Matrix& b) |
9481 | 157 : MArray<FixedPoint> (dim_vector (a.rows(), a.cols())) |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
158 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
159 if ((rows() != b.rows()) || (cols() != b.cols())) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
160 (*current_liboctave_error_handler) ("matrix size mismatch"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
161 return; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
162 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
163 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
164 for (int j = 0; j < cols (); j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
165 for (int i = 0; i < rows (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
166 elem (i, j) = FixedPoint(is, ds, (unsigned int)a.elem (i, j), |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
167 (unsigned int)b.elem (i,j)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
168 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
169 |
9481 | 170 FixedMatrix::FixedMatrix (const MArray<int> &is, const MArray<int> &ds, |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
171 const Matrix& a, const Matrix& b) |
9481 | 172 : MArray<FixedPoint> (dim_vector (a.rows(), a.cols())) |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
173 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
174 if ((rows() != b.rows()) || (cols() != b.cols()) || (rows() != is.rows()) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
175 || (cols() != is.cols()) || (rows() != ds.rows()) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
176 || (cols() != ds.cols())) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
177 (*current_liboctave_error_handler) ("matrix size mismatch"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
178 return; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
179 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
180 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
181 for (int j = 0; j < cols (); j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
182 for (int i = 0; i < rows (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
183 elem (i, j) = FixedPoint((unsigned int)is(i,j), (unsigned int)ds(i,j), |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
184 (unsigned int)a.elem (i, j), |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
185 (unsigned int)b.elem (i,j)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
186 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
187 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
188 FixedMatrix::FixedMatrix (const Matrix &is, const Matrix &ds, const Matrix& a, |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
189 const Matrix& b) |
9481 | 190 : MArray<FixedPoint> (dim_vector (a.rows(), a.cols())) |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
191 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
192 if ((rows() != b.rows()) || (cols() != b.cols()) || (rows() != is.rows()) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
193 || (cols() != is.cols()) || (rows() != ds.rows()) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
194 || (cols() != ds.cols())) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
195 (*current_liboctave_error_handler) ("matrix size mismatch"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
196 return; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
197 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
198 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
199 for (int j = 0; j < cols (); j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
200 for (int i = 0; i < rows (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
201 elem (i, j) = FixedPoint((unsigned int)is(i,j), (unsigned int)ds(i,j), |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
202 (unsigned int)a.elem (i, j), |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
203 (unsigned int)b.elem (i,j)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
204 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
205 |
9481 | 206 FixedMatrix::FixedMatrix (const MArray<int> &a) |
207 : MArray<FixedPoint> (dim_vector (a.rows(), a.cols())) | |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
208 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
209 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
210 for (int j = 0; j < cols (); j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
211 for (int i = 0; i < rows (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
212 elem (i, j) = FixedPoint(a.elem (i, j)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
213 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
214 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
215 FixedMatrix::FixedMatrix (const Matrix &a) |
9481 | 216 : MArray<FixedPoint> (dim_vector (a.rows(), a.cols())) |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
217 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
218 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
219 for (int j = 0; j < cols (); j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
220 for (int i = 0; i < rows (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
221 elem (i, j) = FixedPoint(a.elem (i, j)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
222 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
223 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
224 FixedMatrix::FixedMatrix (const FixedRowVector& rv) |
9481 | 225 : MArray<FixedPoint> (dim_vector (1, rv.length ()), FixedPoint()) |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
226 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
227 for (int i = 0; i < rv.length (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
228 elem (0, i) = rv.elem (i); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
229 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
230 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
231 FixedMatrix::FixedMatrix (const FixedColumnVector& cv) |
9481 | 232 : MArray<FixedPoint> (dim_vector (cv.length (), 1), FixedPoint()) |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
233 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
234 for (int i = 0; i < cv.length (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
235 elem (i, 0) = cv.elem (i); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
236 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
237 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
238 #define GET_FIXED_PROP(METHOD) \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
239 Matrix \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
240 FixedMatrix:: METHOD (void) const \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
241 { \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
242 int nr = rows(); \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
243 int nc = cols(); \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
244 Matrix retval(nr,nc); \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
245 for (int i = 0; i < nr; i++) \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
246 for (int j = 0; j < nc; j++) \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
247 retval(i,j) = (double) elem(i,j) . METHOD (); \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
248 return retval; \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
249 } \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
250 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
251 GET_FIXED_PROP(sign); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
252 GET_FIXED_PROP(signbit); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
253 GET_FIXED_PROP(getdecsize); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
254 GET_FIXED_PROP(getintsize); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
255 GET_FIXED_PROP(getnumber); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
256 GET_FIXED_PROP(fixedpoint); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
257 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
258 #undef GET_FIXED_PROP |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
259 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
260 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
261 FixedMatrix::chdecsize (const double n) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
262 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
263 int nr = rows(); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
264 int nc = cols(); |
9481 | 265 FixedMatrix retval(dim_vector (nr,nc)); |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
266 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
267 for (int i = 0; i < nr; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
268 for (int j = 0; j < nc; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
269 retval(i,j) = FixedPoint(elem(i,j).getintsize(), (int)n, elem(i,j)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
270 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
271 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
272 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
273 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
274 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
275 FixedMatrix::chdecsize (const Matrix &n) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
276 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
277 int nr = rows(); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
278 int nc = cols(); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
279 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
280 if ((nr != n.rows()) || (nc != n.cols())) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
281 (*current_liboctave_error_handler) ("matrix size mismatch in chdecsize"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
282 return FixedMatrix(); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
283 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
284 |
9481 | 285 FixedMatrix retval(dim_vector (nr, nc)); |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
286 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
287 for (int i = 0; i < nr; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
288 for (int j = 0; j < nc; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
289 retval(i,j) = FixedPoint(elem(i,j).getintsize(), (int)n(i,j), elem(i,j)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
290 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
291 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
292 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
293 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
294 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
295 FixedMatrix::chintsize (const double n) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
296 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
297 int nr = rows(); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
298 int nc = cols(); |
9481 | 299 FixedMatrix retval(dim_vector (nr, nc)); |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
300 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
301 for (int i = 0; i < nr; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
302 for (int j = 0; j < nc; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
303 retval(i,j) = FixedPoint((int)n, elem(i,j).getdecsize(), elem(i,j)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
304 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
305 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
306 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
307 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
308 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
309 FixedMatrix::chintsize (const Matrix &n) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
310 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
311 int nr = rows(); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
312 int nc = cols(); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
313 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
314 if ((nr != n.rows()) || (nc != n.cols())) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
315 (*current_liboctave_error_handler) ("matrix size mismatch in chintsize"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
316 return FixedMatrix(); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
317 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
318 |
9481 | 319 FixedMatrix retval(dim_vector (nr, nc)); |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
320 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
321 for (int i = 0; i < nr; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
322 for (int j = 0; j < nc; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
323 retval(i,j) = FixedPoint((int)n(i,j), elem(i,j).getdecsize(), elem(i,j)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
324 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
325 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
326 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
327 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
328 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
329 FixedMatrix::incdecsize (const double n) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
330 return chdecsize(n + getdecsize()); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
331 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
332 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
333 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
334 FixedMatrix::incdecsize (const Matrix &n) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
335 if ((n.rows() != rows()) || (n.cols() != cols())) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
336 (*current_liboctave_error_handler) ("matrix size mismatch in chintsize"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
337 return FixedMatrix(); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
338 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
339 return chdecsize(n + getdecsize()); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
340 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
341 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
342 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
343 FixedMatrix::incdecsize () { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
344 return chdecsize(1 + getdecsize()); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
345 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
346 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
347 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
348 FixedMatrix::incintsize (const double n) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
349 return chintsize(n + getintsize()); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
350 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
351 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
352 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
353 FixedMatrix::incintsize (const Matrix &n) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
354 if ((n.rows() != rows()) || (n.cols() != cols())) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
355 (*current_liboctave_error_handler) ("matrix size mismatch in chintsize"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
356 return FixedMatrix(); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
357 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
358 return chintsize(n + getintsize()); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
359 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
360 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
361 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
362 FixedMatrix::incintsize () { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
363 return chintsize(1 + getintsize()); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
364 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
365 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
366 bool |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
367 FixedMatrix::operator == (const FixedMatrix& a) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
368 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
369 if (rows () != a.rows () || cols () != a.cols ()) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
370 return false; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
371 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
372 for (int i = 0; i < rows(); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
373 for (int j = 0; j < cols(); j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
374 if (elem(i,j) != a.elem(i,j)) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
375 return false; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
376 return true; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
377 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
378 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
379 bool |
2914 | 380 FixedMatrix::operator != (const FixedMatrix& a) const |
381 { | |
382 return !(*this == a); | |
383 } | |
384 | |
385 bool | |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
386 FixedMatrix::is_symmetric (void) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
387 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
388 if (is_square () && rows () > 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
389 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
390 for (int i = 0; i < rows (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
391 for (int j = i+1; j < cols (); j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
392 if (elem (i, j) != elem (j, i)) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
393 return false; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
394 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
395 return true; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
396 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
397 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
398 return false; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
399 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
400 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
401 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
402 FixedMatrix::concat (const FixedMatrix& rb, const Array<int>& ra_idx) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
403 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
404 if (rb.numel() > 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
405 insert (rb, ra_idx(0), ra_idx(1)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
406 return *this; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
407 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
408 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
409 FixedComplexMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
410 FixedMatrix::concat (const FixedComplexMatrix& rb, const Array<int>& ra_idx) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
411 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
412 FixedComplexMatrix retval (*this); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
413 if (rb.numel() > 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
414 retval.insert (rb, ra_idx(0), ra_idx(1)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
415 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
416 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
417 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
418 FixedMatrix& |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
419 FixedMatrix::insert (const FixedMatrix& a, int r, int c) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
420 { |
9481 | 421 Array<FixedPoint>::insert (a, r, c); |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
422 return *this; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
423 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
424 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
425 FixedMatrix& |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
426 FixedMatrix::insert (const FixedRowVector& a, int r, int c) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
427 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
428 int a_len = a.length (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
429 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
430 if (r < 0 || r >= rows () || c < 0 || c + a_len > cols ()) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
431 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
432 (*current_liboctave_error_handler) ("range error for insert"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
433 return *this; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
434 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
435 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
436 if (a_len > 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
437 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
438 make_unique (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
439 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
440 for (int i = 0; i < a_len; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
441 xelem (r, c+i) = a.elem (i); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
442 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
443 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
444 return *this; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
445 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
446 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
447 FixedMatrix& |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
448 FixedMatrix::insert (const FixedColumnVector& a, int r, int c) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
449 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
450 int a_len = a.length (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
451 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
452 if (r < 0 || r + a_len > rows () || c < 0 || c >= cols ()) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
453 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
454 (*current_liboctave_error_handler) ("range error for insert"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
455 return *this; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
456 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
457 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
458 if (a_len > 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
459 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
460 make_unique (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
461 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
462 for (int i = 0; i < a_len; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
463 xelem (r+i, c) = a.elem (i); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
464 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
465 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
466 return *this; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
467 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
468 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
469 FixedMatrix& |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
470 FixedMatrix::fill (FixedPoint val) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
471 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
472 int nr = rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
473 int nc = cols (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
474 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
475 if (nr > 0 && nc > 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
476 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
477 make_unique (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
478 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
479 for (int j = 0; j < nc; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
480 for (int i = 0; i < nr; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
481 xelem (i, j) = val; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
482 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
483 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
484 return *this; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
485 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
486 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
487 FixedMatrix& |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
488 FixedMatrix::fill (FixedPoint val, int r1, int c1, int r2, int c2) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
489 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
490 int nr = rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
491 int nc = cols (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
492 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
493 if (r1 < 0 || r2 < 0 || c1 < 0 || c2 < 0 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
494 || r1 >= nr || r2 >= nr || c1 >= nc || c2 >= nc) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
495 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
496 (*current_liboctave_error_handler) ("range error for fill"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
497 return *this; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
498 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
499 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
500 if (r1 > r2) { int tmp = r1; r1 = r2; r2 = tmp; } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
501 if (c1 > c2) { int tmp = c1; c1 = c2; c2 = tmp; } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
502 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
503 if (r2 >= r1 && c2 >= c1) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
504 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
505 make_unique (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
506 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
507 for (int j = c1; j <= c2; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
508 for (int i = r1; i <= r2; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
509 xelem (i, j) = val; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
510 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
511 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
512 return *this; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
513 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
514 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
515 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
516 FixedMatrix::append (const FixedMatrix& a) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
517 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
518 int nr = rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
519 int nc = cols (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
520 if (nr != a.rows ()) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
521 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
522 (*current_liboctave_error_handler) ("row dimension mismatch for append"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
523 return FixedMatrix (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
524 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
525 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
526 int nc_insert = nc; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
527 FixedMatrix retval (nr, nc + a.cols ()); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
528 retval.insert (*this, 0, 0); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
529 retval.insert (a, 0, nc_insert); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
530 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
531 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
532 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
533 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
534 FixedMatrix::append (const FixedRowVector& a) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
535 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
536 int nr = rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
537 int nc = cols (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
538 if (nr != 1) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
539 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
540 (*current_liboctave_error_handler) ("row dimension mismatch for append"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
541 return FixedMatrix (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
542 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
543 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
544 int nc_insert = nc; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
545 FixedMatrix retval (nr, nc + a.length ()); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
546 retval.insert (*this, 0, 0); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
547 retval.insert (a, 0, nc_insert); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
548 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
549 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
550 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
551 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
552 FixedMatrix::append (const FixedColumnVector& a) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
553 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
554 int nr = rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
555 int nc = cols (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
556 if (nr != a.length ()) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
557 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
558 (*current_liboctave_error_handler) ("row dimension mismatch for append"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
559 return FixedMatrix (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
560 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
561 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
562 int nc_insert = nc; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
563 FixedMatrix retval (nr, nc + 1); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
564 retval.insert (*this, 0, 0); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
565 retval.insert (a, 0, nc_insert); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
566 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
567 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
568 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
569 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
570 FixedMatrix::stack (const FixedMatrix& a) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
571 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
572 int nr = rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
573 int nc = cols (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
574 if (nc != a.cols ()) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
575 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
576 (*current_liboctave_error_handler) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
577 ("column dimension mismatch for stack"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
578 return FixedMatrix (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
579 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
580 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
581 int nr_insert = nr; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
582 FixedMatrix retval (nr + a.rows (), nc); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
583 retval.insert (*this, 0, 0); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
584 retval.insert (a, nr_insert, 0); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
585 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
586 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
587 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
588 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
589 FixedMatrix::stack (const FixedRowVector& a) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
590 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
591 int nr = rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
592 int nc = cols (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
593 if (nc != a.length ()) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
594 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
595 (*current_liboctave_error_handler) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
596 ("column dimension mismatch for stack"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
597 return FixedMatrix (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
598 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
599 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
600 int nr_insert = nr; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
601 FixedMatrix retval (nr + 1, nc); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
602 retval.insert (*this, 0, 0); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
603 retval.insert (a, nr_insert, 0); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
604 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
605 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
606 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
607 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
608 FixedMatrix::stack (const FixedColumnVector& a) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
609 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
610 int nr = rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
611 int nc = cols (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
612 if (nc != 1) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
613 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
614 (*current_liboctave_error_handler) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
615 ("column dimension mismatch for stack"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
616 return FixedMatrix (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
617 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
618 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
619 int nr_insert = nr; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
620 FixedMatrix retval (nr + a.length (), nc); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
621 retval.insert (*this, 0, 0); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
622 retval.insert (a, nr_insert, 0); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
623 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
624 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
625 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
626 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
627 FixedMatrix::extract (int r1, int c1, int r2, int c2) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
628 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
629 if (r1 > r2) { int tmp = r1; r1 = r2; r2 = tmp; } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
630 if (c1 > c2) { int tmp = c1; c1 = c2; c2 = tmp; } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
631 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
632 int new_r = r2 - r1 + 1; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
633 int new_c = c2 - c1 + 1; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
634 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
635 FixedMatrix result (new_r, new_c); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
636 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
637 for (int j = 0; j < new_c; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
638 for (int i = 0; i < new_r; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
639 result.xelem (i, j) = elem (r1+i, c1+j); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
640 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
641 return result; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
642 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
643 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
644 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
645 FixedMatrix::extract_n (int r1, int c1, int nr, int nc) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
646 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
647 FixedMatrix result (nr, nc); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
648 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
649 for (int j = 0; j < nc; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
650 for (int i = 0; i < nr; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
651 result.xelem (i, j) = elem (r1+i, c1+j); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
652 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
653 return result; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
654 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
655 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
656 // extract row or column i. |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
657 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
658 FixedRowVector |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
659 FixedMatrix::row (int i) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
660 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
661 int nc = cols (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
662 if (i < 0 || i >= rows ()) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
663 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
664 (*current_liboctave_error_handler) ("invalid row selection"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
665 return FixedRowVector (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
666 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
667 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
668 FixedRowVector retval (nc); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
669 for (int j = 0; j < nc; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
670 retval.xelem (j) = elem (i, j); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
671 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
672 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
673 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
674 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
675 FixedRowVector |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
676 FixedMatrix::row (char *s) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
677 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
678 if (! s) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
679 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
680 (*current_liboctave_error_handler) ("invalid row selection"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
681 return FixedRowVector (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
682 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
683 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
684 char c = *s; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
685 if (c == 'f' || c == 'F') |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
686 return row (0); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
687 else if (c == 'l' || c == 'L') |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
688 return row (rows () - 1); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
689 else |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
690 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
691 (*current_liboctave_error_handler) ("invalid row selection"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
692 return FixedRowVector (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
693 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
694 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
695 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
696 FixedColumnVector |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
697 FixedMatrix::column (int i) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
698 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
699 int nr = rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
700 if (i < 0 || i >= cols ()) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
701 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
702 (*current_liboctave_error_handler) ("invalid column selection"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
703 return FixedColumnVector (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
704 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
705 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
706 FixedColumnVector retval (nr); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
707 for (int j = 0; j < nr; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
708 retval.xelem (j) = elem (j, i); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
709 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
710 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
711 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
712 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
713 FixedColumnVector |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
714 FixedMatrix::column (char *s) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
715 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
716 if (! s) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
717 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
718 (*current_liboctave_error_handler) ("invalid column selection"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
719 return FixedColumnVector (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
720 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
721 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
722 char c = *s; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
723 if (c == 'f' || c == 'F') |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
724 return column (0); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
725 else if (c == 'l' || c == 'L') |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
726 return column (cols () - 1); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
727 else |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
728 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
729 (*current_liboctave_error_handler) ("invalid column selection"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
730 return FixedColumnVector (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
731 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
732 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
733 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
734 // unary operations |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
735 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
736 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
737 FixedMatrix::operator ! (void) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
738 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
739 int nr = rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
740 int nc = cols (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
741 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
742 FixedMatrix b (nr, nc); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
743 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
744 for (int j = 0; j < nc; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
745 for (int i = 0; i < nr; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
746 b.elem (i, j) = ! elem (i, j) ; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
747 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
748 return b; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
749 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
750 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
751 // column vector by row vector -> matrix operations |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
752 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
753 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
754 operator * (const FixedColumnVector& v, const FixedRowVector& a) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
755 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
756 FixedMatrix retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
757 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
758 int len = v.length (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
759 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
760 if (len != 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
761 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
762 int a_len = a.length (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
763 |
9481 | 764 retval.resize (len, a_len); |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
765 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
766 for (int i = 0; i < len; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
767 for (int j = 0; j < a_len; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
768 retval.elem(j,i) = v.elem(i) * a.elem(j); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
769 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
770 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
771 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
772 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
773 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
774 // other operations. |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
775 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
776 FixedMatrix |
5248 | 777 FixedMatrix::map (fp_fp_Mapper f) const |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
778 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
779 FixedMatrix b (*this); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
780 return b.apply (f); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
781 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
782 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
783 FixedMatrix& |
5248 | 784 FixedMatrix::apply (fp_fp_Mapper f) |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
785 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
786 FixedPoint *d = fortran_vec (); // Ensures only one reference to my privates! |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
787 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
788 for (int i = 0; i < length (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
789 d[i] = f (d[i]); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
790 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
791 return *this; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
792 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
793 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
794 boolMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
795 FixedMatrix::all (int dim) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
796 { |
9481 | 797 return do_mx_red_op<bool, FixedPoint> (*this, dim, mx_inline_all); |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
798 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
799 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
800 boolMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
801 FixedMatrix::any (int dim) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
802 { |
9481 | 803 return do_mx_red_op<bool, FixedPoint> (*this, dim, mx_inline_any); |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
804 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
805 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
806 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
807 FixedMatrix::cumprod (int dim) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
808 { |
9481 | 809 return do_mx_cum_op<FixedPoint, FixedPoint> (*this, dim, mx_inline_cumprod); |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
810 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
811 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
812 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
813 FixedMatrix::cumsum (int dim) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
814 { |
9481 | 815 return do_mx_cum_op<FixedPoint, FixedPoint> (*this, dim, mx_inline_cumsum); |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
816 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
817 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
818 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
819 FixedMatrix::prod (int dim) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
820 { |
9481 | 821 return do_mx_red_op<FixedPoint, FixedPoint> (*this, dim, mx_inline_prod); |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
822 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
823 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
824 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
825 FixedMatrix::sum (int dim) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
826 { |
9481 | 827 return do_mx_red_op<FixedPoint, FixedPoint> (*this, dim, mx_inline_sum); |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
828 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
829 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
830 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
831 FixedMatrix::sumsq (int dim) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
832 { |
9481 | 833 return do_mx_red_op<FixedPoint, FixedPoint> (*this, dim, mx_inline_sumsq); |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
834 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
835 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
836 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
837 FixedMatrix::abs (void) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
838 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
839 int nr = rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
840 int nc = cols (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
841 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
842 FixedMatrix retval (nr, nc); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
843 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
844 for (int j = 0; j < nc; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
845 for (int i = 0; i < nr; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
846 retval (i, j) = ::abs(elem (i, j)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
847 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
848 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
849 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
850 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
851 FixedColumnVector |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
852 FixedMatrix::diag (void) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
853 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
854 return diag (0); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
855 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
856 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
857 FixedColumnVector |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
858 FixedMatrix::diag (int k) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
859 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
860 int nnr = rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
861 int nnc = cols (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
862 if (k > 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
863 nnc -= k; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
864 else if (k < 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
865 nnr += k; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
866 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
867 FixedColumnVector d; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
868 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
869 if (nnr > 0 && nnc > 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
870 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
871 int ndiag = (nnr < nnc) ? nnr : nnc; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
872 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
873 d.resize (ndiag); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
874 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
875 if (k > 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
876 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
877 for (int i = 0; i < ndiag; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
878 d.elem (i) = elem (i, i+k); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
879 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
880 else if ( k < 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
881 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
882 for (int i = 0; i < ndiag; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
883 d.elem (i) = elem (i-k, i); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
884 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
885 else |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
886 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
887 for (int i = 0; i < ndiag; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
888 d.elem (i) = elem (i, i); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
889 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
890 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
891 else |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
892 std::cerr << "diag: requested diagonal out of range\n"; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
893 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
894 return d; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
895 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
896 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
897 FixedColumnVector |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
898 FixedMatrix::row_min (void) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
899 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
900 Array<int> index; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
901 return row_min (index); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
902 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
903 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
904 FixedColumnVector |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
905 FixedMatrix::row_min (Array<int>& index) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
906 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
907 FixedColumnVector result; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
908 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
909 int nr = rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
910 int nc = cols (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
911 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
912 if (nr > 0 && nc > 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
913 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
914 result.resize (nr); |
9481 | 915 index.resize (dim_vector (nr, 1)); |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
916 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
917 for (int i = 0; i < nr; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
918 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
919 int idx_j = 0; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
920 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
921 FixedPoint tmp_min = elem (i, idx_j); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
922 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
923 for (int j = 1; j < nc; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
924 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
925 FixedPoint tmp = elem (i, j); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
926 if (tmp < tmp_min) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
927 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
928 idx_j = j; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
929 tmp_min = tmp; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
930 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
931 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
932 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
933 result.elem (i) = tmp_min; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
934 index.elem (i) = idx_j; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
935 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
936 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
937 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
938 return result; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
939 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
940 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
941 FixedColumnVector |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
942 FixedMatrix::row_max (void) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
943 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
944 Array<int> index; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
945 return row_max (index); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
946 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
947 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
948 FixedColumnVector |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
949 FixedMatrix::row_max (Array<int>& index) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
950 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
951 FixedColumnVector result; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
952 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
953 int nr = rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
954 int nc = cols (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
955 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
956 if (nr > 0 && nc > 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
957 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
958 result.resize (nr); |
9481 | 959 index.resize (dim_vector (nr, 1)); |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
960 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
961 for (int i = 0; i < nr; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
962 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
963 int idx_j = 0; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
964 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
965 FixedPoint tmp_max = elem (i, idx_j); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
966 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
967 for (int j = 1; j < nc; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
968 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
969 FixedPoint tmp = elem (i, j); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
970 if (tmp > tmp_max) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
971 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
972 idx_j = j; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
973 tmp_max = tmp; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
974 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
975 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
976 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
977 result.elem (i) = tmp_max; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
978 index.elem (i) = idx_j; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
979 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
980 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
981 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
982 return result; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
983 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
984 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
985 FixedRowVector |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
986 FixedMatrix::column_min (void) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
987 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
988 Array<int> index; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
989 return column_min (index); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
990 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
991 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
992 FixedRowVector |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
993 FixedMatrix::column_min (Array<int>& index) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
994 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
995 FixedRowVector result; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
996 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
997 int nr = rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
998 int nc = cols (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
999 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1000 if (nr > 0 && nc > 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1001 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1002 result.resize (nc); |
9481 | 1003 index.resize (dim_vector (1, nc)); |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1004 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1005 for (int j = 0; j < nc; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1006 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1007 int idx_i = 0; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1008 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1009 FixedPoint tmp_min = elem (idx_i, j); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1010 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1011 for (int i = 1; i < nr; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1012 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1013 FixedPoint tmp = elem (i, j); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1014 if (tmp < tmp_min) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1015 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1016 idx_i = i; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1017 tmp_min = tmp; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1018 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1019 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1020 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1021 result.elem (j) = tmp_min; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1022 index.elem (j) = idx_i; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1023 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1024 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1025 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1026 return result; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1027 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1028 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1029 FixedRowVector |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1030 FixedMatrix::column_max (void) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1031 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1032 Array<int> index; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1033 return column_max (index); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1034 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1035 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1036 FixedRowVector |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1037 FixedMatrix::column_max (Array<int>& index) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1038 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1039 FixedRowVector result; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1040 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1041 int nr = rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1042 int nc = cols (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1043 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1044 if (nr > 0 && nc > 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1045 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1046 result.resize (nc); |
9481 | 1047 index.resize (dim_vector (1, nc)); |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1048 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1049 for (int j = 0; j < nc; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1050 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1051 int idx_i = 0; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1052 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1053 FixedPoint tmp_max = elem (idx_i, j); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1054 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1055 for (int i = 1; i < nr; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1056 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1057 FixedPoint tmp = elem (i, j); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1058 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1059 if (tmp > tmp_max) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1060 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1061 idx_i = i; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1062 tmp_max = tmp; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1063 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1064 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1065 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1066 result.elem (j) = tmp_max; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1067 index.elem (j) = idx_i; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1068 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1069 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1070 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1071 return result; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1072 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1073 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1074 #define DO_FIXED_MAT_FUNC(FUNC) \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1075 FixedMatrix FUNC (const FixedMatrix& x) \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1076 { \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1077 FixedMatrix retval ( x.rows(), x.cols()); \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1078 for (int j = 0; j < x.cols(); j++) \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1079 for (int i = 0; i < x.rows(); i++) \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1080 retval(i,j) = FUNC ( x (i,j) ); \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1081 return retval; \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1082 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1083 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1084 DO_FIXED_MAT_FUNC(real); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1085 DO_FIXED_MAT_FUNC(imag); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1086 DO_FIXED_MAT_FUNC(conj); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1087 DO_FIXED_MAT_FUNC(abs); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1088 DO_FIXED_MAT_FUNC(cos); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1089 DO_FIXED_MAT_FUNC(cosh); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1090 DO_FIXED_MAT_FUNC(sin); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1091 DO_FIXED_MAT_FUNC(sinh); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1092 DO_FIXED_MAT_FUNC(tan); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1093 DO_FIXED_MAT_FUNC(tanh); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1094 DO_FIXED_MAT_FUNC(sqrt); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1095 DO_FIXED_MAT_FUNC(exp); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1096 DO_FIXED_MAT_FUNC(log); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1097 DO_FIXED_MAT_FUNC(log10); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1098 DO_FIXED_MAT_FUNC(round); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1099 DO_FIXED_MAT_FUNC(rint); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1100 DO_FIXED_MAT_FUNC(floor); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1101 DO_FIXED_MAT_FUNC(ceil); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1102 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1103 FixedMatrix elem_pow (const FixedMatrix &a, const FixedMatrix &b) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1104 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1105 FixedMatrix retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1106 int a_nr = a.rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1107 int a_nc = a.cols (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1108 int b_nr = b.rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1109 int b_nc = b.cols (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1110 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1111 if (a_nr == 1 && a_nc == 1) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1112 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1113 retval.resize(b_nr,b_nc); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1114 FixedPoint ad = a(0,0); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1115 for (int j = 0; j < b_nc; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1116 for (int i = 0; i < b_nr; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1117 retval(i,j) = pow(ad, b(i,j)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1118 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1119 else if (b_nr == 1 && b_nc == 1) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1120 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1121 retval.resize(a_nr,a_nc); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1122 FixedPoint bd = b(0,0); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1123 for (int j = 0; j < a_nc; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1124 for (int i = 0; i < a_nr; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1125 retval(i,j) = pow(a(i,j), bd); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1126 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1127 else if ((a_nr == b_nr) && (a_nc == b_nc)) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1128 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1129 retval.resize(a_nr,a_nc); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1130 for (int j = 0; j < a_nc; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1131 for (int i = 0; i < a_nr; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1132 retval(i,j) = pow(a(i,j), b(i,j)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1133 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1134 else |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1135 gripe_nonconformant ("operator .^", a_nr, a_nc, a_nr, a_nc); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1136 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1137 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1138 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1139 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1140 FixedMatrix elem_pow (const FixedMatrix &a, const FixedPoint &b) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1141 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1142 return elem_pow (a, FixedMatrix(1, 1, b)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1143 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1144 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1145 FixedMatrix elem_pow (const FixedPoint &a, const FixedMatrix &b) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1146 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1147 return elem_pow (FixedMatrix(1, 1, a), b); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1148 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1149 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1150 FixedMatrix pow (const FixedMatrix& a, int b) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1151 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1152 FixedMatrix retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1153 int nr = a.rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1154 int nc = a.cols (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1155 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1156 if (nr == 0 || nc == 0 || nr != nc) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1157 (*current_liboctave_error_handler) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1158 ("for A^x, A must be square and x scalar"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1159 else if (b == 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1160 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1161 retval = a; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1162 for (int j = 0; j < nc; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1163 for (int i = 0; i < nr; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1164 retval(i,j) = |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1165 FixedPoint(a(i,j).getintsize(), a(i,j).getdecsize(), 1, 0); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1166 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1167 else |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1168 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1169 if (b < 0 ) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1170 (*current_liboctave_error_handler) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1171 ("can not treat matrix inversion"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1172 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1173 FixedMatrix atmp (a); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1174 retval = atmp; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1175 b--; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1176 while (b > 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1177 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1178 if (b & 1) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1179 retval = retval * atmp; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1180 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1181 b >>= 1; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1182 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1183 if (b > 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1184 atmp = atmp * atmp; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1185 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1186 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1187 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1188 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1189 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1190 FixedMatrix pow (const FixedMatrix &a, const double b) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1191 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1192 int bi = (int)b; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1193 if ((double)bi != b) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1194 (*current_liboctave_error_handler) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1195 ("can only treat integer powers of a matrix"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1196 return FixedMatrix(); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1197 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1198 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1199 return pow(a, bi); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1200 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1201 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1202 FixedMatrix pow (const FixedMatrix &a, const FixedPoint &b) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1203 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1204 return pow(a, b.fixedpoint()); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1205 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1206 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1207 FixedMatrix pow (const FixedMatrix &a, const FixedMatrix &b) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1208 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1209 if (a.rows() == 0 || a.rows() == 0 || a.rows() != a.rows() || |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1210 b.rows() != 1 || b.cols() != 1) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1211 (*current_liboctave_error_handler) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1212 ("for A^x, A must be square and x scalar"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1213 return FixedMatrix(); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1214 } else |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1215 return pow(a, b(0,0).fixedpoint()); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1216 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1217 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1218 FixedMatrix atan2 (const FixedMatrix &x, const FixedMatrix &y) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1219 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1220 FixedMatrix retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1221 if ((x.rows() == y.rows()) && (x.cols() == y.cols())) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1222 retval.resize(x.rows(),x.cols()); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1223 for (int j = 0; j < x.cols(); j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1224 for (int i = 0; i < x.rows(); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1225 retval(i,j) = atan2 ( x(i,j), y(i,j)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1226 } else |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1227 (*current_liboctave_error_handler) ("matrix size mismatch"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1228 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1229 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1230 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1231 std::ostream& |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1232 operator << (std::ostream& os, const FixedMatrix& a) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1233 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1234 for (int i = 0; i < a.rows (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1235 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1236 for (int j = 0; j < a.cols (); j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1237 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1238 os << " " << a.elem(i,j); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1239 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1240 os << "\n"; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1241 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1242 return os; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1243 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1244 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1245 std::istream& |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1246 operator >> (std::istream& is, FixedMatrix& a) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1247 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1248 int nr = a.rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1249 int nc = a.cols (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1250 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1251 if (nr < 1 || nc < 1) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1252 is.clear (std::ios::badbit); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1253 else |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1254 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1255 FixedPoint tmp; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1256 for (int i = 0; i < nr; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1257 for (int j = 0; j < nc; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1258 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1259 is >> tmp; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1260 if (is) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1261 a.elem (i, j) = tmp; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1262 else |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1263 goto done; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1264 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1265 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1266 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1267 done: |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1268 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1269 return is; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1270 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1271 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1272 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1273 operator * (const FixedMatrix& a, const FixedMatrix& b) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1274 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1275 FixedMatrix retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1276 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1277 int a_nr = a.rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1278 int a_nc = a.cols (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1279 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1280 int b_nr = b.rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1281 int b_nc = b.cols (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1282 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1283 if (a_nc != b_nr) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1284 gripe_nonconformant ("operator *", a_nr, a_nc, b_nr, b_nc); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1285 else |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1286 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1287 retval.resize (a_nr, b_nc, FixedPoint()); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1288 if (a_nr != 0 && a_nc != 0 && b_nc != 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1289 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1290 for (int j = 0; j < b_nr; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1291 for (int i = 0; i < b_nc; i++) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1292 FixedPoint tmp = b.elem(j,i); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1293 for (int k = 0; k < a_nr; k++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1294 retval.elem (k,i) += a.elem(k,j) * tmp; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1295 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1296 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1297 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1298 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1299 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1300 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1301 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1302 // XXX FIXME XXX -- it would be nice to share code among the min/max |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1303 // functions below. |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1304 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1305 #define EMPTY_RETURN_CHECK(T) \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1306 if (nr == 0 || nc == 0) \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1307 return T (nr, nc); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1308 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1309 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1310 min (FixedPoint d, const FixedMatrix& m) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1311 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1312 int nr = m.rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1313 int nc = m.columns (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1314 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1315 EMPTY_RETURN_CHECK (FixedMatrix); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1316 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1317 FixedMatrix result (nr, nc); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1318 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1319 for (int j = 0; j < nc; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1320 for (int i = 0; i < nr; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1321 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1322 OCTAVE_QUIT; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1323 result (i, j) = m(i,j) < d ? m(i,j) : d; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1324 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1325 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1326 return result; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1327 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1328 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1329 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1330 min (const FixedMatrix& m, FixedPoint d) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1331 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1332 int nr = m.rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1333 int nc = m.columns (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1334 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1335 EMPTY_RETURN_CHECK (FixedMatrix); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1336 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1337 FixedMatrix result (nr, nc); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1338 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1339 for (int j = 0; j < nc; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1340 for (int i = 0; i < nr; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1341 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1342 OCTAVE_QUIT; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1343 result (i, j) = m(i,j) < d ? m(i,j) : d; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1344 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1345 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1346 return result; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1347 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1348 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1349 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1350 min (const FixedMatrix& a, const FixedMatrix& b) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1351 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1352 int nr = a.rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1353 int nc = a.columns (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1354 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1355 if (nr != b.rows () || nc != b.columns ()) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1356 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1357 (*current_liboctave_error_handler) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1358 ("two-arg min expecting args of same size"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1359 return FixedMatrix (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1360 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1361 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1362 EMPTY_RETURN_CHECK (FixedMatrix); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1363 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1364 FixedMatrix result (nr, nc); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1365 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1366 for (int j = 0; j < nc; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1367 for (int i = 0; i < nr; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1368 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1369 OCTAVE_QUIT; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1370 result (i, j) = a(i,j) < b(i,j) ? a(i,j) : b(i,j); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1371 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1372 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1373 return result; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1374 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1375 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1376 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1377 max (FixedPoint d, const FixedMatrix& m) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1378 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1379 int nr = m.rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1380 int nc = m.columns (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1381 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1382 EMPTY_RETURN_CHECK (FixedMatrix); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1383 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1384 FixedMatrix result (nr, nc); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1385 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1386 for (int j = 0; j < nc; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1387 for (int i = 0; i < nr; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1388 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1389 OCTAVE_QUIT; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1390 result (i, j) = m(i,j) > d ? m(i,j) : d; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1391 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1392 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1393 return result; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1394 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1395 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1396 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1397 max (const FixedMatrix& m, FixedPoint d) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1398 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1399 int nr = m.rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1400 int nc = m.columns (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1401 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1402 EMPTY_RETURN_CHECK (FixedMatrix); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1403 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1404 FixedMatrix result (nr, nc); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1405 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1406 for (int j = 0; j < nc; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1407 for (int i = 0; i < nr; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1408 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1409 OCTAVE_QUIT; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1410 result (i, j) = m(i,j) > d ? m(i,j) : d; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1411 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1412 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1413 return result; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1414 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1415 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1416 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1417 max (const FixedMatrix& a, const FixedMatrix& b) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1418 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1419 int nr = a.rows (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1420 int nc = a.columns (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1421 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1422 if (nr != b.rows () || nc != b.columns ()) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1423 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1424 (*current_liboctave_error_handler) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1425 ("two-arg max expecting args of same size"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1426 return FixedMatrix (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1427 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1428 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1429 EMPTY_RETURN_CHECK (FixedMatrix); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1430 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1431 FixedMatrix result (nr, nc); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1432 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1433 for (int j = 0; j < nc; j++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1434 for (int i = 0; i < nr; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1435 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1436 OCTAVE_QUIT; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1437 result (i, j) = a(i,j) > b(i,j) ? a(i,j) : b(i,j); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1438 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1439 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1440 return result; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1441 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1442 |
9481 | 1443 MS_CMP_OPS(FixedMatrix, FixedPoint) |
1444 MS_BOOL_OPS(FixedMatrix, FixedPoint) | |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1445 |
9481 | 1446 SM_CMP_OPS(FixedPoint, FixedMatrix) |
1447 SM_BOOL_OPS(FixedPoint, FixedMatrix) | |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1448 |
9481 | 1449 MM_CMP_OPS(FixedMatrix, FixedMatrix) |
1450 MM_BOOL_OPS(FixedMatrix, FixedMatrix) | |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1451 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1452 /* |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1453 ;;; Local Variables: *** |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1454 ;;; mode: C++ *** |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1455 ;;; End: *** |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
1456 */ |