Mercurial > forge
annotate main/fixed/src/fixedNDArray.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) 2004 Motorola Inc |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
4 Copyright (C) 2004 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/dNDArray.h> |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
35 #include <octave/CNDArray.h> |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
36 #include <octave/gripes.h> |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
37 #include <octave/ops.h> |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
38 #include <octave/quit.h> |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
39 |
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 "fixedNDArray.h" |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
42 #include "fixedCNDArray.h" |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
43 |
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:
4404
diff
changeset
|
44 #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:
4404
diff
changeset
|
45 |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
46 // Fixed Point NDArray class. |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
47 |
9481 | 48 FixedNDArray::FixedNDArray (const MArray<int> &is, const MArray<int> &ds) |
49 : MArray<FixedPoint> (is.dims()) | |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
50 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
51 if (dims () != ds.dims ()) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
52 (*current_liboctave_error_handler) ("NDArray size mismatch"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
53 return; |
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 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
56 for (int i = 0; i < nelem (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
57 elem (i) = FixedPoint((unsigned int)is(i), (unsigned int)ds(i)); |
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 FixedNDArray::FixedNDArray (const NDArray &is, const NDArray &ds) |
9481 | 62 : MArray<FixedPoint> (is.dims()) |
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 (dims () != ds.dims ()) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
65 (*current_liboctave_error_handler) ("NDArray 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 i = 0; i < nelem (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
70 elem (i) = FixedPoint((unsigned int)is(i), (unsigned int)ds(i)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
71 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
72 |
9481 | 73 FixedNDArray::FixedNDArray (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
|
74 const FixedNDArray& a) |
9481 | 75 : MArray<FixedPoint> (a.dims()) |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
76 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
77 if ((dims () != is.dims ()) || (dims () != ds.dims ())) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
78 (*current_liboctave_error_handler) ("NDArray size mismatch"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
79 return; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
80 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
81 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
82 for (int i = 0; i < nelem (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
83 elem (i) = FixedPoint((unsigned int)is(i), (unsigned int)ds(i), |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
84 a.elem (i)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
85 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
86 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
87 FixedNDArray::FixedNDArray (const NDArray &is, const NDArray &ds, |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
88 const FixedNDArray& a) |
9481 | 89 : MArray<FixedPoint> (a.dims()) |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
90 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
91 if ((dims () != is.dims ()) || (dims () != ds.dims ())) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
92 (*current_liboctave_error_handler) ("NDArray size mismatch"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
93 return; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
94 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
95 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
96 for (int i = 0; i < nelem (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
97 elem (i) = FixedPoint((unsigned int)is(i), (unsigned int)ds(i), |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
98 a.elem (i)); |
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 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
101 FixedNDArray::FixedNDArray (unsigned int is, unsigned int ds, |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
102 const FixedNDArray& a) |
9481 | 103 : MArray<FixedPoint> (a.dims()) |
2383
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 for (int i = 0; i < nelem (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
106 elem (i) = FixedPoint(is, ds, a.elem (i)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
107 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
108 |
9481 | 109 FixedNDArray::FixedNDArray (const MArray<int> &is, |
110 const MArray<int> &ds, | |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
111 const NDArray& a) |
9481 | 112 : MArray<FixedPoint> (a.dims()) |
2383
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 if ((dims () != is.dims ()) || (dims () != ds.dims ())) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
115 (*current_liboctave_error_handler) ("NDArray size mismatch"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
116 return; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
117 } |
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 for (int i = 0; i < nelem (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
120 elem (i) = FixedPoint((unsigned int)is(i), (unsigned int)ds(i), |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
121 a.elem (i)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
122 } |
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 FixedNDArray::FixedNDArray (const NDArray &is, const NDArray &ds, |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
125 const NDArray& a) |
9481 | 126 : MArray<FixedPoint> (a.dims()) |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
127 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
128 if ((dims () != is.dims ()) || (dims () != ds.dims ())) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
129 (*current_liboctave_error_handler) ("NDArray size mismatch"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
130 return; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
131 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
132 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
133 for (int i = 0; i < nelem (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
134 elem (i) = FixedPoint((unsigned int)is(i), (unsigned int)ds(i), |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
135 a.elem (i)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
136 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
137 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
138 FixedNDArray::FixedNDArray (unsigned int is, unsigned int ds, |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
139 const NDArray& a) |
9481 | 140 : MArray<FixedPoint> (a.dims()) |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
141 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
142 for (int i = 0; i < nelem (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
143 elem (i) = FixedPoint(is, ds, a.elem (i)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
144 } |
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 FixedNDArray::FixedNDArray (unsigned int is, unsigned int ds, |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
147 const NDArray& a, const NDArray& b) |
9481 | 148 : MArray<FixedPoint> (a.dims()) |
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 if (dims() != b.dims()) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
151 (*current_liboctave_error_handler) ("NDArray size mismatch"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
152 return; |
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 for (int i = 0; i < nelem (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
156 elem (i) = FixedPoint(is, ds, (unsigned int)a.elem (i), |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
157 (unsigned int)b.elem (i)); |
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 |
9481 | 160 FixedNDArray::FixedNDArray (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
|
161 const NDArray& a, const NDArray& b) |
9481 | 162 : MArray<FixedPoint> (a.dims()) |
2383
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 if ((dims() != b.dims()) || (dims() != is.dims()) || |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
165 (dims() != ds.dims())) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
166 (*current_liboctave_error_handler) ("NDArray size mismatch"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
167 return; |
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 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
170 for (int i = 0; i < nelem (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
171 elem (i) = FixedPoint((unsigned int)is(i), (unsigned int)ds(i), |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
172 (unsigned int)a.elem (i), |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
173 (unsigned int)b.elem (i)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
174 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
175 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
176 FixedNDArray::FixedNDArray (const NDArray &is, const NDArray &ds, |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
177 const NDArray& a, const NDArray& b) |
9481 | 178 : MArray<FixedPoint> (a.dims()) |
2383
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 if ((dims() != b.dims()) || (dims() != is.dims()) || |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
181 (dims() != ds.dims())) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
182 (*current_liboctave_error_handler) ("NDArray size mismatch"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
183 return; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
184 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
185 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
186 for (octave_idx_type i = 0; i < nelem (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
187 elem (i) = FixedPoint((unsigned int)is(i), (unsigned int)ds(i), |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
188 (unsigned int)a.elem (i), |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
189 (unsigned int)b.elem (i)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
190 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
191 |
9481 | 192 FixedNDArray::FixedNDArray (const MArray<int> &a) |
193 : MArray<FixedPoint> (a.dims()) | |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
194 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
195 for (octave_idx_type i = 0; i < nelem (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
196 elem (i) = FixedPoint(a.elem (i)); |
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 FixedNDArray::FixedNDArray (const NDArray &a) |
9481 | 200 : MArray<FixedPoint> (a.dims()) |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
201 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
202 for (octave_idx_type i = 0; i < nelem (); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
203 elem (i) = FixedPoint(a.elem (i)); |
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 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
206 #define GET_FIXED_PROP(METHOD) \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
207 NDArray \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
208 FixedNDArray:: METHOD (void) const \ |
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 int nel = nelem(); \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
211 NDArray retval(dims()); \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
212 for (int i = 0; i < nel; i++) \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
213 retval(i) = (double) elem(i) . METHOD (); \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
214 return retval; \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
215 } \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
216 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
217 GET_FIXED_PROP(sign); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
218 GET_FIXED_PROP(signbit); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
219 GET_FIXED_PROP(getdecsize); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
220 GET_FIXED_PROP(getintsize); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
221 GET_FIXED_PROP(getnumber); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
222 GET_FIXED_PROP(fixedpoint); |
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 #undef GET_FIXED_PROP |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
225 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
226 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
227 FixedNDArray::chdecsize (const double n) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
228 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
229 int nel = nelem(); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
230 FixedNDArray retval(dims()); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
231 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
232 for (int i = 0; i < nel; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
233 retval(i) = FixedPoint(elem(i).getintsize(), (int)n, elem(i)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
234 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
235 return retval; |
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 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
239 FixedNDArray::chdecsize (const NDArray &n) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
240 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
241 int nel = nelem(); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
242 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
243 if (dims() != n.dims()) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
244 (*current_liboctave_error_handler) ("NDArray size mismatch in chdecsize"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
245 return FixedNDArray(); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
246 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
247 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
248 FixedNDArray retval(dims()); |
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 for (int i = 0; i < nel; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
251 retval(i) = FixedPoint(elem(i).getintsize(), (int)n(i), elem(i)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
252 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
253 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
254 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
255 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
256 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
257 FixedNDArray::chintsize (const double n) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
258 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
259 int nel = nelem(); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
260 FixedNDArray retval(dims()); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
261 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
262 for (int i = 0; i < nel; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
263 retval(i) = FixedPoint((int)n, elem(i).getdecsize(), elem(i)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
264 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
265 return retval; |
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 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
268 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
269 FixedNDArray::chintsize (const NDArray &n) |
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 int nel = nelem(); |
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 if (dims() != n.dims()) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
274 (*current_liboctave_error_handler) ("NDArray size mismatch in chintsize"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
275 return FixedNDArray(); |
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 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
278 FixedNDArray retval(dims()); |
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 for (int i = 0; i < nel; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
281 retval(i) = FixedPoint((int)n(i), elem(i).getdecsize(), elem(i)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
282 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
283 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
284 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
285 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
286 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
287 FixedNDArray::incdecsize (const double n) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
288 return chdecsize(n + getdecsize()); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
289 } |
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 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
292 FixedNDArray::incdecsize (const NDArray &n) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
293 if (dims() != n.dims()) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
294 (*current_liboctave_error_handler) ("NDArray size mismatch in chintsize"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
295 return FixedNDArray(); |
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 return chdecsize(n + getdecsize()); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
298 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
299 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
300 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
301 FixedNDArray::incdecsize () { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
302 return chdecsize(1 + getdecsize()); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
303 } |
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 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
306 FixedNDArray::incintsize (const double n) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
307 return chintsize(n + getintsize()); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
308 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
309 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
310 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
311 FixedNDArray::incintsize (const NDArray &n) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
312 if (dims() != n.dims()) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
313 (*current_liboctave_error_handler) ("NDArray size mismatch in chintsize"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
314 return FixedNDArray(); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
315 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
316 return chintsize(n + getintsize()); |
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 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
319 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
320 FixedNDArray::incintsize () { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
321 return chintsize(1 + getintsize()); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
322 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
323 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
324 bool |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
325 FixedNDArray::operator == (const FixedNDArray& a) const |
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 if (dims () != a.dims ()) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
328 return false; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
329 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
330 for (int i = 0; i < nelem(); i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
331 if (elem(i) != a.elem(i)) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
332 return false; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
333 return true; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
334 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
335 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
336 bool |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
337 FixedNDArray::operator != (const FixedNDArray& a) const |
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 !(*this != a); |
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 // unary operations |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
343 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
344 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
345 FixedNDArray::operator ! (void) const |
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 int nel = nelem (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
348 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
349 FixedNDArray b (dims()); |
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 for (int i = 0; i < nel; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
352 b.elem (i) = ! elem (i); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
353 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
354 return b; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
355 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
356 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
357 // other operations. |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
358 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
359 boolNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
360 FixedNDArray::all (octave_idx_type dim) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
361 { |
9481 | 362 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
|
363 } |
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 boolNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
366 FixedNDArray::any (octave_idx_type dim) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
367 { |
9481 | 368 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
|
369 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
370 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
371 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
372 FixedNDArray::cumprod (octave_idx_type dim) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
373 { |
9481 | 374 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
|
375 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
376 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
377 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
378 FixedNDArray::cumsum (octave_idx_type dim) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
379 { |
9481 | 380 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
|
381 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
382 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
383 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
384 FixedNDArray::prod (octave_idx_type dim) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
385 { |
9481 | 386 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
|
387 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
388 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
389 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
390 FixedNDArray::sum (octave_idx_type dim) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
391 { |
9481 | 392 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
|
393 } |
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 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
396 FixedNDArray::sumsq (octave_idx_type dim) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
397 { |
9481 | 398 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
|
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 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
402 FixedNDArray::max (octave_idx_type dim) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
403 { |
9481 | 404 return do_mx_minmax_op<FixedPoint> (*this, dim, mx_inline_max); |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
405 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
406 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
407 FixedNDArray |
9481 | 408 FixedNDArray::max (Array<octave_idx_type>& idx_arg, octave_idx_type dim) const |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
409 { |
9481 | 410 return do_mx_minmax_op<FixedPoint> (*this, idx_arg, dim, mx_inline_max); |
2383
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 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
413 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
414 FixedNDArray::min (octave_idx_type dim) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
415 { |
9481 | 416 return do_mx_minmax_op<FixedPoint> (*this, dim, mx_inline_min); |
2383
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 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
419 FixedNDArray |
9481 | 420 FixedNDArray::min (Array<octave_idx_type>& idx_arg, octave_idx_type dim) const |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
421 { |
9481 | 422 return do_mx_minmax_op<FixedPoint> (*this, idx_arg, dim, mx_inline_min); |
2383
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 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
426 FixedNDArray::abs (void) const |
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 octave_idx_type nel = nelem (); |
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 FixedNDArray retval (dims()); |
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 for (octave_idx_type i = 0; i < nel; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
433 retval (i) = ::abs(elem (i)); |
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 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
436 } |
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 FixedMatrix |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
439 FixedNDArray::fixed_matrix_value (void) const |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
440 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
441 FixedMatrix retval; |
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 octave_idx_type nd = ndims (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
444 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
445 switch (nd) |
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 case 1: |
9481 | 448 retval = FixedMatrix (Array<FixedPoint> (*this, dim_vector (dimensions(0), 1))); |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
449 break; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
450 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
451 case 2: |
9481 | 452 retval = FixedMatrix (Array<FixedPoint> (*this, dim_vector (dimensions(0), |
453 dimensions(1)))); | |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
454 break; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
455 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
456 default: |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
457 (*current_liboctave_error_handler) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
458 ("invalid conversion of FixedNDArray to FixedMatrix"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
459 break; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
460 } |
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 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
463 } |
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 #define DO_FIXED_ND_FUNC(FUNC) \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
466 FixedNDArray FUNC (const FixedNDArray& x) \ |
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 octave_idx_type nel = x.nelem (); \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
469 FixedNDArray retval ( x.dims()); \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
470 for (octave_idx_type i = 0; i < nel; i++) \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
471 retval(i) = FUNC ( x (i) ); \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
472 return retval; \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
473 } |
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 DO_FIXED_ND_FUNC(real); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
476 DO_FIXED_ND_FUNC(imag); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
477 DO_FIXED_ND_FUNC(conj); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
478 DO_FIXED_ND_FUNC(abs); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
479 DO_FIXED_ND_FUNC(cos); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
480 DO_FIXED_ND_FUNC(cosh); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
481 DO_FIXED_ND_FUNC(sin); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
482 DO_FIXED_ND_FUNC(sinh); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
483 DO_FIXED_ND_FUNC(tan); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
484 DO_FIXED_ND_FUNC(tanh); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
485 DO_FIXED_ND_FUNC(sqrt); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
486 DO_FIXED_ND_FUNC(exp); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
487 DO_FIXED_ND_FUNC(log); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
488 DO_FIXED_ND_FUNC(log10); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
489 DO_FIXED_ND_FUNC(round); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
490 DO_FIXED_ND_FUNC(rint); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
491 DO_FIXED_ND_FUNC(floor); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
492 DO_FIXED_ND_FUNC(ceil); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
493 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
494 FixedNDArray elem_pow (const FixedNDArray &a, const FixedNDArray &b) |
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 FixedNDArray retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
497 dim_vector a_dv = a.dims (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
498 int a_nel = a.numel (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
499 dim_vector b_dv = b.dims (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
500 int b_nel = b.numel (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
501 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
502 if (a_nel == 1) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
503 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
504 retval.resize(b_dv); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
505 FixedPoint ad = a(0); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
506 for (int i = 0; i < b_nel; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
507 retval(i) = pow(ad, b(i)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
508 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
509 else if (b_nel == 1) |
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 retval.resize(a_dv); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
512 FixedPoint bd = b(0); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
513 for (int i = 0; i < a_nel; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
514 retval(i) = pow(a(i), bd); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
515 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
516 else if (a_dv == b_dv) |
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 retval.resize(a_dv); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
519 for (int i = 0; i < a_nel; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
520 retval(i) = pow(a(i), b(i)); |
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 else |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
523 gripe_nonconformant ("operator .^", a_dv, b_dv); |
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 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
526 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
527 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
528 FixedNDArray elem_pow (const FixedNDArray &a, const FixedPoint &b) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
529 { |
9481 | 530 return elem_pow (a, FixedNDArray(dim_vector (1, 1), b)); |
2383
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 FixedNDArray elem_pow (const FixedPoint &a, const FixedNDArray &b) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
534 { |
9481 | 535 return elem_pow (FixedNDArray(dim_vector (1, 1), a), b); |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
536 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
537 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
538 FixedNDArray atan2 (const FixedNDArray &x, const FixedNDArray &y) |
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 FixedNDArray retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
541 if (x.dims() == y.dims()) { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
542 int nel = x.nelem (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
543 retval.resize(x.dims()); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
544 for (int i = 0; i < nel; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
545 retval(i) = atan2 ( x(i), y(i)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
546 } else |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
547 (*current_liboctave_error_handler) ("NDArray size mismatch"); |
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 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
552 FixedNDArray::concat (const FixedNDArray& rb, const Array<octave_idx_type>& ra_idx) |
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 if (rb.numel () > 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
555 insert (rb, ra_idx); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
556 return *this; |
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 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
559 FixedComplexNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
560 FixedNDArray::concat (const FixedComplexNDArray& rb, |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
561 const Array<octave_idx_type>& ra_idx) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
562 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
563 FixedComplexNDArray retval (*this); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
564 if (rb.numel () > 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
565 retval.insert (rb, ra_idx); |
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 FixedNDArray& |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
570 FixedNDArray::insert (const FixedNDArray& a, const Array<octave_idx_type>& ra_idx) |
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 Array<FixedPoint>::insert (a, ra_idx); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
573 return *this; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
574 } |
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 void |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
577 FixedNDArray::increment_index (Array<octave_idx_type>& ra_idx, |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
578 const dim_vector& dimensions, |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
579 octave_idx_type start_dimension) |
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 ::increment_index (ra_idx, dimensions, start_dimension); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
582 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
583 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
584 octave_idx_type |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
585 FixedNDArray::compute_index (Array<octave_idx_type>& ra_idx, |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
586 const dim_vector& dimensions) |
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 return ::compute_index (ra_idx, dimensions); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
589 } |
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 std::ostream& |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
592 operator << (std::ostream& os, const FixedNDArray& a) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
593 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
594 int nel = a.nelem (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
595 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
596 for (int i = 0; i < nel; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
597 os << " " << a.elem(i) << "\n"; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
598 return os; |
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 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
601 std::istream& |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
602 operator >> (std::istream& is, FixedNDArray& a) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
603 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
604 int nel = a.nelem (); |
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 if (nel < 1 ) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
607 is.clear (std::ios::badbit); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
608 else |
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 FixedPoint tmp; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
611 for (int i = 0; i < nel; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
612 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
613 is >> tmp; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
614 if (is) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
615 a.elem (i) = tmp; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
616 else |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
617 goto done; |
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 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
620 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
621 done: |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
622 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
623 return is; |
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 // 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
|
627 // functions below. |
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 #define EMPTY_RETURN_CHECK(T) \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
630 if (nel == 0) \ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
631 return T (dv); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
632 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
633 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
634 min (FixedPoint d, const FixedNDArray& m) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
635 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
636 dim_vector dv = m.dims (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
637 int nel = dv.numel (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
638 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
639 EMPTY_RETURN_CHECK (FixedNDArray); |
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 FixedNDArray result (dv); |
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 for (int i = 0; i < nel; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
644 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
645 OCTAVE_QUIT; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
646 result (i) = m(i) < d ? m(i) : d; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
647 } |
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 return result; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
650 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
651 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
652 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
653 min (const FixedNDArray& m, FixedPoint d) |
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 dim_vector dv = m.dims (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
656 int nel = dv.numel (); |
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 EMPTY_RETURN_CHECK (FixedNDArray); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
659 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
660 FixedNDArray result (dv); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
661 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
662 for (int i = 0; i < nel; i++) |
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 OCTAVE_QUIT; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
665 result (i) = m(i) < d ? m(i) : d; |
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 return result; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
669 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
670 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
671 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
672 min (const FixedNDArray& a, const FixedNDArray& b) |
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 dim_vector dv = a.dims (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
675 int nel = dv.numel (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
676 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
677 if (dv != b.dims ()) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
678 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
679 (*current_liboctave_error_handler) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
680 ("two-arg min expecting args of same size"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
681 return FixedNDArray (); |
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 EMPTY_RETURN_CHECK (FixedNDArray); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
685 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
686 FixedNDArray result (dv); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
687 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
688 for (int i = 0; i < nel; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
689 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
690 OCTAVE_QUIT; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
691 result (i) = a(i) < b(i) ? a(i) : b(i); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
692 } |
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 return result; |
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 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
697 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
698 max (FixedPoint d, const FixedNDArray& m) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
699 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
700 dim_vector dv = m.dims (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
701 int nel = dv.numel (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
702 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
703 EMPTY_RETURN_CHECK (FixedNDArray); |
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 FixedNDArray result (dv); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
706 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
707 for (int i = 0; i < nel; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
708 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
709 OCTAVE_QUIT; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
710 result (i) = m(i) > d ? m(i) : d; |
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 return result; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
714 } |
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 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
717 max (const FixedNDArray& m, FixedPoint d) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
718 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
719 dim_vector dv = m.dims (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
720 int nel = dv.numel (); |
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 EMPTY_RETURN_CHECK (FixedNDArray); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
723 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
724 FixedNDArray result (dv); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
725 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
726 for (int i = 0; i < nel; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
727 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
728 OCTAVE_QUIT; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
729 result (i) = m(i) > d ? m(i) : d; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
730 } |
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 return result; |
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 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
735 FixedNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
736 max (const FixedNDArray& a, const FixedNDArray& b) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
737 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
738 dim_vector dv = a.dims (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
739 int nel = dv.numel (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
740 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
741 if (dv != b.dims ()) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
742 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
743 (*current_liboctave_error_handler) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
744 ("two-arg min expecting args of same size"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
745 return FixedNDArray (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
746 } |
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 EMPTY_RETURN_CHECK (FixedNDArray); |
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 FixedNDArray result (dv); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
751 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
752 for (int i = 0; i < nel; i++) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
753 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
754 OCTAVE_QUIT; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
755 result (i) = a(i) > b(i) ? a(i) : b(i); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
756 } |
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 return result; |
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 |
9481 | 761 NDS_CMP_OPS(FixedNDArray, FixedPoint) |
762 NDS_BOOL_OPS(FixedNDArray, FixedPoint) | |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
763 |
9481 | 764 SND_CMP_OPS(FixedPoint, FixedNDArray) |
765 SND_BOOL_OPS(FixedPoint, FixedNDArray) | |
2383
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
766 |
9481 | 767 NDND_CMP_OPS(FixedNDArray, FixedNDArray) |
768 NDND_BOOL_OPS(FixedNDArray, FixedNDArray) | |
2383
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 ;;; Local Variables: *** |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
772 ;;; mode: C++ *** |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
773 ;;; End: *** |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
774 */ |