GNU Octave  4.4.1
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-2018 John W. Eaton
4 Copyright (C) 2009-2010 VZLU Prague
5 
6 This file is part of Octave.
7 
8 Octave is free software: you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with Octave; see the file COPYING. If not, see
20 <https://www.gnu.org/licenses/>.
21 
22 */
23 
24 #if defined (HAVE_CONFIG_H)
25 # include "config.h"
26 #endif
27 
28 #include <iostream>
29 #include <limits>
30 #include <vector>
31 
32 #include "dNDArray.h"
33 #include "fNDArray.h"
34 #include "int8NDArray.h"
35 #include "int16NDArray.h"
36 #include "int32NDArray.h"
37 #include "int64NDArray.h"
38 #include "uint8NDArray.h"
39 #include "uint16NDArray.h"
40 #include "uint32NDArray.h"
41 #include "uint64NDArray.h"
42 
43 #include "data-conv.h"
44 #include "lo-ieee.h"
45 #include "lo-utils.h"
46 #include "lo-specfun.h"
47 #include "lo-mappers.h"
48 #include "mach-info.h"
49 #include "mx-base.h"
50 #include "quit.h"
51 #include "oct-locbuf.h"
52 
53 #include "defun.h"
54 #include "errwarn.h"
55 #include "mxarray.h"
56 #include "ovl.h"
57 #include "oct-lvalue.h"
58 #include "oct-hdf5.h"
59 #include "oct-stream.h"
60 #include "ops.h"
61 #include "ov-base.h"
62 #include "ov-base-mat.h"
63 #include "ov-base-mat.cc"
64 #include "ov-scalar.h"
65 #include "ov-re-mat.h"
66 #include "ov-flt-re-mat.h"
67 #include "ov-complex.h"
68 #include "ov-cx-mat.h"
69 #include "ov-re-sparse.h"
70 #include "ov-re-diag.h"
71 #include "ov-cx-diag.h"
72 #include "ov-lazy-idx.h"
73 #include "ov-perm.h"
74 #include "pr-flt-fmt.h"
75 #include "pr-output.h"
76 #include "variables.h"
77 
78 #include "byte-swap.h"
79 #include "ls-oct-text.h"
80 #include "ls-utils.h"
81 #include "ls-hdf5.h"
82 
83 
84 template class octave_base_matrix<NDArray>;
85 
87 
88 static octave_base_value *
90 {
91  const octave_matrix& v = dynamic_cast<const octave_matrix&> (a);
92 
93  return new octave_float_matrix (v.float_array_value ());
94 }
95 
98 {
102 }
103 
106 {
107  octave_base_value *retval = nullptr;
108 
109  if (matrix.numel () == 1)
110  retval = new octave_scalar (matrix (0));
111 
112  return retval;
113 }
114 
115 double
117 {
118  if (isempty ())
119  err_invalid_conversion ("real matrix", "real scalar");
120 
121  warn_implicit_conversion ("Octave:array-to-scalar",
122  "real matrix", "real scalar");
123 
124  return matrix(0, 0);
125 }
126 
127 float
129 {
130  if (isempty ())
131  err_invalid_conversion ("real matrix", "real scalar");
132 
133  warn_implicit_conversion ("Octave:array-to-scalar",
134  "real matrix", "real scalar");
135 
136  return matrix(0, 0);
137 }
138 
139 // FIXME
140 
141 Matrix
143 {
144  return Matrix (matrix);
145 }
146 
149 {
150  return FloatMatrix (Matrix (matrix));
151 }
152 
153 Complex
155 {
156  if (rows () == 0 || columns () == 0)
157  err_invalid_conversion ("real matrix", "complex scalar");
158 
159  warn_implicit_conversion ("Octave:array-to-scalar",
160  "real matrix", "complex scalar");
161 
162  return Complex (matrix(0, 0), 0);
163 }
164 
167 {
168  float tmp = lo_ieee_float_nan_value ();
169 
171 
172  if (rows () == 0 || columns () == 0)
173  err_invalid_conversion ("real matrix", "complex scalar");
174 
175  warn_implicit_conversion ("Octave:array-to-scalar",
176  "real matrix", "complex scalar");
177 
178  retval = matrix(0, 0);
179 
180  return retval;
181 }
182 
183 // FIXME
184 
187 {
188  return ComplexMatrix (Matrix (matrix));
189 }
190 
193 {
194  return FloatComplexMatrix (Matrix (matrix));
195 }
196 
199 {
200  return ComplexNDArray (matrix);
201 }
202 
205 {
206  return FloatComplexNDArray (matrix);
207 }
208 
211 {
212  if (matrix.any_element_is_nan ())
214  if (warn && matrix.any_element_not_one_or_zero ())
216 
217  return boolNDArray (matrix);
218 }
219 
222 {
223  charNDArray retval (dims ());
224 
225  octave_idx_type nel = numel ();
226 
227  for (octave_idx_type i = 0; i < nel; i++)
228  retval.elem (i) = static_cast<char>(matrix.elem (i));
229 
230  return retval;
231 }
232 
235 {
236  return SparseMatrix (Matrix (matrix));
237 }
238 
241 {
242  // FIXME: Need a SparseComplexMatrix (Matrix) constructor to make
243  // this function more efficient. Then this should become
244  // return SparseComplexMatrix (matrix.matrix_value ());
246 }
247 
250 {
251  return NDArray (matrix);
252 }
253 
256 {
257  return FloatNDArray (matrix);
258 }
259 
262 {
263  return int8NDArray (matrix);
264 }
265 
268 {
269  return int16NDArray (matrix);
270 }
271 
274 {
275  return int32NDArray (matrix);
276 }
277 
280 {
281  return int64NDArray (matrix);
282 }
283 
286 {
287  return uint8NDArray (matrix);
288 }
289 
292 {
293  return uint16NDArray (matrix);
294 }
295 
298 {
299  return uint32NDArray (matrix);
300 }
301 
304 {
305  return uint64NDArray (matrix);
306 }
307 
310 {
312  if (k == 0 && matrix.ndims () == 2
313  && (matrix.rows () == 1 || matrix.columns () == 1))
315  else
317 
318  return retval;
319 }
320 
323 {
324  if (matrix.ndims () != 2
325  || (matrix.rows () != 1 && matrix.columns () != 1))
326  error ("diag: expecting vector argument");
327 
328  Matrix mat (matrix);
329 
330  return mat.diag (m, n);
331 }
332 
333 // We override these two functions to allow reshaping both
334 // the matrix and the index cache.
336 octave_matrix::reshape (const dim_vector& new_dims) const
337 {
338  if (idx_cache)
339  {
340  return new octave_matrix (matrix.reshape (new_dims),
341  idx_vector (idx_cache->as_array ().reshape (new_dims),
342  idx_cache->extent (0)));
343  }
344  else
345  return octave_base_matrix<NDArray>::reshape (new_dims);
346 }
347 
350 {
351  if (idx_cache)
352  {
353  return new octave_matrix (matrix.squeeze (),
355  idx_cache->extent (0)));
356  }
357  else
359 }
360 
363 {
364  if (idx_cache)
365  {
366  // This is a valid index matrix, so sort via integers because it's
367  // generally more efficient.
368  return octave_lazy_index (*idx_cache).sort (dim, mode);
369  }
370  else
372 }
373 
376  sortmode mode) const
377 {
378  if (idx_cache)
379  {
380  // This is a valid index matrix, so sort via integers because it's
381  // generally more efficient.
382  return octave_lazy_index (*idx_cache).sort (sidx, dim, mode);
383  }
384  else
385  return octave_base_matrix<NDArray>::sort (sidx, dim, mode);
386 }
387 
388 sortmode
390 {
391  if (idx_cache)
392  {
393  // This is a valid index matrix, so check via integers because it's
394  // generally more efficient.
395  return idx_cache->as_array ().issorted (mode);
396  }
397  else
399 }
402 {
403  if (idx_cache)
404  {
405  // This is a valid index matrix, so sort via integers because it's
406  // generally more efficient.
407  return octave_lazy_index (*idx_cache).sort_rows_idx (mode);
408  }
409  else
411 }
412 
413 sortmode
415 {
416  if (idx_cache)
417  {
418  // This is a valid index matrix, so check via integers because it's
419  // generally more efficient.
420  return idx_cache->as_array ().is_sorted_rows (mode);
421  }
422  else
424 }
425 
428 {
430  dim_vector dv = dims ();
431  octave_idx_type nel = dv.numel ();
432 
433  charNDArray chm (dv);
434 
435  bool warned = false;
436 
437  for (octave_idx_type i = 0; i < nel; i++)
438  {
439  octave_quit ();
440 
441  double d = matrix(i);
442 
443  if (octave::math::isnan (d))
445 
446  int ival = octave::math::nint (d);
447 
448  if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
449  {
450  // FIXME: is there something better we could do?
451 
452  ival = 0;
453 
454  if (! warned)
455  {
456  ::warning ("range error for conversion to character value");
457  warned = true;
458  }
459  }
460 
461  chm(i) = static_cast<char> (ival);
462  }
463 
464  retval = octave_value (chm, type);
465 
466  return retval;
467 }
468 
469 bool
471 {
472  dim_vector dv = dims ();
473 
474  if (dv.ndims () > 2)
475  {
476  NDArray tmp = array_value ();
477 
478  os << "# ndims: " << dv.ndims () << "\n";
479 
480  for (int i=0; i < dv.ndims (); i++)
481  os << ' ' << dv(i);
482 
483  os << "\n" << tmp;
484  }
485  else
486  {
487  // Keep this case, rather than use generic code above for backward
488  // compatibility. Makes load_ascii much more complex!!
489  os << "# rows: " << rows () << "\n"
490  << "# columns: " << columns () << "\n";
491 
492  os << matrix_value ();
493  }
494 
495  return true;
496 }
497 
498 bool
500 {
501  string_vector keywords(2);
502 
503  keywords[0] = "ndims";
504  keywords[1] = "rows";
505 
506  std::string kw;
507  octave_idx_type val = 0;
508 
509  if (! extract_keyword (is, keywords, kw, val, true))
510  error ("load: failed to extract number of rows and columns");
511 
512  if (kw == "ndims")
513  {
514  int mdims = static_cast<int> (val);
515 
516  if (mdims < 0)
517  error ("load: failed to extract number of dimensions");
518 
519  dim_vector dv;
520  dv.resize (mdims);
521 
522  for (int i = 0; i < mdims; i++)
523  is >> dv(i);
524 
525  if (! is)
526  error ("load: failed to read dimensions");
527 
528  NDArray tmp(dv);
529 
530  is >> tmp;
531 
532  if (! is)
533  error ("load: failed to load matrix constant");
534 
535  matrix = tmp;
536  }
537  else if (kw == "rows")
538  {
539  octave_idx_type nr = val;
540  octave_idx_type nc = 0;
541 
542  if (nr < 0 || ! extract_keyword (is, "columns", nc) || nc < 0)
543  error ("load: failed to extract number of rows and columns");
544 
545  if (nr > 0 && nc > 0)
546  {
547  Matrix tmp (nr, nc);
548  is >> tmp;
549  if (! is)
550  error ("load: failed to load matrix constant");
551 
552  matrix = tmp;
553  }
554  else if (nr == 0 || nc == 0)
555  matrix = Matrix (nr, nc);
556  else
557  panic_impossible ();
558  }
559  else
560  panic_impossible ();
561 
562  return true;
563 }
564 
565 bool
567 {
568 
569  dim_vector dv = dims ();
570  if (dv.ndims () < 1)
571  return false;
572 
573  // Use negative value for ndims to differentiate with old format!!
574  int32_t tmp = - dv.ndims ();
575  os.write (reinterpret_cast<char *> (&tmp), 4);
576  for (int i = 0; i < dv.ndims (); i++)
577  {
578  tmp = dv(i);
579  os.write (reinterpret_cast<char *> (&tmp), 4);
580  }
581 
582  NDArray m = array_value ();
583  save_type st = LS_DOUBLE;
584  if (save_as_floats)
585  {
586  if (m.too_large_for_float ())
587  {
588  warning ("save: some values too large to save as floats --");
589  warning ("save: saving as doubles instead");
590  }
591  else
592  st = LS_FLOAT;
593  }
594  else if (dv.numel () > 8192) // FIXME: make this configurable.
595  {
596  double max_val, min_val;
597  if (m.all_integers (max_val, min_val))
598  st = get_save_type (max_val, min_val);
599  }
600 
601  const double *mtmp = m.data ();
602  write_doubles (os, mtmp, st, dv.numel ());
603 
604  return true;
605 }
606 
607 bool
608 octave_matrix::load_binary (std::istream& is, bool swap,
610 {
611  char tmp;
612  int32_t mdims;
613  if (! is.read (reinterpret_cast<char *> (&mdims), 4))
614  return false;
615  if (swap)
616  swap_bytes<4> (&mdims);
617  if (mdims < 0)
618  {
619  mdims = - mdims;
620  int32_t di;
621  dim_vector dv;
622  dv.resize (mdims);
623 
624  for (int i = 0; i < mdims; i++)
625  {
626  if (! is.read (reinterpret_cast<char *> (&di), 4))
627  return false;
628  if (swap)
629  swap_bytes<4> (&di);
630  dv(i) = di;
631  }
632 
633  // Convert an array with a single dimension to be a row vector.
634  // Octave should never write files like this, other software
635  // might.
636 
637  if (mdims == 1)
638  {
639  mdims = 2;
640  dv.resize (mdims);
641  dv(1) = dv(0);
642  dv(0) = 1;
643  }
644 
645  if (! is.read (reinterpret_cast<char *> (&tmp), 1))
646  return false;
647 
648  NDArray m(dv);
649  double *re = m.fortran_vec ();
650  read_doubles (is, re, static_cast<save_type> (tmp), dv.numel (),
651  swap, fmt);
652 
653  if (! is)
654  return false;
655 
656  matrix = m;
657  }
658  else
659  {
660  int32_t nr, nc;
661  nr = mdims;
662  if (! is.read (reinterpret_cast<char *> (&nc), 4))
663  return false;
664  if (swap)
665  swap_bytes<4> (&nc);
666  if (! is.read (reinterpret_cast<char *> (&tmp), 1))
667  return false;
668  Matrix m (nr, nc);
669  double *re = m.fortran_vec ();
670  octave_idx_type len = nr * nc;
671  read_doubles (is, re, static_cast<save_type> (tmp), len, swap, fmt);
672 
673  if (! is)
674  return false;
675 
676  matrix = m;
677  }
678  return true;
679 }
680 
681 bool
683  bool save_as_floats)
684 {
685  bool retval = false;
686 
687 #if defined (HAVE_HDF5)
688 
689  dim_vector dv = dims ();
690  int empty = save_hdf5_empty (loc_id, name, dv);
691  if (empty)
692  return (empty > 0);
693 
694  int rank = dv.ndims ();
695  hid_t space_hid, data_hid;
696  space_hid = data_hid = -1;
697  NDArray m = array_value ();
698 
699  OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
700 
701  // Octave uses column-major, while HDF5 uses row-major ordering
702  for (int i = 0; i < rank; i++)
703  hdims[i] = dv(rank-i-1);
704 
705  space_hid = H5Screate_simple (rank, hdims, nullptr);
706 
707  if (space_hid < 0) return false;
708 
709  hid_t save_type_hid = H5T_NATIVE_DOUBLE;
710 
711  if (save_as_floats)
712  {
713  if (m.too_large_for_float ())
714  {
715  warning ("save: some values too large to save as floats --");
716  warning ("save: saving as doubles instead");
717  }
718  else
719  save_type_hid = H5T_NATIVE_FLOAT;
720  }
721 #if defined (HAVE_HDF5_INT2FLOAT_CONVERSIONS)
722  // hdf5 currently doesn't support float/integer conversions
723  else
724  {
725  double max_val, min_val;
726 
727  if (m.all_integers (max_val, min_val))
728  save_type_hid
729  = save_type_to_hdf5 (get_save_type (max_val, min_val));
730  }
731 #endif
732 
733 #if defined (HAVE_HDF5_18)
734  data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
736 #else
737  data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
739 #endif
740  if (data_hid < 0)
741  {
742  H5Sclose (space_hid);
743  return false;
744  }
745 
746  double *mtmp = m.fortran_vec ();
747  retval = H5Dwrite (data_hid, H5T_NATIVE_DOUBLE, octave_H5S_ALL, octave_H5S_ALL,
748  octave_H5P_DEFAULT, mtmp) >= 0;
749 
750  H5Dclose (data_hid);
751  H5Sclose (space_hid);
752 
753 #else
754  octave_unused_parameter (loc_id);
755  octave_unused_parameter (name);
756  octave_unused_parameter (save_as_floats);
757 
758  warn_save ("hdf5");
759 #endif
760 
761  return retval;
762 }
763 
764 bool
766 {
767  bool retval = false;
768 
769 #if defined (HAVE_HDF5)
770 
771  dim_vector dv;
772  int empty = load_hdf5_empty (loc_id, name, dv);
773  if (empty > 0)
774  matrix.resize (dv);
775  if (empty)
776  return (empty > 0);
777 
778 #if defined (HAVE_HDF5_18)
779  hid_t data_hid = H5Dopen (loc_id, name, octave_H5P_DEFAULT);
780 #else
781  hid_t data_hid = H5Dopen (loc_id, name);
782 #endif
783  hid_t space_id = H5Dget_space (data_hid);
784 
785  hsize_t rank = H5Sget_simple_extent_ndims (space_id);
786 
787  if (rank < 1)
788  {
789  H5Sclose (space_id);
790  H5Dclose (data_hid);
791  return false;
792  }
793 
794  OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
795  OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank);
796 
797  H5Sget_simple_extent_dims (space_id, hdims, maxdims);
798 
799  // Octave uses column-major, while HDF5 uses row-major ordering
800  if (rank == 1)
801  {
802  dv.resize (2);
803  dv(0) = 1;
804  dv(1) = hdims[0];
805  }
806  else
807  {
808  dv.resize (rank);
809  for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
810  dv(j) = hdims[i];
811  }
812 
813  NDArray m (dv);
814  double *re = m.fortran_vec ();
815  if (H5Dread (data_hid, H5T_NATIVE_DOUBLE, octave_H5S_ALL, octave_H5S_ALL,
816  octave_H5P_DEFAULT, re) >= 0)
817  {
818  retval = true;
819  matrix = m;
820  }
821 
822  H5Sclose (space_id);
823  H5Dclose (data_hid);
824 
825 #else
826  octave_unused_parameter (loc_id);
827  octave_unused_parameter (name);
828 
829  warn_load ("hdf5");
830 #endif
831 
832  return retval;
833 }
834 
835 void
837  bool pr_as_read_syntax) const
838 {
839  octave_print_internal (os, matrix, pr_as_read_syntax,
841 }
842 
843 mxArray *
845 {
847 
848  double *pr = static_cast<double *> (retval->get_data ());
849 
850  mwSize nel = numel ();
851 
852  const double *p = matrix.data ();
853 
854  for (mwIndex i = 0; i < nel; i++)
855  pr[i] = p[i];
856 
857  return retval;
858 }
859 
860 // This uses a smarter strategy for doing the complex->real mappers. We
861 // allocate an array for a real result and keep filling it until a complex
862 // result is produced.
863 static octave_value
864 do_rc_map (const NDArray& a, Complex (&fcn) (double))
865 {
866  octave_idx_type n = a.numel ();
867  NoAlias<NDArray> rr (a.dims ());
868 
869  for (octave_idx_type i = 0; i < n; i++)
870  {
871  octave_quit ();
872 
873  Complex tmp = fcn (a(i));
874  if (tmp.imag () == 0.0)
875  rr(i) = tmp.real ();
876  else
877  {
878  NoAlias<ComplexNDArray> rc (a.dims ());
879 
880  for (octave_idx_type j = 0; j < i; j++)
881  rc(j) = rr(j);
882 
883  rc(i) = tmp;
884 
885  for (octave_idx_type j = i+1; j < n; j++)
886  {
887  octave_quit ();
888 
889  rc(j) = fcn (a(j));
890  }
891 
892  return new octave_complex_matrix (rc);
893  }
894  }
895 
896  return rr;
897 }
898 
901 {
902  switch (umap)
903  {
904  case umap_imag:
905  return NDArray (matrix.dims (), 0.0);
906 
907  case umap_real:
908  case umap_conj:
909  return matrix;
910 
911  // Mappers handled specially.
912 #define ARRAY_METHOD_MAPPER(UMAP, FCN) \
913  case umap_ ## UMAP: \
914  return octave_value (matrix.FCN ())
915 
920 
921 #define ARRAY_MAPPER(UMAP, TYPE, FCN) \
922  case umap_ ## UMAP: \
923  return octave_value (matrix.map<TYPE> (FCN))
924 
925 #define RC_ARRAY_MAPPER(UMAP, TYPE, FCN) \
926  case umap_ ## UMAP: \
927  return do_rc_map (matrix, FCN)
928 
931  ARRAY_MAPPER (angle, double, std::arg);
932  ARRAY_MAPPER (arg, double,std::arg);
935  ARRAY_MAPPER (atan, double, ::atan);
947  ARRAY_MAPPER (ceil, double, ::ceil);
948  ARRAY_MAPPER (cos, double, ::cos);
949  ARRAY_MAPPER (cosh, double, ::cosh);
950  ARRAY_MAPPER (exp, double, ::exp);
953  ARRAY_MAPPER (floor, double, ::floor);
961  ARRAY_MAPPER (sin, double, ::sin);
962  ARRAY_MAPPER (sinh, double, ::sinh);
964  ARRAY_MAPPER (tan, double, ::tan);
965  ARRAY_MAPPER (tanh, double, ::tanh);
967  ARRAY_MAPPER (xsignbit, double, octave::math::signbit);
968 
969  // Special cases for Matlab compatibility.
970  case umap_xtolower:
971  case umap_xtoupper:
972  return matrix;
973 
974  case umap_xisalnum:
975  case umap_xisalpha:
976  case umap_xisascii:
977  case umap_xiscntrl:
978  case umap_xisdigit:
979  case umap_xisgraph:
980  case umap_xislower:
981  case umap_xisprint:
982  case umap_xispunct:
983  case umap_xisspace:
984  case umap_xisupper:
985  case umap_xisxdigit:
986  {
987  octave_value str_conv = convert_to_str (true, true);
988  return str_conv.map (umap);
989  }
990 
991  default:
992  return octave_base_value::map (umap);
993  }
994 }
save_type
Definition: data-conv.h:85
octave_idx_type write(const octave_value &data, octave_idx_type block_size, oct_data_conv::data_type output_type, octave_idx_type skip, mach_info::float_format flt_fmt)
Definition: oct-stream.cc:6704
double erfcx(double x)
Definition: lo-specfun.cc:1756
octave_idx_type rows(void) const
Definition: Array.h:404
Complex complex_value(bool=false) const
Definition: ov-re-mat.cc:154
FloatComplexMatrix float_complex_matrix_value(bool=false) const
Definition: ov-re-mat.cc:192
octave_value map(octave_base_value::unary_mapper_t umap) const
Definition: ov.h:1473
Matrix matrix_value(bool=false) const
Definition: ov-re-mat.cc:142
Complex rc_log10(double x)
Definition: lo-mappers.cc:307
intNDArray< octave_int64 > int64NDArray
Definition: int64NDArray.h:33
octave_value convert_to_str_internal(bool pad, bool force, char type) const
Definition: ov-re-mat.cc:427
OCTAVE_IDX_TYPE mwSize
Definition: mxarray.in.h:93
const T * data(void) const
Definition: Array.h:582
octave_value reshape(const dim_vector &new_dims) const
Definition: ov-re-mat.cc:336
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
Definition: ov-re-mat.cc:836
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
Definition: ov-re-mat.cc:608
octave_idx_type extent(octave_idx_type n) const
Definition: idx-vector.h:560
Complex rc_acosh(double x)
Definition: lo-mappers.cc:241
Complex rc_sqrt(double x)
Definition: lo-mappers.cc:322
sortmode
Definition: oct-sort.h:105
std::complex< double > erfi(std::complex< double > z, double relerr=0)
void warn_logical_conversion(void)
Definition: errwarn.cc:359
int current_print_indent_level(void) const
Definition: ov-base.h:849
octave_value as_double(void) const
Definition: ov-re-mat.cc:249
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:4986
const octave_hdf5_id octave_H5S_ALL
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
Definition: ov-lazy-idx.cc:149
intNDArray< octave_uint32 > uint32NDArray
Definition: uint32NDArray.h:33
octave_value as_int64(void) const
Definition: ov-re-mat.cc:279
double erfi(double x)
Definition: lo-specfun.cc:1775
Return the CPU time used by your Octave session The first output is the total time spent executing your process and is equal to the sum of second and third which are the number of CPU seconds spent executing in user mode and the number of CPU seconds spent executing in system mode
Definition: data.cc:6348
static octave_value do_rc_map(const NDArray &a, Complex(&fcn)(double))
Definition: ov-re-mat.cc:864
save_type get_save_type(double, double)
Definition: ls-utils.cc:35
Array< T > squeeze(void) const
Chop off leading singleton dimensions.
Definition: Array.cc:116
intNDArray< octave_uint8 > uint8NDArray
Definition: uint8NDArray.h:33
ComplexNDArray complex_array_value(bool=false) const
Definition: ov-re-mat.cc:198
FloatComplex float_complex_value(bool=false) const
Definition: ov-re-mat.cc:166
intNDArray< octave_uint16 > uint16NDArray
Definition: uint16NDArray.h:33
octave_value squeeze(void) const
Definition: ov-re-mat.cc:349
double asinh(double x)
Definition: lo-specfun.h:67
for large enough k
Definition: lu.cc:617
bool isna(double x)
Definition: lo-mappers.cc:45
void resize(int n, int fill_value=0)
Definition: dim-vector.h:310
const T * fortran_vec(void) const
Definition: Array.h:584
octave_value as_uint32(void) const
Definition: ov-re-mat.cc:297
Complex rc_lgamma(double x)
Definition: lo-specfun.cc:2211
OCTAVE_EXPORT octave_value_list or N dimensional array whose elements are all equal to the base of natural logarithms The constant ex $e satisfies the equation log(e)
bool isnan(bool)
Definition: lo-mappers.h:187
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
Definition: ov-lazy-idx.cc:104
std::complex< T > ceil(const std::complex< T > &x)
Definition: lo-mappers.h:112
void error(const char *fmt,...)
Definition: error.cc:578
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
Definition: ov-re-mat.cc:362
bool isinf(double x)
Definition: lo-mappers.h:225
std::complex< T > floor(const std::complex< T > &x)
Definition: lo-mappers.h:139
static T abs(T x)
Definition: pr-output.cc:1696
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
Definition: Array.h:442
static octave_base_value * default_numeric_demotion_function(const octave_base_value &a)
Definition: ov-re-mat.cc:89
void write_doubles(std::ostream &os, const double *data, save_type type, octave_idx_type len)
Definition: data-conv.cc:887
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
Definition: ov-base.h:180
FloatComplexNDArray float_complex_array_value(bool=false) const
Definition: ov-re-mat.cc:204
octave_matrix(void)
Definition: ov-re-mat.h:55
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
Ordering is auto-detected or can be specified.
Definition: Array.cc:2086
octave_idx_type columns(void) const
Definition: Array.h:413
int load_hdf5_empty(octave_hdf5_id loc_id, const char *name, dim_vector &d)
Definition: ls-hdf5.cc:953
T & elem(octave_idx_type n)
Definition: Array.h:488
Complex acos(const Complex &x)
Definition: lo-mappers.cc:83
NDArray array_value(bool=false) const
Definition: ov-re-mat.h:170
Complex atan(const Complex &x)
Definition: lo-mappers.h:80
intNDArray< octave_int16 > int16NDArray
Definition: int16NDArray.h:33
float float_value(bool=false) const
Definition: ov-re-mat.cc:128
double fix(double x)
Definition: lo-mappers.h:127
bool too_large_for_float(void) const
Definition: dNDArray.cc:622
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
Definition: ov-base-mat.h:133
Complex asin(const Complex &x)
Definition: lo-mappers.cc:105
void err_nan_to_logical_conversion(void)
octave_value as_uint64(void) const
Definition: ov-re-mat.cc:303
#define RC_ARRAY_MAPPER(UMAP, TYPE, FCN)
Complex log2(const Complex &x)
Definition: lo-mappers.cc:137
octave_value as_single(void) const
Definition: ov-re-mat.cc:255
Complex erfc(const Complex &x)
Definition: lo-specfun.cc:1653
std::complex< double > erf(std::complex< double > z, double relerr=0)
virtual octave_value map(unary_mapper_t) const
Definition: ov-base.cc:1121
octave_value arg
Definition: pr-output.cc:3244
octave_function * fcn
Definition: ov-class.cc:1754
F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
double double_value(bool=false) const
Definition: ov-re-mat.cc:116
mxArray * as_mxArray(void) const
Definition: ov-re-mat.cc:844
void warn_load(const char *type) const
Definition: ov-base.cc:1097
Array< T > reshape(octave_idx_type nr, octave_idx_type nc) const
Definition: Array.h:549
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:400
bool swap
Definition: load-save.cc:738
Complex rc_atanh(double x)
Definition: lo-mappers.cc:266
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
Definition: ov-re-mat.cc:765
SparseMatrix sparse_matrix_value(bool=false) const
Definition: ov-re-mat.cc:234
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
Definition: ov-base-mat.h:145
double lgamma(double x)
Definition: lo-specfun.h:377
octave_base_value * try_narrowing_conversion(void)
Definition: ov-re-mat.cc:105
octave_value squeeze(void) const
Definition: ov-base-mat.h:72
Complex expm1(const Complex &x)
Definition: lo-specfun.cc:1875
create a structure array and initialize its values The dimensions of each cell array of values must match Singleton cells and non cell values are repeated so that they fill the entire array If the cells are empty
Definition: ov-struct.cc:1736
void octave_print_internal(std::ostream &os, const float_display_format &fmt, bool d, bool pr_as_read_syntax)
Definition: pr-output.cc:1780
nd deftypefn *std::string name
Definition: sysdep.cc:647
double acosh(double x)
Definition: lo-specfun.h:49
Matrix diag(octave_idx_type k=0) const
Definition: dMatrix.cc:2583
double gamma(double x)
Definition: lo-specfun.cc:1913
void swap_bytes< 4 >(void *ptr)
Definition: byte-swap.h:60
MArray< T > reshape(const dim_vector &new_dims) const
Definition: MArray.h:91
sortmode issorted(sortmode mode=UNSORTED) const
Ordering is auto-detected or can be specified.
Definition: Array.cc:2033
virtual octave_value convert_to_str(bool pad=false, bool force=false, char type='\'') const
Definition: ov-base.cc:375
octave_value diag(octave_idx_type k=0) const
Definition: ov-base-mat.h:127
intNDArray< octave_int8 > int8NDArray
Definition: int8NDArray.h:33
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
Definition: ls-oct-text.cc:82
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:772
sortmode issorted(sortmode mode=UNSORTED) const
Definition: ov-base-mat.h:139
Complex log1p(const Complex &x)
Definition: lo-specfun.cc:1959
octave_idx_type rows(void) const
Definition: ov-base.h:316
octave_value as_uint8(void) const
Definition: ov-re-mat.cc:285
double signum(double x)
Definition: lo-mappers.h:244
ComplexMatrix complex_matrix_value(bool=false) const
Definition: ov-re-mat.cc:186
double dawson(double x)
Definition: lo-specfun.cc:1518
octave_value as_int16(void) const
Definition: ov-re-mat.cc:267
bool save_as_floats
Definition: load-save.cc:1617
bool all_integers(double &max_val, double &min_val) const
Definition: dNDArray.cc:586
Complex rc_log2(double x)
Definition: lo-mappers.cc:292
void resize(const dim_vector &dv, const T &rfv)
Resizing (with fill).
Definition: Array.cc:1010
sortmode issorted(sortmode mode=UNSORTED) const
Definition: ov-re-mat.cc:389
octave_hdf5_id save_type_to_hdf5(save_type st)
Definition: ls-hdf5.cc:997
double tmp
Definition: data.cc:6252
octave_value retval
Definition: data.cc:6246
Complex rc_log(double x)
Definition: lo-mappers.cc:279
#define panic_impossible()
Definition: error.h:40
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
Definition: ov-re-mat.cc:414
std::complex< double > erfcx(std::complex< double > z, double relerr=0)
int64_t octave_hdf5_id
bool save_ascii(std::ostream &os)
Definition: ov-re-mat.cc:470
double atanh(double x)
Definition: lo-specfun.h:72
void warn_save(const char *type) const
Definition: ov-base.cc:1106
octave_value map(unary_mapper_t umap) const
Definition: ov-re-mat.cc:900
octave_value reshape(const dim_vector &new_dims) const
Definition: ov-base-mat.h:113
idx type
Definition: ov.cc:3114
Definition: dMatrix.h:36
octave_value as_uint16(void) const
Definition: ov-re-mat.cc:291
Complex erf(const Complex &x)
Definition: lo-specfun.cc:1638
float lo_ieee_float_nan_value(void)
Definition: lo-ieee.cc:123
double cbrt(double x)
Definition: lo-specfun.h:298
double erfcinv(double x)
Definition: lo-specfun.cc:1745
void mxArray
Definition: mex.h:55
type_conv_info numeric_demotion_function(void) const
Definition: ov-re-mat.cc:97
friend class octave_value
Definition: ov-base.h:228
Complex rc_acos(double x)
Definition: lo-mappers.cc:228
void warning(const char *fmt,...)
Definition: error.cc:801
charNDArray max(char d, const charNDArray &m)
Definition: chNDArray.cc:227
int save_hdf5_empty(octave_hdf5_id loc_id, const char *name, const dim_vector &d)
Definition: ls-hdf5.cc:897
intNDArray< octave_int32 > int32NDArray
Definition: int32NDArray.h:33
This is a simple wrapper template that will subclass an Array<T> type or any later type derived from ...
Definition: Array.h:892
void err_invalid_conversion(const std::string &from, const std::string &to)
Definition: errwarn.cc:68
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
Definition: ov-re-mat.cc:682
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
Definition: dim-vector.h:362
bool any_element_not_one_or_zero(void) const
Definition: dNDArray.cc:565
p
Definition: lu.cc:138
octave_value as_int8(void) const
Definition: ov-re-mat.cc:261
bool save_binary(std::ostream &os, bool &save_as_floats)
Definition: ov-re-mat.cc:566
dim_vector dims(void) const
Definition: ov-base-mat.h:105
void warn_implicit_conversion(const char *id, const char *from, const char *to)
Definition: errwarn.cc:338
Complex rc_asin(double x)
Definition: lo-mappers.cc:253
bool isfinite(double x)
Definition: lo-mappers.h:201
FloatMatrix float_matrix_value(bool=false) const
Definition: ov-re-mat.cc:148
double roundb(double x)
Definition: lo-mappers.h:156
Complex rc_log1p(double x)
Definition: lo-specfun.cc:2248
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Definition: oct-locbuf.h:41
double erfinv(double x)
Definition: lo-specfun.cc:1864
octave_idx_type numel(void) const
Definition: ov-base-mat.h:107
double round(double x)
Definition: lo-mappers.h:145
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
Definition: ov-base-mat.h:142
FloatNDArray float_array_value(bool=false) const
Definition: ov-re-mat.h:172
for i
Definition: data.cc:5264
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
Definition: ov-re-mat.cc:401
static int static_type_id(void)
const octave_hdf5_id octave_H5P_DEFAULT
octave_idx_type columns(void) const
Definition: ov-base.h:323
bool isempty(void) const
Definition: ov-base.h:359
std::complex< float > FloatComplex
Definition: oct-cmplx.h:32
#define ARRAY_MAPPER(UMAP, TYPE, FCN)
octave_idx_type ndims(void) const
Number of dimensions.
Definition: dim-vector.h:295
std::complex< double > Complex
Definition: oct-cmplx.h:31
bool load_ascii(std::istream &is)
Definition: ov-re-mat.cc:499
charNDArray char_array_value(bool=false) const
Definition: ov-re-mat.cc:221
Array< octave_idx_type > as_array(void) const
Definition: idx-vector.cc:1271
octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:366
#define ARRAY_METHOD_MAPPER(UMAP, FCN)
OCTAVE_IDX_TYPE mwIndex
Definition: mxarray.in.h:94
write the output to stdout if nargout is
Definition: load-save.cc:1612
void err_nan_to_character_conversion(void)
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
octave_value diag(octave_idx_type k=0) const
Definition: ov-re-mat.cc:309
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
Definition: utils.cc:888
dim_vector dv
Definition: sub2ind.cc:263
double signbit(double x)
Definition: lo-mappers.h:63
octave::stream os
Definition: file-io.cc:627
boolNDArray bool_array_value(bool warn=false) const
Definition: ov-re-mat.cc:210
bool any_element_is_nan(void) const
Definition: dNDArray.cc:553
SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
Definition: ov-re-mat.cc:240
NDArray squeeze(void) const
Definition: dNDArray.h:141
int ndims(void) const
Definition: Array.h:590
octave_value as_int32(void) const
Definition: ov-re-mat.cc:273
intNDArray< octave_uint64 > uint64NDArray
Definition: uint64NDArray.h:33
int nint(double x)
Definition: lo-mappers.cc:206
std::complex< double > erfc(std::complex< double > z, double relerr=0)