GNU Octave 11.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-2026 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 "mappers.h"
50#include "lo-utils.h"
51#include "mach-info.h"
52#include "mx-base.h"
53#include "oct-locbuf.h"
54#include "oct-specfun.h"
55#include "quit.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 if (octave::math::isnan (m_matrix.elem (i)))
219 retval.elem (i) = 0;
220 else
221 retval.elem (i) = static_cast<char> (m_matrix.elem (i));
222
223 return retval;
224}
225
231
234{
235 // FIXME: Need a SparseComplexMatrix (Matrix) constructor to make
236 // this function more efficient. Then this should become
237 // return SparseComplexMatrix (matrix.matrix_value ());
239}
240
243{
244 return NDArray (m_matrix);
245}
246
249{
250 return FloatNDArray (m_matrix);
251}
252
255{
256 return int8NDArray (m_matrix);
257}
258
261{
262 return int16NDArray (m_matrix);
263}
264
267{
268 return int32NDArray (m_matrix);
269}
270
273{
274 return int64NDArray (m_matrix);
275}
276
279{
280 return uint8NDArray (m_matrix);
281}
282
288
294
300
303{
304 octave_value retval;
305 if (k == 0 && m_matrix.ndims () == 2
306 && (m_matrix.rows () == 1 || m_matrix.columns () == 1))
308 else
310
311 return retval;
312}
313
316{
317 if (m_matrix.ndims () != 2
318 || (m_matrix.rows () != 1 && m_matrix.columns () != 1))
319 error ("diag: expecting vector argument");
320
321 FloatMatrix mat (m_matrix);
322
323 return mat.diag (m, n);
324}
325
328{
329 octave_value retval;
330 const dim_vector& dv = dims ();
331 octave_idx_type nel = dv.numel ();
332
333 charNDArray chm (dv);
334
335 bool warned = false;
336
337 for (octave_idx_type i = 0; i < nel; i++)
338 {
339 octave_quit ();
340
341 float d = m_matrix(i);
342
343 if (octave::math::isnan (d))
344 octave::err_nan_to_character_conversion ();
345
346 int ival = octave::math::nint (d);
347
348 if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
349 {
350 // FIXME: is there something better we could do?
351
352 ival = 0;
353
354 if (! warned)
355 {
356 ::warning ("range error for conversion to character value");
357 warned = true;
358 }
359 }
360
361 chm(i) = static_cast<char> (ival);
362 }
363
364 retval = octave_value (chm, type);
365
366 return retval;
367}
368
369bool
371{
372 const dim_vector& dv = dims ();
373
374 if (dv.ndims () > 2)
375 {
377
378 os << "# ndims: " << dv.ndims () << "\n";
379
380 for (int i=0; i < dv.ndims (); i++)
381 os << ' ' << dv(i);
382
383 os << "\n" << tmp;
384 }
385 else
386 {
387 // Keep this case, rather than use generic code above for backward
388 // compatibility. Makes load_ascii much more complex!!
389 os << "# rows: " << rows () << "\n"
390 << "# columns: " << columns () << "\n";
391
392 os << float_matrix_value ();
393 }
394
395 return true;
396}
397
398bool
400{
401 string_vector keywords(2);
402
403 keywords[0] = "ndims";
404 keywords[1] = "rows";
405
406 std::string kw;
407 octave_idx_type val = 0;
408
409 if (! extract_keyword (is, keywords, kw, val, true))
410 error ("load: failed to extract number of rows and columns");
411
412 // Set "C" locale for the duration of this function to avoid the performance
413 // panelty of frequently switching the locale when reading floating point
414 // values from the stream.
415 char *prev_locale = std::setlocale (LC_ALL, nullptr);
416 std::string old_locale (prev_locale ? prev_locale : "");
417 std::setlocale (LC_ALL, "C");
418 octave::unwind_action act
419 ([&old_locale] () { std::setlocale (LC_ALL, old_locale.c_str ()); });
420
421 if (kw == "ndims")
422 {
423 int mdims = static_cast<int> (val);
424
425 if (mdims < 0)
426 error ("load: failed to extract number of dimensions");
427
428 dim_vector dv;
429 dv.resize (mdims);
430
431 for (int i = 0; i < mdims; i++)
432 is >> dv(i);
433
434 if (! is)
435 error ("load: failed to read dimensions");
436
437 FloatNDArray tmp(dv);
438
439 is >> tmp;
440
441 if (! is)
442 error ("load: failed to load matrix constant");
443
444 m_matrix = tmp;
445 }
446 else if (kw == "rows")
447 {
448 octave_idx_type nr = val;
449 octave_idx_type nc = 0;
450
451 if (nr < 0 || ! extract_keyword (is, "columns", nc) || nc < 0)
452 error ("load: failed to extract number of rows and columns");
453
454 if (nr > 0 && nc > 0)
455 {
456 FloatMatrix tmp (nr, nc);
457 is >> tmp;
458 if (! is)
459 error ("load: failed to load matrix constant");
460
461 m_matrix = tmp;
462 }
463 else if (nr == 0 || nc == 0)
464 m_matrix = FloatMatrix (nr, nc);
465 else
466 error ("unexpected dimensions in octave_float_matrix::load_ascii - please report this bug");
467 }
468 else
469 error ("unexpected dimensions keyword (= '%s') octave_float_matrix::load_ascii - please report this bug", kw.c_str ());
470
471 return true;
472}
473
474bool
475octave_float_matrix::save_binary (std::ostream& os, bool)
476{
477 const dim_vector& dv = dims ();
478 if (dv.ndims () < 1)
479 return false;
480
481 // Use negative value for ndims to differentiate with old format!!
482 int32_t tmp = - dv.ndims ();
483 os.write (reinterpret_cast<char *> (&tmp), 4);
484 for (int i = 0; i < dv.ndims (); i++)
485 {
486 tmp = dv(i);
487 os.write (reinterpret_cast<char *> (&tmp), 4);
488 }
489
491 save_type st = LS_FLOAT;
492 if (dv.numel () > 8192) // FIXME: make this configurable.
493 {
494 float max_val, min_val;
495 if (m.all_integers (max_val, min_val))
496 st = octave::get_save_type (max_val, min_val);
497 }
498
499 const float *mtmp = m.data ();
500 write_floats (os, mtmp, st, dv.numel ());
501
502 return true;
503}
504
505bool
506octave_float_matrix::load_binary (std::istream& is, bool swap,
507 octave::mach_info::float_format fmt)
508{
509 char tmp;
510 int32_t mdims;
511 if (! is.read (reinterpret_cast<char *> (&mdims), 4))
512 return false;
513 if (swap)
514 swap_bytes<4> (&mdims);
515 if (mdims < 0)
516 {
517 mdims = - mdims;
518 int32_t di;
519 dim_vector dv;
520 dv.resize (mdims);
521
522 for (int i = 0; i < mdims; i++)
523 {
524 if (! is.read (reinterpret_cast<char *> (&di), 4))
525 return false;
526 if (swap)
527 swap_bytes<4> (&di);
528 dv(i) = di;
529 }
530
531 // Convert an array with a single dimension to be a row vector.
532 // Octave should never write files like this, other software
533 // might.
534
535 if (mdims == 1)
536 {
537 mdims = 2;
538 dv.resize (mdims);
539 dv(1) = dv(0);
540 dv(0) = 1;
541 }
542
543 if (! is.read (reinterpret_cast<char *> (&tmp), 1))
544 return false;
545
546 FloatNDArray m(dv);
547 float *re = m.rwdata ();
548 read_floats (is, re, static_cast<save_type> (tmp), dv.numel (),
549 swap, fmt);
550
551 if (! is)
552 return false;
553
554 m_matrix = m;
555 }
556 else
557 {
558 int32_t nr, nc;
559 nr = mdims;
560 if (! is.read (reinterpret_cast<char *> (&nc), 4))
561 return false;
562 if (swap)
563 swap_bytes<4> (&nc);
564 if (! is.read (reinterpret_cast<char *> (&tmp), 1))
565 return false;
566 FloatMatrix m (nr, nc);
567 float *re = m.rwdata ();
568 octave_idx_type len = static_cast<octave_idx_type> (nr) * nc;
569 read_floats (is, re, static_cast<save_type> (tmp), len, swap, fmt);
570
571 if (! is)
572 return false;
573
574 m_matrix = m;
575 }
576 return true;
577}
578
579bool
580octave_float_matrix::save_hdf5 (octave_hdf5_id loc_id, const char *name, bool)
581{
582 bool retval = false;
583
584#if defined (HAVE_HDF5)
585
586 const dim_vector& dv = dims ();
587 int empty = save_hdf5_empty (loc_id, name, dv);
588 if (empty)
589 return (empty > 0);
590
591 int rank = dv.ndims ();
592 hid_t space_hid, data_hid;
593 space_hid = data_hid = -1;
595
596 OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
597
598 // Octave uses column-major, while HDF5 uses row-major ordering
599 for (int i = 0; i < rank; i++)
600 hdims[i] = dv(rank-i-1);
601
602 space_hid = H5Screate_simple (rank, hdims, nullptr);
603
604 if (space_hid < 0) return false;
605
606 hid_t save_type_hid = H5T_NATIVE_FLOAT;
607
608#if defined (HAVE_HDF5_INT2FLOAT_CONVERSIONS)
609 // hdf5 currently doesn't support float/integer conversions
610 else
611 {
612 float max_val, min_val;
613
614 if (m.all_integers (max_val, min_val))
615 save_type_hid
616 = save_type_to_hdf5 (octave::get_save_type (max_val, min_val));
617 }
618#endif
619#if defined (HAVE_HDF5_18)
620 data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
623#else
624 data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
626#endif
627 if (data_hid < 0)
628 {
629 H5Sclose (space_hid);
630 return false;
631 }
632
633 const float *mtmp = m.data ();
634 retval = H5Dwrite (data_hid, H5T_NATIVE_FLOAT, octave_H5S_ALL, octave_H5S_ALL,
635 octave_H5P_DEFAULT, mtmp) >= 0;
636
637 H5Dclose (data_hid);
638 H5Sclose (space_hid);
639
640#else
641 octave_unused_parameter (loc_id);
642 octave_unused_parameter (name);
643
644 warn_save ("hdf5");
645#endif
646
647 return retval;
648}
649
650bool
652{
653 bool retval = false;
654
655#if defined (HAVE_HDF5)
656
657 dim_vector dv;
658 int empty = load_hdf5_empty (loc_id, name, dv);
659 if (empty > 0)
660 m_matrix.resize (dv);
661 if (empty)
662 return (empty > 0);
663
664#if defined (HAVE_HDF5_18)
665 hid_t data_hid = H5Dopen (loc_id, name, octave_H5P_DEFAULT);
666#else
667 hid_t data_hid = H5Dopen (loc_id, name);
668#endif
669 hid_t space_id = H5Dget_space (data_hid);
670
671 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
672
673 if (rank < 1)
674 {
675 H5Sclose (space_id);
676 H5Dclose (data_hid);
677 return false;
678 }
679
680 OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
681 OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank);
682
683 H5Sget_simple_extent_dims (space_id, hdims, maxdims);
684
685 // Octave uses column-major, while HDF5 uses row-major ordering
686 if (rank == 1)
687 {
688 dv.resize (2);
689 dv(0) = 1;
690 dv(1) = hdims[0];
691 }
692 else
693 {
694 dv.resize (rank);
695 for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
696 dv(j) = hdims[i];
697 }
698
699 FloatNDArray m (dv);
700 float *re = m.rwdata ();
701 if (H5Dread (data_hid, H5T_NATIVE_FLOAT, octave_H5S_ALL, octave_H5S_ALL,
702 octave_H5P_DEFAULT, re) >= 0)
703 {
704 retval = true;
705 m_matrix = m;
706 }
707
708 H5Sclose (space_id);
709 H5Dclose (data_hid);
710
711#else
712 octave_unused_parameter (loc_id);
713 octave_unused_parameter (name);
714
715 warn_load ("hdf5");
716#endif
717
718 return retval;
719}
720
721void
723 bool pr_as_read_syntax) const
724{
725 octave_print_internal (os, m_matrix, pr_as_read_syntax,
727}
728
729mxArray *
730octave_float_matrix::as_mxArray (bool interleaved) const
731{
732 mxArray *retval = new mxArray (interleaved, mxSINGLE_CLASS, dims (), mxREAL);
733
734 mxSingle *pd = static_cast<mxSingle *> (retval->get_data ());
735
736 mwSize nel = numel ();
737
738 const float *pdata = m_matrix.data ();
739
740 for (mwIndex i = 0; i < nel; i++)
741 pd[i] = pdata[i];
742
743 return retval;
744}
745
746// This uses a smarter strategy for doing the complex->real mappers. We
747// allocate an array for a real result and keep filling it until a complex
748// result is produced.
749static octave_value
750do_rc_map (const FloatNDArray& a, FloatComplex (&fcn) (float))
751{
752 octave_idx_type n = a.numel ();
753 FloatNDArray rr (a.dims ());
754
755 for (octave_idx_type i = 0; i < n; i++)
756 {
757 octave_quit ();
758
759 FloatComplex tmp = fcn (a(i));
760 if (tmp.imag () == 0.0)
761 rr.xelem (i) = tmp.real ();
762 else
763 {
764 FloatComplexNDArray rc (a.dims ());
765
766 for (octave_idx_type j = 0; j < i; j++)
767 rc.xelem (j) = rr.xelem (j);
768
769 rc.xelem (i) = tmp;
770
771 for (octave_idx_type j = i+1; j < n; j++)
772 {
773 octave_quit ();
774
775 rc.xelem (j) = fcn (a(j));
776 }
777
778 return new octave_float_complex_matrix (rc);
779 }
780 }
781
782 return rr;
783}
784
787{
788 switch (umap)
789 {
790 case umap_imag:
791 return FloatNDArray (m_matrix.dims (), 0.0);
792
793 case umap_real:
794 case umap_conj:
795 return m_matrix;
796
797 // Mappers handled specially.
798#define ARRAY_METHOD_MAPPER(UMAP, FCN) \
799 case umap_ ## UMAP: \
800 return octave_value (m_matrix.FCN ())
801
806
807#define ARRAY_MAPPER(UMAP, TYPE, FCN) \
808 case umap_ ## UMAP: \
809 return octave_value (m_matrix.map<TYPE> (FCN))
810
811#define RC_ARRAY_MAPPER(UMAP, TYPE, FCN) \
812 case umap_ ## UMAP: \
813 return do_rc_map (m_matrix, FCN)
814
815 RC_ARRAY_MAPPER (acos, FloatComplex, octave::math::rc_acos);
816 RC_ARRAY_MAPPER (acosh, FloatComplex, octave::math::rc_acosh);
817 ARRAY_MAPPER (angle, float, std::arg);
818 ARRAY_MAPPER (arg, float, std::arg);
819 RC_ARRAY_MAPPER (asin, FloatComplex, octave::math::rc_asin);
820 ARRAY_MAPPER (asinh, float, octave::math::asinh);
821 ARRAY_MAPPER (atan, float, ::atanf);
822 RC_ARRAY_MAPPER (atanh, FloatComplex, octave::math::rc_atanh);
823 ARRAY_MAPPER (erf, float, octave::math::erf);
824 ARRAY_MAPPER (erfinv, float, octave::math::erfinv);
825 ARRAY_MAPPER (erfcinv, float, octave::math::erfcinv);
826 ARRAY_MAPPER (erfc, float, octave::math::erfc);
827 ARRAY_MAPPER (erfcx, float, octave::math::erfcx);
828 ARRAY_MAPPER (erfi, float, octave::math::erfi);
829 ARRAY_MAPPER (dawson, float, octave::math::dawson);
830 ARRAY_MAPPER (gamma, float, octave::math::gamma);
831 RC_ARRAY_MAPPER (lgamma, FloatComplex, octave::math::rc_lgamma);
832 ARRAY_MAPPER (cbrt, float, octave::math::cbrt);
833 ARRAY_MAPPER (ceil, float, ::ceilf);
834 ARRAY_MAPPER (cos, float, ::cosf);
835 ARRAY_MAPPER (cosh, float, ::coshf);
836 ARRAY_MAPPER (exp, float, ::expf);
837 ARRAY_MAPPER (expm1, float, octave::math::expm1);
838 ARRAY_MAPPER (fix, float, octave::math::fix);
839 ARRAY_MAPPER (floor, float, ::floorf);
840 RC_ARRAY_MAPPER (log, FloatComplex, octave::math::rc_log);
841 RC_ARRAY_MAPPER (log2, FloatComplex, octave::math::rc_log2);
842 RC_ARRAY_MAPPER (log10, FloatComplex, octave::math::rc_log10);
843 RC_ARRAY_MAPPER (log1p, FloatComplex, octave::math::rc_log1p);
844 ARRAY_MAPPER (round, float, octave::math::round);
845 ARRAY_MAPPER (roundb, float, octave::math::roundb);
846 ARRAY_MAPPER (signum, float, octave::math::signum);
847 ARRAY_MAPPER (sin, float, ::sinf);
848 ARRAY_MAPPER (sinh, float, ::sinhf);
849 RC_ARRAY_MAPPER (sqrt, FloatComplex, octave::math::rc_sqrt);
850 ARRAY_MAPPER (tan, float, ::tanf);
851 ARRAY_MAPPER (tanh, float, ::tanhf);
852 ARRAY_MAPPER (isna, bool, octave::math::isna);
853 ARRAY_MAPPER (xsignbit, float, octave::math::signbit);
854
855 // Special cases for Matlab compatibility.
856 case umap_xtolower:
857 case umap_xtoupper:
858 return m_matrix;
859
860 case umap_xisalnum:
861 case umap_xisalpha:
862 case umap_xisascii:
863 case umap_xiscntrl:
864 case umap_xisdigit:
865 case umap_xisgraph:
866 case umap_xislower:
867 case umap_xisprint:
868 case umap_xispunct:
869 case umap_xisspace:
870 case umap_xisupper:
871 case umap_xisxdigit:
872 {
873 octave_value str_conv = convert_to_str (true, true);
874 return str_conv.map (umap);
875 }
876
877 default:
878 return octave_base_value::map (umap);
879 }
880}
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-base.h:529
T & elem(octave_idx_type n)
Size of the specified dimension.
Definition Array-base.h:585
int ndims() const
Size of the specified dimension.
Definition Array-base.h:701
octave_idx_type rows() const
Definition Array-base.h:485
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
octave_idx_type columns() const
Definition Array-base.h:497
const T * data() const
Size of the specified dimension.
Definition Array-base.h:687
T * rwdata()
Size of the specified dimension.
octave_idx_type numel() const
Number of elements in the array.
Definition Array-base.h:440
FloatMatrix diag(octave_idx_type k=0) const
Definition fMatrix.cc:2454
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:92
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
Definition dim-vector.h:341
void resize(int n, int fill_value=0)
Definition dim-vector.h:278
octave_idx_type ndims() const
Number of dimensions.
Definition dim-vector.h:263
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:1526
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)
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:884
save_type
Definition data-conv.h:85
@ LS_FLOAT
Definition data-conv.h:92
void warning(const char *fmt,...)
Definition error.cc:1083
void error(const char *fmt,...)
Definition error.cc:1008
void err_invalid_conversion(const std::string &from, const std::string &to)
Definition errwarn.cc:71
void warn_logical_conversion()
Definition errwarn.cc:366
void warn_implicit_conversion(const char *id, const char *from, const char *to)
Definition errwarn.cc:345
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
Complex log2(const Complex &x)
Definition mappers.cc:140
Complex asin(const Complex &x)
Definition mappers.cc:106
bool isna(double x)
Definition mappers.cc:46
Complex acos(const Complex &x)
Definition mappers.cc:84
float lo_ieee_float_nan_value()
Definition lo-ieee.cc:116
int save_hdf5_empty(octave_hdf5_id loc_id, const char *name, const dim_vector &d)
Definition ls-hdf5.cc:1255
int load_hdf5_empty(octave_hdf5_id loc_id, const char *name, dim_vector &d)
Definition ls-hdf5.cc:1312
octave_hdf5_id save_type_to_hdf5(save_type st)
Definition ls-hdf5.cc:1356
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
std::complex< T > ceil(const std::complex< T > &x)
Definition mappers.h:115
Complex atan(const Complex &x)
Definition mappers.h:83
double roundb(double x)
Definition mappers.h:159
std::complex< T > floor(const std::complex< T > &x)
Definition mappers.h:142
bool isfinite(double x)
Definition mappers.h:229
bool isinf(double x)
Definition mappers.h:212
double signum(double x)
Definition mappers.h:255
double round(double x)
Definition mappers.h:148
bool isnan(bool)
Definition mappers.h:192
double fix(double x)
Definition mappers.h:130
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
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)
double asinh(double x)
Definition oct-specfun.h:57
double atanh(double x)
Definition oct-specfun.h:62
double acosh(double x)
Definition oct-specfun.h:39
double lgamma(double x)
#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)
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
intNDArray< octave_uint16 > uint16NDArray
intNDArray< octave_uint32 > uint32NDArray
intNDArray< octave_uint64 > uint64NDArray
intNDArray< octave_uint8 > uint8NDArray
F77_RET_T len
Definition xerbla.cc:61