GNU Octave  8.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
ov-cx-mat.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1996-2023 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 <ostream>
33 #include <vector>
34 
35 #include "dNDArray.h"
36 #include "fNDArray.h"
37 
38 #include "data-conv.h"
39 #include "lo-ieee.h"
40 #include "lo-specfun.h"
41 #include "lo-mappers.h"
42 #include "mx-base.h"
43 #include "mach-info.h"
44 #include "oct-locbuf.h"
45 
46 #include "errwarn.h"
47 #include "mxarray.h"
48 #include "ovl.h"
49 #include "oct-hdf5.h"
50 #include "oct-stream.h"
51 #include "ops.h"
52 #include "ov-base.h"
53 #include "ov-base-mat.h"
54 #include "ov-base-mat.cc"
55 #include "ov-complex.h"
56 #include "ov-cx-mat.h"
57 #include "ov-flt-cx-mat.h"
58 #include "ov-re-mat.h"
59 #include "ov-scalar.h"
60 #include "pr-output.h"
61 
62 #include "byte-swap.h"
63 #include "ls-oct-text.h"
64 #include "ls-hdf5.h"
65 #include "ls-utils.h"
66 
67 
69 
71  "complex matrix", "double");
72 
73 static octave_base_value *
75 {
76  const octave_complex_matrix& v = dynamic_cast<const octave_complex_matrix&> (a);
77 
79 }
80 
83 {
87 }
88 
91 {
92  octave_base_value *retval = nullptr;
93 
94  if (m_matrix.numel () == 1)
95  {
96  Complex c = m_matrix (0);
97 
98  if (c.imag () == 0.0)
99  retval = new octave_scalar (c.real ());
100  else
101  retval = new octave_complex (c);
102  }
103  else if (m_matrix.all_elements_are_real ())
104  retval = new octave_matrix (::real (m_matrix));
105 
106  return retval;
107 }
108 
109 double
110 octave_complex_matrix::double_value (bool force_conversion) const
111 {
112  if (! force_conversion)
113  warn_implicit_conversion ("Octave:imag-to-real",
114  "complex matrix", "real scalar");
115 
116  if (rows () == 0 || columns () == 0)
117  err_invalid_conversion ("complex matrix", "real scalar");
118 
119  warn_implicit_conversion ("Octave:array-to-scalar",
120  "complex matrix", "real scalar");
121 
122  return std::real (m_matrix(0, 0));
123 }
124 
125 float
126 octave_complex_matrix::float_value (bool force_conversion) const
127 {
128  if (! force_conversion)
129  warn_implicit_conversion ("Octave:imag-to-real",
130  "complex matrix", "real scalar");
131 
132  if (rows () == 0 || columns () == 0)
133  err_invalid_conversion ("complex matrix", "real scalar");
134 
135  warn_implicit_conversion ("Octave:array-to-scalar",
136  "complex matrix", "real scalar");
137 
138  return std::real (m_matrix(0, 0));
139 }
140 
141 NDArray
142 octave_complex_matrix::array_value (bool force_conversion) const
143 {
144  NDArray retval;
145 
146  if (! force_conversion)
147  warn_implicit_conversion ("Octave:imag-to-real",
148  "complex matrix", "real matrix");
149 
150  retval = ::real (m_matrix);
151 
152  return retval;
153 }
154 
155 Matrix
156 octave_complex_matrix::matrix_value (bool force_conversion) const
157 {
158  Matrix retval;
159 
160  if (! force_conversion)
161  warn_implicit_conversion ("Octave:imag-to-real",
162  "complex matrix", "real matrix");
163 
164  retval = ::real (ComplexMatrix (m_matrix));
165 
166  return retval;
167 }
168 
170 octave_complex_matrix::float_matrix_value (bool force_conversion) const
171 {
172  FloatMatrix retval;
173 
174  if (! force_conversion)
175  warn_implicit_conversion ("Octave:imag-to-real",
176  "complex matrix", "real matrix");
177 
178  retval = ::real (ComplexMatrix (m_matrix));
179 
180  return retval;
181 }
182 
183 Complex
185 {
186  if (rows () == 0 || columns () == 0)
187  err_invalid_conversion ("complex matrix", "complex scalar");
188 
189  warn_implicit_conversion ("Octave:array-to-scalar",
190  "complex matrix", "complex scalar");
191 
192  return m_matrix(0, 0);
193 }
194 
197 {
198  float tmp = lo_ieee_float_nan_value ();
199 
200  FloatComplex retval (tmp, tmp);
201 
202  if (rows () == 0 || columns () == 0)
203  err_invalid_conversion ("complex matrix", "complex scalar");
204 
205  warn_implicit_conversion ("Octave:array-to-scalar",
206  "complex matrix", "complex scalar");
207 
208  retval = m_matrix(0, 0);
209 
210  return retval;
211 }
212 
215 {
216  return ComplexMatrix (m_matrix);
217 }
218 
221 {
223 }
224 
227 {
230  if (warn && (! m_matrix.all_elements_are_real ()
231  || real (m_matrix).any_element_not_one_or_zero ()))
233 
234  return mx_el_ne (m_matrix, Complex (0.0));
235 }
236 
239 {
240  charNDArray retval;
241 
242  if (! frc_str_conv)
243  warn_implicit_conversion ("Octave:num-to-str",
244  "complex matrix", "string");
245  else
246  {
247  retval = charNDArray (dims ());
248  octave_idx_type nel = numel ();
249 
250  for (octave_idx_type i = 0; i < nel; i++)
251  retval.elem (i) = static_cast<char> (std::real (m_matrix.elem (i)));
252  }
253 
254  return retval;
255 }
256 
259 {
260  return FloatComplexNDArray (m_matrix);
261 }
262 
264 octave_complex_matrix::sparse_matrix_value (bool force_conversion) const
265 {
266  SparseMatrix retval;
267 
268  if (! force_conversion)
269  warn_implicit_conversion ("Octave:imag-to-real",
270  "complex matrix", "real matrix");
271 
272  retval = SparseMatrix (::real (ComplexMatrix (m_matrix)));
273 
274  return retval;
275 }
276 
279 {
281 }
282 
285 {
286  return m_matrix;
287 }
288 
291 {
292  return FloatComplexNDArray (m_matrix);
293 }
294 
297 {
298  octave_value retval;
299  if (k == 0 && m_matrix.ndims () == 2
300  && (m_matrix.rows () == 1 || m_matrix.columns () == 1))
302  else
304 
305  return retval;
306 }
307 
310 {
311  if (m_matrix.ndims () != 2
312  || (m_matrix.rows () != 1 && m_matrix.columns () != 1))
313  error ("diag: expecting vector argument");
314 
315  ComplexMatrix mat (m_matrix);
316 
317  return mat.diag (m, n);
318 }
319 
320 bool
322 {
323  dim_vector dv = dims ();
324  if (dv.ndims () > 2)
325  {
327 
328  os << "# ndims: " << dv.ndims () << "\n";
329 
330  for (int i = 0; i < dv.ndims (); i++)
331  os << ' ' << dv(i);
332 
333  os << "\n" << tmp;
334  }
335  else
336  {
337  // Keep this case, rather than use generic code above for backward
338  // compatibility. Makes load_ascii much more complex!!
339  os << "# rows: " << rows () << "\n"
340  << "# columns: " << columns () << "\n";
341 
342  os << complex_matrix_value ();
343  }
344 
345  return true;
346 }
347 
348 bool
350 {
351  string_vector keywords(2);
352 
353  keywords[0] = "ndims";
354  keywords[1] = "rows";
355 
356  std::string kw;
357  octave_idx_type val = 0;
358 
359  if (! extract_keyword (is, keywords, kw, val, true))
360  error ("load: failed to extract number of rows and columns");
361 
362  // Set "C" locale for the duration of this function to avoid the performance
363  // panelty of frequently switching the locale when reading floating point
364  // values from the stream.
365  char *prev_locale = std::setlocale (LC_ALL, nullptr);
366  std::string old_locale (prev_locale ? prev_locale : "");
367  std::setlocale (LC_ALL, "C");
368  octave::unwind_action act
369  ([&old_locale] () { std::setlocale (LC_ALL, old_locale.c_str ()); });
370 
371  if (kw == "ndims")
372  {
373  int mdims = static_cast<int> (val);
374 
375  if (mdims < 0)
376  error ("load: failed to extract number of dimensions");
377 
378  dim_vector dv;
379  dv.resize (mdims);
380 
381  for (int i = 0; i < mdims; i++)
382  is >> dv(i);
383 
384  if (! is)
385  error ("load: failed to read dimensions");
386 
387  ComplexNDArray tmp(dv);
388 
389  is >> tmp;
390 
391  if (! is)
392  error ("load: failed to load matrix constant");
393 
394  m_matrix = tmp;
395  }
396  else if (kw == "rows")
397  {
398  octave_idx_type nr = val;
399  octave_idx_type nc = 0;
400 
401  if (nr < 0 || ! extract_keyword (is, "columns", nc) || nc < 0)
402  error ("load: failed to extract number of rows and columns");
403 
404  if (nr > 0 && nc > 0)
405  {
406  ComplexMatrix tmp (nr, nc);
407  is >> tmp;
408  if (! is)
409  error ("load: failed to load matrix constant");
410 
411  m_matrix = tmp;
412  }
413  else if (nr == 0 || nc == 0)
414  m_matrix = ComplexMatrix (nr, nc);
415  else
416  panic_impossible ();
417  }
418  else
419  panic_impossible ();
420 
421  return true;
422 }
423 
424 bool
425 octave_complex_matrix::save_binary (std::ostream& os, bool save_as_floats)
426 {
427  dim_vector dv = dims ();
428  if (dv.ndims () < 1)
429  return false;
430 
431  // Use negative value for ndims to differentiate with old format!!
432  int32_t tmp = - dv.ndims ();
433  os.write (reinterpret_cast<char *> (&tmp), 4);
434  for (int i = 0; i < dv.ndims (); i++)
435  {
436  tmp = dv(i);
437  os.write (reinterpret_cast<char *> (&tmp), 4);
438  }
439 
441  save_type st = LS_DOUBLE;
442  if (save_as_floats)
443  {
444  if (m.too_large_for_float ())
445  {
446  warning ("save: some values too large to save as floats --");
447  warning ("save: saving as doubles instead");
448  }
449  else
450  st = LS_FLOAT;
451  }
452  else if (dv.numel () > 4096) // FIXME: make this configurable.
453  {
454  double max_val, min_val;
455  if (m.all_integers (max_val, min_val))
456  st = octave::get_save_type (max_val, min_val);
457  }
458 
459  const Complex *mtmp = m.data ();
460  write_doubles (os, reinterpret_cast<const double *> (mtmp), st,
461  2 * dv.numel ());
462 
463  return true;
464 }
465 
466 bool
467 octave_complex_matrix::load_binary (std::istream& is, bool swap,
469 {
470  char tmp;
471  int32_t mdims;
472  if (! is.read (reinterpret_cast<char *> (&mdims), 4))
473  return false;
474  if (swap)
475  swap_bytes<4> (&mdims);
476  if (mdims < 0)
477  {
478  mdims = - mdims;
479  int32_t di;
480  dim_vector dv;
481  dv.resize (mdims);
482 
483  for (int i = 0; i < mdims; i++)
484  {
485  if (! is.read (reinterpret_cast<char *> (&di), 4))
486  return false;
487  if (swap)
488  swap_bytes<4> (&di);
489  dv(i) = di;
490  }
491 
492  // Convert an array with a single dimension to be a row vector.
493  // Octave should never write files like this, other software
494  // might.
495 
496  if (mdims == 1)
497  {
498  mdims = 2;
499  dv.resize (mdims);
500  dv(1) = dv(0);
501  dv(0) = 1;
502  }
503 
504  if (! is.read (reinterpret_cast<char *> (&tmp), 1))
505  return false;
506 
507  ComplexNDArray m(dv);
508  Complex *im = m.fortran_vec ();
509  read_doubles (is, reinterpret_cast<double *> (im),
510  static_cast<save_type> (tmp), 2 * dv.numel (), swap, fmt);
511 
512  if (! is)
513  return false;
514 
515  m_matrix = m;
516  }
517  else
518  {
519  int32_t nr, nc;
520  nr = mdims;
521  if (! is.read (reinterpret_cast<char *> (&nc), 4))
522  return false;
523  if (swap)
524  swap_bytes<4> (&nc);
525  if (! is.read (reinterpret_cast<char *> (&tmp), 1))
526  return false;
527  ComplexMatrix m (nr, nc);
528  Complex *im = m.fortran_vec ();
529  octave_idx_type len = static_cast<octave_idx_type> (nr) * nc;
530  read_doubles (is, reinterpret_cast<double *> (im),
531  static_cast<save_type> (tmp), 2*len, swap, fmt);
532 
533  if (! is)
534  return false;
535 
536  m_matrix = m;
537  }
538  return true;
539 }
540 
541 bool
543  bool save_as_floats)
544 {
545 #if defined (HAVE_HDF5)
546 
547  dim_vector dv = dims ();
548  int empty = save_hdf5_empty (loc_id, name, dv);
549  if (empty)
550  return (empty > 0);
551 
552  int rank = dv.ndims ();
553  hid_t space_hid, data_hid, type_hid;
554  space_hid = data_hid = type_hid = -1;
555  bool retval = true;
557 
558  OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
559 
560  // Octave uses column-major, while HDF5 uses row-major ordering
561  for (int i = 0; i < rank; i++)
562  hdims[i] = dv(rank-i-1);
563 
564  space_hid = H5Screate_simple (rank, hdims, nullptr);
565  if (space_hid < 0) return false;
566 
567  hid_t save_type_hid = H5T_NATIVE_DOUBLE;
568 
569  if (save_as_floats)
570  {
571  if (m.too_large_for_float ())
572  {
573  warning ("save: some values too large to save as floats --");
574  warning ("save: saving as doubles instead");
575  }
576  else
577  save_type_hid = H5T_NATIVE_FLOAT;
578  }
579 #if defined (HAVE_HDF5_INT2FLOAT_CONVERSIONS)
580  // hdf5 currently doesn't support float/integer conversions
581  else
582  {
583  double max_val, min_val;
584 
585  if (m.all_integers (max_val, min_val))
586  save_type_hid
587  = save_type_to_hdf5 (octave::get_save_type (max_val, min_val));
588  }
589 #endif
590 
591  type_hid = hdf5_make_complex_type (save_type_hid);
592  if (type_hid < 0)
593  {
594  H5Sclose (space_hid);
595  return false;
596  }
597 #if defined (HAVE_HDF5_18)
598  data_hid = H5Dcreate (loc_id, name, type_hid, space_hid,
601 #else
602  data_hid = H5Dcreate (loc_id, name, type_hid, space_hid, octave_H5P_DEFAULT);
603 #endif
604  if (data_hid < 0)
605  {
606  H5Sclose (space_hid);
607  H5Tclose (type_hid);
608  return false;
609  }
610 
611  hid_t complex_type_hid = hdf5_make_complex_type (H5T_NATIVE_DOUBLE);
612  if (complex_type_hid < 0) retval = false;
613 
614  if (retval)
615  {
616  Complex *mtmp = m.fortran_vec ();
617  if (H5Dwrite (data_hid, complex_type_hid, octave_H5S_ALL, octave_H5S_ALL,
618  octave_H5P_DEFAULT, mtmp)
619  < 0)
620  {
621  H5Tclose (complex_type_hid);
622  retval = false;
623  }
624  }
625 
626  H5Tclose (complex_type_hid);
627  H5Dclose (data_hid);
628  H5Tclose (type_hid);
629  H5Sclose (space_hid);
630 
631  return retval;
632 
633 #else
634  octave_unused_parameter (loc_id);
635  octave_unused_parameter (name);
636  octave_unused_parameter (save_as_floats);
637 
638  warn_save ("hdf5");
639 
640  return false;
641 #endif
642 }
643 
644 bool
646 {
647  bool retval = false;
648 
649 #if defined (HAVE_HDF5)
650 
651  dim_vector dv;
652  int empty = load_hdf5_empty (loc_id, name, dv);
653  if (empty > 0)
654  m_matrix.resize (dv);
655  if (empty)
656  return (empty > 0);
657 
658 #if defined (HAVE_HDF5_18)
659  hid_t data_hid = H5Dopen (loc_id, name, octave_H5P_DEFAULT);
660 #else
661  hid_t data_hid = H5Dopen (loc_id, name);
662 #endif
663  hid_t type_hid = H5Dget_type (data_hid);
664 
665  hid_t complex_type = hdf5_make_complex_type (H5T_NATIVE_DOUBLE);
666 
667  if (! hdf5_types_compatible (type_hid, complex_type))
668  {
669  H5Tclose (complex_type);
670  H5Dclose (data_hid);
671  return false;
672  }
673 
674  hid_t space_id = H5Dget_space (data_hid);
675 
676  hsize_t rank = H5Sget_simple_extent_ndims (space_id);
677 
678  if (rank < 1)
679  {
680  H5Tclose (complex_type);
681  H5Sclose (space_id);
682  H5Dclose (data_hid);
683  return false;
684  }
685 
686  OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
687  OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank);
688 
689  H5Sget_simple_extent_dims (space_id, hdims, maxdims);
690 
691  // Octave uses column-major, while HDF5 uses row-major ordering
692  if (rank == 1)
693  {
694  dv.resize (2);
695  dv(0) = 1;
696  dv(1) = hdims[0];
697  }
698  else
699  {
700  dv.resize (rank);
701  for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
702  dv(j) = hdims[i];
703  }
704 
705  ComplexNDArray m (dv);
706  Complex *reim = m.fortran_vec ();
707  if (H5Dread (data_hid, complex_type, octave_H5S_ALL, octave_H5S_ALL,
708  octave_H5P_DEFAULT, reim)
709  >= 0)
710  {
711  retval = true;
712  m_matrix = m;
713  }
714 
715  H5Tclose (complex_type);
716  H5Sclose (space_id);
717  H5Dclose (data_hid);
718 
719 #else
720  octave_unused_parameter (loc_id);
721  octave_unused_parameter (name);
722 
723  warn_load ("hdf5");
724 #endif
725 
726  return retval;
727 }
728 
729 void
731  bool pr_as_read_syntax) const
732 {
733  octave_print_internal (os, m_matrix, pr_as_read_syntax,
735 }
736 
737 mxArray *
738 octave_complex_matrix::as_mxArray (bool interleaved) const
739 {
740  mxArray *retval = new mxArray (interleaved, mxDOUBLE_CLASS, dims (),
741  mxCOMPLEX);
742 
743  mwSize nel = numel ();
744 
745  const Complex *pdata = m_matrix.data ();
746 
747  if (interleaved)
748  {
749  mxComplexDouble *pd
750  = static_cast<mxComplexDouble *> (retval->get_data ());
751 
752  for (mwIndex i = 0; i < nel; i++)
753  {
754  pd[i].real = pdata[i].real ();
755  pd[i].imag = pdata[i].imag ();
756  }
757  }
758  else
759  {
760  mxDouble *pr = static_cast<mxDouble *> (retval->get_data ());
761  mxDouble *pi = static_cast<mxDouble *> (retval->get_imag_data ());
762 
763  for (mwIndex i = 0; i < nel; i++)
764  {
765  pr[i] = pdata[i].real ();
766  pi[i] = pdata[i].imag ();
767  }
768  }
769 
770  return retval;
771 }
772 
775 {
776  switch (umap)
777  {
778  // Mappers handled specially.
779  case umap_real:
781  case umap_imag:
783  case umap_conj:
785 
786  // Special cases for Matlab compatibility.
787  case umap_xtolower:
788  case umap_xtoupper:
789  return m_matrix;
790 
791 #define ARRAY_METHOD_MAPPER(UMAP, FCN) \
792  case umap_ ## UMAP: \
793  return octave_value (m_matrix.FCN ())
794 
799 
800 #define ARRAY_MAPPER(UMAP, TYPE, FCN) \
801  case umap_ ## UMAP: \
802  return octave_value (m_matrix.map<TYPE> (FCN))
803 
806  ARRAY_MAPPER (angle, double, std::arg);
807  ARRAY_MAPPER (arg, double, std::arg);
818  ARRAY_MAPPER (cos, Complex, std::cos);
819  ARRAY_MAPPER (cosh, Complex, std::cosh);
820  ARRAY_MAPPER (exp, Complex, std::exp);
824  ARRAY_MAPPER (log, Complex, std::log);
826  ARRAY_MAPPER (log10, Complex, std::log10);
831  ARRAY_MAPPER (sin, Complex, std::sin);
832  ARRAY_MAPPER (sinh, Complex, std::sinh);
833  ARRAY_MAPPER (sqrt, Complex, std::sqrt);
834  ARRAY_MAPPER (tan, Complex, std::tan);
835  ARRAY_MAPPER (tanh, Complex, std::tanh);
837 
838  default:
839  return octave_base_value::map (umap);
840  }
841 }
ComplexColumnVector conj(const ComplexColumnVector &a)
Definition: CColVector.cc:217
boolMatrix mx_el_ne(const boolMatrix &m1, const boolMatrix &m2)
Definition: boolMatrix.cc:91
void swap_bytes< 4 >(void *ptr)
Definition: byte-swap.h:63
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type columns(void) const
Definition: Array.h:471
OCTARRAY_OVERRIDABLE_FUNC_API const T * data(void) const
Size of the specified dimension.
Definition: Array.h:663
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:414
OCTARRAY_API void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
Definition: Array-base.cc:1032
OCTARRAY_OVERRIDABLE_FUNC_API octave_idx_type rows(void) const
Definition: Array.h:459
OCTARRAY_OVERRIDABLE_FUNC_API int ndims(void) const
Size of the specified dimension.
Definition: Array.h:677
OCTARRAY_OVERRIDABLE_FUNC_API T & elem(octave_idx_type n)
Size of the specified dimension.
Definition: Array.h:562
OCTAVE_API ComplexMatrix diag(octave_idx_type k=0) const
Definition: CMatrix.cc:2830
OCTAVE_API bool any_element_is_nan(void) const
Definition: CNDArray.cc:265
OCTAVE_API bool all_elements_are_real(void) const
Definition: CNDArray.cc:279
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(void) const
Number of dimensions.
Definition: dim-vector.h:257
void * get_imag_data(void) const
Definition: mxarray.h:562
void * get_data(void) const
Definition: mxarray.h:497
octave_idx_type numel(void) const
Definition: ov-base-mat.h:119
octave_value diag(octave_idx_type k=0) const
Definition: ov-base-mat.h:139
octave_idx_type columns(void) const
Definition: ov-base.h:363
int current_print_indent_level(void) const
Definition: ov-base.h:903
virtual octave_value map(unary_mapper_t) const
Definition: ov-base.cc:1181
OCTINTERP_API void warn_load(const char *type) const
Definition: ov-base.cc:1157
octave_idx_type rows(void) const
Definition: ov-base.h:356
OCTINTERP_API void warn_save(const char *type) const
Definition: ov-base.cc:1166
NDArray array_value(bool=false) const
Definition: ov-cx-mat.cc:142
SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
Definition: ov-cx-mat.cc:278
float float_value(bool=false) const
Definition: ov-cx-mat.cc:126
octave_value as_double(void) const
Definition: ov-cx-mat.cc:284
charNDArray char_array_value(bool frc_str_conv=false) const
Definition: ov-cx-mat.cc:238
octave_value as_single(void) const
Definition: ov-cx-mat.cc:290
type_conv_info numeric_demotion_function(void) const
Definition: ov-cx-mat.cc:82
octave_value map(unary_mapper_t umap) const
Definition: ov-cx-mat.cc:774
boolNDArray bool_array_value(bool warn=false) const
Definition: ov-cx-mat.cc:226
octave_base_value * try_narrowing_conversion(void)
Definition: ov-cx-mat.cc:90
Complex complex_value(bool=false) const
Definition: ov-cx-mat.cc:184
FloatComplexMatrix float_complex_matrix_value(bool=false) const
Definition: ov-cx-mat.cc:220
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
Definition: ov-cx-mat.cc:467
ComplexNDArray complex_array_value(bool=false) const
Definition: ov-cx-mat.h:129
FloatComplexNDArray float_complex_array_value(bool=false) const
Definition: ov-cx-mat.cc:258
Matrix matrix_value(bool=false) const
Definition: ov-cx-mat.cc:156
SparseMatrix sparse_matrix_value(bool=false) const
Definition: ov-cx-mat.cc:264
ComplexMatrix complex_matrix_value(bool=false) const
Definition: ov-cx-mat.cc:214
double double_value(bool=false) const
Definition: ov-cx-mat.cc:110
FloatComplex float_complex_value(bool=false) const
Definition: ov-cx-mat.cc:196
mxArray * as_mxArray(bool interleaved) const
Definition: ov-cx-mat.cc:738
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
Definition: ov-cx-mat.cc:645
octave_value diag(octave_idx_type k=0) const
Definition: ov-cx-mat.cc:296
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
Definition: ov-cx-mat.cc:730
bool load_ascii(std::istream &is)
Definition: ov-cx-mat.cc:349
bool save_binary(std::ostream &os, bool save_as_floats)
Definition: ov-cx-mat.cc:425
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
Definition: ov-cx-mat.cc:542
bool save_ascii(std::ostream &os)
Definition: ov-cx-mat.cc:321
FloatMatrix float_matrix_value(bool=false) const
Definition: ov-cx-mat.cc:170
static int static_type_id(void)
const octave_hdf5_id octave_H5P_DEFAULT
const octave_hdf5_id octave_H5S_ALL
ColumnVector real(const ComplexColumnVector &a)
Definition: dColVector.cc:137
ColumnVector imag(const ComplexColumnVector &a)
Definition: dColVector.cc:143
void read_doubles(std::istream &is, double *data, save_type type, octave_idx_type len, bool swap, octave::mach_info::float_format fmt)
Definition: data-conv.cc:776
void write_doubles(std::ostream &os, const double *data, save_type type, octave_idx_type len)
Definition: data-conv.cc:892
save_type
Definition: data-conv.h:87
@ LS_DOUBLE
Definition: data-conv.h:95
@ LS_FLOAT
Definition: data-conv.h:94
void warning(const char *fmt,...)
Definition: error.cc:1054
void error(const char *fmt,...)
Definition: error.cc:979
#define panic_impossible()
Definition: error.h:508
void err_invalid_conversion(const std::string &from, const std::string &to)
Definition: errwarn.cc:71
void warn_logical_conversion(void)
Definition: errwarn.cc:365
void warn_implicit_conversion(const char *id, const char *from, const char *to)
Definition: errwarn.cc:344
void err_nan_to_logical_conversion(void)
float lo_ieee_float_nan_value(void)
Definition: lo-ieee.cc:116
Complex log2(const Complex &x)
Definition: lo-mappers.cc:139
Complex asin(const Complex &x)
Definition: lo-mappers.cc:107
bool isna(double x)
Definition: lo-mappers.cc:47
Complex acos(const Complex &x)
Definition: lo-mappers.cc:85
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 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
double dawson(double x)
Definition: lo-specfun.cc:1466
static const double pi
Definition: lo-specfun.cc:1944
Complex expm1(const Complex &x)
Definition: lo-specfun.cc:1823
Complex log1p(const Complex &x)
Definition: lo-specfun.cc:1907
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
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
octave_hdf5_id hdf5_make_complex_type(octave_hdf5_id num_type)
Definition: ls-hdf5.cc:405
bool hdf5_types_compatible(octave_hdf5_id t1, octave_hdf5_id t2)
Definition: ls-hdf5.cc:269
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
class OCTAVE_API ComplexDiagMatrix
Definition: mx-fwd.h:60
class OCTAVE_API ComplexMatrix
Definition: mx-fwd.h:32
class OCTAVE_API charNDArray
Definition: mx-fwd.h:43
class OCTAVE_API SparseMatrix
Definition: mx-fwd.h:55
class OCTAVE_API FloatComplexMatrix
Definition: mx-fwd.h:34
class OCTAVE_API SparseComplexMatrix
Definition: mx-fwd.h:56
class OCTAVE_API FloatComplexNDArray
Definition: mx-fwd.h:41
T octave_idx_type m
Definition: mx-inlines.cc:773
octave_idx_type n
Definition: mx-inlines.cc:753
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:229
#define ARRAY_MAPPER(UMAP, TYPE, FCN)
#define ARRAY_METHOD_MAPPER(UMAP, FCN)
static octave_base_value * default_numeric_demotion_function(const octave_base_value &a)
Definition: ov-cx-mat.cc:74
void octave_print_internal(std::ostream &os, const float_display_format &fmt, bool d, bool pr_as_read_syntax)
Definition: pr-output.cc:1762
static T abs(T x)
Definition: pr-output.cc:1678
F77_RET_T len
Definition: xerbla.cc:61