GNU Octave 10.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-2025 The Octave Project Developers
4//
5// See the file COPYRIGHT.md in the top-level directory of this
6// distribution or <https://octave.org/copyright/>.
7//
8// This file is part of Octave.
9//
10// Octave is free software: you can redistribute it and/or modify it
11// under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// Octave is distributed in the hope that it will be useful, but
16// WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with Octave; see the file COPYING. If not, see
22// <https://www.gnu.org/licenses/>.
23//
24////////////////////////////////////////////////////////////////////////
25
26#if defined (HAVE_CONFIG_H)
27# include "config.h"
28#endif
29
30#include <clocale>
31#include <istream>
32#include <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-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 retval.elem (i) = static_cast<char> (std::real (m_matrix.elem (i)));
248 }
249
250 return retval;
251}
252
258
261{
262 SparseMatrix retval;
263
264 if (! force_conversion)
265 warn_implicit_conversion ("Octave:imag-to-real",
266 "complex matrix", "real matrix");
267
269
270 return retval;
271}
272
278
281{
282 return m_matrix;
283}
284
290
293{
294 octave_value retval;
295 if (k == 0 && m_matrix.ndims () == 2
296 && (m_matrix.rows () == 1 || m_matrix.columns () == 1))
298 else
300
301 return retval;
302}
303
306{
307 if (m_matrix.ndims () != 2
308 || (m_matrix.rows () != 1 && m_matrix.columns () != 1))
309 error ("diag: expecting vector argument");
310
312
313 return mat.diag (m, n);
314}
315
316bool
318{
319 const dim_vector& dv = dims ();
320 if (dv.ndims () > 2)
321 {
323
324 os << "# ndims: " << dv.ndims () << "\n";
325
326 for (int i = 0; i < dv.ndims (); i++)
327 os << ' ' << dv(i);
328
329 os << "\n" << tmp;
330 }
331 else
332 {
333 // Keep this case, rather than use generic code above for backward
334 // compatibility. Makes load_ascii much more complex!!
335 os << "# rows: " << rows () << "\n"
336 << "# columns: " << columns () << "\n";
337
338 os << complex_matrix_value ();
339 }
340
341 return true;
342}
343
344bool
346{
347 string_vector keywords(2);
348
349 keywords[0] = "ndims";
350 keywords[1] = "rows";
351
352 std::string kw;
353 octave_idx_type val = 0;
354
355 if (! extract_keyword (is, keywords, kw, val, true))
356 error ("load: failed to extract number of rows and columns");
357
358 // Set "C" locale for the duration of this function to avoid the performance
359 // panelty of frequently switching the locale when reading floating point
360 // values from the stream.
361 char *prev_locale = std::setlocale (LC_ALL, nullptr);
362 std::string old_locale (prev_locale ? prev_locale : "");
363 std::setlocale (LC_ALL, "C");
364 octave::unwind_action act
365 ([&old_locale] () { std::setlocale (LC_ALL, old_locale.c_str ()); });
366
367 if (kw == "ndims")
368 {
369 int mdims = static_cast<int> (val);
370
371 if (mdims < 0)
372 error ("load: failed to extract number of dimensions");
373
374 dim_vector dv;
375 dv.resize (mdims);
376
377 for (int i = 0; i < mdims; i++)
378 is >> dv(i);
379
380 if (! is)
381 error ("load: failed to read dimensions");
382
383 ComplexNDArray tmp(dv);
384
385 is >> tmp;
386
387 if (! is)
388 error ("load: failed to load matrix constant");
389
390 m_matrix = tmp;
391 }
392 else if (kw == "rows")
393 {
394 octave_idx_type nr = val;
395 octave_idx_type nc = 0;
396
397 if (nr < 0 || ! extract_keyword (is, "columns", nc) || nc < 0)
398 error ("load: failed to extract number of rows and columns");
399
400 if (nr > 0 && nc > 0)
401 {
402 ComplexMatrix tmp (nr, nc);
403 is >> tmp;
404 if (! is)
405 error ("load: failed to load matrix constant");
406
407 m_matrix = tmp;
408 }
409 else if (nr == 0 || nc == 0)
410 m_matrix = ComplexMatrix (nr, nc);
411 else
412 error ("unexpected dimensions in octave_complex_matrix::load_ascii - please report this bug");
413 }
414 else
415 error ("unexpected dimensions keyword (= '%s') octave_complex_matrix::load_ascii - please report this bug", kw.c_str ());
416
417 return true;
418}
419
420bool
421octave_complex_matrix::save_binary (std::ostream& os, bool save_as_floats)
422{
423 const dim_vector& dv = dims ();
424 if (dv.ndims () < 1)
425 return false;
426
427 // Use negative value for ndims to differentiate with old format!!
428 int32_t tmp = - dv.ndims ();
429 os.write (reinterpret_cast<char *> (&tmp), 4);
430 for (int i = 0; i < dv.ndims (); i++)
431 {
432 tmp = dv(i);
433 os.write (reinterpret_cast<char *> (&tmp), 4);
434 }
435
437 save_type st = LS_DOUBLE;
438 if (save_as_floats)
439 {
440 if (m.too_large_for_float ())
441 {
442 warning ("save: some values too large to save as floats --");
443 warning ("save: saving as doubles instead");
444 }
445 else
446 st = LS_FLOAT;
447 }
448 else if (dv.numel () > 4096) // FIXME: make this configurable.
449 {
450 double max_val, min_val;
451 if (m.all_integers (max_val, min_val))
452 st = octave::get_save_type (max_val, min_val);
453 }
454
455 const Complex *mtmp = m.data ();
456 write_doubles (os, reinterpret_cast<const double *> (mtmp), st,
457 2 * dv.numel ());
458
459 return true;
460}
461
462bool
463octave_complex_matrix::load_binary (std::istream& is, bool swap,
464 octave::mach_info::float_format fmt)
465{
466 char tmp;
467 int32_t mdims;
468 if (! is.read (reinterpret_cast<char *> (&mdims), 4))
469 return false;
470 if (swap)
471 swap_bytes<4> (&mdims);
472 if (mdims < 0)
473 {
474 mdims = - mdims;
475 int32_t di;
476 dim_vector dv;
477 dv.resize (mdims);
478
479 for (int i = 0; i < mdims; i++)
480 {
481 if (! is.read (reinterpret_cast<char *> (&di), 4))
482 return false;
483 if (swap)
484 swap_bytes<4> (&di);
485 dv(i) = di;
486 }
487
488 // Convert an array with a single dimension to be a row vector.
489 // Octave should never write files like this, other software
490 // might.
491
492 if (mdims == 1)
493 {
494 mdims = 2;
495 dv.resize (mdims);
496 dv(1) = dv(0);
497 dv(0) = 1;
498 }
499
500 if (! is.read (reinterpret_cast<char *> (&tmp), 1))
501 return false;
502
503 ComplexNDArray m(dv);
504 Complex *im = m.rwdata ();
505 read_doubles (is, reinterpret_cast<double *> (im),
506 static_cast<save_type> (tmp), 2 * dv.numel (), swap, fmt);
507
508 if (! is)
509 return false;
510
511 m_matrix = m;
512 }
513 else
514 {
515 int32_t nr, nc;
516 nr = mdims;
517 if (! is.read (reinterpret_cast<char *> (&nc), 4))
518 return false;
519 if (swap)
520 swap_bytes<4> (&nc);
521 if (! is.read (reinterpret_cast<char *> (&tmp), 1))
522 return false;
523 ComplexMatrix m (nr, nc);
524 Complex *im = m.rwdata ();
525 octave_idx_type len = static_cast<octave_idx_type> (nr) * nc;
526 read_doubles (is, reinterpret_cast<double *> (im),
527 static_cast<save_type> (tmp), 2*len, swap, fmt);
528
529 if (! is)
530 return false;
531
532 m_matrix = m;
533 }
534 return true;
535}
536
537bool
539 bool save_as_floats)
540{
541#if defined (HAVE_HDF5)
542
543 const dim_vector& dv = dims ();
544 int empty = save_hdf5_empty (loc_id, name, dv);
545 if (empty)
546 return (empty > 0);
547
548 int rank = dv.ndims ();
549 hid_t space_hid, data_hid, type_hid;
550 space_hid = data_hid = type_hid = -1;
551 bool retval = true;
553
554 OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
555
556 // Octave uses column-major, while HDF5 uses row-major ordering
557 for (int i = 0; i < rank; i++)
558 hdims[i] = dv(rank-i-1);
559
560 space_hid = H5Screate_simple (rank, hdims, nullptr);
561 if (space_hid < 0) return false;
562
563 hid_t save_type_hid = H5T_NATIVE_DOUBLE;
564
565 if (save_as_floats)
566 {
567 if (m.too_large_for_float ())
568 {
569 warning ("save: some values too large to save as floats --");
570 warning ("save: saving as doubles instead");
571 }
572 else
573 save_type_hid = H5T_NATIVE_FLOAT;
574 }
575#if defined (HAVE_HDF5_INT2FLOAT_CONVERSIONS)
576 // hdf5 currently doesn't support float/integer conversions
577 else
578 {
579 double max_val, min_val;
580
581 if (m.all_integers (max_val, min_val))
582 save_type_hid
583 = save_type_to_hdf5 (octave::get_save_type (max_val, min_val));
584 }
585#endif
586
587 type_hid = hdf5_make_complex_type (save_type_hid);
588 if (type_hid < 0)
589 {
590 H5Sclose (space_hid);
591 return false;
592 }
593#if defined (HAVE_HDF5_18)
594 data_hid = H5Dcreate (loc_id, name, type_hid, space_hid,
597#else
598 data_hid = H5Dcreate (loc_id, name, type_hid, space_hid, octave_H5P_DEFAULT);
599#endif
600 if (data_hid < 0)
601 {
602 H5Sclose (space_hid);
603 H5Tclose (type_hid);
604 return false;
605 }
606
607 hid_t complex_type_hid = hdf5_make_complex_type (H5T_NATIVE_DOUBLE);
608 if (complex_type_hid < 0) retval = false;
609
610 if (retval)
611 {
612 const Complex *mtmp = m.data ();
613 if (H5Dwrite (data_hid, complex_type_hid, octave_H5S_ALL, octave_H5S_ALL,
614 octave_H5P_DEFAULT, mtmp)
615 < 0)
616 {
617 H5Tclose (complex_type_hid);
618 retval = false;
619 }
620 }
621
622 H5Tclose (complex_type_hid);
623 H5Dclose (data_hid);
624 H5Tclose (type_hid);
625 H5Sclose (space_hid);
626
627 return retval;
628
629#else
630 octave_unused_parameter (loc_id);
631 octave_unused_parameter (name);
632 octave_unused_parameter (save_as_floats);
633
634 warn_save ("hdf5");
635
636 return false;
637#endif
638}
639
640bool
642{
643 bool retval = false;
644
645#if defined (HAVE_HDF5)
646
647 dim_vector dv;
648 int empty = load_hdf5_empty (loc_id, name, dv);
649 if (empty > 0)
650 m_matrix.resize (dv);
651 if (empty)
652 return (empty > 0);
653
654#if defined (HAVE_HDF5_18)
655 hid_t data_hid = H5Dopen (loc_id, name, octave_H5P_DEFAULT);
656#else
657 hid_t data_hid = H5Dopen (loc_id, name);
658#endif
659 hid_t type_hid = H5Dget_type (data_hid);
660
661 hid_t complex_type = hdf5_make_complex_type (H5T_NATIVE_DOUBLE);
662
663 if (! hdf5_types_compatible (type_hid, complex_type))
664 {
665 H5Tclose (complex_type);
666 H5Dclose (data_hid);
667 return false;
668 }
669
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 H5Tclose (complex_type);
677 H5Sclose (space_id);
678 H5Dclose (data_hid);
679 return false;
680 }
681
682 OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
683 OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank);
684
685 H5Sget_simple_extent_dims (space_id, hdims, maxdims);
686
687 // Octave uses column-major, while HDF5 uses row-major ordering
688 if (rank == 1)
689 {
690 dv.resize (2);
691 dv(0) = 1;
692 dv(1) = hdims[0];
693 }
694 else
695 {
696 dv.resize (rank);
697 for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
698 dv(j) = hdims[i];
699 }
700
701 ComplexNDArray m (dv);
702 Complex *reim = m.rwdata ();
703 if (H5Dread (data_hid, complex_type, octave_H5S_ALL, octave_H5S_ALL,
704 octave_H5P_DEFAULT, reim)
705 >= 0)
706 {
707 retval = true;
708 m_matrix = m;
709 }
710
711 H5Tclose (complex_type);
712 H5Sclose (space_id);
713 H5Dclose (data_hid);
714
715#else
716 octave_unused_parameter (loc_id);
717 octave_unused_parameter (name);
718
719 warn_load ("hdf5");
720#endif
721
722 return retval;
723}
724
725void
727 bool pr_as_read_syntax) const
728{
729 octave_print_internal (os, m_matrix, pr_as_read_syntax,
731}
732
733mxArray *
734octave_complex_matrix::as_mxArray (bool interleaved) const
735{
736 mxArray *retval = new mxArray (interleaved, mxDOUBLE_CLASS, dims (),
737 mxCOMPLEX);
738
739 mwSize nel = numel ();
740
741 const Complex *pdata = m_matrix.data ();
742
743 if (interleaved)
744 {
745 mxComplexDouble *pd
746 = static_cast<mxComplexDouble *> (retval->get_data ());
747
748 for (mwIndex i = 0; i < nel; i++)
749 {
750 pd[i].real = pdata[i].real ();
751 pd[i].imag = pdata[i].imag ();
752 }
753 }
754 else
755 {
756 mxDouble *pr = static_cast<mxDouble *> (retval->get_data ());
757 mxDouble *pi = static_cast<mxDouble *> (retval->get_imag_data ());
758
759 for (mwIndex i = 0; i < nel; i++)
760 {
761 pr[i] = pdata[i].real ();
762 pi[i] = pdata[i].imag ();
763 }
764 }
765
766 return retval;
767}
768
771{
772 switch (umap)
773 {
774 // Mappers handled specially.
775 case umap_real:
776 return ::real (m_matrix);
777 case umap_imag:
778 return ::imag (m_matrix);
779 case umap_conj:
780 return ::conj (m_matrix);
781
782 // Special cases for Matlab compatibility.
783 case umap_xtolower:
784 case umap_xtoupper:
785 return m_matrix;
786
787#define ARRAY_METHOD_MAPPER(UMAP, FCN) \
788 case umap_ ## UMAP: \
789 return octave_value (m_matrix.FCN ())
790
795
796#define ARRAY_MAPPER(UMAP, TYPE, FCN) \
797 case umap_ ## UMAP: \
798 return octave_value (m_matrix.map<TYPE> (FCN))
799
800 ARRAY_MAPPER (acos, Complex, octave::math::acos);
801 ARRAY_MAPPER (acosh, Complex, octave::math::acosh);
802 ARRAY_MAPPER (angle, double, std::arg);
803 ARRAY_MAPPER (arg, double, std::arg);
804 ARRAY_MAPPER (asin, Complex, octave::math::asin);
805 ARRAY_MAPPER (asinh, Complex, octave::math::asinh);
806 ARRAY_MAPPER (atan, Complex, octave::math::atan);
807 ARRAY_MAPPER (atanh, Complex, octave::math::atanh);
808 ARRAY_MAPPER (erf, Complex, octave::math::erf);
809 ARRAY_MAPPER (erfc, Complex, octave::math::erfc);
810 ARRAY_MAPPER (erfcx, Complex, octave::math::erfcx);
811 ARRAY_MAPPER (erfi, Complex, octave::math::erfi);
812 ARRAY_MAPPER (dawson, Complex, octave::math::dawson);
813 ARRAY_MAPPER (ceil, Complex, octave::math::ceil);
814 ARRAY_MAPPER (cos, Complex, std::cos);
815 ARRAY_MAPPER (cosh, Complex, std::cosh);
816 ARRAY_MAPPER (exp, Complex, std::exp);
817 ARRAY_MAPPER (expm1, Complex, octave::math::expm1);
818 ARRAY_MAPPER (fix, Complex, octave::math::fix);
819 ARRAY_MAPPER (floor, Complex, octave::math::floor);
820 ARRAY_MAPPER (log, Complex, std::log);
821 ARRAY_MAPPER (log2, Complex, octave::math::log2);
822 ARRAY_MAPPER (log10, Complex, std::log10);
823 ARRAY_MAPPER (log1p, Complex, octave::math::log1p);
824 ARRAY_MAPPER (round, Complex, octave::math::round);
825 ARRAY_MAPPER (roundb, Complex, octave::math::roundb);
826 ARRAY_MAPPER (signum, Complex, octave::math::signum);
827 ARRAY_MAPPER (sin, Complex, std::sin);
828 ARRAY_MAPPER (sinh, Complex, std::sinh);
829 ARRAY_MAPPER (sqrt, Complex, std::sqrt);
830 ARRAY_MAPPER (tan, Complex, std::tan);
831 ARRAY_MAPPER (tanh, Complex, std::tanh);
832 ARRAY_MAPPER (isna, bool, octave::math::isna);
833
834 default:
835 return octave_base_value::map (umap);
836 }
837}
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.h:563
int ndims() const
Size of the specified dimension.
Definition Array.h:679
octave_idx_type rows() const
Definition Array.h:463
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
octave_idx_type columns() const
Definition Array.h:475
const T * data() const
Size of the specified dimension.
Definition Array.h:665
T * rwdata()
Size of the specified dimension.
octave_idx_type numel() const
Number of elements in the array.
Definition Array.h:418
ComplexMatrix diag(octave_idx_type k=0) const
Definition CMatrix.cc:2831
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:90
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
Definition dim-vector.h:331
void resize(int n, int fill_value=0)
Definition dim-vector.h:268
octave_idx_type ndims() const
Number of dimensions.
Definition dim-vector.h:253
void * get_data() const
Definition mxarray.h:482
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:274
octave_value as_double() const
Definition ov-cx-mat.cc:280
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:286
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:770
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:463
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:254
Matrix matrix_value(bool=false) const
Definition ov-cx-mat.cc:152
SparseMatrix sparse_matrix_value(bool=false) const
Definition ov-cx-mat.cc:260
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:734
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
Definition ov-cx-mat.cc:641
octave_value diag(octave_idx_type k=0) const
Definition ov-cx-mat.cc:292
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
Definition ov-cx-mat.cc:726
bool load_ascii(std::istream &is)
Definition ov-cx-mat.cc:345
bool save_binary(std::ostream &os, bool save_as_floats)
Definition ov-cx-mat.cc:421
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
Definition ov-cx-mat.cc:538
bool save_ascii(std::ostream &os)
Definition ov-cx-mat.cc:317
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:802
void write_doubles(std::ostream &os, const double *data, save_type type, octave_idx_type len)
Definition data-conv.cc:918
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:1078
void error(const char *fmt,...)
Definition error.cc:1003
void err_invalid_conversion(const std::string &from, const std::string &to)
Definition errwarn.cc:71
void warn_logical_conversion()
Definition errwarn.cc:365
void warn_implicit_conversion(const char *id, const char *from, const char *to)
Definition errwarn.cc:344
float lo_ieee_float_nan_value()
Definition lo-ieee.cc:116
Complex log2(const Complex &x)
Complex asin(const Complex &x)
bool isna(double x)
Definition lo-mappers.cc:47
Complex acos(const Complex &x)
Definition lo-mappers.cc:85
std::complex< T > ceil(const std::complex< T > &x)
Definition lo-mappers.h:103
Complex atan(const Complex &x)
Definition lo-mappers.h:71
double roundb(double x)
Definition lo-mappers.h:147
std::complex< T > floor(const std::complex< T > &x)
Definition lo-mappers.h:130
bool isfinite(double x)
Definition lo-mappers.h:192
bool isinf(double x)
Definition lo-mappers.h:203
double signum(double x)
Definition lo-mappers.h:229
double round(double x)
Definition lo-mappers.h:136
bool isnan(bool)
Definition lo-mappers.h:178
double fix(double x)
Definition lo-mappers.h:118
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 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:1254
int load_hdf5_empty(octave_hdf5_id loc_id, const char *name, dim_vector &d)
Definition ls-hdf5.cc:1311
octave_hdf5_id save_type_to_hdf5(save_type st)
Definition ls-hdf5.cc:1355
octave_hdf5_id hdf5_make_complex_type(octave_hdf5_id num_type)
Definition ls-hdf5.cc:410
bool hdf5_types_compatible(octave_hdf5_id t1, octave_hdf5_id t2)
Definition ls-hdf5.cc:274
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
std::complex< double > Complex
Definition oct-cmplx.h:33
std::complex< float > FloatComplex
Definition oct-cmplx.h:34
int64_t octave_hdf5_id
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Definition oct-locbuf.h:44
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
Definition ov-base.h:246
#define ARRAY_MAPPER(UMAP, TYPE, FCN)
#define ARRAY_METHOD_MAPPER(UMAP, FCN)
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