annotate libinterp/octave-value/ov-bool-mat.cc @ 31605:e88a07dec498 stable

maint: Use macros to begin/end C++ namespaces. * oct-conf-post-public.in.h: Define two macros (OCTAVE_BEGIN_NAMESPACE, OCTAVE_END_NAMESPACE) that can be used to start/end a namespace. * mk-opts.pl, build-env.h, build-env.in.cc, __betainc__.cc, __contourc__.cc, __dsearchn__.cc, __eigs__.cc, __expint__.cc, __ftp__.cc, __gammainc__.cc, __ichol__.cc, __ilu__.cc, __isprimelarge__.cc, __lin_interpn__.cc, __magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, amd.cc, auto-shlib.cc, auto-shlib.h, balance.cc, base-text-renderer.cc, base-text-renderer.h, besselj.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.cc, c-file-ptr-stream.h, call-stack.cc, call-stack.h, ccolamd.cc, cellfun.cc, chol.cc, colamd.cc, colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, data.h, debug.cc, defaults.cc, defaults.h, defun-int.h, defun.cc, det.cc, dirfns.cc, display.cc, display.h, dlmread.cc, dmperm.cc, dot.cc, dynamic-ld.cc, dynamic-ld.h, eig.cc, ellipj.cc, environment.cc, environment.h, error.cc, error.h, errwarn.h, event-manager.cc, event-manager.h, event-queue.cc, event-queue.h, fcn-info.cc, fcn-info.h, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc, ft-text-renderer.cc, ft-text-renderer.h, gcd.cc, getgrent.cc, getpwent.cc, getrusage.cc, givens.cc, gl-render.cc, gl-render.h, gl2ps-print.cc, gl2ps-print.h, graphics-toolkit.cc, graphics-toolkit.h, graphics.cc, graphics.in.h, gsvd.cc, gtk-manager.cc, gtk-manager.h, hash.cc, help.cc, help.h, hess.cc, hex2num.cc, hook-fcn.cc, hook-fcn.h, input.cc, input.h, interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h, inv.cc, jsondecode.cc, jsonencode.cc, kron.cc, latex-text-renderer.cc, latex-text-renderer.h, load-path.cc, load-path.h, load-save.cc, load-save.h, lookup.cc, ls-ascii-helper.cc, ls-ascii-helper.h, ls-oct-text.cc, ls-utils.cc, ls-utils.h, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex-private.h, mex.cc, mgorth.cc, nproc.cc, oct-fstrm.cc, oct-fstrm.h, oct-hdf5-types.cc, oct-hdf5-types.h, oct-hist.cc, oct-hist.h, oct-iostrm.cc, oct-iostrm.h, oct-opengl.h, oct-prcstrm.cc, oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h, oct-process.cc, oct-process.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.cc, oct-strstrm.h, oct-tex-lexer.in.ll, oct-tex-parser.yy, ordqz.cc, ordschur.cc, pager.cc, pager.h, pinv.cc, pow2.cc, pr-flt-fmt.cc, pr-output.cc, procstream.cc, procstream.h, psi.cc, qr.cc, quad.cc, quadcc.cc, qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, settings.cc, settings.h, sighandlers.cc, sighandlers.h, sparse-xdiv.cc, sparse-xdiv.h, sparse-xpow.cc, sparse-xpow.h, sparse.cc, spparms.cc, sqrtm.cc, stack-frame.cc, stack-frame.h, stream-euler.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc, symbfact.cc, syminfo.cc, syminfo.h, symrcm.cc, symrec.cc, symrec.h, symscope.cc, symscope.h, symtab.cc, symtab.h, syscalls.cc, sysdep.cc, sysdep.h, text-engine.cc, text-engine.h, text-renderer.cc, text-renderer.h, time.cc, toplev.cc, tril.cc, tsearch.cc, typecast.cc, url-handle-manager.cc, url-handle-manager.h, urlwrite.cc, utils.cc, utils.h, variables.cc, variables.h, xdiv.cc, xdiv.h, xnorm.cc, xnorm.h, xpow.cc, xpow.h, __delaunayn__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc, __init_gnuplot__.cc, __ode15__.cc, __voronoi__.cc, audiodevinfo.cc, audioread.cc, convhulln.cc, fftw.cc, gzip.cc, mk-build-env-features.sh, mk-builtins.pl, cdef-class.cc, cdef-class.h, cdef-fwd.h, cdef-manager.cc, cdef-manager.h, cdef-method.cc, cdef-method.h, cdef-object.cc, cdef-object.h, cdef-package.cc, cdef-package.h, cdef-property.cc, cdef-property.h, cdef-utils.cc, cdef-utils.h, ov-base.cc, ov-base.h, ov-bool-mat.cc, ov-builtin.h, ov-cell.cc, ov-class.cc, ov-class.h, ov-classdef.cc, ov-classdef.h, ov-complex.cc, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn.h, ov-java.cc, ov-java.h, ov-mex-fcn.h, ov-null-mat.cc, ov-oncleanup.cc, ov-struct.cc, ov-typeinfo.cc, ov-typeinfo.h, ov-usr-fcn.cc, ov-usr-fcn.h, ov.cc, ov.h, octave.cc, octave.h, mk-ops.sh, 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-dm-template.cc, op-dms-template.cc, op-fcdm-fcdm.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-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-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc, op-m-scm.cc, op-m-sm.cc, op-mi.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc, op-pm-template.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, anon-fcn-validator.cc, anon-fcn-validator.h, bp-table.cc, bp-table.h, comment-list.cc, comment-list.h, filepos.h, lex.h, lex.ll, oct-lvalue.cc, oct-lvalue.h, oct-parse.yy, parse.h, profiler.cc, profiler.h, pt-anon-scopes.cc, pt-anon-scopes.h, pt-arg-list.cc, pt-arg-list.h, pt-args-block.cc, pt-args-block.h, pt-array-list.cc, pt-array-list.h, pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h, pt-cbinop.cc, pt-cbinop.h, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h, pt-classdef.cc, pt-classdef.h, pt-cmd.h, pt-colon.cc, pt-colon.h, pt-const.cc, pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc, pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-id.cc, pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.cc, pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc, pt-select.h, pt-spmd.cc, pt-spmd.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc, pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-vm-eval.cc, pt-walk.cc, pt-walk.h, pt.cc, pt.h, token.cc, token.h, Range.cc, Range.h, idx-vector.cc, idx-vector.h, range-fwd.h, CollocWt.cc, CollocWt.h, aepbalance.cc, aepbalance.h, chol.cc, chol.h, gepbalance.cc, gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h, lo-mappers.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h, oct-convn.cc, oct-convn.h, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-norm.h, oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc, qrp.h, randgamma.cc, randgamma.h, randmtzig.cc, randmtzig.h, randpoisson.cc, randpoisson.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h, sparse-lu.cc, sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, child-list.cc, child-list.h, dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc, file-stat.h, lo-sysdep.cc, lo-sysdep.h, lo-sysinfo.cc, lo-sysinfo.h, mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h, oct-password.cc, oct-password.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc, oct-time.h, oct-uname.cc, oct-uname.h, action-container.cc, action-container.h, base-list.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, f77-fcn.h, file-info.cc, file-info.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-hash.cc, lo-hash.h, lo-ieee.h, lo-regexp.cc, lo-regexp.h, lo-utils.cc, lo-utils.h, oct-base64.cc, oct-base64.h, oct-glob.cc, oct-glob.h, oct-inttypes.h, oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-shlib.cc, oct-shlib.h, oct-sparse.cc, oct-sparse.h, oct-string.h, octave-preserve-stream-state.h, pathsearch.cc, pathsearch.h, quit.cc, quit.h, unwind-prot.cc, unwind-prot.h, url-transfer.cc, url-transfer.h : Use new macros to begin/end C++ namespaces.
author Rik <rik@octave.org>
date Thu, 01 Dec 2022 14:23:45 -0800
parents 96f751f8392c
children aac27ad79be6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30390
diff changeset
3 // Copyright (C) 1996-2022 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21691
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21211
diff changeset
27 # include "config.h"
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
28 #endif
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
29
25438
cb1606f78f6b prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
30 #include <istream>
cb1606f78f6b prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents: 25054
diff changeset
31 #include <ostream>
4726
14dc2267c343 [project @ 2004-01-23 20:04:35 by jwe]
jwe
parents: 4687
diff changeset
32 #include <vector>
2901
e6d25bc478dd [project @ 1997-04-30 03:41:26 by jwe]
jwe
parents: 2871
diff changeset
33
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
34 #include "dNDArray.h"
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
35 #include "fNDArray.h"
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
36 #include "int8NDArray.h"
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
37 #include "int16NDArray.h"
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
38 #include "int32NDArray.h"
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
39 #include "int64NDArray.h"
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
40 #include "uint8NDArray.h"
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
41 #include "uint16NDArray.h"
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
42 #include "uint32NDArray.h"
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
43 #include "uint64NDArray.h"
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
44
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
45 #include "lo-ieee.h"
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
46 #include "mx-base.h"
8377
25bc2d31e1bf improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents: 8345
diff changeset
47 #include "oct-locbuf.h"
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
48
9852
aabf7a8c2e57 implement sparse logical conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 9850
diff changeset
49 #include "defun.h"
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 21022
diff changeset
50 #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
51 #include "mxarray.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20939
diff changeset
52 #include "ovl.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
53 #include "oct-hdf5.h"
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
54 #include "ops.h"
3219
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3145
diff changeset
55 #include "ov-base.h"
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3145
diff changeset
56 #include "ov-base-mat.h"
30770ba4457a [project @ 1998-11-13 03:44:31 by jwe]
jwe
parents: 3145
diff changeset
57 #include "ov-base-mat.cc"
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
58 #include "ov-bool.h"
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
59 #include "ov-bool-mat.h"
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
60 #include "ov-re-mat.h"
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
61 #include "pr-output.h"
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
62
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
63 #include "byte-swap.h"
20447
c6224b4e7774 maint: Rename instances of LS_ASCII to LS_TEXT for clarity.
Rik <rik@octave.org>
parents: 20228
diff changeset
64 #include "ls-oct-text.h"
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
65 #include "ls-hdf5.h"
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
66 #include "ls-utils.h"
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
67
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
68 template class octave_base_matrix<boolNDArray>;
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
69
4612
d44675070f1a [project @ 2003-11-14 19:49:56 by jwe]
jwe
parents: 4513
diff changeset
70 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_bool_matrix,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
71 "bool matrix", "logical");
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
72
5759
ce79d238f142 [project @ 2006-04-13 13:04:32 by jwe]
jwe
parents: 5307
diff changeset
73 static octave_base_value *
ce79d238f142 [project @ 2006-04-13 13:04:32 by jwe]
jwe
parents: 5307
diff changeset
74 default_numeric_conversion_function (const octave_base_value& a)
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
75 {
21647
66cae7a6dc47 eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents: 21580
diff changeset
76 const octave_bool_matrix& v = dynamic_cast<const octave_bool_matrix&> (a);
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
77
4668
7849788ca4bd [project @ 2003-11-26 04:28:39 by jwe]
jwe
parents: 4643
diff changeset
78 return new octave_matrix (NDArray (v.bool_array_value ()));
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
79 }
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
80
8345
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
81 octave_base_value::type_conv_info
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
82 octave_bool_matrix::numeric_conversion_function (void) const
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
83 {
8345
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
84 return octave_base_value::type_conv_info (default_numeric_conversion_function,
c777f3ce02d8 smarter conversion lookup
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
85 octave_matrix::static_type_id ());
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
86 }
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
87
5759
ce79d238f142 [project @ 2006-04-13 13:04:32 by jwe]
jwe
parents: 5307
diff changeset
88 octave_base_value *
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
89 octave_bool_matrix::try_narrowing_conversion (void)
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
90 {
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23220
diff changeset
91 octave_base_value *retval = nullptr;
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
92
31138
b3ca7f891750 maint: use "m_" prefix for member variables in class octave_base_matrix.
Rik <rik@octave.org>
parents: 30888
diff changeset
93 if (m_matrix.ndims () == 2)
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
94 {
31138
b3ca7f891750 maint: use "m_" prefix for member variables in class octave_base_matrix.
Rik <rik@octave.org>
parents: 30888
diff changeset
95 boolMatrix bm (m_matrix);
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
96
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5157
diff changeset
97 octave_idx_type nr = bm.rows ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5157
diff changeset
98 octave_idx_type nc = bm.cols ();
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
99
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
100 if (nr == 1 && nc == 1)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
101 retval = new octave_bool (bm (0, 0));
4513
508238e65af7 [project @ 2003-09-19 21:40:57 by jwe]
jwe
parents: 4457
diff changeset
102 }
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
103
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
104 return retval;
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
105 }
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
106
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
107 double
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
108 octave_bool_matrix::double_value (bool) const
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
109 {
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
110 if (rows () == 0 || columns () == 0)
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
111 err_invalid_conversion ("bool matrix", "real scalar");
4455
abbf63293766 [project @ 2003-07-11 01:01:16 by jwe]
jwe
parents: 4192
diff changeset
112
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
113 warn_implicit_conversion ("Octave:array-to-scalar",
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
114 "bool matrix", "real scalar");
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
115
31138
b3ca7f891750 maint: use "m_" prefix for member variables in class octave_base_matrix.
Rik <rik@octave.org>
parents: 30888
diff changeset
116 return m_matrix(0, 0);
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
117 }
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
118
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
119 float
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
120 octave_bool_matrix::float_value (bool) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
121 {
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
122 if (rows () == 0 || columns () == 0)
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
123 err_invalid_conversion ("bool matrix", "real scalar");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
124
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
125 warn_implicit_conversion ("Octave:array-to-scalar",
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
126 "bool matrix", "real scalar");
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
127
31138
b3ca7f891750 maint: use "m_" prefix for member variables in class octave_base_matrix.
Rik <rik@octave.org>
parents: 30888
diff changeset
128 return m_matrix(0, 0);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
129 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
130
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
131 Complex
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
132 octave_bool_matrix::complex_value (bool) const
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
133 {
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
134 if (rows () == 0 || columns () == 0)
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
135 err_invalid_conversion ("bool matrix", "complex scalar");
4455
abbf63293766 [project @ 2003-07-11 01:01:16 by jwe]
jwe
parents: 4192
diff changeset
136
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
137 warn_implicit_conversion ("Octave:array-to-scalar",
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
138 "bool matrix", "complex scalar");
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
139
31138
b3ca7f891750 maint: use "m_" prefix for member variables in class octave_base_matrix.
Rik <rik@octave.org>
parents: 30888
diff changeset
140 return Complex (m_matrix(0, 0), 0);
2871
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
141 }
c691fdf6bebb [project @ 1997-04-19 01:26:38 by jwe]
jwe
parents:
diff changeset
142
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
143 FloatComplex
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
144 octave_bool_matrix::float_complex_value (bool) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
145 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
146 float tmp = lo_ieee_float_nan_value ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
147
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
148 FloatComplex retval (tmp, tmp);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
149
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
150 if (rows () == 0 || columns () == 0)
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
151 err_invalid_conversion ("bool matrix", "complex scalar");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
152
21118
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
153 warn_implicit_conversion ("Octave:array-to-scalar",
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
154 "bool matrix", "complex scalar");
3ac9f47fb04b Invert pattern if/code/else/err_XXX to if !/err_XXX/code.
Rik <rik@octave.org>
parents: 21102
diff changeset
155
31138
b3ca7f891750 maint: use "m_" prefix for member variables in class octave_base_matrix.
Rik <rik@octave.org>
parents: 30888
diff changeset
156 retval = m_matrix(0, 0);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
157
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
158 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
159 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
160
4457
d7d9ca19960a [project @ 2003-07-11 03:05:38 by jwe]
jwe
parents: 4455
diff changeset
161 octave_value
5279
bd32f770c09a [project @ 2005-04-12 21:55:31 by jwe]
jwe
parents: 5275
diff changeset
162 octave_bool_matrix::convert_to_str_internal (bool pad, bool force,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
163 char type) const
4457
d7d9ca19960a [project @ 2003-07-11 03:05:38 by jwe]
jwe
parents: 4455
diff changeset
164 {
4844
9f7ef92b50b0 [project @ 2004-04-02 17:26:53 by jwe]
jwe
parents: 4837
diff changeset
165 octave_value tmp = octave_value (array_value ());
5279
bd32f770c09a [project @ 2005-04-12 21:55:31 by jwe]
jwe
parents: 5275
diff changeset
166 return tmp.convert_to_str (pad, force, type);
4457
d7d9ca19960a [project @ 2003-07-11 03:05:38 by jwe]
jwe
parents: 4455
diff changeset
167 }
d7d9ca19960a [project @ 2003-07-11 03:05:38 by jwe]
jwe
parents: 4455
diff changeset
168
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
169 octave_value
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
170 octave_bool_matrix::as_double (void) const
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
171 {
31138
b3ca7f891750 maint: use "m_" prefix for member variables in class octave_base_matrix.
Rik <rik@octave.org>
parents: 30888
diff changeset
172 return NDArray (m_matrix);
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
173 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
174
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
175 octave_value
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
176 octave_bool_matrix::as_single (void) const
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
177 {
31138
b3ca7f891750 maint: use "m_" prefix for member variables in class octave_base_matrix.
Rik <rik@octave.org>
parents: 30888
diff changeset
178 return FloatNDArray (m_matrix);
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
179 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
180
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
181 octave_value
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
182 octave_bool_matrix::as_int8 (void) const
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
183 {
31138
b3ca7f891750 maint: use "m_" prefix for member variables in class octave_base_matrix.
Rik <rik@octave.org>
parents: 30888
diff changeset
184 return int8NDArray (m_matrix);
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
185 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
186
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
187 octave_value
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
188 octave_bool_matrix::as_int16 (void) const
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
189 {
31138
b3ca7f891750 maint: use "m_" prefix for member variables in class octave_base_matrix.
Rik <rik@octave.org>
parents: 30888
diff changeset
190 return int16NDArray (m_matrix);
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
191 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
192
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
193 octave_value
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
194 octave_bool_matrix::as_int32 (void) const
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
195 {
31138
b3ca7f891750 maint: use "m_" prefix for member variables in class octave_base_matrix.
Rik <rik@octave.org>
parents: 30888
diff changeset
196 return int32NDArray (m_matrix);
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
197 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
198
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
199 octave_value
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
200 octave_bool_matrix::as_int64 (void) const
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
201 {
31138
b3ca7f891750 maint: use "m_" prefix for member variables in class octave_base_matrix.
Rik <rik@octave.org>
parents: 30888
diff changeset
202 return int64NDArray (m_matrix);
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
203 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
204
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
205 octave_value
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
206 octave_bool_matrix::as_uint8 (void) const
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
207 {
31138
b3ca7f891750 maint: use "m_" prefix for member variables in class octave_base_matrix.
Rik <rik@octave.org>
parents: 30888
diff changeset
208 return uint8NDArray (m_matrix);
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
209 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
210
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
211 octave_value
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
212 octave_bool_matrix::as_uint16 (void) const
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
213 {
31138
b3ca7f891750 maint: use "m_" prefix for member variables in class octave_base_matrix.
Rik <rik@octave.org>
parents: 30888
diff changeset
214 return uint16NDArray (m_matrix);
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
215 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
216
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
217 octave_value
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
218 octave_bool_matrix::as_uint32 (void) const
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
219 {
31138
b3ca7f891750 maint: use "m_" prefix for member variables in class octave_base_matrix.
Rik <rik@octave.org>
parents: 30888
diff changeset
220 return uint32NDArray (m_matrix);
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
221 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
222
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
223 octave_value
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
224 octave_bool_matrix::as_uint64 (void) const
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
225 {
31138
b3ca7f891750 maint: use "m_" prefix for member variables in class octave_base_matrix.
Rik <rik@octave.org>
parents: 30888
diff changeset
226 return uint64NDArray (m_matrix);
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
227 }
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
228
4643
ef3a14fb6847 [project @ 2003-11-22 12:25:44 by jwe]
jwe
parents: 4612
diff changeset
229 void
ef3a14fb6847 [project @ 2003-11-22 12:25:44 by jwe]
jwe
parents: 4612
diff changeset
230 octave_bool_matrix::print_raw (std::ostream& os,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
231 bool pr_as_read_syntax) const
4643
ef3a14fb6847 [project @ 2003-11-22 12:25:44 by jwe]
jwe
parents: 4612
diff changeset
232 {
31138
b3ca7f891750 maint: use "m_" prefix for member variables in class octave_base_matrix.
Rik <rik@octave.org>
parents: 30888
diff changeset
233 octave_print_internal (os, m_matrix, pr_as_read_syntax,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
234 current_print_indent_level ());
4643
ef3a14fb6847 [project @ 2003-11-22 12:25:44 by jwe]
jwe
parents: 4612
diff changeset
235 }
ef3a14fb6847 [project @ 2003-11-22 12:25:44 by jwe]
jwe
parents: 4612
diff changeset
236
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
237 bool
6974
9e32bb109980 [project @ 2007-10-08 11:06:47 by jwe]
jwe
parents: 6718
diff changeset
238 octave_bool_matrix::save_ascii (std::ostream& os)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
239 {
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21647
diff changeset
240 dim_vector dv = dims ();
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21647
diff changeset
241 if (dv.ndims () > 2)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
242 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
243 NDArray tmp = array_value ();
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21647
diff changeset
244 os << "# ndims: " << dv.ndims () << "\n";
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
245
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21647
diff changeset
246 for (int i = 0; i < dv.ndims (); i++)
23807
336f89b6208b Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents: 23795
diff changeset
247 os << ' ' << dv(i);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
248
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
249 os << "\n" << tmp;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
250 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
251 else
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
252 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
253 // Keep this case, rather than use generic code above for backward
20449
df4165dfc676 maint: Fix misspelled word compatibility in code comments.
Rik <rik@octave.org>
parents: 20447
diff changeset
254 // compatibility. Makes load_ascii much more complex!!
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
255 os << "# rows: " << rows () << "\n"
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
256 << "# columns: " << columns () << "\n";
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
257
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
258 Matrix tmp = matrix_value ();
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
259
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
260 os << tmp;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
261 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
262
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
263 return true;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
264 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
265
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
266 bool
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
267 octave_bool_matrix::load_ascii (std::istream& is)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
268 {
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4944
diff changeset
269 string_vector keywords (2);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
270
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4944
diff changeset
271 keywords[0] = "ndims";
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4944
diff changeset
272 keywords[1] = "rows";
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
273
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4944
diff changeset
274 std::string kw;
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5157
diff changeset
275 octave_idx_type val = 0;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
276
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
277 if (! extract_keyword (is, keywords, kw, val, true))
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
278 error ("load: failed to extract number of rows and columns");
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
279
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
280 if (kw == "ndims")
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
281 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
282 int mdims = static_cast<int> (val);
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4944
diff changeset
283
20979
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
284 if (mdims < 0)
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
285 error ("load: failed to extract number of dimensions");
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
286
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
287 dim_vector dv;
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
288 dv.resize (mdims);
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
289
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
290 for (int i = 0; i < mdims; i++)
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
291 is >> dv(i);
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
292
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
293 if (! is)
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
294 error ("load: failed to extract dimensions");
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
295
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
296 boolNDArray btmp (dv);
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
297
23577
80c42f4cca13 maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents: 23457
diff changeset
298 if (btmp.isempty ())
31138
b3ca7f891750 maint: use "m_" prefix for member variables in class octave_base_matrix.
Rik <rik@octave.org>
parents: 30888
diff changeset
299 m_matrix = btmp;
20979
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
300 else
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
301 {
20979
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
302 NDArray tmp(dv);
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
303 is >> tmp;
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4944
diff changeset
304
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
305 if (! is)
20979
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
306 error ("load: failed to load matrix constant");
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
307
20979
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
308 for (octave_idx_type i = 0; i < btmp.numel (); i++)
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
309 btmp.elem (i) = (tmp.elem (i) != 0.);
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
310
31138
b3ca7f891750 maint: use "m_" prefix for member variables in class octave_base_matrix.
Rik <rik@octave.org>
parents: 30888
diff changeset
311 m_matrix = btmp;
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
312 }
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
313 }
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
314 else if (kw == "rows")
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
315 {
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
316 octave_idx_type nr = val;
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
317 octave_idx_type nc = 0;
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
318
20979
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
319 if (nr < 0 || ! extract_keyword (is, "columns", nc) || nc < 0)
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
320 error ("load: failed to extract number of rows and columns");
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
321
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
322 if (nr > 0 && nc > 0)
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
323 {
20979
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
324 Matrix tmp (nr, nc);
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
325 is >> tmp;
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
326 if (! is)
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
327 error ("load: failed to load matrix constant");
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
328
20979
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
329 boolMatrix btmp (nr, nc);
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
330 for (octave_idx_type j = 0; j < nc; j++)
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
331 for (octave_idx_type i = 0; i < nr; i++)
30390
a61e1a0f6024 maint: style check C++ files in libinterp/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29958
diff changeset
332 btmp.elem (i, j) = (tmp.elem (i, j) != 0.);
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
333
31138
b3ca7f891750 maint: use "m_" prefix for member variables in class octave_base_matrix.
Rik <rik@octave.org>
parents: 30888
diff changeset
334 m_matrix = btmp;
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
335 }
20979
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
336 else if (nr == 0 || nc == 0)
31138
b3ca7f891750 maint: use "m_" prefix for member variables in class octave_base_matrix.
Rik <rik@octave.org>
parents: 30888
diff changeset
337 m_matrix = boolMatrix (nr, nc);
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
338 else
20979
0963ed389012 maint: invert if/else/error instances.
John W. Eaton <jwe@octave.org>
parents: 20962
diff changeset
339 panic_impossible ();
5099
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4944
diff changeset
340 }
f7e39f977fe8 [project @ 2004-12-24 19:06:01 by jwe]
jwe
parents: 4944
diff changeset
341 else
20962
3aa293be0e8d maint: Invert simple conditionals in if/else/error paradigm.
Rik <rik@octave.org>
parents: 20956
diff changeset
342 panic_impossible ();
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
343
21124
95f8c8cdbffe maint: Eliminate 'bool success' variable where possible.
Rik <rik@octave.org>
parents: 21118
diff changeset
344 return true;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
345 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
346
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
347 bool
26399
586413770c7f pass save_as_floats by value in octave_value save_binary functions
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
348 octave_bool_matrix::save_binary (std::ostream& os, bool /* save_as_floats */)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
349 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
350
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21647
diff changeset
351 dim_vector dv = dims ();
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21647
diff changeset
352 if (dv.ndims () < 1)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
353 return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
354
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
355 // Use negative value for ndims to differentiate with old format!!
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21647
diff changeset
356 int32_t tmp = - dv.ndims ();
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5759
diff changeset
357 os.write (reinterpret_cast<char *> (&tmp), 4);
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21647
diff changeset
358 for (int i = 0; i < dv.ndims (); i++)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
359 {
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21647
diff changeset
360 tmp = dv(i);
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5759
diff changeset
361 os.write (reinterpret_cast<char *> (&tmp), 4);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
362 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
363
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
364 boolNDArray m = bool_array_value ();
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
365 bool *mtmp = m.fortran_vec ();
20228
00cf2847355d Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20218
diff changeset
366 octave_idx_type nel = m.numel ();
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
367 OCTAVE_LOCAL_BUFFER (char, htmp, nel);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
368
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5157
diff changeset
369 for (octave_idx_type i = 0; i < nel; i++)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
370 htmp[i] = (mtmp[i] ? 1 : 0);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
371
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
372 os.write (htmp, nel);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
373
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
374 return true;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
375 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
376
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
377 bool
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
378 octave_bool_matrix::load_binary (std::istream& is, bool swap,
21739
c4ab2e54f100 use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents: 21724
diff changeset
379 octave::mach_info::float_format /* fmt */)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
380 {
5828
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5781
diff changeset
381 int32_t mdims;
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5759
diff changeset
382 if (! is.read (reinterpret_cast<char *> (&mdims), 4))
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
383 return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
384 if (swap)
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4844
diff changeset
385 swap_bytes<4> (&mdims);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
386 if (mdims >= 0)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
387 return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
388
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
389 // mdims is negative for consistency with other matrices, where it is
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
390 // negative to allow the positive value to be used for rows/cols for
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
391 // backward compatibility
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
392 mdims = - mdims;
5828
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5781
diff changeset
393 int32_t di;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
394 dim_vector dv;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
395 dv.resize (mdims);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
396
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
397 for (int i = 0; i < mdims; i++)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
398 {
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5759
diff changeset
399 if (! is.read (reinterpret_cast<char *> (&di), 4))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
400 return false;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
401 if (swap)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
402 swap_bytes<4> (&di);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
403 dv(i) = di;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
404 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
405
5157
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
406 // Convert an array with a single dimension to be a row vector.
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
407 // Octave should never write files like this, other software
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
408 // might.
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
409
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
410 if (mdims == 1)
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
411 {
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
412 mdims = 2;
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
413 dv.resize (mdims);
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
414 dv(1) = dv(0);
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
415 dv(0) = 1;
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
416 }
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
417
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5157
diff changeset
418 octave_idx_type nel = dv.numel ();
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
419 OCTAVE_LOCAL_BUFFER (char, htmp, nel);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
420 if (! is.read (htmp, nel))
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
421 return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
422 boolNDArray m(dv);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
423 bool *mtmp = m.fortran_vec ();
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5157
diff changeset
424 for (octave_idx_type i = 0; i < nel; i++)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
425 mtmp[i] = (htmp[i] ? 1 : 0);
31138
b3ca7f891750 maint: use "m_" prefix for member variables in class octave_base_matrix.
Rik <rik@octave.org>
parents: 30888
diff changeset
426 m_matrix = m;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
427
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
428 return true;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
429 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
430
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
431 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
432 octave_bool_matrix::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
433 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
434 {
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
435 bool retval = true;
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
436
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
437 #if defined (HAVE_HDF5)
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4844
diff changeset
438
4837
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4815
diff changeset
439 dim_vector dv = dims ();
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4815
diff changeset
440 int empty = save_hdf5_empty (loc_id, name, dv);
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4815
diff changeset
441 if (empty)
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
442 return (empty > 0);
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
443
21660
53728df3e4c9 maint: for clarity, call ndims() rather than length() on dimension vectors.
Rik <rik@octave.org>
parents: 21647
diff changeset
444 int rank = dv.ndims ();
18100
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17787
diff changeset
445 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
446 space_hid = data_hid = -1;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
447 boolNDArray m = bool_array_value ();
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
448
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
449 OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
450
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
451 // Octave uses column-major, while HDF5 uses row-major ordering
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
452 for (int i = 0; i < rank; i++)
20218
b2100e1659ac maint: Use cuddled parentheses when indexing dimension_vectors.
Rik <rik@octave.org>
parents: 20163
diff changeset
453 hdims[i] = dv(rank-i-1);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
454
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23586
diff changeset
455 space_hid = H5Screate_simple (rank, hdims, nullptr);
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
456 if (space_hid < 0) return false;
21211
2cf8bc5c7017 use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
457 #if defined (HAVE_HDF5_18)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
458 data_hid = H5Dcreate (loc_id, name, H5T_NATIVE_HBOOL, space_hid,
30346
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29958
diff changeset
459 octave_H5P_DEFAULT, octave_H5P_DEFAULT,
91c6288781ba maint: Shorten some long lines in libinterp to <= 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29958
diff changeset
460 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
461 #else
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
462 data_hid = H5Dcreate (loc_id, name, H5T_NATIVE_HBOOL, space_hid,
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20979
diff changeset
463 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
464 #endif
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
465 if (data_hid < 0)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
466 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
467 H5Sclose (space_hid);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
468 return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
469 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
470
20228
00cf2847355d Deprecate Array::nelem() and Range::nelem() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20218
diff changeset
471 octave_idx_type nel = m.numel ();
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
472 bool *mtmp = m.fortran_vec ();
6276
d26c558691cd [project @ 2007-02-07 09:01:24 by jwe]
jwe
parents: 5958
diff changeset
473 OCTAVE_LOCAL_BUFFER (hbool_t, htmp, nel);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
474
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5157
diff changeset
475 for (octave_idx_type i = 0; i < nel; i++)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
476 htmp[i] = mtmp[i];
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
477
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20979
diff changeset
478 retval = H5Dwrite (data_hid, H5T_NATIVE_HBOOL, 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: 20979
diff changeset
479 octave_H5P_DEFAULT, htmp) >= 0;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
480
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
481 H5Dclose (data_hid);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
482 H5Sclose (space_hid);
4837
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4815
diff changeset
483
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
484 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
485 octave_unused_parameter (loc_id);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
486 octave_unused_parameter (name);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
487
21102
dfcb9d74b253 Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents: 21100
diff changeset
488 warn_save ("hdf5");
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
489 #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
490
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
491 return retval;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
492 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
493
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
494 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
495 octave_bool_matrix::load_hdf5 (octave_hdf5_id loc_id, const char *name)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
496 {
4837
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4815
diff changeset
497 bool retval = false;
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4815
diff changeset
498
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
499 #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
500
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
501 dim_vector dv;
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
502 int empty = load_hdf5_empty (loc_id, name, dv);
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
503 if (empty > 0)
31138
b3ca7f891750 maint: use "m_" prefix for member variables in class octave_base_matrix.
Rik <rik@octave.org>
parents: 30888
diff changeset
504 m_matrix.resize (dv);
4837
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4815
diff changeset
505 if (empty)
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4815
diff changeset
506 return (empty > 0);
4805
b0d6da24caeb [project @ 2004-03-02 03:43:15 by jwe]
jwe
parents: 4726
diff changeset
507
21211
2cf8bc5c7017 use "#if defined (HAVE_FOO)" instead of "#if HAVE_FOO" for feature tests
John W. Eaton <jwe@octave.org>
parents: 21200
diff changeset
508 #if defined (HAVE_HDF5_18)
21022
ebc439187d29 avoid old-style cast warnings from HDF5 macros used in C++ sources
John W. Eaton <jwe@octave.org>
parents: 20979
diff changeset
509 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
510 #else
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
511 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
512 #endif
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
513 hid_t space_id = H5Dget_space (data_hid);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
514
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
515 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
516
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
517 if (rank < 1)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
518 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
519 H5Dclose (data_hid);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
520 return false;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
521 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
522
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
523 OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
524 OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
525
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
526 H5Sget_simple_extent_dims (space_id, hdims, maxdims);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
527
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
528 // Octave uses column-major, while HDF5 uses row-major ordering
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
529 if (rank == 1)
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
530 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
531 dv.resize (2);
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
532 dv(0) = 1;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
533 dv(1) = hdims[0];
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
534 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
535 else
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
536 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
537 dv.resize (rank);
4815
2eb844b27953 [project @ 2004-03-04 00:14:44 by jwe]
jwe
parents: 4805
diff changeset
538 for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
539 dv(j) = hdims[i];
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
540 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
541
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5157
diff changeset
542 octave_idx_type nel = dv.numel ();
6276
d26c558691cd [project @ 2007-02-07 09:01:24 by jwe]
jwe
parents: 5958
diff changeset
543 OCTAVE_LOCAL_BUFFER (hbool_t, htmp, nel);
22407
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
544 if (H5Dread (data_hid, H5T_NATIVE_HBOOL, octave_H5S_ALL, octave_H5S_ALL,
34ce5be04942 maint: Style check C++ code in libinterp/.
Rik <rik@octave.org>
parents: 22323
diff changeset
545 octave_H5P_DEFAULT, htmp)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
546 >= 0)
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
547 {
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
548 retval = true;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
549
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
550 boolNDArray btmp (dv);
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5157
diff changeset
551 for (octave_idx_type i = 0; i < nel; i++)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
552 btmp.elem (i) = htmp[i];
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
553
31138
b3ca7f891750 maint: use "m_" prefix for member variables in class octave_base_matrix.
Rik <rik@octave.org>
parents: 30888
diff changeset
554 m_matrix = btmp;
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
555 }
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
556
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
557 H5Dclose (data_hid);
4837
81f78a2ff8a6 [project @ 2004-03-12 19:13:01 by jwe]
jwe
parents: 4815
diff changeset
558
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
559 #else
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
560 octave_unused_parameter (loc_id);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
561 octave_unused_parameter (name);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
562
21102
dfcb9d74b253 Rename local gripe_XXX functions to err_XXX or warn_XXX.
Rik <rik@octave.org>
parents: 21100
diff changeset
563 warn_load ("hdf5");
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
564 #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
565
4687
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
566 return retval;
e95c86d48732 [project @ 2004-01-06 21:53:34 by jwe]
jwe
parents: 4668
diff changeset
567 }
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4844
diff changeset
568
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5828
diff changeset
569 mxArray *
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
570 octave_bool_matrix::as_mxArray (bool interleaved) const
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5828
diff changeset
571 {
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
572 mxArray *retval = new mxArray (interleaved, mxLOGICAL_CLASS, dims (), mxREAL);
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5828
diff changeset
573
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
574 mxLogical *pd = static_cast<mxLogical *> (retval->get_data ());
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5828
diff changeset
575
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6276
diff changeset
576 mwSize nel = numel ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5828
diff changeset
577
31138
b3ca7f891750 maint: use "m_" prefix for member variables in class octave_base_matrix.
Rik <rik@octave.org>
parents: 30888
diff changeset
578 const bool *pdata = m_matrix.data ();
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5828
diff changeset
579
6686
2aad75fcc93a [project @ 2007-06-03 20:58:28 by dbateman]
dbateman
parents: 6276
diff changeset
580 for (mwIndex i = 0; i < nel; i++)
28126
4c21f99b4ad5 handle interleaved complex data and new typed data access functions for mex
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
581 pd[i] = pdata[i];
5900
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5828
diff changeset
582
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5828
diff changeset
583 return retval;
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5828
diff changeset
584 }
c20eb7330d13 [project @ 2006-07-22 08:31:16 by jwe]
jwe
parents: 5828
diff changeset
585
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 31375
diff changeset
586 OCTAVE_BEGIN_NAMESPACE(octave)
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
587
9850
85f6c386f2bb implement built-in logical
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
588 DEFUN (logical, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21739
diff changeset
589 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30565
diff changeset
590 @deftypefn {} {@var{TF} =} logical (@var{x})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21739
diff changeset
591 Convert the numeric object @var{x} to logical type.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21739
diff changeset
592
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21739
diff changeset
593 Any nonzero values will be converted to true (1) while zero values will be
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30565
diff changeset
594 converted to false (0). The non-numeric value NaN cannot be converted and will
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30565
diff changeset
595 produce an error.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21739
diff changeset
596
31375
96f751f8392c doc: grammar check documentation ahead of 8.1 release.
Rik <rik@octave.org>
parents: 31138
diff changeset
597 Compatibility Note: Octave accepts complex values as input, whereas @sc{matlab}
96f751f8392c doc: grammar check documentation ahead of 8.1 release.
Rik <rik@octave.org>
parents: 31138
diff changeset
598 issues an error.
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21739
diff changeset
599 @seealso{double, single, char}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21739
diff changeset
600 @end deftypefn */)
9850
85f6c386f2bb implement built-in logical
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
601 {
20797
492738d32c60 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20449
diff changeset
602 if (args.length () != 1)
492738d32c60 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20449
diff changeset
603 print_usage ();
492738d32c60 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20449
diff changeset
604
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
605 octave_value retval;
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20853
diff changeset
606
20797
492738d32c60 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20449
diff changeset
607 octave_value arg = args(0);
492738d32c60 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20449
diff changeset
608
23579
c20a0fa91c0c maint: Deprecate is_bool_type and replace with islogical.
Rik <rik@octave.org>
parents: 23577
diff changeset
609 if (arg.islogical ())
20797
492738d32c60 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20449
diff changeset
610 retval = arg;
23586
f6c5db0a02e7 maint: Deprecate is_numeric_type and replace with isnumeric.
Rik <rik@octave.org>
parents: 23583
diff changeset
611 else if (arg.isnumeric ())
9850
85f6c386f2bb implement built-in logical
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
612 {
23583
b7747a2c88b2 maint: Deprecate is_sparse_type and replace with issparse.
Rik <rik@octave.org>
parents: 23579
diff changeset
613 if (arg.issparse ())
20797
492738d32c60 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20449
diff changeset
614 retval = arg.sparse_bool_matrix_value ();
492738d32c60 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20449
diff changeset
615 else if (arg.is_scalar_type ())
492738d32c60 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20449
diff changeset
616 retval = arg.bool_value ();
9850
85f6c386f2bb implement built-in logical
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
617 else
20797
492738d32c60 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20449
diff changeset
618 retval = arg.bool_array_value ();
9850
85f6c386f2bb implement built-in logical
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
619 }
85f6c386f2bb implement built-in logical
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
620 else
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 21022
diff changeset
621 err_wrong_type_arg ("logical", arg);
9850
85f6c386f2bb implement built-in logical
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
622
85f6c386f2bb implement built-in logical
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
623 return retval;
85f6c386f2bb implement built-in logical
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
624 }
12645
d3ccd2e37de6 Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
625
d3ccd2e37de6 Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
626 /*
14429
eff4a5933e28 Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
627 %!test
12645
d3ccd2e37de6 Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
628 %! m = eye (2) != 0;
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20952
diff changeset
629 %! s = ! 0;
12645
d3ccd2e37de6 Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
630 %! c = {"double", "single", "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64", "logical"};
d3ccd2e37de6 Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
631 %! for i = 1:numel (c)
21580
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21301
diff changeset
632 %! assert (logical (eye (2, c{i})), m);
ecce63c99c3f maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents: 21301
diff changeset
633 %! assert (logical (eye (1, c{i})), s);
12645
d3ccd2e37de6 Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
634 %! endfor
d3ccd2e37de6 Allow scalar integer to logical conversion (bug #33219)
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
635 */
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
636
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 31375
diff changeset
637 OCTAVE_END_NAMESPACE(octave)