annotate main/fixed/src/ov-fixed.cc @ 2419:cd41a9562cee octave-forge

Fix for 2.9.x change to do_index method
author adb014
date Mon, 28 Aug 2006 20:03:09 +0000
parents 1728eb2120ef
children 73fa4496fb07
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
17 along with this program; see the file COPYING. If not, write to the Free
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
19
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
20 In addition to the terms of the GPL, you are permitted to link
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
21 this program with any Open Source program, as defined by the
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
22 Open Source Initiative (www.opensource.org)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
23
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
24 */
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
25
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
26 #include <iostream>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
27
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
28 #include <octave/config.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
29 #include <octave/oct-obj.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
30 #include <octave/ov.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
31 #include <octave/parse.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
32 #include <octave/utils.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
33 #include <octave/unwind-prot.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
34 #include <octave/variables.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
35 #include <octave/data-conv.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
36 #include <octave/byte-swap.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
37
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
38 #include "fixed-def.h"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
39 #include "ov-base-fixed.h"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
40 #include "ov-base-fixed.cc"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
41 #include "int/fixed.h"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
42 #include "ov-fixed.h"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
43 #include "fixed-conv.h"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
44
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
45 template class octave_base_fixed<FixedPoint>;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
46
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
47 DEFINE_OCTAVE_ALLOCATOR(octave_fixed);
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 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(octave_fixed, "fixed scalar",
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
50 "FixedPoint");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
51
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
52 NDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
53 octave_fixed::array_value (bool) const
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
54 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
55 return NDArray (dim_vector (1, 1), scalar.fixedpoint ());
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
58 ComplexNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
59 octave_fixed::complex_array_value (bool) const
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 return ComplexNDArray (dim_vector (1, 1), Complex (scalar.fixedpoint ()));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
62 }
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 octave_value
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
65 octave_fixed::resize (const dim_vector& dv, bool) const
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
66 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
67 if (dv.length() > 2)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
68 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
69 error ("Can not resize fixed point to NDArray");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
70 return octave_value ();
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 FixedMatrix retval (dv(0),dv(1));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
73 if (dv.numel())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
74 retval(0) = scalar;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
75 return new octave_fixed_matrix (retval);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
76 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
77
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
78 octave_value
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
79 octave_fixed::subsasgn (const std::string& type,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
80 const std::list<octave_value_list>& idx,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
81 const octave_value& rhs)
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 octave_value retval;
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 switch (type[0])
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
86 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
87 case '(':
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 if (type.length () == 1)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
90 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
91 if (idx.front().valid_scalar_indices ()
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
92 && rhs.is_scalar_type ()
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
93 && rhs.is_numeric_type ())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
94 retval = rhs;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
95 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
96 retval = numeric_assign (type, idx, rhs);
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 else if ((type.length () == 2) && idx.front().valid_scalar_indices ()
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
99 && rhs.is_scalar_type () && rhs.is_numeric_type ())
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 std::list<octave_value_list>::const_iterator p = idx.begin ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
102 octave_value_list key_idx = *++p;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
103
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
104 assert (key_idx.length () == 1);
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 std::string key = key_idx(0).string_value ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
107
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
108 if (key == __FIXED_SIGN_STR)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
109 error("can not directly change the sign in a fixed structure");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
110 else if (key == __FIXED_VALUE_STR)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
111 error("can not directly change the value of a fixed structure");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
112 else if (key == __FIXED_DECSIZE_STR)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
113 retval = new octave_fixed (scalar.chdecsize(rhs.int_value()));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
114 else if (key == __FIXED_INTSIZE_STR)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
115 retval = new octave_fixed (scalar.chintsize(rhs.int_value()));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
116 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
117 error ("fixed point structure has no member `%s'",
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
118 key.c_str ());
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 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
121 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
122 std::string nm = type_name ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
123 error ("in indexed assignment of %s, illegal assignment",
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
124 nm.c_str ());
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 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
127 break;
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 case '.':
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
130 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
131 octave_value_list key_idx = idx.front ();
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 assert (key_idx.length () == 1);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
134
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
135 std::string key = key_idx(0).string_value ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
136
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
137 if (key == __FIXED_SIGN_STR)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
138 error("can not directly change the sign in a fixed structure");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
139 else if (key == __FIXED_VALUE_STR)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
140 error("can not directly change the value of a fixed structure");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
141 else if (key == __FIXED_DECSIZE_STR)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
142 retval = new octave_fixed (scalar.chdecsize(rhs.int_value()));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
143 else if (key == __FIXED_INTSIZE_STR)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
144 retval = new octave_fixed (scalar.chintsize(rhs.int_value()));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
145 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
146 error ("fixed point structure has no member `%s'", key.c_str ());
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 break;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
149
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
150 case '{':
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
151 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
152 std::string nm = type_name ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
153 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
154 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
155 break;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
156
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
157 default:
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
158 panic_impossible ();
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
161 return retval;
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 octave_value
2419
cd41a9562cee Fix for 2.9.x change to do_index method
adb014
parents: 2394
diff changeset
165 octave_fixed::do_index_op (const octave_value_list& idx, bool resize_ok)
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
166 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
167 octave_value retval;
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 if (idx.valid_scalar_indices ())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
170 retval = new octave_fixed (scalar);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
171 else
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 // XXX FIXME XXX -- this doesn't solve the problem of
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
174 //
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
175 // a = 1; a([1,1], [1,1], [1,1])
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 // and similar constructions. Hmm...
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 // XXX FIXME XXX -- using this constructor avoids narrowing the
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
180 // 1x1 matrix back to a scalar value. Need a better solution
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
181 // to this problem.
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 octave_value tmp (new octave_fixed_matrix (fixed_matrix_value ()));
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 retval = tmp.do_index_op (idx, resize_ok);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
186 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
187
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
188 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
189 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
190
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
191 octave_value
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
192 octave_fixed::convert_to_str (bool) const
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 octave_value retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
195
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
196 int ival = NINT (scalar.fixedpoint());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
197
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
198 if (ival < 0 || ival > UCHAR_MAX)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
199 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
200 // XXX FIXME XXX -- is there something better we could do?
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 ival = 0;
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 ::warning ("range error for conversion to character value");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
205 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
206
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
207 retval = octave_value (std::string (1, static_cast<char> (ival)));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
208
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
209 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
210 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
211
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
212 static void
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
213 restore_precision (void *p)
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 bind_internal_variable ("output_precision", *(static_cast<int *> (p)));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
216 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
217
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
218 void
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
219 octave_fixed::print_raw (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
220 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
221 double min_num = abs(scalar).fixedpoint();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
222 int new_prec = scalar.getdecsize() +
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
223 (min_num >= 1. ? (int)log10(min_num) + 1 : 0);
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 octave_value_list tmp = feval ("output_precision");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
226 int prec = tmp(0).int_value ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
227 unwind_protect::add (restore_precision, &prec);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
228 bind_internal_variable ("output_precision", new_prec);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
229
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
230 indent (os);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
231 octave_print_internal (os, scalar_value(), pr_as_read_syntax);
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 unwind_protect::run ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
234 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
235
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
236 bool
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
237 octave_fixed::save_ascii (std::ostream& os, bool& infnan_warned,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
238 bool strip_nan_and_inf)
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 os << scalar.getintsize () << " "
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
241 << scalar.getdecsize () << " "
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
242 << scalar.getnumber () << "\n";
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
243
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
244 return true;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
245 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
246
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
247 bool
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
248 octave_fixed::load_ascii (std::istream& is)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
249 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
250 unsigned int intsize, decsize, number;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
251
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
252 is >> intsize >> decsize >> number;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
253 scalar = FixedPoint (intsize, decsize, number);
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 return is;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
256 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
257
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
258 bool
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
259 octave_fixed::save_binary (std::ostream& os, bool& save_as_floats)
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 unsigned int itmp;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
262 char tmp = (char) sizeof (unsigned int);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
263 os.write (X_CAST (char *, &tmp), 1);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
264
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
265 // intsize and decsize are integers in the range [0:32], so store as char
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
266 tmp = scalar.getintsize ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
267 LS_DO_WRITE (char, &tmp, 1, 1, os);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
268 tmp = scalar.getdecsize ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
269 LS_DO_WRITE (char, &tmp, 1, 1, os);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
270 itmp = scalar.getnumber ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
271 LS_DO_WRITE (unsigned int, &itmp, sizeof (unsigned int), 1, os);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
272
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
273 return true;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
276 bool
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
277 octave_fixed::load_binary (std::istream& is, bool swap,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
278 oct_mach_info::float_format fmt)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
279 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
280 char size;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
281 unsigned int intsize, decsize, number;
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 if (! is.read (X_CAST (char *, &size), 1))
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
284 return false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
285
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
286 LS_DO_READ_1(&intsize, 1, is);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
287 LS_DO_READ_1(&decsize, 1, is);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
288
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
289 if (size == 4)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
290 LS_DO_READ(unsigned int, swap, &number, 4, 1, is);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
291 else if (size == 8)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
292 LS_DO_READ(unsigned int, swap, &number, 8, 1, is);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
293 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
294 return false;
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 if (error_state || ! is)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
297 return false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
298
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
299 scalar = FixedPoint (intsize, decsize, number);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
300 return true;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
303 #if defined (HAVE_HDF5)
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 octave_fixed::save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats)
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 hid_t group_hid = -1;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
308 group_hid = H5Gcreate (loc_id, name, 0);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
309 if (group_hid < 0 ) return false;
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 hsize_t dims[3];
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
312 hid_t space_hid = -1, data_hid = -1;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
313 bool retval = true;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
314 char tmp;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
315 unsigned int num;
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 space_hid = H5Screate_simple (0, dims, (hsize_t*) 0);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
318 if (space_hid < 0)
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 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
321 return false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
322 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
323
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
324 data_hid = H5Dcreate (group_hid, "int", H5T_NATIVE_UCHAR, space_hid,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
325 H5P_DEFAULT);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
326 if (data_hid < 0)
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 H5Sclose (space_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
329 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
330 return false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
331 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
332
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
333 tmp = scalar.getintsize ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
334 retval = H5Dwrite (data_hid, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
335 (void*) &tmp) >= 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
336 H5Dclose (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
337 if (!retval)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
338 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
339 H5Sclose (space_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
340 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
341 return false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
342 }
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 data_hid = H5Dcreate (group_hid, "dec", H5T_NATIVE_UCHAR, space_hid,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
345 H5P_DEFAULT);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
346 if (data_hid < 0)
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 H5Sclose (space_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
349 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
350 return false;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
353 tmp = scalar.getdecsize ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
354 retval = H5Dwrite (data_hid, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
355 (void*) &tmp) >= 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
356 H5Dclose (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
357 if (!retval)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
358 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
359 H5Sclose (space_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
360 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
361 return false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
362 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
363
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
364 data_hid = H5Dcreate (group_hid, "num", H5T_NATIVE_UINT, space_hid,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
365 H5P_DEFAULT);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
366 if (data_hid < 0)
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 H5Sclose (space_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
369 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
370 return false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
371 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
372
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
373 num = scalar.getnumber ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
374 retval = H5Dwrite (data_hid, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
375 (void*) &num) >= 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
376 H5Dclose (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
377 H5Sclose (space_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
378 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
379 return retval;
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 bool
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
383 octave_fixed::load_hdf5 (hid_t loc_id, const char *name,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
384 bool have_h5giterate_bug)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
385 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
386 char intsize, decsize;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
387 unsigned int number;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
388 hid_t group_hid, data_hid, space_id;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
389 hsize_t rank;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
390
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
391 group_hid = H5Gopen (loc_id, name);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
392 if (group_hid < 0 ) return false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
393
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
394 data_hid = H5Dopen (group_hid, "int");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
395 space_id = H5Dget_space (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
396 rank = H5Sget_simple_extent_ndims (space_id);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
397
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
398 if (rank != 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
399 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
400 H5Dclose (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
401 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
402 return false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
403 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
404
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
405 if (H5Dread (data_hid, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
406 H5P_DEFAULT, (void *) &intsize) < 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
407 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
408 H5Dclose (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
409 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
410 return false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
411 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
412
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
413
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
414 H5Dclose (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
415 data_hid = H5Dopen (group_hid, "dec");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
416 space_id = H5Dget_space (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
417 rank = H5Sget_simple_extent_ndims (space_id);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
418
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
419 if (rank != 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
420 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
421 H5Dclose (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
422 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
423 return false;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
426 if (H5Dread (data_hid, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
427 H5P_DEFAULT, (void *) &decsize) < 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
428 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
429 H5Dclose (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
430 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
431 return false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
432 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
433
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
434 H5Dclose (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
435 data_hid = H5Dopen (group_hid, "num");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
436 space_id = H5Dget_space (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
437 rank = H5Sget_simple_extent_ndims (space_id);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
438
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
439 if (rank != 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
440 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
441 H5Dclose (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
442 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
443 return false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
444 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
445
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
446 if (H5Dread (data_hid, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
447 H5P_DEFAULT, (void *) &number) < 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
448 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
449 H5Dclose (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
450 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
451 return false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
452 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
453
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
454 H5Dclose (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
455 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
456
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
457 scalar = FixedPoint (intsize, decsize, number);
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 return true;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
460 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
461 #endif
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 /*
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
464 ;;; Local Variables: ***
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
465 ;;; mode: C++ ***
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
466 ;;; End: ***
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
467 */
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
468