annotate main/fixed/src/ov-fixed.cc @ 9931:58d36e8880db octave-forge

Description: Make the package compile against HDF5 1.8 Author: Rafael Laboissiere <rafael@laboissiere.net>
author jordigh
date Fri, 30 Mar 2012 15:59:45 +0000
parents d84d2fea3c90
children 2deb6b24d293
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: 3935
diff changeset
17 along with this program; see the file COPYING. If not, see
2de537641f94 More copyright updates
adb014
parents: 3935
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 <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>
5248
f8d77845533f Changes for compilation with 3.1.51+
adb014
parents: 4404
diff changeset
31 #include <octave/symtab.h>
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
32 #include <octave/parse.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
33 #include <octave/utils.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
34 #include <octave/unwind-prot.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
35 #include <octave/variables.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
36 #include <octave/data-conv.h>
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
37 #include <octave/byte-swap.h>
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 #include "fixed-def.h"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
40 #include "ov-base-fixed.h"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
41 #include "ov-base-fixed.cc"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
42 #include "int/fixed.h"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
43 #include "ov-fixed.h"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
44 #include "fixed-conv.h"
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
45
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
46 template class octave_base_fixed<FixedPoint>;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
47
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
48 DEFINE_OCTAVE_ALLOCATOR(octave_fixed);
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 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
51 "FixedPoint");
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 NDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
54 octave_fixed::array_value (bool) const
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 return NDArray (dim_vector (1, 1), scalar.fixedpoint ());
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
59 ComplexNDArray
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
60 octave_fixed::complex_array_value (bool) const
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 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
63 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
64
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
65 octave_value
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
66 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
67 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
68 if (dv.length() > 2)
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 error ("Can not resize fixed point to NDArray");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
71 return octave_value ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
72 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
73 FixedMatrix retval (dv(0),dv(1));
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
74 if (dv.numel())
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
75 retval(0) = scalar;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
76 return new octave_fixed_matrix (retval);
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
79 octave_value
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
80 octave_fixed::subsasgn (const std::string& type,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
81 const std::list<octave_value_list>& idx,
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
82 const octave_value& rhs)
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 octave_value retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
85
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
86 switch (type[0])
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 case '(':
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
89 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
90 if (type.length () == 1)
5655
0924c374b60d Update fixed point code for 3.1.x. Minor bug in test code still present though code seems to work fine
adb014
parents: 5248
diff changeset
91 retval = numeric_assign (type, idx, rhs);
0924c374b60d Update fixed point code for 3.1.x. Minor bug in test code still present though code seems to work fine
adb014
parents: 5248
diff changeset
92 else if ((type.length () == 2) && rhs.is_scalar_type () &&
0924c374b60d Update fixed point code for 3.1.x. Minor bug in test code still present though code seems to work fine
adb014
parents: 5248
diff changeset
93 rhs.is_numeric_type ())
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
94 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
95 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
96 octave_value_list key_idx = *++p;
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 assert (key_idx.length () == 1);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
99
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
100 std::string key = key_idx(0).string_value ();
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 if (key == __FIXED_SIGN_STR)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
103 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
104 else if (key == __FIXED_VALUE_STR)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
105 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
106 else if (key == __FIXED_DECSIZE_STR)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
107 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
108 else if (key == __FIXED_INTSIZE_STR)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
109 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
110 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
111 error ("fixed point structure has no member `%s'",
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
112 key.c_str ());
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
113 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
114 else
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 std::string nm = type_name ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
117 error ("in indexed assignment of %s, illegal assignment",
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
118 nm.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 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
121 break;
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 case '.':
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 octave_value_list key_idx = idx.front ();
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 assert (key_idx.length () == 1);
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 std::string key = key_idx(0).string_value ();
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 if (key == __FIXED_SIGN_STR)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
132 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
133 else if (key == __FIXED_VALUE_STR)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
134 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
135 else if (key == __FIXED_DECSIZE_STR)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
136 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
137 else if (key == __FIXED_INTSIZE_STR)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
138 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
139 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
140 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
141 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
142 break;
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 case '{':
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 std::string nm = type_name ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
147 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
148 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
149 break;
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 default:
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
152 panic_impossible ();
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 return retval;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
158 octave_value
2419
cd41a9562cee Fix for 2.9.x change to do_index method
adb014
parents: 2394
diff changeset
159 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
160 {
5655
0924c374b60d Update fixed point code for 3.1.x. Minor bug in test code still present though code seems to work fine
adb014
parents: 5248
diff changeset
161 // XXX FIXME XXX -- this doesn't solve the problem of
0924c374b60d Update fixed point code for 3.1.x. Minor bug in test code still present though code seems to work fine
adb014
parents: 5248
diff changeset
162 //
0924c374b60d Update fixed point code for 3.1.x. Minor bug in test code still present though code seems to work fine
adb014
parents: 5248
diff changeset
163 // a = 1; a([1,1], [1,1], [1,1])
0924c374b60d Update fixed point code for 3.1.x. Minor bug in test code still present though code seems to work fine
adb014
parents: 5248
diff changeset
164 //
0924c374b60d Update fixed point code for 3.1.x. Minor bug in test code still present though code seems to work fine
adb014
parents: 5248
diff changeset
165 // and similar constructions. Hmm...
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
166
5655
0924c374b60d Update fixed point code for 3.1.x. Minor bug in test code still present though code seems to work fine
adb014
parents: 5248
diff changeset
167 // XXX FIXME XXX -- using this constructor avoids narrowing the
0924c374b60d Update fixed point code for 3.1.x. Minor bug in test code still present though code seems to work fine
adb014
parents: 5248
diff changeset
168 // 1x1 matrix back to a scalar value. Need a better solution
0924c374b60d Update fixed point code for 3.1.x. Minor bug in test code still present though code seems to work fine
adb014
parents: 5248
diff changeset
169 // to this problem.
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
170
5655
0924c374b60d Update fixed point code for 3.1.x. Minor bug in test code still present though code seems to work fine
adb014
parents: 5248
diff changeset
171 octave_value tmp (new octave_fixed_matrix (fixed_matrix_value ()));
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
172
5655
0924c374b60d Update fixed point code for 3.1.x. Minor bug in test code still present though code seems to work fine
adb014
parents: 5248
diff changeset
173 return tmp.do_index_op (idx, resize_ok);
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
174 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
175
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
176 octave_value
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
177 octave_fixed::convert_to_str (bool) const
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 octave_value retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
180
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
181 int ival = NINT (scalar.fixedpoint());
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 if (ival < 0 || ival > UCHAR_MAX)
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 // 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
186
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
187 ival = 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
188
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
189 ::warning ("range error for conversion to character value");
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
192 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
193
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
194 return 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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
197 static void
9481
d84d2fea3c90 Re-enable compilation of fixed package
jordigh
parents: 5655
diff changeset
198 restore_precision (int *p)
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
199 {
9481
d84d2fea3c90 Re-enable compilation of fixed package
jordigh
parents: 5655
diff changeset
200 bind_internal_variable ("output_precision", *p);
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
201 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
202
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
203 void
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
204 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
205 {
5248
f8d77845533f Changes for compilation with 3.1.51+
adb014
parents: 4404
diff changeset
206 double min_num = ::abs(scalar).fixedpoint();
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
207 int new_prec = scalar.getdecsize() +
5248
f8d77845533f Changes for compilation with 3.1.51+
adb014
parents: 4404
diff changeset
208 (min_num >= 1. ? (int)::log10(min_num) + 1 : 0);
2383
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 octave_value_list tmp = feval ("output_precision");
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
211 int prec = tmp(0).int_value ();
9481
d84d2fea3c90 Re-enable compilation of fixed package
jordigh
parents: 5655
diff changeset
212
d84d2fea3c90 Re-enable compilation of fixed package
jordigh
parents: 5655
diff changeset
213 unwind_protect frame;
d84d2fea3c90 Re-enable compilation of fixed package
jordigh
parents: 5655
diff changeset
214
d84d2fea3c90 Re-enable compilation of fixed package
jordigh
parents: 5655
diff changeset
215 frame.add_fcn (restore_precision, &prec);
d84d2fea3c90 Re-enable compilation of fixed package
jordigh
parents: 5655
diff changeset
216
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
217 bind_internal_variable ("output_precision", new_prec);
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 indent (os);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
220 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
221 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
222
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
223 bool
3935
283f38d1e7eb remove strip_nan_and_inf arg from save_ascii functions (For John Eaton)
adb014
parents: 3272
diff changeset
224 octave_fixed::save_ascii (std::ostream& os)
2383
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 os << scalar.getintsize () << " "
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
227 << scalar.getdecsize () << " "
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
228 << scalar.getnumber () << "\n";
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 return true;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
231 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
232
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
233 bool
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
234 octave_fixed::load_ascii (std::istream& is)
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 unsigned int intsize, decsize, number;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
237
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
238 is >> intsize >> decsize >> number;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
239 scalar = FixedPoint (intsize, decsize, number);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
240
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
241 return is;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
244 bool
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
245 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
246 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
247 unsigned int itmp;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
248 char tmp = (char) sizeof (unsigned int);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
249 os.write (X_CAST (char *, &tmp), 1);
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 // 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
252 tmp = scalar.getintsize ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
253 LS_DO_WRITE (char, &tmp, 1, 1, os);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
254 tmp = scalar.getdecsize ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
255 LS_DO_WRITE (char, &tmp, 1, 1, os);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
256 itmp = scalar.getnumber ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
257 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
258
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
259 return true;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
262 bool
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
263 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
264 oct_mach_info::float_format fmt)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
265 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
266 char size;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
267 unsigned int intsize, decsize, number;
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 if (! is.read (X_CAST (char *, &size), 1))
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
270 return false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
271
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
272 LS_DO_READ_1(&intsize, 1, is);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
273 LS_DO_READ_1(&decsize, 1, is);
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 if (size == 4)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
276 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
277 else if (size == 8)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
278 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
279 else
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
280 return false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
281
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
282 if (error_state || ! is)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
283 return false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
284
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
285 scalar = FixedPoint (intsize, decsize, number);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
286 return true;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
289 #if defined (HAVE_HDF5)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
290 bool
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
291 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
292 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
293 hid_t group_hid = -1;
9931
58d36e8880db Description: Make the package compile against HDF5 1.8
jordigh
parents: 9481
diff changeset
294 group_hid = H5Gcreate (loc_id, name, 0, H5P_DEFAULT, H5P_DEFAULT);
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
295 if (group_hid < 0 ) return false;
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 hsize_t dims[3];
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
298 hid_t space_hid = -1, data_hid = -1;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
299 bool retval = true;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
300 char tmp;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
301 unsigned int num;
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 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
304 if (space_hid < 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
305 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
306 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
307 return false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
308 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
309
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
310 data_hid = H5Dcreate (group_hid, "int", H5T_NATIVE_UCHAR, space_hid,
9931
58d36e8880db Description: Make the package compile against HDF5 1.8
jordigh
parents: 9481
diff changeset
311 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
312 if (data_hid < 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
313 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
314 H5Sclose (space_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
315 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
316 return false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
317 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
318
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
319 tmp = scalar.getintsize ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
320 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
321 (void*) &tmp) >= 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
322 H5Dclose (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
323 if (!retval)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
324 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
325 H5Sclose (space_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
326 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
327 return false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
328 }
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 data_hid = H5Dcreate (group_hid, "dec", H5T_NATIVE_UCHAR, space_hid,
9931
58d36e8880db Description: Make the package compile against HDF5 1.8
jordigh
parents: 9481
diff changeset
331 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
332 if (data_hid < 0)
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 H5Sclose (space_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
335 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
336 return false;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
339 tmp = scalar.getdecsize ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
340 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
341 (void*) &tmp) >= 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
342 H5Dclose (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
343 if (!retval)
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 H5Sclose (space_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
346 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
347 return false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
348 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
349
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
350 data_hid = H5Dcreate (group_hid, "num", H5T_NATIVE_UINT, space_hid,
9931
58d36e8880db Description: Make the package compile against HDF5 1.8
jordigh
parents: 9481
diff changeset
351 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
352 if (data_hid < 0)
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 H5Sclose (space_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
355 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
356 return false;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
359 num = scalar.getnumber ();
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
360 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
361 (void*) &num) >= 0;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
362 H5Dclose (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
363 H5Sclose (space_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
364 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
365 return retval;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
366 }
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 bool
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
369 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
370 bool have_h5giterate_bug)
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 char intsize, decsize;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
373 unsigned int number;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
374 hid_t group_hid, data_hid, space_id;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
375 hsize_t rank;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
376
9931
58d36e8880db Description: Make the package compile against HDF5 1.8
jordigh
parents: 9481
diff changeset
377 group_hid = H5Gopen (loc_id, name, H5P_DEFAULT);
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
378 if (group_hid < 0 ) return false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
379
9931
58d36e8880db Description: Make the package compile against HDF5 1.8
jordigh
parents: 9481
diff changeset
380 data_hid = H5Dopen (group_hid, "int", H5P_DEFAULT);
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
381 space_id = H5Dget_space (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
382 rank = H5Sget_simple_extent_ndims (space_id);
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 if (rank != 0)
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 H5Dclose (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
387 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
388 return false;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
389 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
390
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
391 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
392 H5P_DEFAULT, (void *) &intsize) < 0)
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 H5Dclose (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
395 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
396 return false;
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
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);
9931
58d36e8880db Description: Make the package compile against HDF5 1.8
jordigh
parents: 9481
diff changeset
401 data_hid = H5Dopen (group_hid, "dec", H5P_DEFAULT);
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
402 space_id = H5Dget_space (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
403 rank = H5Sget_simple_extent_ndims (space_id);
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 (rank != 0)
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 H5Dclose (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
408 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
409 return false;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
412 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
413 H5P_DEFAULT, (void *) &decsize) < 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
414 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
415 H5Dclose (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
416 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
417 return false;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
420 H5Dclose (data_hid);
9931
58d36e8880db Description: Make the package compile against HDF5 1.8
jordigh
parents: 9481
diff changeset
421 data_hid = H5Dopen (group_hid, "num", H5P_DEFAULT);
2383
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
422 space_id = H5Dget_space (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
423 rank = H5Sget_simple_extent_ndims (space_id);
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 if (rank != 0)
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 H5Dclose (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
428 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
429 return false;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
432 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
433 H5P_DEFAULT, (void *) &number) < 0)
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
434 {
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
435 H5Dclose (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
436 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
437 return false;
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
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
440 H5Dclose (data_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
441 H5Gclose (group_hid);
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
442
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
443 scalar = FixedPoint (intsize, decsize, number);
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 return true;
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
446 }
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
447 #endif
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 /*
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
450 ;;; Local Variables: ***
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
451 ;;; mode: C++ ***
d1930f8af7ca Changed the directory structure of fixed to match the package system
hauberg
parents:
diff changeset
452 ;;; End: ***
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