Mercurial > forge
annotate main/fixed/src/ov-fixed.cc @ 2383:d1930f8af7ca octave-forge
Changed the directory structure of fixed to match the package system
author | hauberg |
---|---|
date | Sun, 20 Aug 2006 14:43:38 +0000 |
parents | |
children | 1728eb2120ef |
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 #if defined (__GNUG__) && defined (USE_PRAGMA_INTERFACE_IMPLEMENTATION) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
27 #pragma implementation |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
28 #endif |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
29 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
30 #include <iostream> |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
31 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
32 #include <octave/config.h> |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
33 #include <octave/oct-obj.h> |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
34 #include <octave/ov.h> |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
35 #include <octave/parse.h> |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
36 #include <octave/utils.h> |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
37 #include <octave/unwind-prot.h> |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
38 #include <octave/variables.h> |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
39 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
40 #ifdef CLASS_HAS_LOAD_SAVE |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
41 #include <octave/data-conv.h> |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
42 #include <octave/byte-swap.h> |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
43 #endif |
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 #include "fixed-def.h" |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
46 #include "ov-base-fixed.h" |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
47 #include "ov-base-fixed.cc" |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
48 #include "int/fixed.h" |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
49 #include "ov-fixed.h" |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
50 #include "fixed-conv.h" |
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 template class octave_base_fixed<FixedPoint>; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
53 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
54 DEFINE_OCTAVE_ALLOCATOR(octave_fixed); |
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 #ifdef TYPEID_HAS_CLASS |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
57 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
|
58 "FixedPoint"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
59 #else |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
60 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
|
61 #endif |
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 #ifdef HAVE_ND_ARRAYS |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
64 NDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
65 octave_fixed::array_value (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 return NDArray (dim_vector (1, 1), scalar.fixedpoint ()); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
68 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
69 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
70 ComplexNDArray |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
71 octave_fixed::complex_array_value (bool) const |
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 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
|
74 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
75 #endif |
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 #if defined (HAVE_OCTAVE_CONCAT) || defined (HAVE_OLD_OCTAVE_CONCAT) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
78 octave_value |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
79 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
|
80 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
81 if (dv.length() > 2) |
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 error ("Can not resize fixed point to NDArray"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
84 return octave_value (); |
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 FixedMatrix retval (dv(0),dv(1)); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
87 if (dv.numel()) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
88 retval(0) = scalar; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
89 return new octave_fixed_matrix (retval); |
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 #endif |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
92 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
93 octave_value |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
94 octave_fixed::subsasgn (const std::string& type, |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
95 const std::list<octave_value_list>& idx, |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
96 const octave_value& 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 octave_value retval; |
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 switch (type[0]) |
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 case '(': |
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 if (type.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 if (idx.front().valid_scalar_indices () |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
107 && rhs.is_scalar_type () |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
108 && rhs.is_numeric_type ()) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
109 retval = rhs; |
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 retval = numeric_assign (type, idx, rhs); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
112 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
113 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
|
114 && rhs.is_scalar_type () && rhs.is_numeric_type ()) |
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::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
|
117 octave_value_list key_idx = *++p; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
118 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
119 assert (key_idx.length () == 1); |
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 std::string key = key_idx(0).string_value (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
122 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
123 if (key == __FIXED_SIGN_STR) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
124 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
|
125 else if (key == __FIXED_VALUE_STR) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
126 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
|
127 else if (key == __FIXED_DECSIZE_STR) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
128 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
|
129 else if (key == __FIXED_INTSIZE_STR) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
130 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
|
131 else |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
132 error ("fixed point structure has no member `%s'", |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
133 key.c_str ()); |
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 else |
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 std::string nm = type_name (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
138 error ("in indexed assignment of %s, illegal assignment", |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
139 nm.c_str ()); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
140 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
141 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
142 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 octave_value_list key_idx = idx.front (); |
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 assert (key_idx.length () == 1); |
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 std::string key = key_idx(0).string_value (); |
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 if (key == __FIXED_SIGN_STR) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
153 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
|
154 else if (key == __FIXED_VALUE_STR) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
155 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
|
156 else if (key == __FIXED_DECSIZE_STR) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
157 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
|
158 else if (key == __FIXED_INTSIZE_STR) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
159 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
|
160 else |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
161 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
|
162 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
163 break; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
164 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
165 case '{': |
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 std::string nm = type_name (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
168 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
|
169 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
170 break; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
171 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
172 default: |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
173 panic_impossible (); |
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 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
177 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
178 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
179 octave_value |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
180 octave_fixed::do_index_op (const octave_value_list& idx, int resize_ok) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
181 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
182 octave_value retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
183 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
184 if (idx.valid_scalar_indices ()) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
185 retval = new octave_fixed (scalar); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
186 else |
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 // 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
|
189 // |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
190 // 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
|
191 // |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
192 // and similar constructions. Hmm... |
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 // 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
|
195 // 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
|
196 // to this problem. |
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 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
|
199 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
200 retval = tmp.do_index_op (idx, resize_ok); |
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 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
204 } |
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 octave_value |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
207 octave_fixed::convert_to_str (bool) const |
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 octave_value 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 int ival = NINT (scalar.fixedpoint()); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
212 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
213 if (ival < 0 || ival > UCHAR_MAX) |
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 // 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
|
216 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
217 ival = 0; |
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 ::warning ("range error for conversion to character value"); |
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 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
222 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
|
223 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
224 return retval; |
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 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
227 static void |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
228 restore_precision (void *p) |
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 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
|
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 void |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
234 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
|
235 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
236 double min_num = abs(scalar).fixedpoint(); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
237 int new_prec = scalar.getdecsize() + |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
238 (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
|
239 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
240 octave_value_list tmp = feval ("output_precision"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
241 int prec = tmp(0).int_value (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
242 unwind_protect::add (restore_precision, &prec); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
243 bind_internal_variable ("output_precision", new_prec); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
244 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
245 indent (os); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
246 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
|
247 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
248 unwind_protect::run (); |
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 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
251 #ifdef CLASS_HAS_LOAD_SAVE |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
252 bool |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
253 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
|
254 bool strip_nan_and_inf) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
255 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
256 os << scalar.getintsize () << " " |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
257 << scalar.getdecsize () << " " |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
258 << scalar.getnumber () << "\n"; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
259 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
260 return true; |
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 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
263 bool |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
264 octave_fixed::load_ascii (std::istream& is) |
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 unsigned int intsize, decsize, number; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
267 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
268 is >> intsize >> decsize >> number; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
269 scalar = FixedPoint (intsize, decsize, number); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
270 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
271 return is; |
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 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
274 bool |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
275 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
|
276 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
277 unsigned int itmp; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
278 char tmp = (char) sizeof (unsigned int); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
279 os.write (X_CAST (char *, &tmp), 1); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
280 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
281 // 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
|
282 tmp = scalar.getintsize (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
283 LS_DO_WRITE (char, &tmp, 1, 1, os); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
284 tmp = scalar.getdecsize (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
285 LS_DO_WRITE (char, &tmp, 1, 1, os); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
286 itmp = scalar.getnumber (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
287 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
|
288 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
289 return true; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
290 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
291 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
292 bool |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
293 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
|
294 oct_mach_info::float_format fmt) |
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 char size; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
297 unsigned int intsize, decsize, number; |
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 if (! is.read (X_CAST (char *, &size), 1)) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
300 return false; |
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 LS_DO_READ_1(&intsize, 1, is); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
303 LS_DO_READ_1(&decsize, 1, is); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
304 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
305 if (size == 4) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
306 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
|
307 else if (size == 8) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
308 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
|
309 else |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
310 return false; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
311 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
312 if (error_state || ! is) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
313 return false; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
314 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
315 scalar = FixedPoint (intsize, decsize, number); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
316 return true; |
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 #if defined (HAVE_HDF5) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
320 bool |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
321 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
|
322 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
323 hid_t group_hid = -1; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
324 group_hid = H5Gcreate (loc_id, name, 0); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
325 if (group_hid < 0 ) return false; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
326 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
327 hsize_t dims[3]; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
328 hid_t space_hid = -1, data_hid = -1; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
329 bool retval = true; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
330 char tmp; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
331 unsigned int num; |
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 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
|
334 if (space_hid < 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
335 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
336 H5Gclose (group_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
337 return false; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
338 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
339 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
340 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
|
341 H5P_DEFAULT); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
342 if (data_hid < 0) |
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 H5Sclose (space_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
345 H5Gclose (group_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
346 return false; |
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 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
349 tmp = scalar.getintsize (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
350 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
|
351 (void*) &tmp) >= 0; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
352 H5Dclose (data_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
353 if (!retval) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
354 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
355 H5Sclose (space_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
356 H5Gclose (group_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
357 return false; |
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 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
360 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
|
361 H5P_DEFAULT); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
362 if (data_hid < 0) |
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 H5Sclose (space_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
365 H5Gclose (group_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
366 return false; |
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 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
369 tmp = scalar.getdecsize (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
370 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
|
371 (void*) &tmp) >= 0; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
372 H5Dclose (data_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
373 if (!retval) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
374 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
375 H5Sclose (space_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
376 H5Gclose (group_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
377 return false; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
378 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
379 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
380 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
|
381 H5P_DEFAULT); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
382 if (data_hid < 0) |
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 H5Sclose (space_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
385 H5Gclose (group_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
386 return false; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
387 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
388 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
389 num = scalar.getnumber (); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
390 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
|
391 (void*) &num) >= 0; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
392 H5Dclose (data_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
393 H5Sclose (space_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
394 H5Gclose (group_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
395 return retval; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
396 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
397 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
398 bool |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
399 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
|
400 bool have_h5giterate_bug) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
401 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
402 char intsize, decsize; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
403 unsigned int number; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
404 hid_t group_hid, data_hid, space_id; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
405 hsize_t rank; |
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 group_hid = H5Gopen (loc_id, name); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
408 if (group_hid < 0 ) return false; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
409 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
410 data_hid = H5Dopen (group_hid, "int"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
411 space_id = H5Dget_space (data_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
412 rank = H5Sget_simple_extent_ndims (space_id); |
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 if (rank != 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
415 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
416 H5Dclose (data_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
417 H5Gclose (group_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
418 return false; |
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 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
421 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
|
422 H5P_DEFAULT, (void *) &intsize) < 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
423 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
424 H5Dclose (data_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
425 H5Gclose (group_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
426 return false; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
427 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
428 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
429 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
430 H5Dclose (data_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
431 data_hid = H5Dopen (group_hid, "dec"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
432 space_id = H5Dget_space (data_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
433 rank = H5Sget_simple_extent_ndims (space_id); |
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 if (rank != 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
436 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
437 H5Dclose (data_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
438 H5Gclose (group_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
439 return false; |
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 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
442 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
|
443 H5P_DEFAULT, (void *) &decsize) < 0) |
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 H5Dclose (data_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
446 H5Gclose (group_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
447 return false; |
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 H5Dclose (data_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
451 data_hid = H5Dopen (group_hid, "num"); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
452 space_id = H5Dget_space (data_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
453 rank = H5Sget_simple_extent_ndims (space_id); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
454 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
455 if (rank != 0) |
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 H5Dclose (data_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
458 H5Gclose (group_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
459 return false; |
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 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
462 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
|
463 H5P_DEFAULT, (void *) &number) < 0) |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
464 { |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
465 H5Dclose (data_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
466 H5Gclose (group_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
467 return false; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
468 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
469 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
470 H5Dclose (data_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
471 H5Gclose (group_hid); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
472 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
473 scalar = FixedPoint (intsize, decsize, number); |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
474 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
475 return true; |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
476 } |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
477 #endif |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
478 #endif |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
479 |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
480 /* |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
481 ;;; Local Variables: *** |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
482 ;;; mode: C++ *** |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
483 ;;; End: *** |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
484 */ |
d1930f8af7ca
Changed the directory structure of fixed to match the package system
hauberg
parents:
diff
changeset
|
485 |