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