annotate libinterp/octave-value/ov-bool.cc @ 21100:e39e05d90788

Switch gripe_XXX to either err_XXX or warn_XXX naming scheme. * libinterp/corefcn/errwarn.h, libinterp/corefcn/errwarn.cc: New header and .cc file with common errors and warnings for libinterp. * libinterp/corefcn/module.mk: Add errwarn.h, errwarn.cc to build system. * liboctave/util/lo-array-errwarn.h, liboctave/util/lo-array-errwarn.cc: New header and .cc file with common errors and warnings for liboctave. * liboctave/util/module.mk: Add lo-array-errwarn.h, lo-array-errwarn.cc to build system. * lo-array-gripes.h: #include "lo-array-errwarn.h" for access to class index_exception. Remove const char *error_id_XXX prototypes. * lo-array-gripes.cc: Remove const char *error_id_XXX initializations. Remove index_exception method definitions. * Cell.cc, __pchip_deriv__.cc, __qp__.cc, balance.cc, betainc.cc, cellfun.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, debug.cc, defaults.cc, det.cc, dirfns.cc, eig.cc, fft.cc, fft2.cc, fftn.cc, find.cc, gammainc.cc, gcd.cc, getgrent.cc, getpwent.cc, graphics.in.h, help.cc, hess.cc, hex2num.cc, input.cc, inv.cc, jit-typeinfo.cc, load-save.cc, lookup.cc, ls-hdf5.cc, ls-mat-ascii.cc, ls-mat4.cc, ls-mat5.cc, ls-oct-binary.cc, ls-oct-text.cc, lsode.cc, lu.cc, luinc.cc, max.cc, mgorth.cc, oct-hist.cc, oct-procbuf.cc, oct-stream.cc, oct.h, pager.cc, pinv.cc, pr-output.cc, quad.cc, qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, sparse-xdiv.cc, sparse-xpow.cc, sparse.cc, spparms.cc, sqrtm.cc, str2double.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc, syscalls.cc, typecast.cc, utils.cc, variables.cc, xdiv.cc, xnorm.cc, xpow.cc, __eigs__.cc, __glpk__.cc, __magick_read__.cc, __osmesa_print__.cc, audiodevinfo.cc, audioread.cc, chol.cc, dmperm.cc, fftw.cc, qr.cc, symbfact.cc, symrcm.cc, ov-base-diag.cc, ov-base-int.cc, ov-base-mat.cc, ov-base-scalar.cc, ov-base-sparse.cc, ov-base.cc, ov-bool-mat.cc, ov-bool-sparse.cc, ov-bool.cc, ov-builtin.cc, ov-cell.cc, ov-ch-mat.cc, ov-class.cc, ov-complex.cc, ov-complex.h, ov-cs-list.cc, ov-cx-diag.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-fcn-handle.cc, ov-fcn-inline.cc, ov-float.cc, ov-float.h, ov-flt-complex.cc, ov-flt-complex.h, ov-flt-cx-diag.cc, ov-flt-cx-mat.cc, ov-flt-re-mat.cc, ov-int16.cc, ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-intx.h, ov-mex-fcn.cc, ov-perm.cc, ov-range.cc, ov-re-mat.cc, ov-re-sparse.cc, ov-scalar.cc, ov-scalar.h, ov-str-mat.cc, ov-struct.cc, ov-type-conv.h, ov-uint16.cc, ov-uint32.cc, ov-uint64.cc, ov-uint8.cc, ov-usr-fcn.cc, ov.cc, op-b-b.cc, op-b-bm.cc, op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc, op-chm.cc, op-class.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc, op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc, op-cs-scm.cc, op-cs-sm.cc, op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc, op-dms-template.cc, op-double-conv.cc, op-fcdm-fcdm.cc, op-fcdm-fdm.cc, op-fcm-fcm.cc, op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcn.cc, op-fcs-fcm.cc, op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fdm.cc, op-float-conv.cc, op-fm-fcm.cc, op-fm-fcs.cc, op-fm-fm.cc, op-fm-fs.cc, op-fs-fcm.cc, op-fs-fcs.cc, op-fs-fm.cc, op-fs-fs.cc, op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc, op-i8-i8.cc, op-int-concat.cc, op-int-conv.cc, op-int.h, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc, op-m-scm.cc, op-m-sm.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc, op-range.cc, op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc, op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc, op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc, op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc, op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc, op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc, ops.h, lex.ll, pt-assign.cc, pt-eval.cc, pt-idx.cc, pt-loop.cc, pt-mat.cc, pt-stmt.cc, Array-util.cc, Array-util.h, Array.cc, CColVector.cc, CDiagMatrix.cc, CMatrix.cc, CNDArray.cc, CRowVector.cc, CSparse.cc, DiagArray2.cc, MDiagArray2.cc, MSparse.cc, PermMatrix.cc, Range.cc, Sparse.cc, dColVector.cc, dDiagMatrix.cc, dMatrix.cc, dNDArray.cc, dRowVector.cc, dSparse.cc, fCColVector.cc, fCDiagMatrix.cc, fCMatrix.cc, fCNDArray.cc, fCRowVector.cc, fColVector.cc, fDiagMatrix.cc, fMatrix.cc, fNDArray.cc, fRowVector.cc, idx-vector.cc, CmplxGEPBAL.cc, dbleGEPBAL.cc, fCmplxGEPBAL.cc, floatGEPBAL.cc, Sparse-diag-op-defs.h, Sparse-op-defs.h, Sparse-perm-op-defs.h, mx-inlines.cc, mx-op-defs.h, oct-binmap.h: Replace 'include "gripes.h"' with 'include "errwarn.h". Change all gripe_XXX to err_XXX or warn_XXX or errwarn_XXX.
author Rik <rik@octave.org>
date Mon, 18 Jan 2016 18:28:06 -0800
parents ebc439187d29
children dfcb9d74b253
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
1 /*
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
2
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19598
diff changeset
3 Copyright (C) 1996-2015 John W. Eaton
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
4
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
6
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6974
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6974
diff changeset
10 option) any later version.
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
11
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
15 for more details.
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
16
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6974
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6974
diff changeset
19 <http://www.gnu.org/licenses/>.
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
20
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
21 */
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
22
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
24 #include <config.h>
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
25 #endif
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
26
3503
d14c483b3c12 [project @ 2000-02-01 04:06:07 by jwe]
jwe
parents: 3223
diff changeset
27 #include <iostream>
2901
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents: 2871
diff changeset
28
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
29 #include "mx-base.h"
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
30
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 21022
diff changeset
31 #include "errwarn.h"
15149
62a35ae7d6a2 use forward decls for mxArray in ov.h and ov-base.h
John W. Eaton <jwe@octave.org>
parents: 15057
diff changeset
32 #include "mxarray.h"
19863
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
33 #include "oct-hdf5.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20879
diff changeset
34 #include "ovl.h"
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
35 #include "ops.h"
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
36 #include "ov-bool.h"
4964
269c3d6c0569 [project @ 2004-09-04 01:16:28 by jwe]
jwe
parents: 4944
diff changeset
37 #include "ov-bool-mat.h"
3223
3ee04ff37b3e [project @ 1998-11-20 19:34:15 by jwe]
jwe
parents: 3219
diff changeset
38 #include "ov-base.h"
3ee04ff37b3e [project @ 1998-11-20 19:34:15 by jwe]
jwe
parents: 3219
diff changeset
39 #include "ov-base-scalar.h"
3ee04ff37b3e [project @ 1998-11-20 19:34:15 by jwe]
jwe
parents: 3219
diff changeset
40 #include "ov-base-scalar.cc"
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
41 #include "ov-re-mat.h"
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
42 #include "ov-scalar.h"
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
43 #include "pr-output.h"
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
44
20447
c6224b4e7774 maint: Rename instances of LS_ASCII to LS_TEXT for clarity.
Rik <rik@octave.org>
parents: 19863
diff changeset
45 #include "ls-oct-text.h"
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
46 #include "ls-hdf5.h"
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
47
3223
3ee04ff37b3e [project @ 1998-11-20 19:34:15 by jwe]
jwe
parents: 3219
diff changeset
48 template class octave_base_scalar<bool>;
3ee04ff37b3e [project @ 1998-11-20 19:34:15 by jwe]
jwe
parents: 3219
diff changeset
49
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
50
4612
d44675070f1a [project @ 2003-11-14 19:49:56 by jwe]
jwe
parents: 4457
diff changeset
51 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_bool, "bool", "logical");
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
52
5759
ce79d238f142 [project @ 2006-04-13 13:04:32 by jwe]
jwe
parents: 5731
diff changeset
53 static octave_base_value *
ce79d238f142 [project @ 2006-04-13 13:04:32 by jwe]
jwe
parents: 5731
diff changeset
54 default_numeric_conversion_function (const octave_base_value& a)
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
55 {
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
56 CAST_CONV_ARG (const octave_bool&);
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
57
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
58 return new octave_scalar (v.bool_value ());
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
59 }
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
60
8345
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
61 octave_base_value::type_conv_info
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
62 octave_bool::numeric_conversion_function (void) const
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
63 {
8345
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
64 return octave_base_value::type_conv_info (default_numeric_conversion_function,
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
65 octave_scalar::static_type_id ());
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 7017
diff changeset
66
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
67 }
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
68
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
69 octave_value
5885
bd3041e30d97 [project @ 2006-07-14 20:29:35 by jwe]
jwe
parents: 5775
diff changeset
70 octave_bool::do_index_op (const octave_value_list& idx, bool resize_ok)
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
71 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
72 // FIXME: this doesn't solve the problem of
8437
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
73 //
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
74 // a = 1; a([1,1], [1,1], [1,1])
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
75 //
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
76 // and similar constructions. Hmm...
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
77
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
78 // FIXME: using this constructor avoids narrowing the
8437
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
79 // 1x1 matrix back to a scalar value. Need a better solution
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
80 // to this problem.
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
81
8437
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
82 octave_value tmp (new octave_bool_matrix (bool_matrix_value ()));
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
83
8437
f00578b495e9 remove valid_as_scalar_index
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
84 return tmp.do_index_op (idx, resize_ok);
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
85 }
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
86
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
87 octave_value
5731
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5307
diff changeset
88 octave_bool::resize (const dim_vector& dv, bool fill) const
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
89 {
5731
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5307
diff changeset
90 if (fill)
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5307
diff changeset
91 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
92 boolNDArray retval (dv, false);
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
93 if (dv.numel ())
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
94 retval(0) = scalar;
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
95 return retval;
5731
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5307
diff changeset
96 }
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5307
diff changeset
97 else
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5307
diff changeset
98 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
99 boolNDArray retval (dv);
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
100 if (dv.numel ())
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
101 retval(0) = scalar;
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
102 return retval;
5731
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5307
diff changeset
103 }
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5307
diff changeset
104 }
c7d5a534afa5 [project @ 2006-04-03 19:33:26 by jwe]
jwe
parents: 5307
diff changeset
105
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
106 octave_value
5279
bd32f770c09a [project @ 2005-04-12 21:55:31 by jwe]
jwe
parents: 5105
diff changeset
107 octave_bool::convert_to_str_internal (bool, bool, char type) const
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
108 {
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
109 char s[2];
4358
83d4452bc522 [project @ 2003-02-23 02:16:53 by jwe]
jwe
parents: 4192
diff changeset
110 s[0] = static_cast<char> (scalar);
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
111 s[1] = '\0';
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
112
5279
bd32f770c09a [project @ 2005-04-12 21:55:31 by jwe]
jwe
parents: 5105
diff changeset
113 return octave_value (s, type);
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
114 }
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
115
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
116 bool
6974
9e32bb109980 [project @ 2007-10-08 11:06:47 by jwe]
jwe
parents: 5958
diff changeset
117 octave_bool::save_ascii (std::ostream& os)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
118 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
119 double d = double_value ();
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
120
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
121 octave_write_double (os, d);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
122 os << "\n";
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
123
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
124 return true;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
125 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
126
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
127 bool
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
128 octave_bool::load_ascii (std::istream& is)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
129 {
9469
c6edba80dfae sanity checks for loading sparse matrices
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
130 scalar = (octave_read_value<double> (is) != 0.);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
131
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20940
diff changeset
132 if (! is)
20879
5357423bca0a Code Sprint 2015: remove return/break/goto after error
Andreas Weber <andy.weber.aw@gmail.com>
parents: 20447
diff changeset
133 error ("load: failed to load scalar constant");
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
134
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
135 return true;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
136 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
137
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
138 bool
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
139 octave_bool::save_binary (std::ostream& os, bool& /* save_as_floats */)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
140 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
141 char tmp = (scalar ? 1 : 0);
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5759
diff changeset
142 os.write (reinterpret_cast<char *> (&tmp), 1);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
143
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
144 return true;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
145 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
146
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
147 bool
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
148 octave_bool::load_binary (std::istream& is, bool /* swap */,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
149 oct_mach_info::float_format /* fmt */)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
150 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
151 char tmp;
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5759
diff changeset
152 if (! is.read (reinterpret_cast<char *> (&tmp), 1))
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
153 return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
154 scalar = (tmp ? 1 : 0);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
155 return true;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
156 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
157
19863
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
158 bool
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
159 octave_bool::save_hdf5 (octave_hdf5_id loc_id, const char *name,
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
160 bool /* save_as_floats */)
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
161 {
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
162 bool retval = false;
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
163
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
164 #if defined (HAVE_HDF5)
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4837
diff changeset
165
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
166 hsize_t dimens[3];
18100
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17787
diff changeset
167 hid_t space_hid, data_hid;
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17787
diff changeset
168 space_hid = data_hid = -1;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
169
4815
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4687
diff changeset
170 space_hid = H5Screate_simple (0, dimens, 0);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
171 if (space_hid < 0) return false;
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
172 #if HAVE_HDF5_18
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
173 data_hid = H5Dcreate (loc_id, name, H5T_NATIVE_DOUBLE, space_hid,
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
174 octave_H5P_DEFAULT, octave_H5P_DEFAULT, octave_H5P_DEFAULT);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
175 #else
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
176 data_hid = H5Dcreate (loc_id, name, H5T_NATIVE_DOUBLE, space_hid,
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
177 octave_H5P_DEFAULT);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
178 #endif
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
179 if (data_hid < 0)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
180 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
181 H5Sclose (space_hid);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
182 return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
183 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
184
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
185 double tmp = double_value ();
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
186 retval = H5Dwrite (data_hid, H5T_NATIVE_DOUBLE, octave_H5S_ALL, octave_H5S_ALL,
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
187 octave_H5P_DEFAULT, &tmp) >= 0;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
188
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
189 H5Dclose (data_hid);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
190 H5Sclose (space_hid);
4837
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4815
diff changeset
191
19863
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
192 #else
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
193 gripe_save ("hdf5");
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
194 #endif
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
195
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
196 return retval;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
197 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
198
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
199 bool
19863
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
200 octave_bool::load_hdf5 (octave_hdf5_id loc_id, const char *name)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
201 {
19863
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
202 #if defined (HAVE_HDF5)
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
203
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
204 #if HAVE_HDF5_18
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
205 hid_t data_hid = H5Dopen (loc_id, name, octave_H5P_DEFAULT);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
206 #else
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
207 hid_t data_hid = H5Dopen (loc_id, name);
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
208 #endif
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
209 hid_t space_id = H5Dget_space (data_hid);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
210
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
211 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
212
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
213 if (rank != 0)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
214 {
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
215 H5Dclose (data_hid);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
216 return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
217 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
218
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
219 double dtmp;
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
220 if (H5Dread (data_hid, H5T_NATIVE_DOUBLE, octave_H5S_ALL, octave_H5S_ALL,
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20955
diff changeset
221 octave_H5P_DEFAULT, &dtmp) < 0)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
222 {
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
223 H5Dclose (data_hid);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
224 return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
225 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
226
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
227 scalar = (dtmp != 0.);
4837
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4815
diff changeset
228
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
229 H5Dclose (data_hid);
4837
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4815
diff changeset
230
19863
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
231 #else
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
232 gripe_load ("hdf5");
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
233 #endif
09ed6f7538dd avoid needing to include hdf5 in public header files (bug #44370, #43180)
John W. Eaton <jwe@octave.org> and Mike Miller <mtmiller@ieee.org>
parents: 19697
diff changeset
234
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
235 return true;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4612
diff changeset
236 }
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4837
diff changeset
237
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5885
diff changeset
238 mxArray *
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5885
diff changeset
239 octave_bool::as_mxArray (void) const
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5885
diff changeset
240 {
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5885
diff changeset
241 mxArray *retval = new mxArray (mxLOGICAL_CLASS, 1, 1, mxREAL);
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5885
diff changeset
242
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5885
diff changeset
243 bool *pr = static_cast<bool *> (retval->get_data ());
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5885
diff changeset
244
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5885
diff changeset
245 pr[0] = scalar;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5885
diff changeset
246
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5885
diff changeset
247 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5885
diff changeset
248 }