annotate main/fixed/src/fixedNDArray.cc @ 2383:d1930f8af7ca octave-forge

Changed the directory structure of fixed to match the package system
author hauberg
date Sun, 20 Aug 2006 14:43:38 +0000
parents
children 1728eb2120ef
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
17 along with this program; see the file COPYING. If not, write to the Free
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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 #ifdef HAVE_ND_ARRAYS
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 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
29 #pragma implementation
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
30 #endif
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
31
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
32 #include <iostream>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
33
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
34 #include <octave/config.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
35 #include <octave/lo-error.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
36 #include <octave/lo-utils.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
37 #include <octave/lo-error.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
38 #include <octave/error.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
39 #include <octave/dMatrix.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
40 #include <octave/dNDArray.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
41 #include <octave/CNDArray.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
42 #include <octave/gripes.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
43 #include <octave/ops.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
44
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
45 #ifdef NEED_OCTAVE_QUIT
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
46 #define OCTAVE_QUIT do {} while (0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
47 #else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
48 #include <octave/quit.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
49 #endif
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 #include "fixedMatrix.h"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
52 #include "fixedNDArray.h"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
53 #include "fixedCNDArray.h"
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 // Fixed Point NDArray class.
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
56
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
57 FixedNDArray::FixedNDArray (const MArrayN<int> &is, const MArrayN<int> &ds)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
58 : MArrayN<FixedPoint> (is.dims())
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 if (dims () != ds.dims ()) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
61 (*current_liboctave_error_handler) ("NDArray size mismatch");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
62 return;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
65 for (int i = 0; i < nelem (); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
66 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
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
70 FixedNDArray::FixedNDArray (const NDArray &is, const NDArray &ds)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
71 : MArrayN<FixedPoint> (is.dims())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
72 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
73 if (dims () != ds.dims ()) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
74 (*current_liboctave_error_handler) ("NDArray size mismatch");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
75 return;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
78 for (int i = 0; i < nelem (); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
79 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
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 FixedNDArray::FixedNDArray (const MArrayN<int> &is, const MArrayN<int> &ds,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
83 const FixedNDArray& a)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
84 : MArrayN<FixedPoint> (a.dims())
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 if ((dims () != is.dims ()) || (dims () != ds.dims ())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
87 (*current_liboctave_error_handler) ("NDArray size mismatch");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
88 return;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
89 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
90
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
91 for (int i = 0; i < nelem (); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
92 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
93 a.elem (i));
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 FixedNDArray::FixedNDArray (const NDArray &is, const NDArray &ds,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
97 const FixedNDArray& a)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
98 : MArrayN<FixedPoint> (a.dims())
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 if ((dims () != is.dims ()) || (dims () != ds.dims ())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
101 (*current_liboctave_error_handler) ("NDArray size mismatch");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
102 return;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
103 }
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((unsigned int)is(i), (unsigned int)ds(i),
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
107 a.elem (i));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
108 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
109
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
110 FixedNDArray::FixedNDArray (unsigned int is, unsigned int ds,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
111 const FixedNDArray& a)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
112 : MArrayN<FixedPoint> (a.dims())
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 for (int i = 0; i < nelem (); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
115 elem (i) = FixedPoint(is, ds, a.elem (i));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
116 }
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 FixedNDArray::FixedNDArray (const MArrayN<int> &is,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
119 const MArrayN<int> &ds,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
120 const NDArray& a)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
121 : MArrayN<FixedPoint> (a.dims())
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 if ((dims () != is.dims ()) || (dims () != ds.dims ())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
124 (*current_liboctave_error_handler) ("NDArray size mismatch");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
125 return;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
126 }
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 for (int i = 0; i < nelem (); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
129 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
130 a.elem (i));
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 FixedNDArray::FixedNDArray (const NDArray &is, const NDArray &ds,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
134 const NDArray& a)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
135 : MArrayN<FixedPoint> (a.dims())
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 if ((dims () != is.dims ()) || (dims () != ds.dims ())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
138 (*current_liboctave_error_handler) ("NDArray size mismatch");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
139 return;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
140 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
141
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((unsigned int)is(i), (unsigned int)ds(i),
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
144 a.elem (i));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
145 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
146
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
147 FixedNDArray::FixedNDArray (unsigned int is, unsigned int ds,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
148 const NDArray& a)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
149 : MArrayN<FixedPoint> (a.dims())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
150 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
151 for (int i = 0; i < nelem (); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
152 elem (i) = FixedPoint(is, ds, a.elem (i));
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 FixedNDArray::FixedNDArray (unsigned int is, unsigned int ds,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
156 const NDArray& a, const NDArray& b)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
157 : MArrayN<FixedPoint> (a.dims())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
158 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
159 if (dims() != b.dims()) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
160 (*current_liboctave_error_handler) ("NDArray size mismatch");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
161 return;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
162 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
163
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
164 for (int i = 0; i < nelem (); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
165 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
166 (unsigned int)b.elem (i));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
167 }
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 FixedNDArray::FixedNDArray (const MArrayN<int> &is, const MArrayN<int> &ds,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
170 const NDArray& a, const NDArray& b)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
171 : MArrayN<FixedPoint> (a.dims())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
172 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
173 if ((dims() != b.dims()) || (dims() != is.dims()) ||
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
174 (dims() != ds.dims())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
175 (*current_liboctave_error_handler) ("NDArray size mismatch");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
176 return;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
177 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
178
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
179 for (int i = 0; i < nelem (); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
180 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
181 (unsigned int)a.elem (i),
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
182 (unsigned int)b.elem (i));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
183 }
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 FixedNDArray::FixedNDArray (const NDArray &is, const NDArray &ds,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
186 const NDArray& a, const NDArray& b)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
187 : MArrayN<FixedPoint> (a.dims())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
188 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
189 if ((dims() != b.dims()) || (dims() != is.dims()) ||
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
190 (dims() != ds.dims())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
191 (*current_liboctave_error_handler) ("NDArray size mismatch");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
192 return;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
193 }
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((unsigned int)is(i), (unsigned int)ds(i),
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
197 (unsigned int)a.elem (i),
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
198 (unsigned int)b.elem (i));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
199 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
200
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
201 FixedNDArray::FixedNDArray (const MArrayN<int> &a)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
202 : MArrayN<FixedPoint> (a.dims())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
203 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
204 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
205 elem (i) = FixedPoint(a.elem (i));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
206 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
207
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
208 FixedNDArray::FixedNDArray (const NDArray &a)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
209 : MArrayN<FixedPoint> (a.dims())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
210 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
211 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
212 elem (i) = FixedPoint(a.elem (i));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
213 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
214
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
215 #define GET_FIXED_PROP(METHOD) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
216 NDArray \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
217 FixedNDArray:: METHOD (void) const \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
218 { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
219 int nel = nelem(); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
220 NDArray retval(dims()); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
221 for (int i = 0; i < nel; i++) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
222 retval(i) = (double) elem(i) . METHOD (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
223 return retval; \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
224 } \
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 GET_FIXED_PROP(sign);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
227 GET_FIXED_PROP(signbit);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
228 GET_FIXED_PROP(getdecsize);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
229 GET_FIXED_PROP(getintsize);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
230 GET_FIXED_PROP(getnumber);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
231 GET_FIXED_PROP(fixedpoint);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
232
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
233 #undef GET_FIXED_PROP
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 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
236 FixedNDArray::chdecsize (const double n)
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 int nel = nelem();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
239 FixedNDArray retval(dims());
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 for (int i = 0; i < nel; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
242 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
243
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
244 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
245 }
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 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
248 FixedNDArray::chdecsize (const NDArray &n)
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 int nel = nelem();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
251
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
252 if (dims() != n.dims()) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
253 (*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
254 return FixedNDArray();
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
257 FixedNDArray retval(dims());
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 for (int i = 0; i < nel; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
260 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
261
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
262 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
263 }
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 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
266 FixedNDArray::chintsize (const double n)
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 int nel = nelem();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
269 FixedNDArray retval(dims());
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 for (int i = 0; i < nel; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
272 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
273
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
274 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
275 }
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 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
278 FixedNDArray::chintsize (const NDArray &n)
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 int nel = nelem();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
281
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
282 if (dims() != n.dims()) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
283 (*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
284 return FixedNDArray();
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
287 FixedNDArray retval(dims());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
288
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
289 for (int i = 0; i < nel; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
290 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
291
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
292 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
293 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
294
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
295 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
296 FixedNDArray::incdecsize (const double n) {
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 (const NDArray &n) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
302 if (dims() != n.dims()) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
303 (*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
304 return FixedNDArray();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
305 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
306 return chdecsize(n + getdecsize());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
307 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
308
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
309 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
310 FixedNDArray::incdecsize () {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
311 return chdecsize(1 + getdecsize());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
312 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
313
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
314 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
315 FixedNDArray::incintsize (const double n) {
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 (const NDArray &n) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
321 if (dims() != n.dims()) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
322 (*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
323 return FixedNDArray();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
324 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
325 return chintsize(n + getintsize());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
326 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
327
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
328 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
329 FixedNDArray::incintsize () {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
330 return chintsize(1 + getintsize());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
331 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
332
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
333 bool
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
334 FixedNDArray::operator == (const FixedNDArray& a) const
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 if (dims () != a.dims ())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
337 return false;
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 for (int i = 0; i < nelem(); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
340 if (elem(i) != a.elem(i))
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
341 return false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
342 return true;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
345 bool
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
346 FixedNDArray::operator != (const FixedNDArray& a) const
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
347 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
348 return !(*this != a);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
349 }
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 // unary operations
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
352
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
353 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
354 FixedNDArray::operator ! (void) const
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 int nel = nelem ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
357
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
358 FixedNDArray b (dims());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
359
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
360 for (int i = 0; i < nel; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
361 b.elem (i) = ! elem (i);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
362
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
363 return b;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
364 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
365
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
366 // other operations.
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
367
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
368 boolNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
369 FixedNDArray::all (octave_idx_type dim) const
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 #define FMX_ND_ALL_EXPR elem (iter_idx) .fixedpoint () == 0.0
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
372 MX_ND_ANY_ALL_REDUCTION (MX_ND_ALL_EVAL (FMX_ND_ALL_EXPR), true);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
373 #undef FMX_ND_ALL_EXPR
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
374 }
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 boolNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
377 FixedNDArray::any (octave_idx_type dim) const
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
378 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
379 #define FMX_ND_ANY_EXPR elem (iter_idx) .fixedpoint () != 0.0
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
380 MX_ND_ANY_ALL_REDUCTION (MX_ND_ANY_EVAL (FMX_ND_ANY_EXPR), false);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
381 #undef FMX_ND_ANY_EXPR
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
384 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
385 FixedNDArray::cumprod (octave_idx_type dim) const
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
386 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
387 FixedPoint one(1,0,1,0);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
388 MX_ND_CUMULATIVE_OP (FixedNDArray, FixedPoint, one, *);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
389 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
390
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
391 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
392 FixedNDArray::cumsum (octave_idx_type dim) const
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 FixedPoint zero;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
395 MX_ND_CUMULATIVE_OP (FixedNDArray, FixedPoint, zero, +);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
396 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
397
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
398 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
399 FixedNDArray::prod (octave_idx_type dim) const
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 FixedPoint one(1,0,1,0);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
402 #if (MX_ND_RED_NUM == 6)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
403 MX_ND_REDUCTION (acc *= elem (iter_idx), retval.elem (iter_idx) = acc,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
404 one, FixedPoint acc = one, FixedNDArray, FixedPoint);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
405 #elif (MX_ND_RED_NUM == 5)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
406 MX_ND_REDUCTION (acc *= elem (iter_idx), retval.elem (iter_idx) = acc,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
407 one, FixedPoint acc = one, FixedNDArray);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
408 #else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
409 MX_ND_REDUCTION (retval(result_idx) *= elem (iter_idx), one, FixedNDArray);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
410 #endif
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
414 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
415 FixedNDArray::sum (octave_idx_type dim) const
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
416 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
417 FixedPoint zero;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
418 #if (MX_ND_RED_NUM == 6)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
419 MX_ND_REDUCTION (acc += elem (iter_idx), retval.elem (iter_idx) = acc,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
420 zero, FixedPoint acc = zero, FixedNDArray, FixedPoint);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
421 #elif (MX_ND_RED_NUM == 5)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
422 MX_ND_REDUCTION (acc += elem (iter_idx), retval.elem (iter_idx) = acc,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
423 zero, FixedPoint acc = zero, FixedNDArray);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
424 #else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
425 MX_ND_REDUCTION (retval(result_idx) += elem (iter_idx), zero, FixedNDArray);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
426 #endif
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
429 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
430 FixedNDArray::sumsq (octave_idx_type dim) const
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 FixedPoint zero;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
433 #if (MX_ND_RED_NUM == 6)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
434 MX_ND_REDUCTION (acc += pow (elem (iter_idx), 2),
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
435 retval.elem (iter_idx) = acc,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
436 zero, FixedPoint acc = zero, FixedNDArray, FixedPoint);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
437 #elif (MX_ND_RED_NUM == 5)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
438 MX_ND_REDUCTION (acc += pow (elem (iter_idx), 2),
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
439 retval.elem (iter_idx) = acc,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
440 zero, FixedPoint acc = zero, FixedNDArray);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
441 #else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
442 MX_ND_REDUCTION (retval(result_idx) += pow (elem (iter_idx), 2), zero,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
443 FixedNDArray);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
444 #endif
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
445 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
446
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
447 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
448 FixedNDArray::max (octave_idx_type dim) const
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
449 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
450 ArrayN<octave_idx_type> dummy_idx;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
451 return max (dummy_idx, dim);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
452 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
453
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
454 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
455 FixedNDArray::max (ArrayN<octave_idx_type>& idx_arg, octave_idx_type dim) const
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
456 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
457 dim_vector dv = dims ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
458 dim_vector dr = dims ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
459
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
460 if (dv.numel () == 0 || dim > dv.length () || dim < 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
461 return FixedNDArray ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
462
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
463 dr(dim) = 1;
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 FixedNDArray result (dr);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
466 idx_arg.resize (dr);
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 x_stride = 1;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
469 octave_idx_type x_len = dv(dim);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
470 for (octave_idx_type i = 0; i < dim; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
471 x_stride *= dv(i);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
472
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
473 for (octave_idx_type i = 0; i < dr.numel (); i++)
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 octave_idx_type x_offset;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
476 if (x_stride == 1)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
477 x_offset = i * x_len;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
478 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
479 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
480 octave_idx_type x_offset2 = 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
481 x_offset = i;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
482 while (x_offset >= x_stride)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
483 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
484 x_offset -= x_stride;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
485 x_offset2++;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
486 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
487 x_offset += x_offset2 * x_stride * x_len;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
488 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
489
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
490 octave_idx_type idx_j = 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
491 FixedPoint tmp_max = elem (x_offset);;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
492
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
493 for (octave_idx_type j = 1; j < x_len; j++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
494 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
495 FixedPoint tmp = elem (j * x_stride + x_offset);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
496
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
497 if (tmp > tmp_max)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
498 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
499 idx_j = j;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
500 tmp_max = tmp;
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 }
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 result.elem (i) = tmp_max;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
505 idx_arg.elem (i) = idx_j;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
506 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
507
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
508 return result;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
509 }
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 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
512 FixedNDArray::min (octave_idx_type dim) const
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
513 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
514 ArrayN<octave_idx_type> dummy_idx;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
515 return min (dummy_idx, dim);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
516 }
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 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
519 FixedNDArray::min (ArrayN<octave_idx_type>& idx_arg, octave_idx_type dim) const
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
520 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
521 dim_vector dv = dims ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
522 dim_vector dr = dims ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
523
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
524 if (dv.numel () == 0 || dim > dv.length () || dim < 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
525 return FixedNDArray ();
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 dr(dim) = 1;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
528
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
529 FixedNDArray result (dr);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
530 idx_arg.resize (dr);
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 octave_idx_type x_stride = 1;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
533 octave_idx_type x_len = dv(dim);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
534 for (octave_idx_type i = 0; i < dim; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
535 x_stride *= dv(i);
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 for (octave_idx_type i = 0; i < dr.numel (); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
538 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
539 octave_idx_type x_offset;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
540 if (x_stride == 1)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
541 x_offset = i * x_len;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
542 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
543 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
544 octave_idx_type x_offset2 = 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
545 x_offset = i;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
546 while (x_offset >= x_stride)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
547 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
548 x_offset -= x_stride;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
549 x_offset2++;
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 x_offset += x_offset2 * x_stride * x_len;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
552 }
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 octave_idx_type idx_j = 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
555 FixedPoint tmp_min = elem (x_offset);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
556
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
557 for (octave_idx_type j = 1; j < x_len; j++)
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 FixedPoint tmp = elem (j * x_stride + x_offset);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
560
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
561 if (tmp < tmp_min)
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 idx_j = j;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
564 tmp_min = tmp;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
565 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
566 }
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 result.elem (i) = tmp_min;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
569 idx_arg.elem (i) = idx_j;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
570 }
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 return result;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
573 }
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 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
576 FixedNDArray::abs (void) const
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
577 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
578 octave_idx_type nel = nelem ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
579
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
580 FixedNDArray retval (dims());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
581
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
582 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
583 retval (i) = ::abs(elem (i));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
584
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
585 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
586 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
587
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
588 FixedMatrix
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
589 FixedNDArray::fixed_matrix_value (void) const
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
590 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
591 FixedMatrix retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
592
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
593 octave_idx_type nd = ndims ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
594
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
595 switch (nd)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
596 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
597 case 1:
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
598 retval = FixedMatrix (Array2<FixedPoint> (*this, dimensions(0), 1));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
599 break;
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 case 2:
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
602 retval = FixedMatrix (Array2<FixedPoint> (*this, dimensions(0),
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
603 dimensions(1)));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
604 break;
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 default:
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
607 (*current_liboctave_error_handler)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
608 ("invalid conversion of FixedNDArray to FixedMatrix");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
609 break;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
610 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
611
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
612 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
613 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
614
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
615 #define DO_FIXED_ND_FUNC(FUNC) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
616 FixedNDArray FUNC (const FixedNDArray& x) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
617 { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
618 octave_idx_type nel = x.nelem (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
619 FixedNDArray retval ( x.dims()); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
620 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
621 retval(i) = FUNC ( x (i) ); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
622 return retval; \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
623 }
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 DO_FIXED_ND_FUNC(real);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
626 DO_FIXED_ND_FUNC(imag);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
627 DO_FIXED_ND_FUNC(conj);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
628 DO_FIXED_ND_FUNC(abs);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
629 DO_FIXED_ND_FUNC(cos);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
630 DO_FIXED_ND_FUNC(cosh);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
631 DO_FIXED_ND_FUNC(sin);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
632 DO_FIXED_ND_FUNC(sinh);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
633 DO_FIXED_ND_FUNC(tan);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
634 DO_FIXED_ND_FUNC(tanh);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
635 DO_FIXED_ND_FUNC(sqrt);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
636 DO_FIXED_ND_FUNC(exp);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
637 DO_FIXED_ND_FUNC(log);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
638 DO_FIXED_ND_FUNC(log10);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
639 DO_FIXED_ND_FUNC(round);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
640 DO_FIXED_ND_FUNC(rint);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
641 DO_FIXED_ND_FUNC(floor);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
642 DO_FIXED_ND_FUNC(ceil);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
643
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
644 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
645 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
646 FixedNDArray retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
647 dim_vector a_dv = a.dims ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
648 int a_nel = a.numel ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
649 dim_vector b_dv = b.dims ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
650 int b_nel = b.numel ();
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 if (a_nel == 1)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
653 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
654 retval.resize(b_dv);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
655 FixedPoint ad = a(0);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
656 for (int i = 0; i < b_nel; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
657 retval(i) = pow(ad, b(i));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
658 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
659 else if (b_nel == 1)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
660 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
661 retval.resize(a_dv);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
662 FixedPoint bd = b(0);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
663 for (int i = 0; i < a_nel; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
664 retval(i) = pow(a(i), bd);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
665 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
666 else if (a_dv == b_dv)
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 retval.resize(a_dv);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
669 for (int i = 0; i < a_nel; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
670 retval(i) = pow(a(i), b(i));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
671 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
672 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
673 gripe_nonconformant ("operator .^", a_dv, b_dv);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
674
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
675 return retval;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
678 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
679 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
680 return elem_pow (a, FixedNDArray(dim_vector (1), b));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
681 }
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 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
684 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
685 return elem_pow (FixedNDArray(dim_vector (1), a), b);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
686 }
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 FixedNDArray atan2 (const FixedNDArray &x, const FixedNDArray &y)
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 FixedNDArray retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
691 if (x.dims() == y.dims()) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
692 int nel = x.nelem ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
693 retval.resize(x.dims());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
694 for (int i = 0; i < nel; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
695 retval(i) = atan2 ( x(i), y(i));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
696 } else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
697 (*current_liboctave_error_handler) ("NDArray size mismatch");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
698 return retval;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
701 #ifdef HAVE_OLD_OCTAVE_CONCAT
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
702 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
703 concat (const FixedNDArray& ra, const FixedNDArray& rb,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
704 const Array<octave_idx_type>& ra_idx)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
705 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
706 FixedNDArray retval (ra);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
707 if (rb.numel () > 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
708 retval.insert (rb, ra_idx);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
709 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
710 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
711 #endif
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 #ifdef HAVE_OCTAVE_CONCAT
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
714 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
715 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
716 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
717 if (rb.numel () > 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
718 insert (rb, ra_idx);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
719 return *this;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
720 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
721
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
722 FixedComplexNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
723 FixedNDArray::concat (const FixedComplexNDArray& rb,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
724 const Array<octave_idx_type>& ra_idx)
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 FixedComplexNDArray retval (*this);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
727 if (rb.numel () > 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
728 retval.insert (rb, ra_idx);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
729 return retval;
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 #endif
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
732
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
733 #if defined (HAVE_OCTAVE_CONCAT) || defined (HAVE_OLD_OCTAVE_CONCAT)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
734 FixedNDArray&
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
735 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
736 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
737 Array<FixedPoint>::insert (a, ra_idx);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
738 return *this;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
739 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
740 #endif
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
741
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
742 void
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
743 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
744 const dim_vector& dimensions,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
745 octave_idx_type start_dimension)
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 #ifdef HAVE_OCTAVE_CONCAT
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
748 ::increment_index (ra_idx, dimensions, start_dimension);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
749 #else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
750 error("fixed increment_index not implemented");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
751 #endif
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
752 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
753
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
754 octave_idx_type
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
755 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
756 const dim_vector& dimensions)
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 #ifdef HAVE_OCTAVE_CONCAT
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
759 return ::compute_index (ra_idx, dimensions);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
760 #else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
761 error("fixed compute_index not implemented");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
762 return 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
763 #endif
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
764 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
765
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
766 std::ostream&
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
767 operator << (std::ostream& os, const FixedNDArray& a)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
768 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
769 int nel = a.nelem ();
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 for (int i = 0; i < nel; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
772 os << " " << a.elem(i) << "\n";
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
773 return os;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
774 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
775
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
776 std::istream&
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
777 operator >> (std::istream& is, FixedNDArray& a)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
778 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
779 int nel = a.nelem ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
780
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
781 if (nel < 1 )
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
782 is.clear (std::ios::badbit);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
783 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
784 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
785 FixedPoint tmp;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
786 for (int i = 0; i < nel; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
787 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
788 is >> tmp;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
789 if (is)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
790 a.elem (i) = tmp;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
791 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
792 goto done;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
793 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
794 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
795
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
796 done:
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
797
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
798 return is;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
799 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
800
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
801 // 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
802 // functions below.
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
803
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
804 #define EMPTY_RETURN_CHECK(T) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
805 if (nel == 0) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
806 return T (dv);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
807
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
808 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
809 min (FixedPoint d, const FixedNDArray& m)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
810 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
811 dim_vector dv = m.dims ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
812 int nel = dv.numel ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
813
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
814 EMPTY_RETURN_CHECK (FixedNDArray);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
815
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
816 FixedNDArray result (dv);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
817
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
818 for (int i = 0; i < nel; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
819 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
820 OCTAVE_QUIT;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
821 result (i) = m(i) < d ? m(i) : d;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
822 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
823
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
824 return result;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
825 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
826
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
827 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
828 min (const FixedNDArray& m, FixedPoint d)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
829 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
830 dim_vector dv = m.dims ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
831 int nel = dv.numel ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
832
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
833 EMPTY_RETURN_CHECK (FixedNDArray);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
834
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
835 FixedNDArray result (dv);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
836
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
837 for (int i = 0; i < nel; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
838 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
839 OCTAVE_QUIT;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
840 result (i) = m(i) < d ? m(i) : d;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
841 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
842
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
843 return result;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
844 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
845
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
846 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
847 min (const FixedNDArray& a, const FixedNDArray& b)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
848 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
849 dim_vector dv = a.dims ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
850 int nel = dv.numel ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
851
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
852 if (dv != b.dims ())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
853 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
854 (*current_liboctave_error_handler)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
855 ("two-arg min expecting args of same size");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
856 return FixedNDArray ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
857 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
858
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
859 EMPTY_RETURN_CHECK (FixedNDArray);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
860
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
861 FixedNDArray result (dv);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
862
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
863 for (int i = 0; i < nel; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
864 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
865 OCTAVE_QUIT;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
866 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
867 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
868
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
869 return result;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
870 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
871
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
872 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
873 max (FixedPoint d, const FixedNDArray& m)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
874 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
875 dim_vector dv = m.dims ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
876 int nel = dv.numel ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
877
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
878 EMPTY_RETURN_CHECK (FixedNDArray);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
879
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
880 FixedNDArray result (dv);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
881
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
882 for (int i = 0; i < nel; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
883 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
884 OCTAVE_QUIT;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
885 result (i) = m(i) > d ? m(i) : d;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
886 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
887
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
888 return result;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
889 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
890
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
891 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
892 max (const FixedNDArray& m, FixedPoint d)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
893 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
894 dim_vector dv = m.dims ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
895 int nel = dv.numel ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
896
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
897 EMPTY_RETURN_CHECK (FixedNDArray);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
898
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
899 FixedNDArray result (dv);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
900
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
901 for (int i = 0; i < nel; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
902 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
903 OCTAVE_QUIT;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
904 result (i) = m(i) > d ? m(i) : d;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
905 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
906
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
907 return result;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
908 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
909
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
910 FixedNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
911 max (const FixedNDArray& a, const FixedNDArray& b)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
912 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
913 dim_vector dv = a.dims ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
914 int nel = dv.numel ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
915
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
916 if (dv != b.dims ())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
917 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
918 (*current_liboctave_error_handler)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
919 ("two-arg min expecting args of same size");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
920 return FixedNDArray ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
921 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
922
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
923 EMPTY_RETURN_CHECK (FixedNDArray);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
924
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
925 FixedNDArray result (dv);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
926
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
927 for (int i = 0; i < nel; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
928 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
929 OCTAVE_QUIT;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
930 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
931 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
932
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
933 return result;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
934 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
935
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
936 NDS_CMP_OPS(FixedNDArray, , FixedPoint, )
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
937 NDS_BOOL_OPS(FixedNDArray, FixedPoint, FixedPoint())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
938
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
939 SND_CMP_OPS(FixedPoint, , FixedNDArray, )
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
940 SND_BOOL_OPS(FixedPoint, FixedNDArray, FixedPoint())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
941
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
942 NDND_CMP_OPS(FixedNDArray, , FixedNDArray, )
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
943 NDND_BOOL_OPS(FixedNDArray, FixedNDArray, FixedPoint())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
944
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
945 #endif // HAVE_ND_ARRAYS
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
946
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
947 /*
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
948 ;;; Local Variables: ***
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
949 ;;; mode: C++ ***
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
950 ;;; End: ***
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
951 */