GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
ov-flt-re-mat.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1996-2024 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-base-mat.h"
67 #include "ov-base-mat.cc"
68 #include "ov-scalar.h"
69 #include "ov-float.h"
70 #include "ov-flt-complex.h"
71 #include "ov-re-mat.h"
72 #include "ov-flt-re-mat.h"
73 #include "ov-flt-cx-mat.h"
74 #include "ov-re-sparse.h"
75 #include "ov-flt-re-diag.h"
76 #include "ov-flt-cx-diag.h"
77 #include "pr-output.h"
78 #include "variables.h"
79 #include "ops.h"
80 
81 #include "byte-swap.h"
82 #include "ls-oct-text.h"
83 #include "ls-utils.h"
84 #include "ls-hdf5.h"
85 
86 
88 
90  "single");
91 
94 {
95  octave_base_value *retval = nullptr;
96 
97  if (m_matrix.numel () == 1)
98  retval = new octave_float_scalar (m_matrix (0));
99 
100  return retval;
101 }
102 
103 double
105 {
106  if (isempty ())
107  err_invalid_conversion ("real matrix", "real scalar");
108 
109  warn_implicit_conversion ("Octave:array-to-scalar",
110  "real matrix", "real scalar");
111 
112  return m_matrix(0, 0);
113 }
114 
115 float
117 {
118  if (isempty ())
119  err_invalid_conversion ("real matrix", "real scalar");
120 
121  warn_implicit_conversion ("Octave:array-to-scalar",
122  "real matrix", "real scalar");
123 
124  return m_matrix(0, 0);
125 }
126 
127 // FIXME
128 
129 Matrix
131 {
132  return Matrix (FloatMatrix (m_matrix));
133 }
134 
137 {
138  return FloatMatrix (m_matrix);
139 }
140 
141 Complex
143 {
144  if (rows () == 0 || columns () == 0)
145  err_invalid_conversion ("real matrix", "complex scalar");
146 
147  warn_implicit_conversion ("Octave:array-to-scalar",
148  "real matrix", "complex scalar");
149 
150  return Complex (m_matrix(0, 0), 0);
151 }
152 
155 {
156  double tmp = lo_ieee_float_nan_value ();
157 
158  FloatComplex retval (tmp, tmp);
159 
160  if (rows () == 0 || columns () == 0)
161  err_invalid_conversion ("real matrix", "complex scalar");
162 
163  warn_implicit_conversion ("Octave:array-to-scalar",
164  "real matrix", "complex scalar");
165 
166  retval = m_matrix(0, 0);
167 
168  return retval;
169 }
170 
171 // FIXME
172 
175 {
177 }
178 
181 {
183 }
184 
187 {
188  return ComplexNDArray (m_matrix);
189 }
190 
193 {
194  return FloatComplexNDArray (m_matrix);
195 }
196 
197 NDArray
199 {
200  return NDArray (m_matrix);
201 }
202 
205 {
208  if (warn && m_matrix.any_element_not_one_or_zero ())
210 
211  return boolNDArray (m_matrix);
212 }
213 
216 {
217  charNDArray retval (dims ());
218 
219  octave_idx_type nel = numel ();
220 
221  for (octave_idx_type i = 0; i < nel; i++)
222  retval.elem (i) = static_cast<char> (m_matrix.elem (i));
223 
224  return retval;
225 }
226 
229 {
230  return SparseMatrix (matrix_value ());
231 }
232 
235 {
236  // FIXME: Need a SparseComplexMatrix (Matrix) constructor to make
237  // this function more efficient. Then this should become
238  // return SparseComplexMatrix (matrix.matrix_value ());
240 }
241 
244 {
245  return NDArray (m_matrix);
246 }
247 
250 {
251  return FloatNDArray (m_matrix);
252 }
253 
256 {
257  return int8NDArray (m_matrix);
258 }
259 
262 {
263  return int16NDArray (m_matrix);
264 }
265 
268 {
269  return int32NDArray (m_matrix);
270 }
271 
274 {
275  return int64NDArray (m_matrix);
276 }
277 
280 {
281  return uint8NDArray (m_matrix);
282 }
283 
286 {
287  return uint16NDArray (m_matrix);
288 }
289 
292 {
293  return uint32NDArray (m_matrix);
294 }
295 
298 {
299  return uint64NDArray (m_matrix);
300 }
301 
304 {
305  octave_value retval;
306  if (k == 0 && m_matrix.ndims () == 2
307  && (m_matrix.rows () == 1 || m_matrix.columns () == 1))
309  else
311 
312  return retval;
313 }
314 
317 {
318  if (m_matrix.ndims () != 2
319  || (m_matrix.rows () != 1 && m_matrix.columns () != 1))
320  error ("diag: expecting vector argument");
321 
322  FloatMatrix mat (m_matrix);
323 
324  return mat.diag (m, n);
325 }
326 
328 octave_float_matrix::convert_to_str_internal (bool, bool, char type) const
329 {
330  octave_value retval;
331  dim_vector dv = dims ();
332  octave_idx_type nel = dv.numel ();
333 
334  charNDArray chm (dv);
335 
336  bool warned = false;
337 
338  for (octave_idx_type i = 0; i < nel; i++)
339  {
340  octave_quit ();
341 
342  float d = m_matrix(i);
343 
344  if (octave::math::isnan (d))
346 
347  int ival = octave::math::nint (d);
348 
349  if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
350  {
351  // FIXME: is there something better we could do?
352 
353  ival = 0;
354 
355  if (! warned)
356  {
357  ::warning ("range error for conversion to character value");
358  warned = true;
359  }
360  }
361 
362  chm(i) = static_cast<char> (ival);
363  }
364 
365  retval = octave_value (chm, type);
366 
367  return retval;
368 }
369 
370 bool
372 {
373  dim_vector dv = dims ();
374 
375  if (dv.ndims () > 2)
376  {
378 
379  os << "# ndims: " << dv.ndims () << "\n";
380 
381  for (int i=0; i < dv.ndims (); i++)
382  os << ' ' << dv(i);
383 
384  os << "\n" << tmp;
385  }
386  else
387  {
388  // Keep this case, rather than use generic code above for backward
389  // compatibility. Makes load_ascii much more complex!!
390  os << "# rows: " << rows () << "\n"
391  << "# columns: " << columns () << "\n";
392 
393  os << float_matrix_value ();
394  }
395 
396  return true;
397 }
398 
399 bool
401 {
402  string_vector keywords(2);
403 
404  keywords[0] = "ndims";
405  keywords[1] = "rows";
406 
407  std::string kw;
408  octave_idx_type val = 0;
409 
410  if (! extract_keyword (is, keywords, kw, val, true))
411  error ("load: failed to extract number of rows and columns");
412 
413  // Set "C" locale for the duration of this function to avoid the performance
414  // panelty of frequently switching the locale when reading floating point
415  // values from the stream.
416  char *prev_locale = std::setlocale (LC_ALL, nullptr);
417  std::string old_locale (prev_locale ? prev_locale : "");
418  std::setlocale (LC_ALL, "C");
419  octave::unwind_action act
420  ([&old_locale] () { std::setlocale (LC_ALL, old_locale.c_str ()); });
421 
422  if (kw == "ndims")
423  {
424  int mdims = static_cast<int> (val);
425 
426  if (mdims < 0)
427  error ("load: failed to extract number of dimensions");
428 
429  dim_vector dv;
430  dv.resize (mdims);
431 
432  for (int i = 0; i < mdims; i++)
433  is >> dv(i);
434 
435  if (! is)
436  error ("load: failed to read dimensions");
437 
438  FloatNDArray tmp(dv);
439 
440  is >> tmp;
441 
442  if (! is)
443  error ("load: failed to load matrix constant");
444 
445  m_matrix = tmp;
446  }
447  else if (kw == "rows")
448  {
449  octave_idx_type nr = val;
450  octave_idx_type nc = 0;
451 
452  if (nr < 0 || ! extract_keyword (is, "columns", nc) || nc < 0)
453  error ("load: failed to extract number of rows and columns");
454 
455  if (nr > 0 && nc > 0)
456  {
457  FloatMatrix tmp (nr, nc);
458  is >> tmp;
459  if (! is)
460  error ("load: failed to load matrix constant");
461 
462  m_matrix = tmp;
463  }
464  else if (nr == 0 || nc == 0)
465  m_matrix = FloatMatrix (nr, nc);
466  else
467  panic_impossible ();
468  }
469  else
470  panic_impossible ();
471 
472  return true;
473 }
474 
475 bool
476 octave_float_matrix::save_binary (std::ostream& os, bool)
477 {
478  dim_vector dv = dims ();
479  if (dv.ndims () < 1)
480  return false;
481 
482  // Use negative value for ndims to differentiate with old format!!
483  int32_t tmp = - dv.ndims ();
484  os.write (reinterpret_cast<char *> (&tmp), 4);
485  for (int i = 0; i < dv.ndims (); i++)
486  {
487  tmp = dv(i);
488  os.write (reinterpret_cast<char *> (&tmp), 4);
489  }
490 
492  save_type st = LS_FLOAT;
493  if (dv.numel () > 8192) // FIXME: make this configurable.
494  {
495  float max_val, min_val;
496  if (m.all_integers (max_val, min_val))
497  st = octave::get_save_type (max_val, min_val);
498  }
499 
500  const float *mtmp = m.data ();
501  write_floats (os, mtmp, st, dv.numel ());
502 
503  return true;
504 }
505 
506 bool
507 octave_float_matrix::load_binary (std::istream& is, bool swap,
509 {
510  char tmp;
511  int32_t mdims;
512  if (! is.read (reinterpret_cast<char *> (&mdims), 4))
513  return false;
514  if (swap)
515  swap_bytes<4> (&mdims);
516  if (mdims < 0)
517  {
518  mdims = - mdims;
519  int32_t di;
520  dim_vector dv;
521  dv.resize (mdims);
522 
523  for (int i = 0; i < mdims; i++)
524  {
525  if (! is.read (reinterpret_cast<char *> (&di), 4))
526  return false;
527  if (swap)
528  swap_bytes<4> (&di);
529  dv(i) = di;
530  }
531 
532  // Convert an array with a single dimension to be a row vector.
533  // Octave should never write files like this, other software
534  // might.
535 
536  if (mdims == 1)
537  {
538  mdims = 2;
539  dv.resize (mdims);
540  dv(1) = dv(0);
541  dv(0) = 1;
542  }
543 
544  if (! is.read (reinterpret_cast<char *> (&tmp), 1))
545  return false;
546 
547  FloatNDArray m(dv);
548  float *re = m.fortran_vec ();
549  read_floats (is, re, static_cast<save_type> (tmp), dv.numel (),
550  swap, fmt);
551 
552  if (! is)
553  return false;
554 
555  m_matrix = m;
556  }
557  else
558  {
559  int32_t nr, nc;
560  nr = mdims;
561  if (! is.read (reinterpret_cast<char *> (&nc), 4))
562  return false;
563  if (swap)
564  swap_bytes<4> (&nc);
565  if (! is.read (reinterpret_cast<char *> (&tmp), 1))
566  return false;
567  FloatMatrix m (nr, nc);
568  float *re = m.fortran_vec ();
569  octave_idx_type len = static_cast<octave_idx_type> (nr) * nc;
570  read_floats (is, re, static_cast<save_type> (tmp), len, swap, fmt);
571 
572  if (! is)
573  return false;
574 
575  m_matrix = m;
576  }
577  return true;
578 }
579 
580 bool
581 octave_float_matrix::save_hdf5 (octave_hdf5_id loc_id, const char *name, bool)
582 {
583  bool retval = false;
584 
585 #if defined (HAVE_HDF5)
586 
587  dim_vector dv = dims ();
588  int empty = save_hdf5_empty (loc_id, name, dv);
589  if (empty)
590  return (empty > 0);
591 
592  int rank = dv.ndims ();
593  hid_t space_hid, data_hid;
594  space_hid = data_hid = -1;
596 
597  OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
598 
599  // Octave uses column-major, while HDF5 uses row-major ordering
600  for (int i = 0; i < rank; i++)
601  hdims[i] = dv(rank-i-1);
602 
603  space_hid = H5Screate_simple (rank, hdims, nullptr);
604 
605  if (space_hid < 0) return false;
606 
607  hid_t save_type_hid = H5T_NATIVE_FLOAT;
608 
609 #if defined (HAVE_HDF5_INT2FLOAT_CONVERSIONS)
610  // hdf5 currently doesn't support float/integer conversions
611  else
612  {
613  float max_val, min_val;
614 
615  if (m.all_integers (max_val, min_val))
616  save_type_hid
617  = save_type_to_hdf5 (octave::get_save_type (max_val, min_val));
618  }
619 #endif
620 #if defined (HAVE_HDF5_18)
621  data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
624 #else
625  data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
627 #endif
628  if (data_hid < 0)
629  {
630  H5Sclose (space_hid);
631  return false;
632  }
633 
634  const float *mtmp = m.data ();
635  retval = H5Dwrite (data_hid, H5T_NATIVE_FLOAT, octave_H5S_ALL, octave_H5S_ALL,
636  octave_H5P_DEFAULT, mtmp) >= 0;
637 
638  H5Dclose (data_hid);
639  H5Sclose (space_hid);
640 
641 #else
642  octave_unused_parameter (loc_id);
643  octave_unused_parameter (name);
644 
645  warn_save ("hdf5");
646 #endif
647 
648  return retval;
649 }
650 
651 bool
653 {
654  bool retval = false;
655 
656 #if defined (HAVE_HDF5)
657 
658  dim_vector dv;
659  int empty = load_hdf5_empty (loc_id, name, dv);
660  if (empty > 0)
661  m_matrix.resize (dv);
662  if (empty)
663  return (empty > 0);
664 
665 #if defined (HAVE_HDF5_18)
666  hid_t data_hid = H5Dopen (loc_id, name, octave_H5P_DEFAULT);
667 #else
668  hid_t data_hid = H5Dopen (loc_id, name);
669 #endif
670  hid_t space_id = H5Dget_space (data_hid);
671 
672  hsize_t rank = H5Sget_simple_extent_ndims (space_id);
673 
674  if (rank < 1)
675  {
676  H5Sclose (space_id);
677  H5Dclose (data_hid);
678  return false;
679  }
680 
681  OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
682  OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank);
683 
684  H5Sget_simple_extent_dims (space_id, hdims, maxdims);
685 
686  // Octave uses column-major, while HDF5 uses row-major ordering
687  if (rank == 1)
688  {
689  dv.resize (2);
690  dv(0) = 1;
691  dv(1) = hdims[0];
692  }
693  else
694  {
695  dv.resize (rank);
696  for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
697  dv(j) = hdims[i];
698  }
699 
700  FloatNDArray m (dv);
701  float *re = m.fortran_vec ();
702  if (H5Dread (data_hid, H5T_NATIVE_FLOAT, octave_H5S_ALL, octave_H5S_ALL,
703  octave_H5P_DEFAULT, re) >= 0)
704  {
705  retval = true;
706  m_matrix = m;
707  }
708 
709  H5Sclose (space_id);
710  H5Dclose (data_hid);
711 
712 #else
713  octave_unused_parameter (loc_id);
714  octave_unused_parameter (name);
715 
716  warn_load ("hdf5");
717 #endif
718 
719  return retval;
720 }
721 
722 void
724  bool pr_as_read_syntax) const
725 {
726  octave_print_internal (os, m_matrix, pr_as_read_syntax,
728 }
729 
730 mxArray *
731 octave_float_matrix::as_mxArray (bool interleaved) const
732 {
733  mxArray *retval = new mxArray (interleaved, mxSINGLE_CLASS, dims (), mxREAL);
734 
735  mxSingle *pd = static_cast<mxSingle *> (retval->get_data ());
736 
737  mwSize nel = numel ();
738 
739  const float *pdata = m_matrix.data ();
740 
741  for (mwIndex i = 0; i < nel; i++)
742  pd[i] = pdata[i];
743 
744  return retval;
745 }
746 
747 // This uses a smarter strategy for doing the complex->real mappers. We
748 // allocate an array for a real result and keep filling it until a complex
749 // result is produced.
750 static octave_value
751 do_rc_map (const FloatNDArray& a, FloatComplex (&fcn) (float))
752 {
753  octave_idx_type n = a.numel ();
754  FloatNDArray rr (a.dims ());
755 
756  for (octave_idx_type i = 0; i < n; i++)
757  {
758  octave_quit ();
759 
760  FloatComplex tmp = fcn (a(i));
761  if (tmp.imag () == 0.0)
762  rr.xelem (i) = tmp.real ();
763  else
764  {
765  FloatComplexNDArray rc (a.dims ());
766 
767  for (octave_idx_type j = 0; j < i; j++)
768  rc.xelem (j) = rr.xelem (j);
769 
770  rc.xelem (i) = tmp;
771 
772  for (octave_idx_type j = i+1; j < n; j++)
773  {
774  octave_quit ();
775 
776  rc.xelem (j) = fcn (a(j));
777  }
778 
779  return new octave_float_complex_matrix (rc);
780  }
781  }
782 
783  return rr;
784 }
785 
788 {
789  switch (umap)
790  {
791  case umap_imag:
792  return FloatNDArray (m_matrix.dims (), 0.0);
793 
794  case umap_real:
795  case umap_conj:
796  return m_matrix;
797 
798  // Mappers handled specially.
799 #define ARRAY_METHOD_MAPPER(UMAP, FCN) \
800  case umap_ ## UMAP: \
801  return octave_value (m_matrix.FCN ())
802 
807 
808 #define ARRAY_MAPPER(UMAP, TYPE, FCN) \
809  case umap_ ## UMAP: \
810  return octave_value (m_matrix.map<TYPE> (FCN))
811 
812 #define RC_ARRAY_MAPPER(UMAP, TYPE, FCN) \
813  case umap_ ## UMAP: \
814  return do_rc_map (m_matrix, FCN)
815 
818  ARRAY_MAPPER (angle, float, std::arg);
819  ARRAY_MAPPER (arg, float, std::arg);
822  ARRAY_MAPPER (atan, float, ::atanf);
834  ARRAY_MAPPER (ceil, float, ::ceilf);
835  ARRAY_MAPPER (cos, float, ::cosf);
836  ARRAY_MAPPER (cosh, float, ::coshf);
837  ARRAY_MAPPER (exp, float, ::expf);
840  ARRAY_MAPPER (floor, float, ::floorf);
848  ARRAY_MAPPER (sin, float, ::sinf);
849  ARRAY_MAPPER (sinh, float, ::sinhf);
851  ARRAY_MAPPER (tan, float, ::tanf);
852  ARRAY_MAPPER (tanh, float, ::tanhf);
854  ARRAY_MAPPER (xsignbit, float, octave::math::signbit);
855 
856  // Special cases for Matlab compatibility.
857  case umap_xtolower:
858  case umap_xtoupper:
859  return m_matrix;
860 
861  case umap_xisalnum:
862  case umap_xisalpha:
863  case umap_xisascii:
864  case umap_xiscntrl:
865  case umap_xisdigit:
866  case umap_xisgraph:
867  case umap_xislower:
868  case umap_xisprint:
869  case umap_xispunct:
870  case umap_xisspace:
871  case umap_xisupper:
872  case umap_xisxdigit:
873  {
874  octave_value str_conv = convert_to_str (true, true);
875  return str_conv.map (umap);
876  }
877 
878  default:
879  return octave_base_value::map (umap);
880  }
881 }
void swap_bytes< 4 >(void *ptr)
Definition: byte-swap.h:63
charNDArray max(char d, const charNDArray &m)
Definition: chNDArray.cc:230
T & elem(octave_idx_type n)
Size of the specified dimension.
Definition: Array.h:562
int ndims() const
Size of the specified dimension.
Definition: Array.h:671
octave_idx_type rows() const
Definition: Array.h:459
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
Definition: Array-base.cc:1023
const T * data() const
Size of the specified dimension.
Definition: Array.h:663
octave_idx_type columns() const
Definition: Array.h:471
const dim_vector & dims() const
Return a const-reference so that dims ()(i) works efficiently.
Definition: Array.h:503
octave_idx_type numel() const
Number of elements in the array.
Definition: Array.h:414
FloatMatrix diag(octave_idx_type k=0) const
Definition: fMatrix.cc:2417
bool any_element_not_one_or_zero() const
Definition: fNDArray.cc:287
bool any_element_is_nan() const
Definition: fNDArray.cc:275
Definition: dMatrix.h:42
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:94
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
Definition: dim-vector.h:335
void resize(int n, int fill_value=0)
Definition: dim-vector.h:272
octave_idx_type ndims() const
Number of dimensions.
Definition: dim-vector.h:257
void * get_data() const
Definition: mxarray.h:473
octave_value diag(octave_idx_type k=0) const
Definition: ov-base-mat.h:142
octave_idx_type numel() const
Definition: ov-base-mat.h:122
octave_idx_type rows() const
Definition: ov-base.h:374
octave_idx_type columns() const
Definition: ov-base.h:381
int current_print_indent_level() const
Definition: ov-base.h:920
virtual octave_value map(unary_mapper_t) const
Definition: ov-base.cc:1181
virtual octave_value convert_to_str(bool pad=false, bool force=false, char type='\'') const
Definition: ov-base.cc:434
void warn_load(const char *type) const
Definition: ov-base.cc:1157
bool isempty() const
Definition: ov-base.h:417
friend class octave_value
Definition: ov-base.h:269
void warn_save(const char *type) const
Definition: ov-base.cc:1166
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:1513
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:942
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:836
save_type
Definition: data-conv.h:87
@ LS_FLOAT
Definition: data-conv.h:94
void warning(const char *fmt,...)
Definition: error.cc:1063
void() error(const char *fmt,...)
Definition: error.cc:988
#define panic_impossible()
Definition: error.h:503
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
Definition: int16NDArray.h:36
intNDArray< octave_int32 > int32NDArray
Definition: int32NDArray.h:36
intNDArray< octave_int64 > int64NDArray
Definition: int64NDArray.h:36
intNDArray< octave_int8 > int8NDArray
Definition: int8NDArray.h:36
void err_nan_to_logical_conversion()
void err_nan_to_character_conversion()
float lo_ieee_float_nan_value()
Definition: lo-ieee.cc:116
Complex log2(const Complex &x)
Definition: lo-mappers.cc:141
Complex rc_acosh(double x)
Definition: lo-mappers.cc:253
Complex rc_atanh(double x)
Definition: lo-mappers.cc:278
Complex rc_log(double x)
Definition: lo-mappers.cc:291
Complex asin(const Complex &x)
Definition: lo-mappers.cc:107
int nint(double x)
Definition: lo-mappers.cc:216
Complex rc_asin(double x)
Definition: lo-mappers.cc:265
bool isna(double x)
Definition: lo-mappers.cc:47
Complex rc_acos(double x)
Definition: lo-mappers.cc:240
Complex rc_sqrt(double x)
Definition: lo-mappers.cc:334
Complex rc_log10(double x)
Definition: lo-mappers.cc:319
Complex acos(const Complex &x)
Definition: lo-mappers.cc:85
Complex rc_log2(double x)
Definition: lo-mappers.cc:304
Complex atan(const Complex &x)
Definition: lo-mappers.h:71
double roundb(double x)
Definition: lo-mappers.h:147
bool isfinite(double x)
Definition: lo-mappers.h:192
bool isinf(double x)
Definition: lo-mappers.h:203
double signbit(double x)
Definition: lo-mappers.h:54
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
std::complex< T > floor(const std::complex< T > &x)
Definition: lo-mappers.h:130
std::complex< T > ceil(const std::complex< T > &x)
Definition: lo-mappers.h:103
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)
Definition: lo-specfun.cc:1823
double dawson(double x)
Definition: lo-specfun.cc:1467
double erfcinv(double x)
Definition: lo-specfun.cc:1697
Complex rc_log1p(double x)
Definition: lo-specfun.cc:2215
Complex rc_lgamma(double x)
Definition: lo-specfun.cc:2177
Complex expm1(const Complex &x)
Definition: lo-specfun.cc:1835
Complex log1p(const Complex &x)
Definition: lo-specfun.cc:1919
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:1249
int load_hdf5_empty(octave_hdf5_id loc_id, const char *name, dim_vector &d)
Definition: ls-hdf5.cc:1306
octave_hdf5_id save_type_to_hdf5(save_type st)
Definition: ls-hdf5.cc:1350
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
Definition: ls-oct-text.cc:84
save_type get_save_type(double, double)
Definition: ls-utils.cc:40
float_format
Definition: mach-info.h:38
void mxArray
Definition: mex.h:58
T octave_idx_type m
Definition: mx-inlines.cc:781
octave_idx_type n
Definition: mx-inlines.cc:761
float mxSingle
Definition: mxtypes.h:92
@ mxSINGLE_CLASS
Definition: mxtypes.h:65
int64_t mwIndex
Definition: mxtypes.h:125
@ mxREAL
Definition: mxtypes.h:80
int64_t mwSize
Definition: mxtypes.h:124
std::complex< double > erfc(std::complex< double > z, double relerr=0)
std::complex< double > erfcx(std::complex< double > z, double relerr=0)
std::complex< double > erfi(std::complex< double > z, double relerr=0)
std::complex< double > erf(std::complex< double > z, double relerr=0)
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:235
#define RC_ARRAY_MAPPER(UMAP, TYPE, FCN)
#define ARRAY_MAPPER(UMAP, TYPE, FCN)
#define ARRAY_METHOD_MAPPER(UMAP, FCN)
void octave_print_internal(std::ostream &os, const float_display_format &fmt, bool d, bool pr_as_read_syntax)
Definition: pr-output.cc:1761
template int8_t abs(int8_t)
intNDArray< octave_uint16 > uint16NDArray
Definition: uint16NDArray.h:36
intNDArray< octave_uint32 > uint32NDArray
Definition: uint32NDArray.h:36
intNDArray< octave_uint64 > uint64NDArray
Definition: uint64NDArray.h:36
intNDArray< octave_uint8 > uint8NDArray
Definition: uint8NDArray.h:36
F77_RET_T len
Definition: xerbla.cc:61