GNU Octave 7.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
ov-re-mat.cc
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 1996-2022 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-re-mat.h"
70#include "ov-flt-re-mat.h"
71#include "ov-complex.h"
72#include "ov-cx-mat.h"
73#include "ov-re-sparse.h"
74#include "ov-re-diag.h"
75#include "ov-cx-diag.h"
76#include "ov-lazy-idx.h"
77#include "ov-perm.h"
78#include "pr-flt-fmt.h"
79#include "pr-output.h"
80#include "variables.h"
81
82#include "byte-swap.h"
83#include "ls-oct-text.h"
84#include "ls-utils.h"
85#include "ls-hdf5.h"
86
87
88template class octave_base_matrix<NDArray>;
89
91
92static octave_base_value *
94{
95 const octave_matrix& v = dynamic_cast<const octave_matrix&> (a);
96
97 return new octave_float_matrix (v.float_array_value ());
98}
99
102{
106}
107
110{
111 octave_base_value *retval = nullptr;
112
113 if (matrix.numel () == 1)
114 retval = new octave_scalar (matrix (0));
115
116 return retval;
117}
118
119double
121{
122 if (isempty ())
123 err_invalid_conversion ("real matrix", "real scalar");
124
125 warn_implicit_conversion ("Octave:array-to-scalar",
126 "real matrix", "real scalar");
127
128 return matrix(0, 0);
129}
130
131float
133{
134 if (isempty ())
135 err_invalid_conversion ("real matrix", "real scalar");
136
137 warn_implicit_conversion ("Octave:array-to-scalar",
138 "real matrix", "real scalar");
139
140 return matrix(0, 0);
141}
142
143// FIXME
144
145Matrix
147{
148 return Matrix (matrix);
149}
150
153{
154 return FloatMatrix (Matrix (matrix));
155}
156
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 return Complex (matrix(0, 0), 0);
167}
168
171{
172 float tmp = lo_ieee_float_nan_value ();
173
174 FloatComplex retval (tmp, tmp);
175
176 if (rows () == 0 || columns () == 0)
177 err_invalid_conversion ("real matrix", "complex scalar");
178
179 warn_implicit_conversion ("Octave:array-to-scalar",
180 "real matrix", "complex scalar");
181
182 retval = matrix(0, 0);
183
184 return retval;
185}
186
187// FIXME
188
191{
192 return ComplexMatrix (Matrix (matrix));
193}
194
197{
199}
200
203{
204 return ComplexNDArray (matrix);
205}
206
209{
211}
212
215{
218 if (warn && matrix.any_element_not_one_or_zero ())
220
221 return boolNDArray (matrix);
222}
223
226{
227 charNDArray retval (dims ());
228
229 octave_idx_type nel = numel ();
230
231 for (octave_idx_type i = 0; i < nel; i++)
232 retval.elem (i) = static_cast<char> (matrix.elem (i));
233
234 return retval;
235}
236
239{
240 return SparseMatrix (Matrix (matrix));
241}
242
245{
246 // FIXME: Need a SparseComplexMatrix (Matrix) constructor to make
247 // this function more efficient. Then this should become
248 // return SparseComplexMatrix (matrix.matrix_value ());
250}
251
254{
255 return NDArray (matrix);
256}
257
260{
261 return FloatNDArray (matrix);
262}
263
266{
267 return int8NDArray (matrix);
268}
269
272{
273 return int16NDArray (matrix);
274}
275
278{
279 return int32NDArray (matrix);
280}
281
284{
285 return int64NDArray (matrix);
286}
287
290{
291 return uint8NDArray (matrix);
292}
293
296{
297 return uint16NDArray (matrix);
298}
299
302{
303 return uint32NDArray (matrix);
304}
305
308{
309 return uint64NDArray (matrix);
310}
311
314{
315 octave_value retval;
316 if (k == 0 && matrix.ndims () == 2
317 && (matrix.rows () == 1 || matrix.columns () == 1))
319 else
321
322 return retval;
323}
324
327{
328 if (matrix.ndims () != 2
329 || (matrix.rows () != 1 && matrix.columns () != 1))
330 error ("diag: expecting vector argument");
331
332 Matrix mat (matrix);
333
334 return mat.diag (m, n);
335}
336
337// We override these two functions to allow reshaping both
338// the matrix and the index cache.
340octave_matrix::reshape (const dim_vector& new_dims) const
341{
342 if (idx_cache)
343 {
344 return new octave_matrix (matrix.reshape (new_dims),
346 idx_cache->extent (0)));
347 }
348 else
349 return octave_base_matrix<NDArray>::reshape (new_dims);
350}
351
354{
355 if (idx_cache)
356 {
357 return new octave_matrix (matrix.squeeze (),
359 idx_cache->extent (0)));
360 }
361 else
363}
364
367{
368 if (idx_cache)
369 {
370 // This is a valid index matrix, so sort via integers because it's
371 // generally more efficient.
372 return octave_lazy_index (*idx_cache).sort (dim, mode);
373 }
374 else
375 return octave_base_matrix<NDArray>::sort (dim, mode);
376}
377
380 sortmode mode) const
381{
382 if (idx_cache)
383 {
384 // This is a valid index matrix, so sort via integers because it's
385 // generally more efficient.
386 return octave_lazy_index (*idx_cache).sort (sidx, dim, mode);
387 }
388 else
389 return octave_base_matrix<NDArray>::sort (sidx, dim, mode);
390}
391
394{
395 if (idx_cache)
396 {
397 // This is a valid index matrix, so check via integers because it's
398 // generally more efficient.
399 return idx_cache->as_array ().issorted (mode);
400 }
401 else
403}
406{
407 if (idx_cache)
408 {
409 // This is a valid index matrix, so sort via integers because it's
410 // generally more efficient.
411 return octave_lazy_index (*idx_cache).sort_rows_idx (mode);
412 }
413 else
415}
416
419{
420 if (idx_cache)
421 {
422 // This is a valid index matrix, so check via integers because it's
423 // generally more efficient.
424 return idx_cache->as_array ().is_sorted_rows (mode);
425 }
426 else
428}
429
431octave_matrix::convert_to_str_internal (bool, bool, char type) const
432{
433 octave_value retval;
434 dim_vector dv = dims ();
435 octave_idx_type nel = dv.numel ();
436
437 charNDArray chm (dv);
438
439 bool warned = false;
440
441 for (octave_idx_type i = 0; i < nel; i++)
442 {
443 octave_quit ();
444
445 double d = matrix(i);
446
449
450 int ival = octave::math::nint (d);
451
452 if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
453 {
454 // FIXME: is there something better we could do?
455
456 ival = 0;
457
458 if (! warned)
459 {
460 ::warning ("range error for conversion to character value");
461 warned = true;
462 }
463 }
464
465 chm(i) = static_cast<char> (ival);
466 }
467
468 retval = octave_value (chm, type);
469
470 return retval;
471}
472
473bool
475{
476 dim_vector dv = dims ();
477
478 if (dv.ndims () > 2)
479 {
480 NDArray tmp = array_value ();
481
482 os << "# ndims: " << dv.ndims () << "\n";
483
484 for (int i=0; i < dv.ndims (); i++)
485 os << ' ' << dv(i);
486
487 os << "\n" << tmp;
488 }
489 else
490 {
491 // Keep this case, rather than use generic code above for backward
492 // compatibility. Makes load_ascii much more complex!!
493 os << "# rows: " << rows () << "\n"
494 << "# columns: " << columns () << "\n";
495
496 os << matrix_value ();
497 }
498
499 return true;
500}
501
502bool
504{
505 string_vector keywords(2);
506
507 keywords[0] = "ndims";
508 keywords[1] = "rows";
509
510 std::string kw;
511 octave_idx_type val = 0;
512
513 if (! extract_keyword (is, keywords, kw, val, true))
514 error ("load: failed to extract number of rows and columns");
515
516 // Set "C" locale for the duration of this function to avoid the performance
517 // panelty of frequently switching the locale when reading floating point
518 // values from the stream.
519 char *prev_locale = std::setlocale (LC_ALL, nullptr);
520 std::string old_locale (prev_locale ? prev_locale : "");
521 std::setlocale (LC_ALL, "C");
523 ([&old_locale] () { std::setlocale (LC_ALL, old_locale.c_str ()); });
524
525 if (kw == "ndims")
526 {
527 int mdims = static_cast<int> (val);
528
529 if (mdims < 0)
530 error ("load: failed to extract number of dimensions");
531
532 dim_vector dv;
533 dv.resize (mdims);
534
535 for (int i = 0; i < mdims; i++)
536 is >> dv(i);
537
538 if (! is)
539 error ("load: failed to read dimensions");
540
541 NDArray tmp(dv);
542
543 is >> tmp;
544
545 if (! is)
546 error ("load: failed to load matrix constant");
547
548 matrix = tmp;
549 }
550 else if (kw == "rows")
551 {
552 octave_idx_type nr = val;
553 octave_idx_type nc = 0;
554
555 if (nr < 0 || ! extract_keyword (is, "columns", nc) || nc < 0)
556 error ("load: failed to extract number of rows and columns");
557
558 if (nr > 0 && nc > 0)
559 {
560 Matrix tmp (nr, nc);
561 is >> tmp;
562 if (! is)
563 error ("load: failed to load matrix constant");
564
565 matrix = tmp;
566 }
567 else if (nr == 0 || nc == 0)
568 matrix = Matrix (nr, nc);
569 else
571 }
572 else
574
575 return true;
576}
577
578bool
579octave_matrix::save_binary (std::ostream& os, bool save_as_floats)
580{
581
582 dim_vector dv = dims ();
583 if (dv.ndims () < 1)
584 return false;
585
586 // Use negative value for ndims to differentiate with old format!!
587 int32_t tmp = - dv.ndims ();
588 os.write (reinterpret_cast<char *> (&tmp), 4);
589 for (int i = 0; i < dv.ndims (); i++)
590 {
591 tmp = dv(i);
592 os.write (reinterpret_cast<char *> (&tmp), 4);
593 }
594
595 NDArray m = array_value ();
596 save_type st = LS_DOUBLE;
597 if (save_as_floats)
598 {
599 if (m.too_large_for_float ())
600 {
601 warning ("save: some values too large to save as floats --");
602 warning ("save: saving as doubles instead");
603 }
604 else
605 st = LS_FLOAT;
606 }
607 else if (dv.numel () > 8192) // FIXME: make this configurable.
608 {
609 double max_val, min_val;
610 if (m.all_integers (max_val, min_val))
611 st = octave::get_save_type (max_val, min_val);
612 }
613
614 const double *mtmp = m.data ();
615 write_doubles (os, mtmp, st, dv.numel ());
616
617 return true;
618}
619
620bool
621octave_matrix::load_binary (std::istream& is, bool swap,
623{
624 char tmp;
625 int32_t mdims;
626 if (! is.read (reinterpret_cast<char *> (&mdims), 4))
627 return false;
628 if (swap)
629 swap_bytes<4> (&mdims);
630 if (mdims < 0)
631 {
632 mdims = - mdims;
633 int32_t di;
634 dim_vector dv;
635 dv.resize (mdims);
636
637 for (int i = 0; i < mdims; i++)
638 {
639 if (! is.read (reinterpret_cast<char *> (&di), 4))
640 return false;
641 if (swap)
642 swap_bytes<4> (&di);
643 dv(i) = di;
644 }
645
646 // Convert an array with a single dimension to be a row vector.
647 // Octave should never write files like this, other software
648 // might.
649
650 if (mdims == 1)
651 {
652 mdims = 2;
653 dv.resize (mdims);
654 dv(1) = dv(0);
655 dv(0) = 1;
656 }
657
658 if (! is.read (reinterpret_cast<char *> (&tmp), 1))
659 return false;
660
661 NDArray m(dv);
662 double *re = m.fortran_vec ();
663 read_doubles (is, re, static_cast<save_type> (tmp), dv.numel (),
664 swap, fmt);
665
666 if (! is)
667 return false;
668
669 matrix = m;
670 }
671 else
672 {
673 int32_t nr, nc;
674 nr = mdims;
675 if (! is.read (reinterpret_cast<char *> (&nc), 4))
676 return false;
677 if (swap)
678 swap_bytes<4> (&nc);
679 if (! is.read (reinterpret_cast<char *> (&tmp), 1))
680 return false;
681 Matrix m (nr, nc);
682 double *re = m.fortran_vec ();
683 octave_idx_type len = static_cast<octave_idx_type> (nr) * nc;
684 read_doubles (is, re, static_cast<save_type> (tmp), len, swap, fmt);
685
686 if (! is)
687 return false;
688
689 matrix = m;
690 }
691 return true;
692}
693
694bool
696 bool save_as_floats)
697{
698 bool retval = false;
699
700#if defined (HAVE_HDF5)
701
702 dim_vector dv = dims ();
703 int empty = save_hdf5_empty (loc_id, name, dv);
704 if (empty)
705 return (empty > 0);
706
707 int rank = dv.ndims ();
708 hid_t space_hid, data_hid;
709 space_hid = data_hid = -1;
710 NDArray m = array_value ();
711
712 OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
713
714 // Octave uses column-major, while HDF5 uses row-major ordering
715 for (int i = 0; i < rank; i++)
716 hdims[i] = dv(rank-i-1);
717
718 space_hid = H5Screate_simple (rank, hdims, nullptr);
719
720 if (space_hid < 0) return false;
721
722 hid_t save_type_hid = H5T_NATIVE_DOUBLE;
723
724 if (save_as_floats)
725 {
726 if (m.too_large_for_float ())
727 {
728 warning ("save: some values too large to save as floats --");
729 warning ("save: saving as doubles instead");
730 }
731 else
732 save_type_hid = H5T_NATIVE_FLOAT;
733 }
734#if defined (HAVE_HDF5_INT2FLOAT_CONVERSIONS)
735 // hdf5 currently doesn't support float/integer conversions
736 else
737 {
738 double max_val, min_val;
739
740 if (m.all_integers (max_val, min_val))
741 save_type_hid
742 = save_type_to_hdf5 (octave::get_save_type (max_val, min_val));
743 }
744#endif
745
746#if defined (HAVE_HDF5_18)
747 data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
749#else
750 data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
752#endif
753 if (data_hid < 0)
754 {
755 H5Sclose (space_hid);
756 return false;
757 }
758
759 double *mtmp = m.fortran_vec ();
760 retval = H5Dwrite (data_hid, H5T_NATIVE_DOUBLE, octave_H5S_ALL, octave_H5S_ALL,
761 octave_H5P_DEFAULT, mtmp) >= 0;
762
763 H5Dclose (data_hid);
764 H5Sclose (space_hid);
765
766#else
767 octave_unused_parameter (loc_id);
768 octave_unused_parameter (name);
769 octave_unused_parameter (save_as_floats);
770
771 warn_save ("hdf5");
772#endif
773
774 return retval;
775}
776
777bool
779{
780 bool retval = false;
781
782#if defined (HAVE_HDF5)
783
784 dim_vector dv;
785 int empty = load_hdf5_empty (loc_id, name, dv);
786 if (empty > 0)
787 matrix.resize (dv);
788 if (empty)
789 return (empty > 0);
790
791#if defined (HAVE_HDF5_18)
792 hid_t data_hid = H5Dopen (loc_id, name, octave_H5P_DEFAULT);
793#else
794 hid_t data_hid = H5Dopen (loc_id, name);
795#endif
796 hid_t space_id = H5Dget_space (data_hid);
797
798 hsize_t rank = H5Sget_simple_extent_ndims (space_id);
799
800 if (rank < 1)
801 {
802 H5Sclose (space_id);
803 H5Dclose (data_hid);
804 return false;
805 }
806
807 OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
808 OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank);
809
810 H5Sget_simple_extent_dims (space_id, hdims, maxdims);
811
812 // Octave uses column-major, while HDF5 uses row-major ordering
813 if (rank == 1)
814 {
815 dv.resize (2);
816 dv(0) = 1;
817 dv(1) = hdims[0];
818 }
819 else
820 {
821 dv.resize (rank);
822 for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
823 dv(j) = hdims[i];
824 }
825
826 NDArray m (dv);
827 double *re = m.fortran_vec ();
828 if (H5Dread (data_hid, H5T_NATIVE_DOUBLE, octave_H5S_ALL, octave_H5S_ALL,
829 octave_H5P_DEFAULT, re) >= 0)
830 {
831 retval = true;
832 matrix = m;
833 }
834
835 H5Sclose (space_id);
836 H5Dclose (data_hid);
837
838#else
839 octave_unused_parameter (loc_id);
840 octave_unused_parameter (name);
841
842 warn_load ("hdf5");
843#endif
844
845 return retval;
846}
847
848void
849octave_matrix::print_raw (std::ostream& os,
850 bool pr_as_read_syntax) const
851{
852 octave_print_internal (os, matrix, pr_as_read_syntax,
854}
855
856mxArray *
857octave_matrix::as_mxArray (bool interleaved) const
858{
859 mxArray *retval = new mxArray (interleaved, mxDOUBLE_CLASS, dims (), mxREAL);
860
861 mxDouble *pd = static_cast<mxDouble *> (retval->get_data ());
862
863 mwSize nel = numel ();
864
865 const double *pdata = matrix.data ();
866
867 for (mwIndex i = 0; i < nel; i++)
868 pd[i] = pdata[i];
869
870 return retval;
871}
872
873// This uses a smarter strategy for doing the complex->real mappers. We
874// allocate an array for a real result and keep filling it until a complex
875// result is produced.
876static octave_value
877do_rc_map (const NDArray& a, Complex (&fcn) (double))
878{
879 octave_idx_type n = a.numel ();
880 NDArray rr (a.dims ());
881
882 for (octave_idx_type i = 0; i < n; i++)
883 {
884 octave_quit ();
885
886 Complex tmp = fcn (a(i));
887 if (tmp.imag () == 0.0)
888 rr.xelem (i) = tmp.real ();
889 else
890 {
891 ComplexNDArray rc (a.dims ());
892
893 for (octave_idx_type j = 0; j < i; j++)
894 rc.xelem (j) = rr.xelem (j);
895
896 rc.xelem (i) = tmp;
897
898 for (octave_idx_type j = i+1; j < n; j++)
899 {
900 octave_quit ();
901
902 rc.xelem (j) = fcn (a(j));
903 }
904
905 return new octave_complex_matrix (rc);
906 }
907 }
908
909 return rr;
910}
911
914{
915 switch (umap)
916 {
917 case umap_imag:
918 return NDArray (matrix.dims (), 0.0);
919
920 case umap_real:
921 case umap_conj:
922 return matrix;
923
924 // Mappers handled specially.
925#define ARRAY_METHOD_MAPPER(UMAP, FCN) \
926 case umap_ ## UMAP: \
927 return octave_value (matrix.FCN ())
928
933
934#define ARRAY_MAPPER(UMAP, TYPE, FCN) \
935 case umap_ ## UMAP: \
936 return octave_value (matrix.map<TYPE> (FCN))
937
938#define RC_ARRAY_MAPPER(UMAP, TYPE, FCN) \
939 case umap_ ## UMAP: \
940 return do_rc_map (matrix, FCN)
941
944 ARRAY_MAPPER (angle, double, std::arg);
945 ARRAY_MAPPER (arg, double,std::arg);
948 ARRAY_MAPPER (atan, double, ::atan);
960 ARRAY_MAPPER (ceil, double, ::ceil);
961 ARRAY_MAPPER (cos, double, ::cos);
962 ARRAY_MAPPER (cosh, double, ::cosh);
963 ARRAY_MAPPER (exp, double, ::exp);
966 ARRAY_MAPPER (floor, double, ::floor);
974 ARRAY_MAPPER (sin, double, ::sin);
975 ARRAY_MAPPER (sinh, double, ::sinh);
977 ARRAY_MAPPER (tan, double, ::tan);
978 ARRAY_MAPPER (tanh, double, ::tanh);
980 ARRAY_MAPPER (xsignbit, double, octave::math::signbit);
981
982 // Special cases for Matlab compatibility.
983 case umap_xtolower:
984 case umap_xtoupper:
985 return matrix;
986
987 case umap_xisalnum:
988 case umap_xisalpha:
989 case umap_xisascii:
990 case umap_xiscntrl:
991 case umap_xisdigit:
992 case umap_xisgraph:
993 case umap_xislower:
994 case umap_xisprint:
995 case umap_xispunct:
996 case umap_xisspace:
997 case umap_xisupper:
998 case umap_xisxdigit:
999 {
1000 octave_value str_conv = convert_to_str (true, true);
1001 return str_conv.map (umap);
1002 }
1003
1004 default:
1005 return octave_base_value::map (umap);
1006 }
1007}
void swap_bytes< 4 >(void *ptr)
Definition: byte-swap.h:63
charNDArray max(char d, const charNDArray &m)
Definition: chNDArray.cc:230
T & xelem(octave_idx_type n)
Size of the specified dimension.
Definition: Array.h:504
OCTARRAY_API Array< T, Alloc > squeeze(void) const
Chop off leading singleton dimensions.
Definition: Array.cc:117
octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:411
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
Definition: Array.h:487
T & elem(octave_idx_type n)
Size of the specified dimension.
Definition: Array.h:534
octave_idx_type rows(void) const
Definition: Array.h:449
OCTARRAY_API void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
Definition: Array.cc:1010
octave_idx_type columns(void) const
Definition: Array.h:458
const T * data(void) const
Size of the specified dimension.
Definition: Array.h:616
OCTARRAY_API T * fortran_vec(void)
Size of the specified dimension.
Definition: Array.cc:1744
Array< T, Alloc > reshape(octave_idx_type nr, octave_idx_type nc) const
Size of the specified dimension.
Definition: Array.h:595
int ndims(void) const
Size of the specified dimension.
Definition: Array.h:627
OCTARRAY_API sortmode issorted(sortmode mode=UNSORTED) const
Ordering is auto-detected or can be specified.
Definition: Array.cc:2027
OCTARRAY_API sortmode is_sorted_rows(sortmode mode=UNSORTED) const
Ordering is auto-detected or can be specified.
Definition: Array.cc:2077
MArray< T > reshape(const dim_vector &new_dims) const
Definition: MArray.h:87
Definition: dMatrix.h:42
OCTAVE_API Matrix diag(octave_idx_type k=0) const
Definition: dMatrix.cc:2402
OCTAVE_API bool any_element_is_nan(void) const
Definition: dNDArray.cc:318
OCTAVE_API bool any_element_not_one_or_zero(void) const
Definition: dNDArray.cc:330
OCTAVE_API bool all_integers(double &max_val, double &min_val) const
Definition: dNDArray.cc:351
OCTAVE_API bool too_large_for_float(void) const
Definition: dNDArray.cc:387
NDArray squeeze(void) const
Definition: dNDArray.h:143
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_data(void) const
Definition: mxarray.h:497
OCTAVE_API Array< octave_idx_type > as_array(void) const
Definition: idx-vector.cc:1225
octave_idx_type extent(octave_idx_type n) const
Definition: idx-vector.h:540
octave_idx_type numel(void) const
Definition: ov-base-mat.h:118
octave::idx_vector * idx_cache
Definition: ov-base-mat.h:223
octave_value diag(octave_idx_type k=0) const
Definition: ov-base-mat.h:138
sortmode issorted(sortmode mode=UNSORTED) const
Definition: ov-base-mat.h:150
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
Definition: ov-base-mat.h:156
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
Definition: ov-base-mat.h:144
octave_value squeeze(void) const
Definition: ov-base-mat.h:77
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
Definition: ov-base-mat.h:153
octave_value reshape(const dim_vector &new_dims) const
Definition: ov-base-mat.h:124
dim_vector dims(void) const
Definition: ov-base-mat.h:116
octave_idx_type columns(void) const
Definition: ov-base.h:355
int current_print_indent_level(void) const
Definition: ov-base.h:893
virtual octave_value map(unary_mapper_t) const
Definition: ov-base.cc:1176
virtual octave_value convert_to_str(bool pad=false, bool force=false, char type='\'') const
Definition: ov-base.cc:377
OCTINTERP_API void warn_load(const char *type) const
Definition: ov-base.cc:1152
octave_idx_type rows(void) const
Definition: ov-base.h:348
friend class octave_value
Definition: ov-base.h:256
OCTINTERP_API void warn_save(const char *type) const
Definition: ov-base.cc:1161
bool isempty(void) const
Definition: ov-base.h:391
static int static_type_id(void)
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
Definition: ov-lazy-idx.cc:106
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
Definition: ov-lazy-idx.cc:151
FloatComplexMatrix float_complex_matrix_value(bool=false) const
Definition: ov-re-mat.cc:196
boolNDArray bool_array_value(bool warn=false) const
Definition: ov-re-mat.cc:214
octave_value as_int32(void) const
Definition: ov-re-mat.cc:277
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
Definition: ov-re-mat.cc:405
SparseMatrix sparse_matrix_value(bool=false) const
Definition: ov-re-mat.cc:238
bool load_ascii(std::istream &is)
Definition: ov-re-mat.cc:503
octave_matrix(void)
Definition: ov-re-mat.h:57
octave_value as_uint32(void) const
Definition: ov-re-mat.cc:301
FloatComplex float_complex_value(bool=false) const
Definition: ov-re-mat.cc:170
float float_value(bool=false) const
Definition: ov-re-mat.cc:132
octave_value as_int64(void) const
Definition: ov-re-mat.cc:283
octave_value as_uint8(void) const
Definition: ov-re-mat.cc:289
octave_value as_double(void) const
Definition: ov-re-mat.cc:253
charNDArray char_array_value(bool=false) const
Definition: ov-re-mat.cc:225
FloatMatrix float_matrix_value(bool=false) const
Definition: ov-re-mat.cc:152
bool save_binary(std::ostream &os, bool save_as_floats)
Definition: ov-re-mat.cc:579
bool save_ascii(std::ostream &os)
Definition: ov-re-mat.cc:474
SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
Definition: ov-re-mat.cc:244
FloatComplexNDArray float_complex_array_value(bool=false) const
Definition: ov-re-mat.cc:208
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
Definition: ov-re-mat.cc:621
type_conv_info numeric_demotion_function(void) const
Definition: ov-re-mat.cc:101
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
Definition: ov-re-mat.cc:849
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
Definition: ov-re-mat.cc:366
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
Definition: ov-re-mat.cc:695
octave_base_value * try_narrowing_conversion(void)
Definition: ov-re-mat.cc:109
Complex complex_value(bool=false) const
Definition: ov-re-mat.cc:158
ComplexNDArray complex_array_value(bool=false) const
Definition: ov-re-mat.cc:202
octave_value reshape(const dim_vector &new_dims) const
Definition: ov-re-mat.cc:340
Matrix matrix_value(bool=false) const
Definition: ov-re-mat.cc:146
octave_value as_int8(void) const
Definition: ov-re-mat.cc:265
octave_value diag(octave_idx_type k=0) const
Definition: ov-re-mat.cc:313
octave_value map(unary_mapper_t umap) const
Definition: ov-re-mat.cc:913
mxArray * as_mxArray(bool interleaved) const
Definition: ov-re-mat.cc:857
octave_value squeeze(void) const
Definition: ov-re-mat.cc:353
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
Definition: ov-re-mat.cc:778
octave_value as_int16(void) const
Definition: ov-re-mat.cc:271
sortmode issorted(sortmode mode=UNSORTED) const
Definition: ov-re-mat.cc:393
ComplexMatrix complex_matrix_value(bool=false) const
Definition: ov-re-mat.cc:190
FloatNDArray float_array_value(bool=false) const
Definition: ov-re-mat.h:174
octave_value convert_to_str_internal(bool pad, bool force, char type) const
Definition: ov-re-mat.cc:431
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
Definition: ov-re-mat.cc:418
octave_value as_uint64(void) const
Definition: ov-re-mat.cc:307
octave_value as_single(void) const
Definition: ov-re-mat.cc:259
NDArray array_value(bool=false) const
Definition: ov-re-mat.h:172
octave_value as_uint16(void) const
Definition: ov-re-mat.cc:295
double double_value(bool=false) const
Definition: ov-re-mat.cc:120
octave_value map(octave_base_value::unary_mapper_t umap) const
Definition: ov.h:1634
const octave_hdf5_id octave_H5P_DEFAULT
const octave_hdf5_id octave_H5S_ALL
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:1055
void error(const char *fmt,...)
Definition: error.cc:980
#define panic_impossible()
Definition: error.h:411
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
function gamma(X)
Definition: gamma.f:3
QString name
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
float lo_ieee_float_nan_value(void)
Definition: lo-ieee.cc:116
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
int save_hdf5_empty(octave_hdf5_id loc_id, const char *name, const dim_vector &d)
Definition: ls-hdf5.cc:1251
int load_hdf5_empty(octave_hdf5_id loc_id, const char *name, dim_vector &d)
Definition: ls-hdf5.cc:1307
octave_hdf5_id save_type_to_hdf5(save_type st)
Definition: ls-hdf5.cc:1351
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
Definition: ls-oct-text.cc:84
OCTAVE_NAMESPACE_BEGIN save_type get_save_type(double, double)
Definition: ls-utils.cc:40
void mxArray
Definition: mex.h:58
class OCTAVE_API NDArray
Definition: mx-fwd.h:38
class OCTAVE_API boolNDArray
Definition: mx-fwd.h:42
class OCTAVE_API Matrix
Definition: mx-fwd.h:31
class OCTAVE_API DiagMatrix
Definition: mx-fwd.h:59
class OCTAVE_API ComplexMatrix
Definition: mx-fwd.h:32
class OCTAVE_API SparseMatrix
Definition: mx-fwd.h:55
class OCTAVE_API FloatComplexMatrix
Definition: mx-fwd.h:34
class OCTAVE_API FloatMatrix
Definition: mx-fwd.h:33
class OCTAVE_API ComplexNDArray
Definition: mx-fwd.h:39
class OCTAVE_API SparseComplexMatrix
Definition: mx-fwd.h:56
class OCTAVE_API FloatComplexNDArray
Definition: mx-fwd.h:41
class OCTAVE_API FloatNDArray
Definition: mx-fwd.h:40
std::complex< double > erfi(std::complex< double > z, double relerr=0)
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 > erf(std::complex< double > z, double relerr=0)
double fix(double x)
Definition: lo-mappers.h:118
Complex atan(const Complex &x)
Definition: lo-mappers.h:71
double signum(double x)
Definition: lo-mappers.h:229
double asinh(double x)
Definition: lo-specfun.h:58
double gamma(double x)
Definition: lo-specfun.cc:1912
bool isna(double x)
Definition: lo-mappers.cc:47
Complex rc_acos(double x)
Definition: lo-mappers.cc:236
double signbit(double x)
Definition: lo-mappers.h:54
double atanh(double x)
Definition: lo-specfun.h:63
bool isfinite(double x)
Definition: lo-mappers.h:192
int nint(double x)
Definition: lo-mappers.cc:212
double roundb(double x)
Definition: lo-mappers.h:147
bool isnan(bool)
Definition: lo-mappers.h:178
Complex log1p(const Complex &x)
Definition: lo-specfun.cc:1958
bool isinf(double x)
Definition: lo-mappers.h:203
Complex acos(const Complex &x)
Definition: lo-mappers.cc:85
double round(double x)
Definition: lo-mappers.h:136
Complex asin(const Complex &x)
Definition: lo-mappers.cc:107
double erfcx(double x)
Definition: lo-specfun.cc:1755
Complex rc_log2(double x)
Definition: lo-mappers.cc:300
Complex rc_log(double x)
Definition: lo-mappers.cc:287
Complex erfc(const Complex &x)
Definition: lo-specfun.cc:1652
double acosh(double x)
Definition: lo-specfun.h:40
Complex rc_sqrt(double x)
Definition: lo-mappers.cc:330
double erfcinv(double x)
Definition: lo-specfun.cc:1744
Complex rc_atanh(double x)
Definition: lo-mappers.cc:274
Complex rc_acosh(double x)
Definition: lo-mappers.cc:249
double erfi(double x)
Definition: lo-specfun.cc:1774
Complex rc_log1p(double x)
Definition: lo-specfun.cc:2247
double lgamma(double x)
Definition: lo-specfun.h:336
double erfinv(double x)
Definition: lo-specfun.cc:1863
Complex rc_log10(double x)
Definition: lo-mappers.cc:315
Complex rc_lgamma(double x)
Definition: lo-specfun.cc:2210
std::complex< T > ceil(const std::complex< T > &x)
Definition: lo-mappers.h:103
std::complex< T > floor(const std::complex< T > &x)
Definition: lo-mappers.h:130
double dawson(double x)
Definition: lo-specfun.cc:1517
double cbrt(double x)
Definition: lo-specfun.h:289
Complex rc_asin(double x)
Definition: lo-mappers.cc:261
Complex log2(const Complex &x)
Definition: lo-mappers.cc:139
Complex erf(const Complex &x)
Definition: lo-specfun.cc:1637
Complex expm1(const Complex &x)
Definition: lo-specfun.cc:1874
void err_nan_to_logical_conversion(void)
void err_nan_to_character_conversion(void)
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
sortmode
Definition: oct-sort.h:97
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
Definition: ov-base.h:222
static octave_base_value * default_numeric_demotion_function(const octave_base_value &a)
Definition: ov-re-mat.cc:93
static octave_value do_rc_map(const NDArray &a, Complex(&fcn)(double))
Definition: ov-re-mat.cc:877
#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:1762
static T abs(T x)
Definition: pr-output.cc:1678
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