annotate libinterp/octave-value/ov-lazy-idx.h @ 19897:09ed6f7538dd

avoid needing to include hdf5 in public header files (bug #44370, #43180) * oct-hdf5-id.cc, oct-hdf5-id.h: New files. * libinterp/corefcn/module.mk: Update. * libgui/src/module.mk (src_libgui_src_la_CPPFLAGS): Remove $(HDF5_CPPFLAGS) from the list. * load-save.h (enum load_save_format_type): Always include LS_HDF5 in the list of values. * ls-hdf5.cc (read_hdf5_data, save_hdf5_data): Call check_hdf5_id_type. * oct-hdf5.h: Also #define HDF5_SAVE_TYPE. * ov.h, ov-base.h: Include oct-hdf5-id.h instead of oct-hdf5.h. Always declare load_hdf5 and save_hdf5 functions. * ov-base-int.cc, ov-base-int.h, ov-base.cc, ov-bool-mat.cc, ov-bool-mat.h, ov-bool-sparse.cc, ov-bool-sparse.h, ov-bool.cc, ov-bool.h, ov-cell.cc, ov-cell.h, ov-class.cc, ov-class.h, ov-complex.cc, ov-complex.h, ov-cx-mat.cc, ov-cx-mat.h, ov-cx-sparse.cc, ov-cx-sparse.h, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn-inline.cc, ov-fcn-inline.h, ov-float.cc, ov-float.h, ov-flt-complex.cc, ov-flt-complex.h, ov-flt-cx-mat.cc, ov-flt-cx-mat.h, ov-flt-re-mat.cc, ov-flt-re-mat.h, ov-int16.cc, ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-lazy-idx.h, ov-oncleanup.cc, ov-oncleanup.h, ov-range.cc ov-range.h, ov-re-mat.cc, ov-re-mat.h, ov-re-sparse.cc, ov-re-sparse.h, ov-scalar.cc, ov-scalar.h, ov-str-mat.cc, ov-str-mat.h, ov-struct.cc, ov-struct.h, ov-uint16.cc, ov-uint32.cc, ov-uint64.cc, ov-uint8.cc: Move #ifdef HAVE_HDF5 inside load_hdf5 and save_hdf5 functions. Always declare and define load_hdf5 and save_hdf5 functions.
author John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
date Thu, 26 Feb 2015 10:49:20 -0500
parents 4197fc428c7d
children 0d56160e346d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
1 /*
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
2
19731
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 18416
diff changeset
3 Copyright (C) 2010-2015 VZLU Prague
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
4
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
5 This file is part of Octave.
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
6
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
10 option) any later version.
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
11
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
15 for more details.
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
16
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, see
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>.
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
20
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
21 */
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
22
17822
ebb3ef964372 maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents: 17787
diff changeset
23 #if !defined (octave_ov_lazy_idx_h)
ebb3ef964372 maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents: 17787
diff changeset
24 #define octave_ov_lazy_idx_h 1
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
25
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
26 #include "ov-re-mat.h"
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
27
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
28 // Lazy indices that stay in idx_vector form until the conversion to NDArray is
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
29 // actually needed.
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
30
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
31 class
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
32 OCTINTERP_API
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
33 octave_lazy_index : public octave_base_value
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
34 {
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
35 public:
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
36
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
37 octave_lazy_index (void)
11584
cda4aa780d58 Another round of initialising members in the constructor initialisation list
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents: 11523
diff changeset
38 : octave_base_value (), index (), value () { }
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
39
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
40 octave_lazy_index (const idx_vector& idx)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11584
diff changeset
41 : octave_base_value (), index (idx), value () { }
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
42
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
43 octave_lazy_index (const octave_lazy_index& i)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11584
diff changeset
44 : octave_base_value (), index (i.index), value (i.value) { }
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
45
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
46 ~octave_lazy_index (void) { }
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
47
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
48 octave_base_value *clone (void) const
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
49 { return new octave_lazy_index (*this); }
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
50 octave_base_value *empty_clone (void) const { return new octave_matrix (); }
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
51
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
52 type_conv_info numeric_conversion_function (void) const;
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
53
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
54 octave_base_value *try_narrowing_conversion (void);
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
55
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
56 size_t byte_size (void) const { return numel () * sizeof (octave_idx_type); }
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
57
10339
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10325
diff changeset
58 octave_value squeeze (void) const;
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
59
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
60 octave_value full_value (void) const { return make_value (); }
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
61
18129
e473c4853afc enable non-integer ranges as indices by default and deprecate preference
John W. Eaton <jwe@octave.org>
parents: 17822
diff changeset
62 idx_vector index_vector (bool /* require_integers */ = false) const { return index; }
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
63
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
64 builtin_type_t builtin_type (void) const { return btyp_double; }
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
65
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
66 bool is_real_matrix (void) const { return true; }
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
67
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
68 bool is_real_type (void) const { return true; }
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
69
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
70 bool is_double_type (void) const { return true; }
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
71
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
72 bool is_float_type (void) const { return true; }
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
73
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
74 octave_value subsref (const std::string& type,
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
75 const std::list<octave_value_list>& idx)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
76 { return make_value ().subsref (type, idx); }
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
77
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
78 octave_value_list subsref (const std::string& type,
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
79 const std::list<octave_value_list>& idx, int)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
80 { return subsref (type, idx); }
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
81
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
82 octave_value do_index_op (const octave_value_list& idx,
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
83 bool resize_ok = false)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
84 { return make_value ().do_index_op (idx, resize_ok); }
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
85
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
86 dim_vector dims (void) const { return index.orig_dimensions (); }
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
87
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
88 octave_idx_type numel (void) const { return index.length (0); }
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
89
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
90 octave_idx_type nnz (void) const { return numel (); }
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
91
10339
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10325
diff changeset
92 octave_value reshape (const dim_vector& new_dims) const;
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
93
10339
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10325
diff changeset
94 octave_value permute (const Array<int>& vec, bool inv = false) const;
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
95
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
96 octave_value resize (const dim_vector& dv, bool fill = false) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
97 { return make_value ().resize (dv, fill); }
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
98
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
99 octave_value all (int dim = 0) const { return make_value ().all (dim); }
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
100 octave_value any (int dim = 0) const { return make_value ().any (dim); }
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
101
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
102 MatrixType matrix_type (void) const { return make_value ().matrix_type (); }
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
103 MatrixType matrix_type (const MatrixType& _typ) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
104 { return make_value ().matrix_type (_typ); }
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
105
10339
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10325
diff changeset
106 octave_value sort (octave_idx_type dim = 0, sortmode mode = ASCENDING) const;
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10325
diff changeset
107
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10325
diff changeset
108 octave_value sort (Array<octave_idx_type> &sidx, octave_idx_type dim = 0,
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10325
diff changeset
109 sortmode mode = ASCENDING) const;
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
110
10339
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10325
diff changeset
111 sortmode is_sorted (sortmode mode = UNSORTED) const;
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
112
10339
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10325
diff changeset
113 Array<octave_idx_type> sort_rows_idx (sortmode mode = ASCENDING) const;
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10325
diff changeset
114
de2d43bcb083 optimize some lazy index operations
Jaroslav Hajek <highegg@gmail.com>
parents: 10325
diff changeset
115 sortmode is_sorted_rows (sortmode mode = UNSORTED) const;
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
116
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
117 bool is_matrix_type (void) const { return true; }
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
118
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
119 bool is_numeric_type (void) const { return true; }
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
120
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
121 bool is_defined (void) const { return true; }
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
122
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
123 bool is_constant (void) const { return true; }
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
124
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
125 bool is_true (void) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
126 { return make_value ().is_true (); }
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
127
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
128 bool print_as_scalar (void) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
129 { return make_value ().print_as_scalar (); }
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
130
18416
bcd71a2531d3 Support disp/display overloading in classdef
Michael Goffioul <michael.goffioul@gmail.com>
parents: 18129
diff changeset
131 void print (std::ostream& os, bool pr_as_read_syntax = false)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
132 { make_value ().print (os, pr_as_read_syntax); }
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
133
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
134 void print_info (std::ostream& os, const std::string& prefix) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
135 { make_value ().print_info (os, prefix); }
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
136
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
137 #define FORWARD_VALUE_QUERY(TYPE,NAME) \
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
138 TYPE \
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
139 NAME (void) const { return make_value ().NAME (); }
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
140
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
141 FORWARD_VALUE_QUERY (int8NDArray, int8_array_value)
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
142 FORWARD_VALUE_QUERY (int16NDArray, int16_array_value)
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
143 FORWARD_VALUE_QUERY (int32NDArray, int32_array_value)
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
144 FORWARD_VALUE_QUERY (int64NDArray, int64_array_value)
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
145 FORWARD_VALUE_QUERY (uint8NDArray, uint8_array_value)
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
146 FORWARD_VALUE_QUERY (uint16NDArray, uint16_array_value)
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
147 FORWARD_VALUE_QUERY (uint32NDArray, uint32_array_value)
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
148 FORWARD_VALUE_QUERY (uint64NDArray, uint64_array_value)
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
149
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
150 #define FORWARD_VALUE_QUERY1(TYPE,NAME) \
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
151 TYPE \
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
152 NAME (bool flag = false) const { return make_value ().NAME (flag); }
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
153
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
154 FORWARD_VALUE_QUERY1 (double, double_value)
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
155
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
156 FORWARD_VALUE_QUERY1 (float, float_value)
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
157
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
158 FORWARD_VALUE_QUERY1 (double, scalar_value)
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
159
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
160 FORWARD_VALUE_QUERY1 (Matrix, matrix_value)
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
161
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
162 FORWARD_VALUE_QUERY1 (FloatMatrix, float_matrix_value)
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
163
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
164 FORWARD_VALUE_QUERY1 (Complex, complex_value)
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
165
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
166 FORWARD_VALUE_QUERY1 (FloatComplex, float_complex_value)
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
167
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
168 FORWARD_VALUE_QUERY1 (ComplexMatrix, complex_matrix_value)
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
169
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
170 FORWARD_VALUE_QUERY1 (FloatComplexMatrix, float_complex_matrix_value)
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
171
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
172 FORWARD_VALUE_QUERY1 (ComplexNDArray, complex_array_value)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11584
diff changeset
173
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
174 FORWARD_VALUE_QUERY1 (FloatComplexNDArray, float_complex_array_value)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11584
diff changeset
175
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
176 FORWARD_VALUE_QUERY1 (boolNDArray, bool_array_value)
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
177
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
178 FORWARD_VALUE_QUERY1 (charNDArray, char_array_value)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11584
diff changeset
179
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
180 FORWARD_VALUE_QUERY1 (NDArray, array_value)
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
181
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
182 FORWARD_VALUE_QUERY1 (FloatNDArray, float_array_value)
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
183
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
184 FORWARD_VALUE_QUERY1 (SparseMatrix, sparse_matrix_value)
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
185
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
186 FORWARD_VALUE_QUERY1 (SparseComplexMatrix, sparse_complex_matrix_value)
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
187
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
188 octave_value diag (octave_idx_type k = 0) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
189 { return make_value ().diag (k); }
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
190
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
191 octave_value convert_to_str_internal (bool pad, bool force, char type) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
192 { return make_value ().convert_to_str_internal (pad, force, type); }
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
193
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
194 void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
195 { return make_value ().print_raw (os, pr_as_read_syntax); }
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
196
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
197 bool save_ascii (std::ostream& os);
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
198
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
199 bool load_ascii (std::istream& is);
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
200
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
201 bool save_binary (std::ostream& os, bool& save_as_floats);
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
202
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11584
diff changeset
203 bool load_binary (std::istream& is, bool swap,
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
204 oct_mach_info::float_format fmt);
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
205
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
206
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
207 int write (octave_stream& os, int block_size,
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
208 oct_data_conv::data_type output_type, int skip,
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
209 oct_mach_info::float_format flt_fmt) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
210 { return make_value ().write (os, block_size, output_type, skip, flt_fmt); }
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
211
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
212 // Unsafe. This function exists to support the MEX interface.
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
213 // You should not use it anywhere else.
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11584
diff changeset
214 void *mex_get_data (void) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
215 { return make_value ().mex_get_data (); }
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
216
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
217 mxArray *as_mxArray (void) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
218 { return make_value ().as_mxArray (); }
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
219
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
220 octave_value map (unary_mapper_t umap) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
221 { return make_value ().map (umap); }
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
222
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
223 private:
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
224 const octave_value& make_value (void) const
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
225 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
226 if (value.is_undefined ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
227 value = octave_value (index, false);
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
228
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
229 return value;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
230 }
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
231
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
232 octave_value& make_value (void)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
233 {
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
234 if (value.is_undefined ())
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
235 value = octave_value (index, false);
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
236
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
237 return value;
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
238 }
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
239
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
240 idx_vector index;
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
241 mutable octave_value value;
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
242
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
243 static octave_base_value *
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
244 numeric_conversion_function (const octave_base_value&);
10886
9993f1354713 update news
Jaroslav Hajek <highegg@gmail.com>
parents: 10884
diff changeset
245
10325
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
246 DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
247 };
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
248
8b3cfc1288e2 implement lazy index conversions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
249 #endif