annotate libinterp/octave-value/ov-base-int.cc @ 17787:175b392e91fe

Use GNU style coding conventions for code in libinterp/ * libinterp/corefcn/Cell.h, libinterp/corefcn/__contourc__.cc, libinterp/corefcn/__dispatch__.cc, libinterp/corefcn/__lin_interpn__.cc, libinterp/corefcn/__pchip_deriv__.cc, libinterp/corefcn/__qp__.cc, libinterp/corefcn/balance.cc, libinterp/corefcn/besselj.cc, libinterp/corefcn/betainc.cc, libinterp/corefcn/bitfcns.cc, libinterp/corefcn/bsxfun.cc, libinterp/corefcn/c-file-ptr-stream.cc, libinterp/corefcn/c-file-ptr-stream.h, libinterp/corefcn/cellfun.cc, libinterp/corefcn/colloc.cc, libinterp/corefcn/comment-list.h, libinterp/corefcn/conv2.cc, libinterp/corefcn/daspk.cc, libinterp/corefcn/dasrt.cc, libinterp/corefcn/dassl.cc, libinterp/corefcn/data.cc, libinterp/corefcn/debug.cc, libinterp/corefcn/defaults.cc, libinterp/corefcn/defaults.in.h, libinterp/corefcn/defun-int.h, libinterp/corefcn/defun.cc, libinterp/corefcn/det.cc, libinterp/corefcn/dirfns.cc, libinterp/corefcn/display.cc, libinterp/corefcn/dlmread.cc, libinterp/corefcn/dot.cc, libinterp/corefcn/dynamic-ld.cc, libinterp/corefcn/dynamic-ld.h, libinterp/corefcn/eig.cc, libinterp/corefcn/ellipj.cc, libinterp/corefcn/error.cc, libinterp/corefcn/error.h, libinterp/corefcn/event-queue.h, libinterp/corefcn/fft.cc, libinterp/corefcn/fft2.cc, libinterp/corefcn/fftn.cc, libinterp/corefcn/file-io.cc, libinterp/corefcn/filter.cc, libinterp/corefcn/find.cc, libinterp/corefcn/gammainc.cc, libinterp/corefcn/gcd.cc, libinterp/corefcn/getgrent.cc, libinterp/corefcn/getpwent.cc, libinterp/corefcn/getrusage.cc, libinterp/corefcn/givens.cc, libinterp/corefcn/gl-render.cc, libinterp/corefcn/gl2ps-renderer.cc, libinterp/corefcn/gl2ps-renderer.h, libinterp/corefcn/graphics.cc, libinterp/corefcn/graphics.in.h, libinterp/corefcn/gripes.cc, libinterp/corefcn/gripes.h, libinterp/corefcn/help.cc, libinterp/corefcn/hess.cc, libinterp/corefcn/hex2num.cc, libinterp/corefcn/input.cc, libinterp/corefcn/input.h, libinterp/corefcn/inv.cc, libinterp/corefcn/jit-ir.h, libinterp/corefcn/jit-typeinfo.cc, libinterp/corefcn/jit-typeinfo.h, libinterp/corefcn/jit-util.h, libinterp/corefcn/kron.cc, libinterp/corefcn/load-path.cc, libinterp/corefcn/load-path.h, libinterp/corefcn/load-save.cc, libinterp/corefcn/load-save.h, libinterp/corefcn/lookup.cc, libinterp/corefcn/ls-ascii-helper.cc, libinterp/corefcn/ls-hdf5.cc, libinterp/corefcn/ls-hdf5.h, libinterp/corefcn/ls-mat-ascii.cc, libinterp/corefcn/ls-mat-ascii.h, libinterp/corefcn/ls-mat4.cc, libinterp/corefcn/ls-mat5.cc, libinterp/corefcn/ls-mat5.h, libinterp/corefcn/ls-oct-ascii.cc, libinterp/corefcn/lsode.cc, libinterp/corefcn/lu.cc, libinterp/corefcn/luinc.cc, libinterp/corefcn/mappers.cc, libinterp/corefcn/matrix_type.cc, libinterp/corefcn/max.cc, libinterp/corefcn/md5sum.cc, libinterp/corefcn/mex.cc, libinterp/corefcn/mexproto.h, libinterp/corefcn/mgorth.cc, libinterp/corefcn/mxarray.in.h, libinterp/corefcn/nproc.cc, libinterp/corefcn/oct-hist.cc, libinterp/corefcn/oct-lvalue.h, libinterp/corefcn/oct-map.cc, libinterp/corefcn/oct-map.h, libinterp/corefcn/oct-obj.h, libinterp/corefcn/oct-prcstrm.h, libinterp/corefcn/oct-stdstrm.h, libinterp/corefcn/oct-stream.cc, libinterp/corefcn/oct-stream.h, libinterp/corefcn/octave-link.cc, libinterp/corefcn/octave-link.h, libinterp/corefcn/pager.cc, libinterp/corefcn/pinv.cc, libinterp/corefcn/pr-output.cc, libinterp/corefcn/procstream.h, libinterp/corefcn/profiler.cc, libinterp/corefcn/pt-jit.cc, libinterp/corefcn/pt-jit.h, libinterp/corefcn/quad.cc, libinterp/corefcn/quadcc.cc, libinterp/corefcn/qz.cc, libinterp/corefcn/rand.cc, libinterp/corefcn/rcond.cc, libinterp/corefcn/regexp.cc, libinterp/corefcn/schur.cc, libinterp/corefcn/sighandlers.cc, libinterp/corefcn/sighandlers.h, libinterp/corefcn/sparse-xdiv.cc, libinterp/corefcn/sparse-xdiv.h, libinterp/corefcn/sparse-xpow.cc, libinterp/corefcn/sparse.cc, libinterp/corefcn/spparms.cc, libinterp/corefcn/sqrtm.cc, libinterp/corefcn/str2double.cc, libinterp/corefcn/strfind.cc, libinterp/corefcn/strfns.cc, libinterp/corefcn/sub2ind.cc, libinterp/corefcn/svd.cc, libinterp/corefcn/syl.cc, libinterp/corefcn/symtab.cc, libinterp/corefcn/symtab.h, libinterp/corefcn/syscalls.cc, libinterp/corefcn/sysdep.cc, libinterp/corefcn/sysdep.h, libinterp/corefcn/time.cc, libinterp/corefcn/toplev.cc, libinterp/corefcn/toplev.h, libinterp/corefcn/tril.cc, libinterp/corefcn/txt-eng-ft.cc, libinterp/corefcn/txt-eng-ft.h, libinterp/corefcn/txt-eng.h, libinterp/corefcn/typecast.cc, libinterp/corefcn/urlwrite.cc, libinterp/corefcn/utils.cc, libinterp/corefcn/variables.cc, libinterp/corefcn/variables.h, libinterp/corefcn/xdiv.cc, libinterp/corefcn/xdiv.h, libinterp/corefcn/xnorm.h, libinterp/corefcn/xpow.cc, libinterp/corefcn/xpow.h, libinterp/corefcn/zfstream.cc, libinterp/corefcn/zfstream.h, libinterp/dldfcn/__delaunayn__.cc, libinterp/dldfcn/__dsearchn__.cc, libinterp/dldfcn/__eigs__.cc, libinterp/dldfcn/__fltk_uigetfile__.cc, libinterp/dldfcn/__glpk__.cc, libinterp/dldfcn/__init_fltk__.cc, libinterp/dldfcn/__init_gnuplot__.cc, libinterp/dldfcn/__magick_read__.cc, libinterp/dldfcn/__voronoi__.cc, libinterp/dldfcn/amd.cc, libinterp/dldfcn/ccolamd.cc, libinterp/dldfcn/chol.cc, libinterp/dldfcn/colamd.cc, libinterp/dldfcn/convhulln.cc, libinterp/dldfcn/dmperm.cc, libinterp/dldfcn/fftw.cc, libinterp/dldfcn/qr.cc, libinterp/dldfcn/symbfact.cc, libinterp/dldfcn/symrcm.cc, libinterp/dldfcn/tsearch.cc, libinterp/octave-value/ov-base-diag.cc, libinterp/octave-value/ov-base-diag.h, libinterp/octave-value/ov-base-int.cc, libinterp/octave-value/ov-base-int.h, libinterp/octave-value/ov-base-mat.h, libinterp/octave-value/ov-base-scalar.cc, libinterp/octave-value/ov-base-scalar.h, libinterp/octave-value/ov-base-sparse.cc, libinterp/octave-value/ov-base-sparse.h, libinterp/octave-value/ov-base.cc, libinterp/octave-value/ov-base.h, libinterp/octave-value/ov-bool-mat.cc, libinterp/octave-value/ov-bool-mat.h, libinterp/octave-value/ov-bool-sparse.cc, libinterp/octave-value/ov-bool-sparse.h, libinterp/octave-value/ov-bool.cc, libinterp/octave-value/ov-bool.h, libinterp/octave-value/ov-builtin.cc, libinterp/octave-value/ov-builtin.h, libinterp/octave-value/ov-cell.cc, libinterp/octave-value/ov-cell.h, libinterp/octave-value/ov-ch-mat.cc, libinterp/octave-value/ov-ch-mat.h, libinterp/octave-value/ov-class.cc, libinterp/octave-value/ov-class.h, libinterp/octave-value/ov-colon.h, libinterp/octave-value/ov-complex.cc, libinterp/octave-value/ov-complex.h, libinterp/octave-value/ov-cx-diag.cc, libinterp/octave-value/ov-cx-diag.h, libinterp/octave-value/ov-cx-mat.cc, libinterp/octave-value/ov-cx-mat.h, libinterp/octave-value/ov-cx-sparse.cc, libinterp/octave-value/ov-cx-sparse.h, libinterp/octave-value/ov-dld-fcn.h, libinterp/octave-value/ov-fcn-handle.cc, libinterp/octave-value/ov-fcn-handle.h, libinterp/octave-value/ov-fcn-inline.cc, libinterp/octave-value/ov-fcn-inline.h, libinterp/octave-value/ov-fcn.h, libinterp/octave-value/ov-float.cc, libinterp/octave-value/ov-float.h, libinterp/octave-value/ov-flt-complex.cc, libinterp/octave-value/ov-flt-complex.h, libinterp/octave-value/ov-flt-cx-diag.cc, libinterp/octave-value/ov-flt-cx-diag.h, libinterp/octave-value/ov-flt-cx-mat.cc, libinterp/octave-value/ov-flt-cx-mat.h, libinterp/octave-value/ov-flt-re-diag.cc, libinterp/octave-value/ov-flt-re-diag.h, libinterp/octave-value/ov-flt-re-mat.cc, libinterp/octave-value/ov-flt-re-mat.h, libinterp/octave-value/ov-int16.cc, libinterp/octave-value/ov-int32.cc, libinterp/octave-value/ov-int64.cc, libinterp/octave-value/ov-int8.cc, libinterp/octave-value/ov-intx.h, libinterp/octave-value/ov-java.cc, libinterp/octave-value/ov-lazy-idx.h, libinterp/octave-value/ov-mex-fcn.cc, libinterp/octave-value/ov-mex-fcn.h, libinterp/octave-value/ov-null-mat.cc, libinterp/octave-value/ov-null-mat.h, libinterp/octave-value/ov-oncleanup.cc, libinterp/octave-value/ov-perm.cc, libinterp/octave-value/ov-perm.h, libinterp/octave-value/ov-range.cc, libinterp/octave-value/ov-range.h, libinterp/octave-value/ov-re-diag.cc, libinterp/octave-value/ov-re-diag.h, libinterp/octave-value/ov-re-mat.cc, libinterp/octave-value/ov-re-mat.h, libinterp/octave-value/ov-re-sparse.cc, libinterp/octave-value/ov-re-sparse.h, libinterp/octave-value/ov-scalar.cc, libinterp/octave-value/ov-scalar.h, libinterp/octave-value/ov-str-mat.cc, libinterp/octave-value/ov-str-mat.h, libinterp/octave-value/ov-struct.cc, libinterp/octave-value/ov-struct.h, libinterp/octave-value/ov-type-conv.h, libinterp/octave-value/ov-typeinfo.cc, libinterp/octave-value/ov-typeinfo.h, libinterp/octave-value/ov-uint16.cc, libinterp/octave-value/ov-uint32.cc, libinterp/octave-value/ov-uint64.cc, libinterp/octave-value/ov-uint8.cc, libinterp/octave-value/ov-usr-fcn.cc, libinterp/octave-value/ov-usr-fcn.h, libinterp/octave-value/ov.cc, libinterp/octave-value/ov.h, libinterp/octave.cc, libinterp/operators/op-b-bm.cc, libinterp/operators/op-b-sbm.cc, libinterp/operators/op-bm-b.cc, libinterp/operators/op-bm-bm.cc, libinterp/operators/op-cdm-cdm.cc, libinterp/operators/op-chm.cc, libinterp/operators/op-class.cc, libinterp/operators/op-cm-cm.cc, libinterp/operators/op-cm-cs.cc, libinterp/operators/op-cm-s.cc, libinterp/operators/op-cm-scm.cc, libinterp/operators/op-cm-sm.cc, libinterp/operators/op-cs-cm.cc, libinterp/operators/op-cs-cs.cc, libinterp/operators/op-cs-scm.cc, libinterp/operators/op-cs-sm.cc, libinterp/operators/op-dm-dm.cc, libinterp/operators/op-dm-scm.cc, libinterp/operators/op-double-conv.cc, libinterp/operators/op-fcdm-fcdm.cc, libinterp/operators/op-fcm-fcm.cc, libinterp/operators/op-fcm-fcs.cc, libinterp/operators/op-fcm-fm.cc, libinterp/operators/op-fcm-fs.cc, libinterp/operators/op-fcs-fcm.cc, libinterp/operators/op-fcs-fcs.cc, libinterp/operators/op-fcs-fm.cc, libinterp/operators/op-fcs-fs.cc, libinterp/operators/op-fdm-fdm.cc, libinterp/operators/op-float-conv.cc, libinterp/operators/op-fm-fcm.cc, libinterp/operators/op-fm-fcs.cc, libinterp/operators/op-fm-fm.cc, libinterp/operators/op-fm-fs.cc, libinterp/operators/op-fs-fcm.cc, libinterp/operators/op-fs-fcs.cc, libinterp/operators/op-fs-fm.cc, libinterp/operators/op-fs-fs.cc, libinterp/operators/op-m-cm.cc, libinterp/operators/op-m-cs.cc, libinterp/operators/op-m-m.cc, libinterp/operators/op-m-s.cc, libinterp/operators/op-m-scm.cc, libinterp/operators/op-m-sm.cc, libinterp/operators/op-pm-scm.cc, libinterp/operators/op-range.cc, libinterp/operators/op-s-cm.cc, libinterp/operators/op-s-cs.cc, libinterp/operators/op-s-scm.cc, libinterp/operators/op-sbm-b.cc, libinterp/operators/op-sbm-bm.cc, libinterp/operators/op-sbm-sbm.cc, libinterp/operators/op-scm-cm.cc, libinterp/operators/op-scm-cs.cc, libinterp/operators/op-scm-m.cc, libinterp/operators/op-scm-s.cc, libinterp/operators/op-scm-scm.cc, libinterp/operators/op-scm-sm.cc, libinterp/operators/op-sm-cm.cc, libinterp/operators/op-sm-m.cc, libinterp/operators/op-sm-s.cc, libinterp/operators/op-sm-scm.cc, libinterp/operators/op-sm-sm.cc, libinterp/operators/op-str-m.cc, libinterp/operators/op-str-s.cc, libinterp/operators/op-str-str.cc, libinterp/operators/ops.h, libinterp/parse-tree/lex.h, libinterp/parse-tree/parse.h, libinterp/parse-tree/pt-arg-list.cc, libinterp/parse-tree/pt-arg-list.h, libinterp/parse-tree/pt-assign.cc, libinterp/parse-tree/pt-assign.h, libinterp/parse-tree/pt-binop.cc, libinterp/parse-tree/pt-binop.h, libinterp/parse-tree/pt-bp.h, libinterp/parse-tree/pt-cbinop.cc, libinterp/parse-tree/pt-check.cc, libinterp/parse-tree/pt-colon.cc, libinterp/parse-tree/pt-colon.h, libinterp/parse-tree/pt-const.cc, libinterp/parse-tree/pt-decl.cc, libinterp/parse-tree/pt-decl.h, libinterp/parse-tree/pt-eval.cc, libinterp/parse-tree/pt-except.h, libinterp/parse-tree/pt-exp.h, libinterp/parse-tree/pt-fcn-handle.cc, libinterp/parse-tree/pt-id.cc, libinterp/parse-tree/pt-id.h, libinterp/parse-tree/pt-idx.cc, libinterp/parse-tree/pt-idx.h, libinterp/parse-tree/pt-loop.h, libinterp/parse-tree/pt-mat.cc, libinterp/parse-tree/pt-misc.cc, libinterp/parse-tree/pt-misc.h, libinterp/parse-tree/pt-pr-code.cc, libinterp/parse-tree/pt-select.h, libinterp/parse-tree/pt-stmt.h, libinterp/parse-tree/token.h, libinterp/version.cc: Use GNU style coding conventions for code in libinterp/
author Rik <rik@octave.org>
date Mon, 28 Oct 2013 19:51:46 -0700
parents d63878346099
children 6a71e5030df5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
1 /*
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
2
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 15215
diff changeset
3 Copyright (C) 2004-2013 John W. Eaton
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
4
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
6
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6974
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6974
diff changeset
10 option) any later version.
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
11
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
15 for more details.
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
16
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6974
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6974
diff changeset
19 <http://www.gnu.org/licenses/>.
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
20
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
21 */
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
22
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
24 #include <config.h>
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
25 #endif
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
26
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
27 #include <iostream>
15215
9020dddc925a use std::numeric_limits for integer max and min values
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
28 #include <limits>
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
29 #include <vector>
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
30
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
31 #include "lo-ieee.h"
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
32 #include "lo-utils.h"
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
33 #include "mx-base.h"
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
34 #include "quit.h"
8377
25bc2d31e1bf improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents: 7534
diff changeset
35 #include "oct-locbuf.h"
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
36
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
37 #include "defun.h"
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
38 #include "gripes.h"
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
39 #include "oct-obj.h"
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
40 #include "oct-lvalue.h"
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4932
diff changeset
41 #include "oct-stream.h"
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
42 #include "ops.h"
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
43 #include "ov-base.h"
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
44 #include "ov-base-mat.h"
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
45 #include "ov-base-mat.cc"
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
46 #include "ov-base-scalar.h"
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
47 #include "ov-base-scalar.cc"
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
48 #include "ov-base-int.h"
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
49 #include "ov-int-traits.h"
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
50 #include "pr-output.h"
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
51 #include "variables.h"
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
52
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
53 #include "byte-swap.h"
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
54 #include "ls-oct-ascii.h"
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
55 #include "ls-utils.h"
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
56 #include "ls-hdf5.h"
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
57
7534
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
58 // We have all the machinery below (octave_base_int_helper and
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
59 // octave_base_int_helper_traits) to avoid a few warnings from GCC
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
60 // about comparisons always false due to limited range of data types.
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
61 // Ugh. The cure may be worse than the disease.
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
62
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
63 template <class T, bool is_signed = true, bool can_be_too_big = true>
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
64 struct octave_base_int_helper
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
65 {
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
66 static bool
15215
9020dddc925a use std::numeric_limits for integer max and min values
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
67 char_value_out_of_range (T val)
9020dddc925a use std::numeric_limits for integer max and min values
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
68 {
9020dddc925a use std::numeric_limits for integer max and min values
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
69 return val < 0 || val > std::numeric_limits<unsigned char>::max ();
9020dddc925a use std::numeric_limits for integer max and min values
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
70 }
7534
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
71 };
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
72
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
73 template <class T>
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
74 struct octave_base_int_helper<T, false, false>
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
75 {
9149
7120fbbecf97 ov-base-int.cc: correct result for template specialization
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
76 static bool char_value_out_of_range (T) { return false; }
7534
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
77 };
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
78
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
79 template <class T>
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
80 struct octave_base_int_helper<T, false, true>
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
81 {
15215
9020dddc925a use std::numeric_limits for integer max and min values
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
82 static bool char_value_out_of_range (T val)
9020dddc925a use std::numeric_limits for integer max and min values
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
83 {
9020dddc925a use std::numeric_limits for integer max and min values
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
84 return val > std::numeric_limits<unsigned char>::max ();
9020dddc925a use std::numeric_limits for integer max and min values
John W. Eaton <jwe@octave.org>
parents: 15195
diff changeset
85 }
7534
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
86 };
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
87
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
88 template <class T>
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
89 struct octave_base_int_helper<T, true, false>
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
90 {
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
91 static bool char_value_out_of_range (T val) { return val < 0; }
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
92 };
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
93
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
94 // For all types other than char, signed char, and unsigned char, we
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
95 // assume that the upper limit for the range of allowable values is
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
96 // larger than the range for unsigned char. If that's not true, we
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
97 // are still OK, but will see the warnings again for any other types
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
98 // that do not meet this assumption.
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
99
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
100 template <class T>
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
101 struct octave_base_int_helper_traits
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
102 {
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
103 static const bool can_be_larger_than_uchar_max = true;
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
104 };
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
105
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
106 template <>
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
107 struct octave_base_int_helper_traits<char>
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
108 {
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
109 static const bool can_be_larger_than_uchar_max = false;
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
110 };
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
111
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
112 template <>
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
113 struct octave_base_int_helper_traits<signed char>
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
114 {
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
115 static const bool can_be_larger_than_uchar_max = false;
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
116 };
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
117
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
118 template <>
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
119 struct octave_base_int_helper_traits<unsigned char>
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
120 {
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
121 static const bool can_be_larger_than_uchar_max = false;
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
122 };
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
123
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
124
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
125 template <class T>
5759
ce79d238f142 [project @ 2006-04-13 13:04:32 by jwe]
jwe
parents: 5307
diff changeset
126 octave_base_value *
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
127 octave_base_int_matrix<T>::try_narrowing_conversion (void)
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
128 {
5759
ce79d238f142 [project @ 2006-04-13 13:04:32 by jwe]
jwe
parents: 5307
diff changeset
129 octave_base_value *retval = 0;
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
130
4932
43f4ebd2704c [project @ 2004-08-05 13:26:10 by jwe]
jwe
parents: 4917
diff changeset
131 if (this->matrix.nelem () == 1)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
132 retval = new typename octave_value_int_traits<T>::scalar_type
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
133 (this->matrix (0));
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
134
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
135 return retval;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
136 }
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
137
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
138 template <class T>
5992
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
139 octave_value
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
140 octave_base_int_matrix<T>::convert_to_str_internal (bool, bool, char type) const
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
141 {
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
142 octave_value retval;
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
143 dim_vector dv = this->dims ();
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
144 octave_idx_type nel = dv.numel ();
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
145
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
146 charNDArray chm (dv);
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
147
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
148 bool warned = false;
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
149
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
150 for (octave_idx_type i = 0; i < nel; i++)
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
151 {
10142
829e69ec3110 make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents: 9892
diff changeset
152 octave_quit ();
5992
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
153
8918
f5408862892f Consistently use element_type in the array classes.
Jason Riedy <jason@acm.org>
parents: 8377
diff changeset
154 typename T::element_type tmp = this->matrix(i);
5992
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
155
8918
f5408862892f Consistently use element_type in the array classes.
Jason Riedy <jason@acm.org>
parents: 8377
diff changeset
156 typedef typename T::element_type::val_type val_type;
7534
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
157
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
158 val_type ival = tmp.value ();
5992
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
159
7534
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
160 static const bool is_signed = std::numeric_limits<val_type>::is_signed;
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
161 static const bool can_be_larger_than_uchar_max
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
162 = octave_base_int_helper_traits<val_type>::can_be_larger_than_uchar_max;
7534
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
163
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
164 if (octave_base_int_helper<val_type, is_signed,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
165 can_be_larger_than_uchar_max>::char_value_out_of_range (ival))
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
166 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
167 // FIXME: is there something better we could do?
5992
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
168
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
169 ival = 0;
5992
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
170
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
171 if (! warned)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
172 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
173 ::warning ("range error for conversion to character value");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
174 warned = true;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
175 }
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
176 }
5992
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
177 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
178 chm (i) = static_cast<char> (ival);
5992
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
179 }
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
180
9689
34d6f005db4b eliminate is_string argument from octave_value character array constructors
John W. Eaton <jwe@octave.org>
parents: 9149
diff changeset
181 retval = octave_value (chm, type);
5992
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
182
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
183 return retval;
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
184 }
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
185
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
186 template <class T>
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
187 bool
6974
9e32bb109980 [project @ 2007-10-08 11:06:47 by jwe]
jwe
parents: 6959
diff changeset
188 octave_base_int_matrix<T>::save_ascii (std::ostream& os)
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
189 {
4932
43f4ebd2704c [project @ 2004-08-05 13:26:10 by jwe]
jwe
parents: 4917
diff changeset
190 dim_vector d = this->dims ();
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
191
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
192 os << "# ndims: " << d.length () << "\n";
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
193
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
194 for (int i = 0; i < d.length (); i++)
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
195 os << " " << d (i);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
196
4932
43f4ebd2704c [project @ 2004-08-05 13:26:10 by jwe]
jwe
parents: 4917
diff changeset
197 os << "\n" << this->matrix;
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
198
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
199 return true;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
200 }
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
201
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
202 template <class T>
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
203 bool
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
204 octave_base_int_matrix<T>::load_ascii (std::istream& is)
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
205 {
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
206 int mdims = 0;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
207 bool success = true;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
208
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
209 if (extract_keyword (is, "ndims", mdims, true))
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
210 {
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
211 if (mdims >= 0)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
212 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
213 dim_vector dv;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
214 dv.resize (mdims);
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
215
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
216 for (int i = 0; i < mdims; i++)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
217 is >> dv(i);
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
218
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
219 T tmp(dv);
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
220
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
221 is >> tmp;
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
222
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
223 if (!is)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
224 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
225 error ("load: failed to load matrix constant");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
226 success = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
227 }
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
228
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
229 this->matrix = tmp;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
230 }
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
231 else
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
232 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
233 error ("load: failed to extract number of rows and columns");
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
234 success = false;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
235 }
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
236 }
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
237 else
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
238 error ("load: failed to extract number of dimensions");
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
239
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
240 return success;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
241 }
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
242
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
243 template <class T>
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
244 bool
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
245 octave_base_int_matrix<T>::save_binary (std::ostream& os, bool&)
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
246 {
4932
43f4ebd2704c [project @ 2004-08-05 13:26:10 by jwe]
jwe
parents: 4917
diff changeset
247 dim_vector d = this->dims ();
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
248 if (d.length () < 1)
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
249 return false;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
250
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
251 // Use negative value for ndims to differentiate with old format!!
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
252 int32_t tmp = - d.length ();
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5759
diff changeset
253 os.write (reinterpret_cast<char *> (&tmp), 4);
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
254 for (int i=0; i < d.length (); i++)
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
255 {
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
256 tmp = d(i);
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5759
diff changeset
257 os.write (reinterpret_cast<char *> (&tmp), 4);
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
258 }
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
259
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
260 os.write (reinterpret_cast<const char *> (this->matrix.data ()),
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
261 this->byte_size ());
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
262
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
263 return true;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
264 }
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
265
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
266 template <class T>
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
267 bool
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
268 octave_base_int_matrix<T>::load_binary (std::istream& is, bool swap,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
269 oct_mach_info::float_format )
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
270 {
5828
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5760
diff changeset
271 int32_t mdims;
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5759
diff changeset
272 if (! is.read (reinterpret_cast<char *> (&mdims), 4))
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
273 return false;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
274 if (swap)
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4932
diff changeset
275 swap_bytes<4> (&mdims);
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
276 if (mdims >= 0)
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
277 return false;
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
278
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
279 mdims = - mdims;
5828
22e23bee74c8 [project @ 2006-05-23 06:05:14 by jwe]
jwe
parents: 5760
diff changeset
280 int32_t di;
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
281 dim_vector dv;
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
282 dv.resize (mdims);
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
283
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
284 for (int i = 0; i < mdims; i++)
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
285 {
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5759
diff changeset
286 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
287 return false;
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
288 if (swap)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
289 swap_bytes<4> (&di);
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
290 dv(i) = di;
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
291 }
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
292
5157
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
293 // 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
294 // Octave should never write files like this, other software
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
295 // might.
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
296
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
297 if (mdims == 1)
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
298 {
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
299 mdims = 2;
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
300 dv.resize (mdims);
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
301 dv(1) = dv(0);
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
302 dv(0) = 1;
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
303 }
8ca032643f55 [project @ 2005-02-23 00:18:58 by jwe]
jwe
parents: 5105
diff changeset
304
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
305 T m (dv);
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
306
5760
8d7162924bd3 [project @ 2006-04-14 04:01:37 by jwe]
jwe
parents: 5759
diff changeset
307 if (! is.read (reinterpret_cast<char *> (m.fortran_vec ()), m.byte_size ()))
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
308 return false;
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
309
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
310 if (swap)
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
311 {
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
312 int nel = dv.numel ();
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
313 int bytes = nel / m.byte_size ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
314 for (int i = 0; i < nel; i++)
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
315 switch (bytes)
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
316 {
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
317 case 8:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
318 swap_bytes<8> (&m(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
319 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
320 case 4:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
321 swap_bytes<4> (&m(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
322 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
323 case 2:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
324 swap_bytes<2> (&m(i));
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
325 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
326 case 1:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
327 default:
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
328 break;
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
329 }
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
330 }
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
331
4932
43f4ebd2704c [project @ 2004-08-05 13:26:10 by jwe]
jwe
parents: 4917
diff changeset
332 this->matrix = m;
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
333 return true;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
334 }
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
335
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
336 #if defined (HAVE_HDF5)
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
337
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
338 template <class T>
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
339 bool
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
340 octave_base_int_matrix<T>::save_hdf5 (hid_t loc_id, const char *name, bool)
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
341 {
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
342 hid_t save_type_hid = HDF5_SAVE_TYPE;
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
343 bool retval = true;
4932
43f4ebd2704c [project @ 2004-08-05 13:26:10 by jwe]
jwe
parents: 4917
diff changeset
344 dim_vector dv = this->dims ();
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
345 int empty = save_hdf5_empty (loc_id, name, dv);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
346 if (empty)
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
347 return (empty > 0);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
348
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
349 int rank = dv.length ();
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
350 hid_t space_hid = -1, data_hid = -1;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
351 OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
352
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
353 // Octave uses column-major, while HDF5 uses row-major ordering
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
354 for (int i = 0; i < rank; i++)
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
355 hdims[i] = dv (rank-i-1);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
356
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
357 space_hid = H5Screate_simple (rank, hdims, 0);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
358
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
359 if (space_hid < 0) return false;
9892
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
360 #if HAVE_HDF5_18
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
361 data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
362 H5P_DEFAULT, H5P_DEFAULT, 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
363 #else
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
364 data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
365 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
366 #endif
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
367 if (data_hid < 0)
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
368 {
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
369 H5Sclose (space_hid);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
370 return false;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
371 }
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
372
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
373 retval = H5Dwrite (data_hid, save_type_hid, H5S_ALL, H5S_ALL,
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
374 H5P_DEFAULT, this->matrix.data ()) >= 0;
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
375
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
376 H5Dclose (data_hid);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
377 H5Sclose (space_hid);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
378
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
379 return retval;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
380 }
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
381
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
382 template <class T>
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
383 bool
9881
b3089dba88bf Remove HDF5 cruft for older versions of HDF5
Kacper Kowalik
parents: 9689
diff changeset
384 octave_base_int_matrix<T>::load_hdf5 (hid_t loc_id, const char *name)
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
385 {
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
386 hid_t save_type_hid = HDF5_SAVE_TYPE;
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
387 bool retval = false;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
388 dim_vector dv;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
389 int empty = load_hdf5_empty (loc_id, name, dv);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
390 if (empty > 0)
14861
f7afecdd87ef maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
391 this->matrix.resize (dv);
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
392 if (empty)
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
393 return (empty > 0);
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
394
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
395 #if HAVE_HDF5_18
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
396 hid_t data_hid = H5Dopen (loc_id, name, H5P_DEFAULT);
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
397 #else
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
398 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
399 #endif
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
400 hid_t space_id = H5Dget_space (data_hid);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
401
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
402 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
403
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
404 if (rank < 1)
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
405 {
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
406 H5Sclose (space_id);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
407 H5Dclose (data_hid);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
408 return false;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
409 }
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
410
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
411 OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
412 OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
413
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
414 H5Sget_simple_extent_dims (space_id, hdims, maxdims);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
415
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
416 // Octave uses column-major, while HDF5 uses row-major ordering
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
417 if (rank == 1)
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
418 {
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
419 dv.resize (2);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
420 dv(0) = 1;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
421 dv(1) = hdims[0];
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
422 }
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
423 else
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
424 {
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
425 dv.resize (rank);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
426 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
427 dv(j) = hdims[i];
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
428 }
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
429
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
430 T m (dv);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
431 if (H5Dread (data_hid, save_type_hid, H5S_ALL, H5S_ALL,
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
432 H5P_DEFAULT, m.fortran_vec ()) >= 0)
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
433 {
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
434 retval = true;
4932
43f4ebd2704c [project @ 2004-08-05 13:26:10 by jwe]
jwe
parents: 4917
diff changeset
435 this->matrix = m;
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
436 }
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
437
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
438 H5Sclose (space_id);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
439 H5Dclose (data_hid);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
440
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
441 return retval;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
442 }
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
443
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
444 #endif
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
445
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
446 template <class T>
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
447 void
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
448 octave_base_int_matrix<T>::print_raw (std::ostream& os,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
449 bool pr_as_read_syntax) const
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
450 {
4932
43f4ebd2704c [project @ 2004-08-05 13:26:10 by jwe]
jwe
parents: 4917
diff changeset
451 octave_print_internal (os, this->matrix, pr_as_read_syntax,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
452 this->current_print_indent_level ());
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
453 }
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
454
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
455 template <class T>
5992
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
456 octave_value
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
457 octave_base_int_scalar<T>::convert_to_str_internal (bool, bool, char type) const
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
458 {
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
459 octave_value retval;
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
460
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
461 T tmp = this->scalar;
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
462
7534
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
463 typedef typename T::val_type val_type;
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
464
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
465 val_type ival = tmp.value ();
5992
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
466
7534
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
467 static const bool is_signed = std::numeric_limits<val_type>::is_signed;
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
468 static const bool can_be_larger_than_uchar_max
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
469 = octave_base_int_helper_traits<val_type>::can_be_larger_than_uchar_max;
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
470
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
471 if (octave_base_int_helper<val_type, is_signed,
ef755c763b62 avoid more "comparison is always false due to limited range of data type" warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
472 can_be_larger_than_uchar_max>::char_value_out_of_range (ival))
5992
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
473 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
474 // FIXME: is there something better we could do?
5992
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
475
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
476 ival = 0;
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
477
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
478 ::warning ("range error for conversion to character value");
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
479 }
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
480 else
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
481 retval = octave_value (std::string (1, static_cast<char> (ival)), type);
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
482
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
483 return retval;
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
484 }
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
485
4289ed95dde8 [project @ 2006-09-15 20:29:18 by jwe]
jwe
parents: 5958
diff changeset
486 template <class T>
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
487 bool
6974
9e32bb109980 [project @ 2007-10-08 11:06:47 by jwe]
jwe
parents: 6959
diff changeset
488 octave_base_int_scalar<T>::save_ascii (std::ostream& os)
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
489 {
4932
43f4ebd2704c [project @ 2004-08-05 13:26:10 by jwe]
jwe
parents: 4917
diff changeset
490 os << this->scalar << "\n";
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
491 return true;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
492 }
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
493
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
494 template <class T>
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
495 bool
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
496 octave_base_int_scalar<T>::load_ascii (std::istream& is)
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
497 {
4932
43f4ebd2704c [project @ 2004-08-05 13:26:10 by jwe]
jwe
parents: 4917
diff changeset
498 is >> this->scalar;
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
499 if (!is)
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
500 {
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
501 error ("load: failed to load scalar constant");
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
502 return false;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
503 }
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
504 return true;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
505 }
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
506
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
507 template <class T>
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
508 bool
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
509 octave_base_int_scalar<T>::save_binary (std::ostream& os, bool&)
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
510 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
511 os.write (reinterpret_cast<char *> (&(this->scalar)), this->byte_size ());
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
512 return true;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
513 }
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
514
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
515 template <class T>
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
516 bool
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
517 octave_base_int_scalar<T>::load_binary (std::istream& is, bool swap,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
518 oct_mach_info::float_format)
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
519 {
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
520 T tmp;
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
521 if (! is.read (reinterpret_cast<char *> (&tmp), this->byte_size ()))
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
522 return false;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
523
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
524 if (swap)
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
525 switch (this->byte_size ())
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
526 {
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
527 case 8:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
528 swap_bytes<8> (&tmp);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
529 break;
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
530 case 4:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
531 swap_bytes<4> (&tmp);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
532 break;
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
533 case 2:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
534 swap_bytes<2> (&tmp);
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
535 break;
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
536 case 1:
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
537 default:
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
538 break;
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
539 }
4932
43f4ebd2704c [project @ 2004-08-05 13:26:10 by jwe]
jwe
parents: 4917
diff changeset
540 this->scalar = tmp;
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
541 return true;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
542 }
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
543
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
544 #if defined (HAVE_HDF5)
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4932
diff changeset
545
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
546 template <class T>
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
547 bool
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
548 octave_base_int_scalar<T>::save_hdf5 (hid_t loc_id, const char *name, bool)
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
549 {
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
550 hid_t save_type_hid = HDF5_SAVE_TYPE;
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
551 bool retval = true;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
552 hsize_t dimens[3];
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
553 hid_t space_hid = -1, data_hid = -1;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
554
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
555 space_hid = H5Screate_simple (0, dimens, 0);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
556 if (space_hid < 0) return false;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
557
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
558 #if HAVE_HDF5_18
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
559 data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
560 H5P_DEFAULT, H5P_DEFAULT, 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
561 #else
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
562 data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
563 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
564 #endif
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
565 if (data_hid < 0)
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
566 {
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
567 H5Sclose (space_hid);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
568 return false;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
569 }
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
570
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
571 retval = H5Dwrite (data_hid, save_type_hid, H5S_ALL, H5S_ALL,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
572 H5P_DEFAULT, &(this->scalar)) >= 0;
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
573
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
574 H5Dclose (data_hid);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
575 H5Sclose (space_hid);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
576
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
577 return retval;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
578 }
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
579
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
580 template <class T>
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
581 bool
9881
b3089dba88bf Remove HDF5 cruft for older versions of HDF5
Kacper Kowalik
parents: 9689
diff changeset
582 octave_base_int_scalar<T>::load_hdf5 (hid_t loc_id, const char *name)
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
583 {
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
584 hid_t save_type_hid = HDF5_SAVE_TYPE;
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
585 #if HAVE_HDF5_18
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
586 hid_t data_hid = H5Dopen (loc_id, name, H5P_DEFAULT);
ac69e6f4b33d Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
Kacper Kowalik <xarthisius.kk@gmail.com>
parents: 9881
diff changeset
587 #else
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
588 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
589 #endif
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
590 hid_t space_id = H5Dget_space (data_hid);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
591
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
592 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
593
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
594 if (rank != 0)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
595 {
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
596 H5Dclose (data_hid);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
597 return false;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
598 }
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
599
4917
f69e95587ba3 [project @ 2004-07-27 14:03:03 by jwe]
jwe
parents: 4903
diff changeset
600 T tmp;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
601 if (H5Dread (data_hid, save_type_hid, H5S_ALL, H5S_ALL,
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 10160
diff changeset
602 H5P_DEFAULT, &tmp) < 0)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
603 {
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
604 H5Dclose (data_hid);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
605 return false;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
606 }
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
607
4932
43f4ebd2704c [project @ 2004-08-05 13:26:10 by jwe]
jwe
parents: 4917
diff changeset
608 this->scalar = tmp;
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
609
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
610 H5Dclose (data_hid);
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
611
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
612 return true;
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
613 }
4944
44046bbaa52c [project @ 2004-08-31 05:30:46 by jwe]
jwe
parents: 4932
diff changeset
614
4903
bfe64e459ce3 [project @ 2004-06-14 19:20:26 by jwe]
jwe
parents:
diff changeset
615 #endif