annotate main/fixed/src/fixedRowVector.cc @ 9481:d84d2fea3c90 octave-forge

Re-enable compilation of fixed package
author jordigh
date Wed, 22 Feb 2012 22:07:33 +0000
parents f8d77845533f
children
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 // Fixed Point RowVector manipulations.
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
4 Copyright (C) 2003 Motorola Inc
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
5 Copyright (C) 2003 David Bateman
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
6
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
7 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
8 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
9 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
10 later version.
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
11
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
12 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
13 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
14 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
15 for more details.
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
16
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
4404
2de537641f94 More copyright updates
adb014
parents: 3272
diff changeset
18 along with this program; see the file COPYING. If not, see
2de537641f94 More copyright updates
adb014
parents: 3272
diff changeset
19 <http://www.gnu.org/licenses/>.
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
20
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
21 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
22 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
23 Open Source Initiative (www.opensource.org)
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
27 #include <iostream>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
28
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
29 #include <octave/config.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
30 #include <octave/lo-utils.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
31 #include <octave/lo-error.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
32 #include <octave/error.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
33 #include <octave/gripes.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
34 #include <octave/ops.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
35
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
36 #include "fixedMatrix.h"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
37 #include "fixedColVector.h"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
38 #include "fixedRowVector.h"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
39
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
40 // Fixed Point Row Vector class
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
41
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
42 FixedRowVector::FixedRowVector (const MArray<int> &is, const MArray<int> &ds)
9481
d84d2fea3c90 Re-enable compilation of fixed package
jordigh
parents: 5248
diff changeset
43 : MArray<FixedPoint> (dim_vector (1, is.length()))
2383
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 if (length() != ds.length()) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
46 (*current_liboctave_error_handler) ("vector size mismatch");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
47 return;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
48 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
49
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
50 for (int i = 0; i < length (); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
51 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
52 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
53
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
54 FixedRowVector::FixedRowVector (const RowVector &is, const RowVector &ds)
9481
d84d2fea3c90 Re-enable compilation of fixed package
jordigh
parents: 5248
diff changeset
55 : MArray<FixedPoint> (dim_vector (1, is.length()))
2383
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 if (length() != ds.length()) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
58 (*current_liboctave_error_handler) ("vector size mismatch");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
59 return;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
60 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
61
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
62 for (int i = 0; i < length (); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
63 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
64 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
65
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
66 FixedRowVector::FixedRowVector (const MArray<int> &is, const MArray<int> &ds,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
67 const FixedRowVector& a)
9481
d84d2fea3c90 Re-enable compilation of fixed package
jordigh
parents: 5248
diff changeset
68 : MArray<FixedPoint> (dim_vector (1, a.length()))
2383
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 if ((length() != is.length()) || (length() != ds.length())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
71 (*current_liboctave_error_handler) ("vector size mismatch");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
72 return;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
73 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
74
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
75 for (int i = 0; i < length (); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
76 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
77 a.elem (i));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
78 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
79
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
80 FixedRowVector::FixedRowVector (const RowVector &is, const RowVector &ds,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
81 const FixedRowVector& a)
9481
d84d2fea3c90 Re-enable compilation of fixed package
jordigh
parents: 5248
diff changeset
82 : MArray<FixedPoint> (dim_vector (1, a.length()))
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
83 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
84 if ((length() != is.length()) || (length() != ds.length())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
85 (*current_liboctave_error_handler) ("vector size mismatch");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
86 return;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
87 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
88
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
89 for (int i = 0; i < length (); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
90 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
91 a.elem (i));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
92 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
93
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
94 FixedRowVector::FixedRowVector (unsigned int is, unsigned int ds,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
95 const FixedRowVector& a)
9481
d84d2fea3c90 Re-enable compilation of fixed package
jordigh
parents: 5248
diff changeset
96 : MArray<FixedPoint> (dim_vector (1, a.length()))
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
97 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
98 for (int i = 0; i < length (); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
99 elem (i) = FixedPoint(is, ds, a.elem (i));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
100 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
101
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
102 FixedRowVector::FixedRowVector (const MArray<int> &is, const MArray<int> &ds,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
103 const RowVector& a)
9481
d84d2fea3c90 Re-enable compilation of fixed package
jordigh
parents: 5248
diff changeset
104 : MArray<FixedPoint> (dim_vector (1, a.length()))
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
105 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
106 if ((length() != is.length()) || (length() != ds.length())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
107 (*current_liboctave_error_handler) ("vector size mismatch");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
108 return;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
111 for (int i = 0; i < length (); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
112 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
113 a.elem (i));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
114 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
115
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
116 FixedRowVector::FixedRowVector (const RowVector &is, const RowVector &ds,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
117 const RowVector& a)
9481
d84d2fea3c90 Re-enable compilation of fixed package
jordigh
parents: 5248
diff changeset
118 : MArray<FixedPoint> (dim_vector (1, a.length()))
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
119 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
120 if ((length() != is.length()) || (length() != ds.length())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
121 (*current_liboctave_error_handler) ("vector size mismatch");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
122 return;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
123 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
124
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
125 for (int i = 0; i < length (); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
126 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
127 a.elem (i));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
128 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
129
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
130 FixedRowVector::FixedRowVector (unsigned int is, unsigned int ds,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
131 const RowVector& a)
9481
d84d2fea3c90 Re-enable compilation of fixed package
jordigh
parents: 5248
diff changeset
132 : MArray<FixedPoint> (dim_vector (1, a.length()))
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
133 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
134 for (int i = 0; i < length (); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
135 elem (i) = FixedPoint(is, ds, a.elem (i));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
136 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
137
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
138 FixedRowVector::FixedRowVector (const MArray<int> &is, const MArray<int> &ds,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
139 const RowVector& a, const RowVector& b)
9481
d84d2fea3c90 Re-enable compilation of fixed package
jordigh
parents: 5248
diff changeset
140 : MArray<FixedPoint> (dim_vector (1, a.length()))
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
141 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
142 if ((length() != b.length()) || (length() != is.length()) ||
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
143 (length() != ds.length())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
144 (*current_liboctave_error_handler) ("vector size mismatch");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
145 return;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
148 for (int i = 0; i < length (); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
149 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
150 (unsigned int)a.elem (i),
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
151 (unsigned int)b.elem (i));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
152 }
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 FixedRowVector::FixedRowVector (const RowVector &is, const RowVector &ds,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
155 const RowVector& a, const RowVector& b)
9481
d84d2fea3c90 Re-enable compilation of fixed package
jordigh
parents: 5248
diff changeset
156 : MArray<FixedPoint> (dim_vector (1, a.length()))
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
157 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
158 if ((length() != b.length()) || (length() != is.length()) ||
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
159 (length() != ds.length())) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
160 (*current_liboctave_error_handler) ("vector 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 < length (); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
165 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
166 (unsigned int)a.elem (i),
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
167 (unsigned int)b.elem (i));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
168 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
169
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
170 FixedRowVector::FixedRowVector (unsigned int is, unsigned int ds,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
171 const RowVector& a, const RowVector& b)
9481
d84d2fea3c90 Re-enable compilation of fixed package
jordigh
parents: 5248
diff changeset
172 : MArray<FixedPoint> (dim_vector (1, a.length()))
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
173 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
174 if (length() != b.length()) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
175 (*current_liboctave_error_handler) ("vector 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 < length (); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
180 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
181 (unsigned int)b.elem (i));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
182 }
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 #define GET_FIXED_PROP(METHOD) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
185 RowVector \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
186 FixedRowVector:: METHOD (void) const \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
187 { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
188 int len = length(); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
189 RowVector retval(len); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
190 for (int i = 0; i < len; i++) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
191 retval(i) = (double) elem(i) . METHOD (); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
192 return retval; \
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 GET_FIXED_PROP(sign);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
196 GET_FIXED_PROP(signbit);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
197 GET_FIXED_PROP(getdecsize);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
198 GET_FIXED_PROP(getintsize);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
199 GET_FIXED_PROP(getnumber);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
200 GET_FIXED_PROP(fixedpoint);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
201
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
202 #undef GET_FIXED_PROP
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 FixedRowVector
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
205 FixedRowVector::chdecsize (const double n)
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 int len = length();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
208 FixedRowVector retval(len);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
209
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
210 for (int i = 0; i < len; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
211 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
212
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
213 return retval;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
216 FixedRowVector
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
217 FixedRowVector::chdecsize (const RowVector &n)
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 len = length();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
220
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
221 if (len != n.length()) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
222 (*current_liboctave_error_handler) ("vector size mismatch in chdecsize");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
223 return FixedRowVector();
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 FixedRowVector retval(len);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
227
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
228 for (int i = 0; i < len; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
229 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
230
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
231 return retval;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
234 FixedRowVector
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
235 FixedRowVector::chintsize (const double n)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
236 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
237 int len = length();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
238 FixedRowVector retval(len);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
239
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
240 for (int i = 0; i < len; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
241 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
242
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
243 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
244 }
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 FixedRowVector
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
247 FixedRowVector::chintsize (const RowVector &n)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
248 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
249 int len = length();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
250
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
251 if (len != n.length()) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
252 (*current_liboctave_error_handler) ("vector size mismatch in chdecsize");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
253 return FixedRowVector();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
254 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
255
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
256 FixedRowVector retval(len);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
257
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
258 for (int i = 0; i < len; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
259 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
260
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
261 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
262 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
263
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
264 FixedRowVector
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
265 FixedRowVector::incdecsize (const double n) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
266 return chdecsize(n + getdecsize());
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
269 FixedRowVector
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
270 FixedRowVector::incdecsize (const RowVector &n) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
271 if (n.length() != length()) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
272 (*current_liboctave_error_handler) ("vector size mismatch in incdecsize");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
273 return FixedRowVector();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
274 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
275 return chdecsize(n + getdecsize());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
276 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
277
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
278 FixedRowVector
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
279 FixedRowVector::incdecsize () {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
280 return chdecsize(1 + getdecsize());
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
283 FixedRowVector
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
284 FixedRowVector::incintsize (const double n) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
285 return chintsize(n + getintsize());
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
288 FixedRowVector
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
289 FixedRowVector::incintsize (const RowVector &n) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
290 if (n.length() != length()) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
291 (*current_liboctave_error_handler) ("vector size mismatch in incintsize");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
292 return FixedRowVector();
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 return chintsize(n + getintsize());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
295 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
296
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
297 FixedRowVector
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
298 FixedRowVector::incintsize () {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
299 return chintsize(1 + getintsize());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
300 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
301
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
302 // Fixed Point Row Vector class.
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
303
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
304 bool
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
305 FixedRowVector::operator == (const FixedRowVector& a) const
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
306 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
307 int len = length ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
308 if (len != a.length ())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
309 return 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
310
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
311 for (int i = 0; i < len; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
312 if (elem(i) != a.elem(i))
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
313 return false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
314 return true;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
315 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
316
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
317 bool
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
318 FixedRowVector::operator != (const FixedRowVector& a) const
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
319 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
320 return !(*this == a);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
321 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
322
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
323 FixedRowVector&
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
324 FixedRowVector::insert (const FixedRowVector& a, int c)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
325 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
326 int a_len = a.length ();
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 if (c < 0 || c + a_len > length ())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
329 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
330 (*current_liboctave_error_handler) ("range error for insert");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
331 return *this;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
334 if (a_len > 0)
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 make_unique ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
337
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
338 for (int i = 0; i < a_len; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
339 xelem (c+i) = a.elem (i);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
340 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
341
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
342 return *this;
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 FixedRowVector&
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
346 FixedRowVector::fill (FixedPoint val)
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 int len = length ();
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 if (len > 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
351 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
352 make_unique ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
353
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
354 for (int i = 0; i < len; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
355 xelem (i) = val;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
356 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
357
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
358 return *this;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
359 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
360
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
361 FixedRowVector&
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
362 FixedRowVector::fill (FixedPoint val, int c1, int c2)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
363 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
364 int len = length ();
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 if (c1 < 0 || c2 < 0 || c1 >= len || c2 >= len)
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 (*current_liboctave_error_handler) ("range error for fill");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
369 return *this;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
372 if (c1 > c2) { int tmp = c1; c1 = c2; c2 = tmp; }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
373
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
374 if (c2 >= c1)
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 make_unique ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
377
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
378 for (int i = c1; i <= c2; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
379 xelem (i) = val;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
380 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
381
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
382 return *this;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
385 FixedRowVector
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
386 FixedRowVector::append (const FixedRowVector& a) const
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
387 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
388 int len = length ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
389 int nc_insert = len;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
390 FixedRowVector retval (len + a.length ());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
391 retval.insert (*this, 0);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
392 retval.insert (a, nc_insert);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
393 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
394 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
395
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
396 FixedColumnVector
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
397 FixedRowVector::transpose (void) const
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
398 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
399 return FixedColumnVector (*this);
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
402 FixedRowVector
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
403 FixedRowVector::extract (int c1, int c2) const
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
404 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
405 if (c1 > c2) { int tmp = c1; c1 = c2; c2 = tmp; }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
406
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
407 int new_c = c2 - c1 + 1;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
408
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
409 FixedRowVector result (new_c);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
410
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
411 for (int i = 0; i < new_c; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
412 result.xelem (i) = elem (c1+i);
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 return result;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
415 }
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 FixedRowVector
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
418 FixedRowVector::extract_n (int r1, int n) const
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
419 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
420 FixedRowVector result (n);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
421
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
422 for (int i = 0; i < n; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
423 result.xelem (i) = elem (r1+i);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
424
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
425 return result;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
426 }
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 #define DO_FIXED_VEC_FUNC(FUNC, MT) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
429 MT FUNC (const FixedRowVector& x) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
430 { \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
431 MT retval (x.length()); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
432 for (int i = 0; i < x.length(); i++) \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
433 retval(i) = FUNC ( x (i) ); \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
434 return retval; \
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
435 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
436
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
437 DO_FIXED_VEC_FUNC(real, FixedRowVector);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
438 DO_FIXED_VEC_FUNC(imag, FixedRowVector);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
439 DO_FIXED_VEC_FUNC(conj, FixedRowVector);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
440 DO_FIXED_VEC_FUNC(abs, FixedRowVector);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
441 DO_FIXED_VEC_FUNC(cos, FixedRowVector);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
442 DO_FIXED_VEC_FUNC(cosh, FixedRowVector);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
443 DO_FIXED_VEC_FUNC(sin, FixedRowVector);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
444 DO_FIXED_VEC_FUNC(sinh, FixedRowVector);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
445 DO_FIXED_VEC_FUNC(tan, FixedRowVector);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
446 DO_FIXED_VEC_FUNC(tanh, FixedRowVector);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
447 DO_FIXED_VEC_FUNC(sqrt, FixedRowVector);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
448 DO_FIXED_VEC_FUNC(exp, FixedRowVector);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
449 DO_FIXED_VEC_FUNC(log, FixedRowVector);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
450 DO_FIXED_VEC_FUNC(log10, FixedRowVector);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
451 DO_FIXED_VEC_FUNC(round, FixedRowVector);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
452 DO_FIXED_VEC_FUNC(rint, FixedRowVector);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
453 DO_FIXED_VEC_FUNC(floor, FixedRowVector);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
454 DO_FIXED_VEC_FUNC(ceil, FixedRowVector);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
455
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
456 FixedRowVector elem_pow (const FixedRowVector &a,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
457 const FixedRowVector &b)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
458 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
459 FixedRowVector retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
460 int a_len = a.length ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
461 int b_len = b.length ();
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 if (a_len == 1)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
464 {
9481
d84d2fea3c90 Re-enable compilation of fixed package
jordigh
parents: 5248
diff changeset
465 retval.resize(b_len);
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
466 FixedPoint ad = a(0);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
467 for (int i = 0; i < b_len; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
468 retval(i) = pow(ad, b(i));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
469 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
470 else if (b_len == 1)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
471 {
9481
d84d2fea3c90 Re-enable compilation of fixed package
jordigh
parents: 5248
diff changeset
472 retval.resize(a_len);
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
473 FixedPoint bd = b(0);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
474 for (int i = 0; i < a_len; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
475 retval(i) = pow(a(i), bd);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
476 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
477 else if (a_len == b_len)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
478 {
9481
d84d2fea3c90 Re-enable compilation of fixed package
jordigh
parents: 5248
diff changeset
479 retval.resize(a_len);
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
480 for (int i = 0; i < a_len; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
481 retval(i) = pow(a(i), b(i));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
482 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
483 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
484 gripe_nonconformant ("operator .^", a_len, b_len);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
485
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
486 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
487 }
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 FixedRowVector elem_pow (const FixedRowVector &a, const FixedPoint &b)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
490 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
491 return elem_pow (a, FixedRowVector(1, b));
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
494 FixedRowVector elem_pow (const FixedPoint &a, const FixedRowVector &b)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
495 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
496 return elem_pow (FixedRowVector(1, a), b);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
497 }
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 // row vector by matrix -> row vector
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
500
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
501 FixedRowVector
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
502 operator * (const FixedRowVector& v, const FixedMatrix& a)
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 FixedRowVector retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
505
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
506 int len = v.length ();
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 int a_nr = a.rows ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
509 int a_nc = a.cols ();
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 if (a_nr != len)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
512 gripe_nonconformant ("operator *", 1, len, a_nr, a_nc);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
513 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
514 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
515 int a_nr = a.rows ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
516 int a_nc = a.cols ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
517
9481
d84d2fea3c90 Re-enable compilation of fixed package
jordigh
parents: 5248
diff changeset
518 retval.resize (a_nc, FixedPoint());
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
519 if (len != 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
520 for (int i = 0; i < a_nc; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
521 for (int j = 0; j < a_nr; j++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
522 retval.elem (i) += v.elem(j) * a.elem(j,i);
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
525 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
526 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
527
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
528 // other operations
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
529 FixedRowVector
5248
f8d77845533f Changes for compilation with 3.1.51+
adb014
parents: 4404
diff changeset
530 FixedRowVector::map (fp_fp_Mapper f) const
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
531 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
532 FixedRowVector b (*this);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
533 return b.apply (f);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
534 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
535
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
536 FixedRowVector&
5248
f8d77845533f Changes for compilation with 3.1.51+
adb014
parents: 4404
diff changeset
537 FixedRowVector::apply (fp_fp_Mapper f)
2383
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 FixedPoint *d = fortran_vec (); // Ensures only one reference to my privates!
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
540
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
541 for (int i = 0; i < length (); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
542 d[i] = f (d[i]);
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 return *this;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
545 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
546
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
547 FixedPoint
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
548 FixedRowVector::min (void) const
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
549 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
550 int len = length ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
551 if (len == 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
552 return FixedPoint();
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 FixedPoint res = elem (0);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
555 double res_val = res.fixedpoint ();
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 (int i = 1; i < len; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
558 if (elem (i) .fixedpoint () < res_val) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
559 res = elem (i);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
560 res_val = res.fixedpoint ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
561 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
562
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
563 return res;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
564 }
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 FixedPoint
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
567 FixedRowVector::max (void) const
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
568 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
569 int len = length ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
570 if (len == 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
571 return FixedPoint();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
572
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
573 FixedPoint res = elem (0);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
574 double res_val = res.fixedpoint ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
575
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
576 for (int i = 1; i < len; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
577 if (elem (i) .fixedpoint () > res_val) {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
578 res = elem (i);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
579 res_val = res.fixedpoint ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
580 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
581
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
582 return res;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
583 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
584
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
585 std::ostream&
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
586 operator << (std::ostream& os, const FixedRowVector& a)
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 for (int i = 0; i < a.length (); i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
589 os << " " << a.elem (i);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
590 return os;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
591 }
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 std::istream&
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
594 operator >> (std::istream& is, FixedRowVector& a)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
595 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
596 int len = a.length();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
597
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
598 if (len < 1)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
599 is.clear (std::ios::badbit);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
600 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
601 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
602 FixedPoint tmp;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
603 for (int i = 0; i < len; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
604 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
605 is >> tmp;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
606 if (is)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
607 a.elem (i) = tmp;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
608 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
609 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 is;
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 // row vector by column vector -> scalar
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
616
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
617 FixedPoint
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
618 operator * (const FixedRowVector& v, const FixedColumnVector& a)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
619 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
620 FixedPoint retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
621
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
622 int len = v.length ();
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 int a_len = a.length ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
625
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
626 if (len != a_len)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
627 gripe_nonconformant ("operator *", len, a_len);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
628 else if (len != 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
629 for (int i = 0; i < len; i++)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
630 retval += v.elem(i) * a.elem(i);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
631
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
632 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
633 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
634
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
635 /*
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
636 ;;; Local Variables: ***
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
637 ;;; mode: C++ ***
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
638 ;;; End: ***
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
639 */