annotate main/fixed/src/ov-base-fixed-mat.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 7b7cd174847c
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) 2003 Motorola Inc
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
4 Copyright (C) 2003 David Bateman
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
5
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
6 This program is free software; you can redistribute it and/or modify it
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
9 later version.
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
10
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
11 This program is distributed in the hope that it will be useful, but WITHOUT
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
14 for more details.
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
15
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
4404
2de537641f94 More copyright updates
adb014
parents: 3272
diff changeset
17 along with this program; see the file COPYING. If not, see
2de537641f94 More copyright updates
adb014
parents: 3272
diff changeset
18 <http://www.gnu.org/licenses/>.
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
19
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
20 In addition to the terms of the GPL, you are permitted to link
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
21 this program with any Open Source program, as defined by the
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
22 Open Source Initiative (www.opensource.org)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
23
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
24 */
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
25
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
26 #include <config.h>
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 #include <octave/oct-obj.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
29 #include <octave/ov-base.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
30 #include <octave/ov-base-scalar.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
31 #include <octave/pr-output.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
32
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
33 template <class MT>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
34 octave_value_list
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
35 octave_base_fixed_matrix<MT>::dotref (const octave_value_list& idx)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
36 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
37 octave_value_list retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
38
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
39 assert (idx.length () == 1);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
40
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
41 std::string nm = idx(0).string_value ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
42
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
43 if (nm == __FIXED_SIGN_STR)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
44 retval(0) = octave_value (matrix.sign());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
45 else if (nm == __FIXED_VALUE_STR)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
46 retval(0) = octave_value (matrix.fixedpoint());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
47 else if (nm == __FIXED_DECSIZE_STR)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
48 retval(0) = octave_value (matrix.getdecsize());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
49 else if (nm == __FIXED_INTSIZE_STR)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
50 retval(0) = octave_value (matrix.getintsize());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
51 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
52 error ("fixed point structure has no member `%s'", nm.c_str ());
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 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
55 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
56
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
57 template <class MT>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
58 octave_value
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
59 octave_base_fixed_matrix<MT>::subsref (const std::string& type,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
60 const std::list<octave_value_list>& idx)
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 octave_value retval;
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 switch (type[0])
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 case '(':
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
67 retval = do_index_op (idx.front ());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
68 break;
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 case '.':
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
71 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
72 octave_value_list t = dotref (idx.front ());
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 retval = (t.length () == 1) ? t(0) : octave_value (t);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
75 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
76 break;
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 case '{':
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 std::string nm = type_name ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
81 error ("%s cannot be indexed with %c", nm.c_str (), type[0]);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
82 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
83 break;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
84
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
85 default:
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
86 panic_impossible ();
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 return retval.next_subsref (type, idx);
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
92 template <class MT>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
93 void
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
94 octave_base_fixed_matrix<MT>::assign (const octave_value_list& idx,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
95 const MT& rhs)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
96 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
97 int len = idx.length ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
98
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
99 if (len > 2)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
100 error ("invalid number of indices (%d) for indexed assignment",
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
101 len);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
102 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
103 {
9481
d84d2fea3c90 Re-enable compilation of fixed package
jordigh
parents: 5248
diff changeset
104 Array<idx_vector> ra_idx (dim_vector (len, 1));
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
105
5248
f8d77845533f Changes for compilation with 3.1.51+
adb014
parents: 4404
diff changeset
106 for (octave_idx_type i = 0; i < len; i++)
f8d77845533f Changes for compilation with 3.1.51+
adb014
parents: 4404
diff changeset
107 ra_idx(i) = idx(i).index_vector ();
f8d77845533f Changes for compilation with 3.1.51+
adb014
parents: 4404
diff changeset
108
f8d77845533f Changes for compilation with 3.1.51+
adb014
parents: 4404
diff changeset
109 matrix.assign (ra_idx, rhs, MT::resize_fill_value ());
2383
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 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
112
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
113 template <class MT>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
114 bool
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
115 octave_base_fixed_matrix<MT>::is_true (void) const
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 bool retval = false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
118
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
119 if (rows () > 0 && columns () > 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
120 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
121 boolMatrix m = (matrix.all () . all ());
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 retval = (m.rows () == 1 && m.columns () == 1 && m(0,0));
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
126 return retval;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
129 template <class MT>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
130 bool
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
131 octave_base_fixed_matrix<MT>::valid_as_scalar_index (void) const
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 // XXX FIXME XXX
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
134 return false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
135 }
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 template <class MT>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
138 bool
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
139 octave_base_fixed_matrix<MT>::print_as_scalar (void) const
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 int nr = rows ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
142 int nc = columns ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
143
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
144 return (nr == 1 && nc == 1 || (nr == 0 || nc == 0));
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 template <class MT>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
148 void
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
149 octave_base_fixed_matrix<MT>::print (std::ostream& os, bool pr_as_read_syntax) const
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 print_raw (os, pr_as_read_syntax);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
152 newline (os);
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 template <class MT>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
156 bool
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
157 octave_base_fixed_matrix<MT>::print_name_tag (std::ostream& os,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
158 const std::string& name) const
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
159 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
160 bool retval = false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
161
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
162 indent (os);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
163
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
164 if (print_as_scalar ())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
165 os << name << " = ";
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
166 else
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 os << name << " =";
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
169 newline (os);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
170 newline (os);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
171 retval = true;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
174 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
175 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
176
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
177 template <class MT>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
178 void
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
179 octave_base_fixed_matrix<MT>::print_info (std::ostream& os,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
180 const std::string& prefix) const
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
181 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
182 matrix.print_info (os, prefix);
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 /*
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
186 ;;; Local Variables: ***
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
187 ;;; mode: C++ ***
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
188 ;;; End: ***
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
189 */