GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
ov-flt-re-mat.cc
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1996-2025 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if defined (HAVE_CONFIG_H)
27# include "config.h"
28#endif
29
30#include <clocale>
31#include <istream>
32#include <limits>
33#include <ostream>
34#include <vector>
35
36#include "dNDArray.h"
37#include "fNDArray.h"
38#include "int8NDArray.h"
39#include "int16NDArray.h"
40#include "int32NDArray.h"
41#include "int64NDArray.h"
42#include "uint8NDArray.h"
43#include "uint16NDArray.h"
44#include "uint32NDArray.h"
45#include "uint64NDArray.h"
46
47#include "data-conv.h"
48#include "lo-ieee.h"
49#include "lo-utils.h"
50#include "lo-specfun.h"
51#include "lo-mappers.h"
52#include "mach-info.h"
53#include "mx-base.h"
54#include "quit.h"
55#include "oct-locbuf.h"
56
57#include "defun.h"
58#include "errwarn.h"
59#include "mxarray.h"
60#include "ovl.h"
61#include "oct-lvalue.h"
62#include "oct-hdf5.h"
63#include "oct-stream.h"
64#include "ops.h"
65#include "ov-base.h"
66#include "ov-scalar.h"
67#include "ov-float.h"
68#include "ov-flt-complex.h"
69#include "ov-re-mat.h"
70#include "ov-flt-re-mat.h"
71#include "ov-flt-cx-mat.h"
72#include "ov-re-sparse.h"
73#include "ov-flt-re-diag.h"
74#include "ov-flt-cx-diag.h"
75#include "pr-output.h"
76#include "variables.h"
77#include "ops.h"
78
79#include "byte-swap.h"
80#include "ls-oct-text.h"
81#include "ls-utils.h"
82#include "ls-hdf5.h"
83
84
86 "single");
87
90{
91 octave_base_value *retval = nullptr;
92
93 if (m_matrix.numel () == 1)
94 retval = new octave_float_scalar (m_matrix (0));
95
96 return retval;
97}
98
99double
101{
102 if (isempty ())
103 err_invalid_conversion ("real matrix", "real scalar");
104
105 warn_implicit_conversion ("Octave:array-to-scalar",
106 "real matrix", "real scalar");
107
108 return m_matrix(0, 0);
109}
110
111float
113{
114 if (isempty ())
115 err_invalid_conversion ("real matrix", "real scalar");
116
117 warn_implicit_conversion ("Octave:array-to-scalar",
118 "real matrix", "real scalar");
119
120 return m_matrix(0, 0);
121}
122
123// FIXME
124
125Matrix
127{
128 return Matrix (FloatMatrix (m_matrix));
129}
130
136
139{
140 if (rows () == 0 || columns () == 0)
141 err_invalid_conversion ("real matrix", "complex scalar");
142
143 warn_implicit_conversion ("Octave:array-to-scalar",
144 "real matrix", "complex scalar");
145
146 return Complex (m_matrix(0, 0), 0);
147}
148
151{
152 double tmp = lo_ieee_float_nan_value ();
153
154 FloatComplex retval (tmp, tmp);
155
156 if (rows () == 0 || columns () == 0)
157 err_invalid_conversion ("real matrix", "complex scalar");
158
159 warn_implicit_conversion ("Octave:array-to-scalar",
160 "real matrix", "complex scalar");
161
162 retval = m_matrix(0, 0);
163
164 return retval;
165}
166
167// FIXME
168
174
180
186
192
195{
196 return NDArray (m_matrix);
197}
198
201{
203 octave::err_nan_to_logical_conversion ();
206
207 return boolNDArray (m_matrix);
208}
209
212{
213 charNDArray retval (dims ());
214
215 octave_idx_type nel = numel ();
216
217 for (octave_idx_type i = 0; i < nel; i++)
218 retval.elem (i) = static_cast<char> (m_matrix.elem (i));
219
220 return retval;
221}
222
228
231{
232 // FIXME: Need a SparseComplexMatrix (Matrix) constructor to make
233 // this function more efficient. Then this should become
234 // return SparseComplexMatrix (matrix.matrix_value ());
236}
237
240{
241 return NDArray (m_matrix);
242}
243
246{
247 return FloatNDArray (m_matrix);
248}
249
252{
253 return int8NDArray (m_matrix);
254}
255
258{
259 return int16NDArray (m_matrix);
260}
261
264{
265 return int32NDArray (m_matrix);
266}
267
270{
271 return int64NDArray (m_matrix);
272}
273
276{
277 return uint8NDArray (m_matrix);
278}
279
285
291
297
300{
301 octave_value retval;
302 if (k == 0 && m_matrix.ndims () == 2
303 && (m_matrix.rows () == 1 || m_matrix.columns () == 1))
305 else
307
308 return retval;
309}
310
313{
314 if (m_matrix.ndims () != 2
315 || (m_matrix.rows () != 1 && m_matrix.columns () != 1))
316 error ("diag: expecting vector argument");
317
318 FloatMatrix mat (m_matrix);
319
320 return mat.diag (m, n);
321}
322
325{
326 octave_value retval;
327 const dim_vector& dv = dims ();
328 octave_idx_type nel = dv.numel ();
329
330 charNDArray chm (dv);
331
332 bool warned = false;
333
334 for (octave_idx_type i = 0; i < nel; i++)
335 {
336 octave_quit ();
337
338 float d = m_matrix(i);
339
340 if (octave::math::isnan (d))
341 octave::err_nan_to_character_conversion ();
342
343 int ival = octave::math::nint (d);
344
345 if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
346 {
347 // FIXME: is there something better we could do?
348
349 ival = 0;
350
351 if (! warned)
352 {
353 ::warning ("range error for conversion to character value");
354 warned = true;
355 }
356 }
357
358 chm(i) = static_cast<char> (ival);
359 }
360
361 retval = octave_value (chm, type);
362
363 return retval;
364}
365
366bool
368{
369 const dim_vector& dv = dims ();
370
371 if (dv.ndims () > 2)
372 {
374
375 os << "# ndims: " << dv.ndims () << "\n";
376
377 for (int i=0; i < dv.ndims (); i++)
378 os << ' ' << dv(i);
379
380 os << "\n" << tmp;
381 }
382 else
383 {
384 // Keep this case, rather than use generic code above for backward
385 // compatibility. Makes load_ascii much more complex!!
386 os << "# rows: " << rows () << "\n"
387 << "# columns: " << columns () << "\n";
388
389 os << float_matrix_value ();
390 }
391
392 return true;
393}
394
395bool
397{
398 string_vector keywords(2);
399
400 keywords[0] = "ndims";
401 keywords[1] = "rows";
402
403 std::string kw;
404 octave_idx_type val = 0;
405
406 if (! extract_keyword (is, keywords, kw, val, true))
407 error ("load: failed to extract number of rows and columns");
408
409 // Set "C" locale for the duration of this function to avoid the performance
410 // panelty of frequently switching the locale when reading floating point
411 // values from the stream.
412 char *prev_locale = std::setlocale (LC_ALL, nullptr);
413 std::string old_locale (prev_locale ? prev_locale : "");
414 std::setlocale (LC_ALL, "C");
415 octave::unwind_action act
416 ([&old_locale] () { std::setlocale (LC_ALL, old_locale.c_str ()); });
417
418 if (kw == "ndims")
419 {
420 int mdims = static_cast<int> (val);
421
422 if (mdims < 0)
423 error ("load: failed to extract number of dimensions");
424
425 dim_vector dv;
426 dv.resize (mdims);
427
428 for (int i = 0; i < mdims; i++)
429 is >> dv(i);
430
431 if (! is)
432 error ("load: failed to read dimensions");
433
434 FloatNDArray tmp(dv);
435
436 is >> tmp;
437
438 if (! is)
439 error ("load: failed to load matrix constant");
440
441 m_matrix = tmp;
442 }
443 else if (kw == "rows")
444 {
445 octave_idx_type nr = val;
446 octave_idx_type nc = 0;
447
448 if (nr < 0 || ! extract_keyword (is, "columns", nc) || nc < 0)
449 error ("load: failed to extract number of rows and columns");
450
451 if (nr > 0 && nc > 0)
452 {
453 FloatMatrix tmp (nr, nc);
454 is >> tmp;
455 if (! is)
456 error ("load: failed to load matrix constant");
457
458 m_matrix = tmp;
459 }
460 else if (nr == 0 || nc == 0)
461 m_matrix = FloatMatrix (nr, nc);
462 else
463 error ("unexpected dimensions in octave_float_matrix::load_ascii - please report this bug");
464 }
465 else
466 error ("unexpected dimensions keyword (= '%s') octave_float_matrix::load_ascii - please report this bug", kw.c_str ());
467
468 return true;
469}
470
471bool
472octave_float_matrix::save_binary (std::ostream& os, bool)
473{
474 const dim_vector& dv = dims ();
475 if (dv.ndims () < 1)
476 return false;
477
478 // Use negative value for ndims to differentiate with old format!!
479 int32_t tmp = - dv.ndims ();
480 os.write (reinterpret_cast<char *> (&tmp), 4);
481 for (int i = 0; i < dv.ndims (); i++)
482 {
483 tmp = dv(i);
484 os.write (reinterpret_cast<char *> (&tmp), 4);
485 }
486
488 save_type st = LS_FLOAT;
489 if (dv.numel () > 8192) // FIXME: make this configurable.
490 {
491 float max_val, min_val;
492 if (m.all_integers (max_val, min_val))
493 st = octave::get_save_type (max_val, min_val);
494 }
495
496 const float *mtmp = m.data ();
497 write_floats (os, mtmp, st, dv.numel ());
498
499 return true;
500}
501
502bool
503octave_float_matrix::load_binary (std::istream& is, bool swap,
504 octave::mach_info::float_format fmt)
505{
506 char tmp;
507 int32_t mdims;
508 if (! is.read (reinterpret_cast<char *> (&mdims), 4))
509 return false;
510 if (swap)
511 swap_bytes<4> (&mdims);
512 if (mdims < 0)
513 {
514 mdims = - mdims;
515 int32_t di;
516 dim_vector dv;
517 dv.resize (mdims);
518
519 for (int i = 0; i < mdims; i++)
520 {
521 if (! is.read (reinterpret_cast<char *> (&di), 4))
522 return false;
523 if (swap)
524 swap_bytes<4> (&di);
525 dv(i) = di;
526 }
527
528 // Convert an array with a single dimension to be a row vector.
529 // Octave should never write files like this, other software
530 // might.
531
532 if (mdims == 1)
533 {
534 mdims = 2;
535 dv.resize (mdims);
536 dv(1) = dv(0);
537 dv(0) = 1;
538 }
539
540 if (! is.read (reinterpret_cast<char *> (&tmp), 1))
541 return false;
542
543 FloatNDArray m(dv);
544 float *re = m.rwdata ();
545 read_floats (is, re, static_cast<save_type> (tmp), dv.numel (),
546 swap, fmt);
547
548 if (! is)
549 return false;
550
551 m_matrix = m;
552 }
553 else
554 {
555 int32_t nr, nc;
556 nr = mdims;
557 if (! is.read (reinterpret_cast<char *> (&nc), 4))
558 return false;
559 if (swap)
560 swap_bytes<4> (&nc);
561 if (! is.read (reinterpret_cast<char *> (&tmp), 1))
562 return false;
563 FloatMatrix m (nr, nc);
564 float *re = m.rwdata ();
565 octave_idx_type len = static_cast<octave_idx_type> (nr) * nc;
566 read_floats (is, re, static_cast<save_type> (tmp), len, swap, fmt);
567
568 if (! is)
569 return false;
570
571 m_matrix = m;
572 }
573 return true;
574}
575
576bool
577octave_float_matrix::save_hdf5 (octave_hdf5_id loc_id, const char *name, bool)
578{
579 bool retval = false;
580
581#if defined (HAVE_HDF5)
582
583 const dim_vector& dv = dims ();
584 int empty = save_hdf5_empty (loc_id, name, dv);
585 if (empty)
586 return (empty > 0);
587
588 int rank = dv.ndims ();
589 hid_t space_hid, data_hid;
590 space_hid = data_hid = -1;
592
593 OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
594
595 // Octave uses column-major, while HDF5 uses row-major ordering
596 for (int i = 0; i < rank; i++)
597 hdims[i] = dv(rank-i-1);
598
599 space_hid = H5Screate_simple (rank, hdims, nullptr);
600
601 if (space_hid < 0) return false;
602
603 hid_t save_type_hid = H5T_NATIVE_FLOAT;
604
605#if defined (HAVE_HDF5_INT2FLOAT_CONVERSIONS)
606 // hdf5 currently doesn't support float/integer conversions
607 else
608 {
609 float max_val, min_val;
610
611 if (m.all_integers (max_val, min_val))
612 save_type_hid
613 = save_type_to_hdf5 (octave::get_save_type (max_val, min_val));
614 }
615#endif
616#if defined (HAVE_HDF5_18)
617 data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
620#else
621 data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
623#endif
624 if (data_hid < 0)
625 {
626 H5Sclose (space_hid);
627 return false;
628 }
629
630 const float *mtmp = m.data ();
631 retval = H5Dwrite (data_hid, H5T_NATIVE_FLOAT, octave_H5S_ALL, octave_H5S_ALL,
632 octave_H5P_DEFAULT, mtmp) >= 0;
633
634 H5Dclose (data_hid);
635 H5Sclose (space_hid);
636
637#else
638 octave_unused_parameter (loc_id);
639 octave_unused_parameter (name);
640
641 warn_save ("hdf5");
642#endif
643
644 return retval;
645}
646
647bool
649{
650 bool retval = false;
651
652#if defined (HAVE_HDF5)
653
654 dim_vector dv;
655 int empty = load_hdf5_empty (loc_id, name, dv);
656 if (empty > 0)
657 m_matrix.resize (dv);
658 if (empty)
659 return (empty > 0);
660
661#if defined (HAVE_HDF5_18)
662 hid_t data_hid = H5Dopen (loc_id, name, octave_H5P_DEFAULT);
663#else
664 hid_t data_hid = H5Dopen (loc_id, name);
665#endif
666 hid_t space_id = H5Dget_space (data_hid);
667
668 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
669
670 if (rank < 1)
671 {
672 H5Sclose (space_id);
673 H5Dclose (data_hid);
674 return false;
675 }
676
677 OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
678 OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank);
679
680 H5Sget_simple_extent_dims (space_id, hdims, maxdims);
681
682 // Octave uses column-major, while HDF5 uses row-major ordering
683 if (rank == 1)
684 {
685 dv.resize (2);
686 dv(0) = 1;
687 dv(1) = hdims[0];
688 }
689 else
690 {
691 dv.resize (rank);
692 for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
693 dv(j) = hdims[i];
694 }
695
696 FloatNDArray m (dv);
697 float *re = m.rwdata ();
698 if (H5Dread (data_hid, H5T_NATIVE_FLOAT, octave_H5S_ALL, octave_H5S_ALL,
699 octave_H5P_DEFAULT, re) >= 0)
700 {
701 retval = true;
702 m_matrix = m;
703 }
704
705 H5Sclose (space_id);
706 H5Dclose (data_hid);
707
708#else
709 octave_unused_parameter (loc_id);
710 octave_unused_parameter (name);
711
712 warn_load ("hdf5");
713#endif
714
715 return retval;
716}
717
718void
720 bool pr_as_read_syntax) const
721{
722 octave_print_internal (os, m_matrix, pr_as_read_syntax,
724}
725
726mxArray *
727octave_float_matrix::as_mxArray (bool interleaved) const
728{
729 mxArray *retval = new mxArray (interleaved, mxSINGLE_CLASS, dims (), mxREAL);
730
731 mxSingle *pd = static_cast<mxSingle *> (retval->get_data ());
732
733 mwSize nel = numel ();
734
735 const float *pdata = m_matrix.data ();
736
737 for (mwIndex i = 0; i < nel; i++)
738 pd[i] = pdata[i];
739
740 return retval;
741}
742
743// This uses a smarter strategy for doing the complex->real mappers. We
744// allocate an array for a real result and keep filling it until a complex
745// result is produced.
746static octave_value
747do_rc_map (const FloatNDArray& a, FloatComplex (&fcn) (float))
748{
749 octave_idx_type n = a.numel ();
750 FloatNDArray rr (a.dims ());
751
752 for (octave_idx_type i = 0; i < n; i++)
753 {
754 octave_quit ();
755
756 FloatComplex tmp = fcn (a(i));
757 if (tmp.imag () == 0.0)
758 rr.xelem (i) = tmp.real ();
759 else
760 {
761 FloatComplexNDArray rc (a.dims ());
762
763 for (octave_idx_type j = 0; j < i; j++)
764 rc.xelem (j) = rr.xelem (j);
765
766 rc.xelem (i) = tmp;
767
768 for (octave_idx_type j = i+1; j < n; j++)
769 {
770 octave_quit ();
771
772 rc.xelem (j) = fcn (a(j));
773 }
774
775 return new octave_float_complex_matrix (rc);
776 }
777 }
778
779 return rr;
780}
781
784{
785 switch (umap)
786 {
787 case umap_imag:
788 return FloatNDArray (m_matrix.dims (), 0.0);
789
790 case umap_real:
791 case umap_conj:
792 return m_matrix;
793
794 // Mappers handled specially.
795#define ARRAY_METHOD_MAPPER(UMAP, FCN) \
796 case umap_ ## UMAP: \
797 return octave_value (m_matrix.FCN ())
798
803
804#define ARRAY_MAPPER(UMAP, TYPE, FCN) \
805 case umap_ ## UMAP: \
806 return octave_value (m_matrix.map<TYPE> (FCN))
807
808#define RC_ARRAY_MAPPER(UMAP, TYPE, FCN) \
809 case umap_ ## UMAP: \
810 return do_rc_map (m_matrix, FCN)
811
812 RC_ARRAY_MAPPER (acos, FloatComplex, octave::math::rc_acos);
813 RC_ARRAY_MAPPER (acosh, FloatComplex, octave::math::rc_acosh);
814 ARRAY_MAPPER (angle, float, std::arg);
815 ARRAY_MAPPER (arg, float, std::arg);
816 RC_ARRAY_MAPPER (asin, FloatComplex, octave::math::rc_asin);
817 ARRAY_MAPPER (asinh, float, octave::math::asinh);
818 ARRAY_MAPPER (atan, float, ::atanf);
819 RC_ARRAY_MAPPER (atanh, FloatComplex, octave::math::rc_atanh);
820 ARRAY_MAPPER (erf, float, octave::math::erf);
821 ARRAY_MAPPER (erfinv, float, octave::math::erfinv);
822 ARRAY_MAPPER (erfcinv, float, octave::math::erfcinv);
823 ARRAY_MAPPER (erfc, float, octave::math::erfc);
824 ARRAY_MAPPER (erfcx, float, octave::math::erfcx);
825 ARRAY_MAPPER (erfi, float, octave::math::erfi);
826 ARRAY_MAPPER (dawson, float, octave::math::dawson);
827 ARRAY_MAPPER (gamma, float, octave::math::gamma);
828 RC_ARRAY_MAPPER (lgamma, FloatComplex, octave::math::rc_lgamma);
829 ARRAY_MAPPER (cbrt, float, octave::math::cbrt);
830 ARRAY_MAPPER (ceil, float, ::ceilf);
831 ARRAY_MAPPER (cos, float, ::cosf);
832 ARRAY_MAPPER (cosh, float, ::coshf);
833 ARRAY_MAPPER (exp, float, ::expf);
834 ARRAY_MAPPER (expm1, float, octave::math::expm1);
835 ARRAY_MAPPER (fix, float, octave::math::fix);
836 ARRAY_MAPPER (floor, float, ::floorf);
837 RC_ARRAY_MAPPER (log, FloatComplex, octave::math::rc_log);
838 RC_ARRAY_MAPPER (log2, FloatComplex, octave::math::rc_log2);
839 RC_ARRAY_MAPPER (log10, FloatComplex, octave::math::rc_log10);
840 RC_ARRAY_MAPPER (log1p, FloatComplex, octave::math::rc_log1p);
841 ARRAY_MAPPER (round, float, octave::math::round);
842 ARRAY_MAPPER (roundb, float, octave::math::roundb);
843 ARRAY_MAPPER (signum, float, octave::math::signum);
844 ARRAY_MAPPER (sin, float, ::sinf);
845 ARRAY_MAPPER (sinh, float, ::sinhf);
846 RC_ARRAY_MAPPER (sqrt, FloatComplex, octave::math::rc_sqrt);
847 ARRAY_MAPPER (tan, float, ::tanf);
848 ARRAY_MAPPER (tanh, float, ::tanhf);
849 ARRAY_MAPPER (isna, bool, octave::math::isna);
850 ARRAY_MAPPER (xsignbit, float, octave::math::signbit);
851
852 // Special cases for Matlab compatibility.
853 case umap_xtolower:
854 case umap_xtoupper:
855 return m_matrix;
856
857 case umap_xisalnum:
858 case umap_xisalpha:
859 case umap_xisascii:
860 case umap_xiscntrl:
861 case umap_xisdigit:
862 case umap_xisgraph:
863 case umap_xislower:
864 case umap_xisprint:
865 case umap_xispunct:
866 case umap_xisspace:
867 case umap_xisupper:
868 case umap_xisxdigit:
869 {
870 octave_value str_conv = convert_to_str (true, true);
871 return str_conv.map (umap);
872 }
873
874 default:
875 return octave_base_value::map (umap);
876 }
877}
void swap_bytes< 4 >(void *ptr)
Definition byte-swap.h:63
const dim_vector & dims() const
Return a const-reference so that dims ()(i) works efficiently.
Definition Array.h:507
T & elem(octave_idx_type n)
Size of the specified dimension.
Definition Array.h:563
int ndims() const
Size of the specified dimension.
Definition Array.h:679
octave_idx_type rows() const
Definition Array.h:463
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
octave_idx_type columns() const
Definition Array.h:475
const T * data() const
Size of the specified dimension.
Definition Array.h:665
T * rwdata()
Size of the specified dimension.
octave_idx_type numel() const
Number of elements in the array.
Definition Array.h:418
FloatMatrix diag(octave_idx_type k=0) const
Definition fMatrix.cc:2418
bool any_element_not_one_or_zero() const
Definition fNDArray.cc:287
bool all_integers(float &max_val, float &min_val) const
Definition fNDArray.cc:308
bool any_element_is_nan() const
Definition fNDArray.cc:275
Vector representing the dimensions (size) of an Array.
Definition dim-vector.h:90
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
Definition dim-vector.h:331
void resize(int n, int fill_value=0)
Definition dim-vector.h:268
octave_idx_type ndims() const
Number of dimensions.
Definition dim-vector.h:253
void * get_data() const
Definition mxarray.h:482
octave_value diag(octave_idx_type k=0) const
octave_idx_type numel() const
octave_idx_type rows() const
Definition ov-base.h:384
octave_idx_type columns() const
Definition ov-base.h:391
int current_print_indent_level() const
Definition ov-base.h:945
virtual octave_value map(unary_mapper_t) const
Definition ov-base.cc:1170
virtual octave_value convert_to_str(bool pad=false, bool force=false, char type='\'') const
Definition ov-base.cc:431
void warn_load(const char *type) const
Definition ov-base.cc:1152
bool isempty() const
Definition ov-base.h:429
friend class octave_value
Definition ov-base.h:278
void warn_save(const char *type) const
Definition ov-base.cc:1161
FloatNDArray float_array_value(bool=false) const
ComplexNDArray complex_array_value(bool=false) const
charNDArray char_array_value(bool=false) const
octave_base_value * try_narrowing_conversion()
bool save_binary(std::ostream &os, bool save_as_floats)
octave_value as_double() const
octave_value map(unary_mapper_t umap) const
octave_value as_uint16() const
ComplexMatrix complex_matrix_value(bool=false) const
octave_value as_int16() const
FloatComplex float_complex_value(bool=false) const
FloatMatrix float_matrix_value(bool=false) const
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
octave_value as_int64() const
octave_value as_single() const
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
bool save_ascii(std::ostream &os)
double double_value(bool=false) const
FloatComplexNDArray float_complex_array_value(bool=false) const
Complex complex_value(bool=false) const
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
octave_value as_uint64() const
SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
Matrix matrix_value(bool=false) const
octave_value convert_to_str_internal(bool pad, bool force, char type) const
octave_value diag(octave_idx_type k=0) const
octave_value as_uint32() const
boolNDArray bool_array_value(bool warn=false) const
float float_value(bool=false) const
SparseMatrix sparse_matrix_value(bool=false) const
bool load_ascii(std::istream &is)
NDArray array_value(bool=false) const
octave_value as_int8() const
octave_value as_int32() const
octave_value as_uint8() const
FloatComplexMatrix float_complex_matrix_value(bool=false) const
mxArray * as_mxArray(bool interleaved) const
octave_value map(octave_base_value::unary_mapper_t umap) const
Definition ov.h:1528
const octave_hdf5_id octave_H5P_DEFAULT
const octave_hdf5_id octave_H5S_ALL
void write_floats(std::ostream &os, const float *data, save_type type, octave_idx_type len)
Definition data-conv.cc:968
void read_floats(std::istream &is, float *data, save_type type, octave_idx_type len, bool swap, octave::mach_info::float_format fmt)
Definition data-conv.cc:862
save_type
Definition data-conv.h:85
@ LS_FLOAT
Definition data-conv.h:92
void warning(const char *fmt,...)
Definition error.cc:1078
void error(const char *fmt,...)
Definition error.cc:1003
void err_invalid_conversion(const std::string &from, const std::string &to)
Definition errwarn.cc:71
void warn_logical_conversion()
Definition errwarn.cc:365
void warn_implicit_conversion(const char *id, const char *from, const char *to)
Definition errwarn.cc:344
function gamma(x)
Definition gamma.f:3
intNDArray< octave_int16 > int16NDArray
intNDArray< octave_int32 > int32NDArray
intNDArray< octave_int64 > int64NDArray
intNDArray< octave_int8 > int8NDArray
Definition int8NDArray.h:36
float lo_ieee_float_nan_value()
Definition lo-ieee.cc:116
Complex log2(const Complex &x)
Complex asin(const Complex &x)
bool isna(double x)
Definition lo-mappers.cc:47
Complex acos(const Complex &x)
Definition lo-mappers.cc:85
std::complex< T > ceil(const std::complex< T > &x)
Definition lo-mappers.h:103
Complex atan(const Complex &x)
Definition lo-mappers.h:71
double roundb(double x)
Definition lo-mappers.h:147
std::complex< T > floor(const std::complex< T > &x)
Definition lo-mappers.h:130
bool isfinite(double x)
Definition lo-mappers.h:192
bool isinf(double x)
Definition lo-mappers.h:203
double signum(double x)
Definition lo-mappers.h:229
double round(double x)
Definition lo-mappers.h:136
bool isnan(bool)
Definition lo-mappers.h:178
double fix(double x)
Definition lo-mappers.h:118
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
double erfinv(double x)
double erfi(double x)
double dawson(double x)
Complex erf(const Complex &x)
double erfcinv(double x)
double erfcx(double x)
Complex expm1(const Complex &x)
Complex log1p(const Complex &x)
Complex erfc(const Complex &x)
double cbrt(double x)
Definition lo-specfun.h:289
double asinh(double x)
Definition lo-specfun.h:58
double atanh(double x)
Definition lo-specfun.h:63
double acosh(double x)
Definition lo-specfun.h:40
double lgamma(double x)
Definition lo-specfun.h:336
int save_hdf5_empty(octave_hdf5_id loc_id, const char *name, const dim_vector &d)
Definition ls-hdf5.cc:1254
int load_hdf5_empty(octave_hdf5_id loc_id, const char *name, dim_vector &d)
Definition ls-hdf5.cc:1311
octave_hdf5_id save_type_to_hdf5(save_type st)
Definition ls-hdf5.cc:1355
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
std::complex< double > Complex
Definition oct-cmplx.h:33
std::complex< float > FloatComplex
Definition oct-cmplx.h:34
int64_t octave_hdf5_id
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Definition oct-locbuf.h:44
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
Definition ov-base.h:246
#define ARRAY_MAPPER(UMAP, TYPE, FCN)
#define ARRAY_METHOD_MAPPER(UMAP, FCN)
#define RC_ARRAY_MAPPER(UMAP, TYPE, FCN)
void octave_print_internal(std::ostream &os, const float_display_format &fmt, bool d, bool pr_as_read_syntax)
template int8_t abs(int8_t)
intNDArray< octave_uint16 > uint16NDArray
intNDArray< octave_uint32 > uint32NDArray
intNDArray< octave_uint64 > uint64NDArray
intNDArray< octave_uint8 > uint8NDArray
F77_RET_T len
Definition xerbla.cc:61