GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ov-re-mat.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2017 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 the
10 Free Software Foundation; either version 3 of the License, or (at your
11 option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 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 <http://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-output.h"
75 #include "variables.h"
76 
77 #include "byte-swap.h"
78 #include "ls-oct-text.h"
79 #include "ls-utils.h"
80 #include "ls-hdf5.h"
81 
82 
83 template class octave_base_matrix<NDArray>;
84 
86 
87 static octave_base_value *
89 {
90  const octave_matrix& v = dynamic_cast<const octave_matrix&> (a);
91 
92  return new octave_float_matrix (v.float_array_value ());
93 }
94 
97 {
101 }
102 
105 {
107 
108  if (matrix.numel () == 1)
109  retval = new octave_scalar (matrix (0));
110 
111  return retval;
112 }
113 
114 double
116 {
117  if (is_empty ())
118  err_invalid_conversion ("real matrix", "real scalar");
119 
120  warn_implicit_conversion ("Octave:array-to-scalar",
121  "real matrix", "real scalar");
122 
123  return matrix(0, 0);
124 }
125 
126 float
128 {
129  if (is_empty ())
130  err_invalid_conversion ("real matrix", "real scalar");
131 
132  warn_implicit_conversion ("Octave:array-to-scalar",
133  "real matrix", "real scalar");
134 
135  return matrix(0, 0);
136 }
137 
138 // FIXME
139 
140 Matrix
142 {
143  return Matrix (matrix);
144 }
145 
148 {
149  return FloatMatrix (Matrix (matrix));
150 }
151 
152 Complex
154 {
155  if (rows () == 0 || columns () == 0)
156  err_invalid_conversion ("real matrix", "complex scalar");
157 
158  warn_implicit_conversion ("Octave:array-to-scalar",
159  "real matrix", "complex scalar");
160 
161  return Complex (matrix(0, 0), 0);
162 }
163 
166 {
167  float tmp = lo_ieee_float_nan_value ();
168 
169  FloatComplex retval (tmp, tmp);
170 
171  if (rows () == 0 || columns () == 0)
172  err_invalid_conversion ("real matrix", "complex scalar");
173 
174  warn_implicit_conversion ("Octave:array-to-scalar",
175  "real matrix", "complex scalar");
176 
177  retval = matrix(0, 0);
178 
179  return retval;
180 }
181 
182 // FIXME
183 
186 {
187  return ComplexMatrix (Matrix (matrix));
188 }
189 
192 {
193  return FloatComplexMatrix (Matrix (matrix));
194 }
195 
198 {
199  return ComplexNDArray (matrix);
200 }
201 
204 {
205  return FloatComplexNDArray (matrix);
206 }
207 
210 {
211  if (matrix.any_element_is_nan ())
213  if (warn && matrix.any_element_not_one_or_zero ())
215 
216  return boolNDArray (matrix);
217 }
218 
221 {
222  charNDArray retval (dims ());
223 
224  octave_idx_type nel = numel ();
225 
226  for (octave_idx_type i = 0; i < nel; i++)
227  retval.elem (i) = static_cast<char>(matrix.elem (i));
228 
229  return retval;
230 }
231 
234 {
235  return SparseMatrix (Matrix (matrix));
236 }
237 
240 {
241  // FIXME: Need a SparseComplexMatrix (Matrix) constructor to make
242  // this function more efficient. Then this should become
243  // return SparseComplexMatrix (matrix.matrix_value ());
245 }
246 
249 {
250  return NDArray (matrix);
251 }
252 
255 {
256  return FloatNDArray (matrix);
257 }
258 
261 {
262  return int8NDArray (matrix);
263 }
264 
267 {
268  return int16NDArray (matrix);
269 }
270 
273 {
274  return int32NDArray (matrix);
275 }
276 
279 {
280  return int64NDArray (matrix);
281 }
282 
285 {
286  return uint8NDArray (matrix);
287 }
288 
291 {
292  return uint16NDArray (matrix);
293 }
294 
297 {
298  return uint32NDArray (matrix);
299 }
300 
303 {
304  return uint64NDArray (matrix);
305 }
306 
309 {
311  if (k == 0 && matrix.ndims () == 2
312  && (matrix.rows () == 1 || matrix.columns () == 1))
313  retval = DiagMatrix (DiagArray2<double> (matrix));
314  else
316 
317  return retval;
318 }
319 
322 {
323  if (matrix.ndims () != 2
324  || (matrix.rows () != 1 && matrix.columns () != 1))
325  error ("diag: expecting vector argument");
326 
327  Matrix mat (matrix);
328 
329  return mat.diag (m, n);
330 }
331 
332 // We override these two functions to allow reshaping both
333 // the matrix and the index cache.
335 octave_matrix::reshape (const dim_vector& new_dims) const
336 {
337  if (idx_cache)
338  {
339  return new octave_matrix (matrix.reshape (new_dims),
340  idx_vector (idx_cache->as_array ().reshape (new_dims),
341  idx_cache->extent (0)));
342  }
343  else
344  return octave_base_matrix<NDArray>::reshape (new_dims);
345 }
346 
349 {
350  if (idx_cache)
351  {
352  return new octave_matrix (matrix.squeeze (),
354  idx_cache->extent (0)));
355  }
356  else
358 }
359 
362 {
363  if (idx_cache)
364  {
365  // This is a valid index matrix, so sort via integers because it's
366  // generally more efficient.
367  return octave_lazy_index (*idx_cache).sort (dim, mode);
368  }
369  else
370  return octave_base_matrix<NDArray>::sort (dim, mode);
371 }
372 
375  sortmode mode) const
376 {
377  if (idx_cache)
378  {
379  // This is a valid index matrix, so sort via integers because it's
380  // generally more efficient.
381  return octave_lazy_index (*idx_cache).sort (sidx, dim, mode);
382  }
383  else
384  return octave_base_matrix<NDArray>::sort (sidx, dim, mode);
385 }
386 
387 sortmode
389 {
390  if (idx_cache)
391  {
392  // This is a valid index matrix, so check via integers because it's
393  // generally more efficient.
394  return idx_cache->as_array ().is_sorted (mode);
395  }
396  else
398 }
401 {
402  if (idx_cache)
403  {
404  // This is a valid index matrix, so sort via integers because it's
405  // generally more efficient.
406  return octave_lazy_index (*idx_cache).sort_rows_idx (mode);
407  }
408  else
410 }
411 
412 sortmode
414 {
415  if (idx_cache)
416  {
417  // This is a valid index matrix, so check via integers because it's
418  // generally more efficient.
419  return idx_cache->as_array ().is_sorted_rows (mode);
420  }
421  else
423 }
424 
427 {
429  dim_vector dv = dims ();
430  octave_idx_type nel = dv.numel ();
431 
432  charNDArray chm (dv);
433 
434  bool warned = false;
435 
436  for (octave_idx_type i = 0; i < nel; i++)
437  {
438  octave_quit ();
439 
440  double d = matrix(i);
441 
442  if (octave::math::isnan (d))
444 
445  int ival = octave::math::nint (d);
446 
447  if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
448  {
449  // FIXME: is there something better we could do?
450 
451  ival = 0;
452 
453  if (! warned)
454  {
455  ::warning ("range error for conversion to character value");
456  warned = true;
457  }
458  }
459 
460  chm(i) = static_cast<char> (ival);
461  }
462 
463  retval = octave_value (chm, type);
464 
465  return retval;
466 }
467 
468 bool
469 octave_matrix::save_ascii (std::ostream& os)
470 {
471  dim_vector dv = dims ();
472 
473  if (dv.ndims () > 2)
474  {
475  NDArray tmp = array_value ();
476 
477  os << "# ndims: " << dv.ndims () << "\n";
478 
479  for (int i=0; i < dv.ndims (); i++)
480  os << " " << dv(i);
481 
482  os << "\n" << tmp;
483  }
484  else
485  {
486  // Keep this case, rather than use generic code above for backward
487  // compatibility. Makes load_ascii much more complex!!
488  os << "# rows: " << rows () << "\n"
489  << "# columns: " << columns () << "\n";
490 
491  os << matrix_value ();
492  }
493 
494  return true;
495 }
496 
497 bool
499 {
501 
502  keywords[0] = "ndims";
503  keywords[1] = "rows";
504 
505  std::string kw;
506  octave_idx_type val = 0;
507 
508  if (! extract_keyword (is, keywords, kw, val, true))
509  error ("load: failed to extract number of rows and columns");
510 
511  if (kw == "ndims")
512  {
513  int mdims = static_cast<int> (val);
514 
515  if (mdims < 0)
516  error ("load: failed to extract number of dimensions");
517 
518  dim_vector dv;
519  dv.resize (mdims);
520 
521  for (int i = 0; i < mdims; i++)
522  is >> dv(i);
523 
524  if (! is)
525  error ("load: failed to read dimensions");
526 
527  NDArray tmp(dv);
528 
529  is >> tmp;
530 
531  if (! is)
532  error ("load: failed to load matrix constant");
533 
534  matrix = tmp;
535  }
536  else if (kw == "rows")
537  {
538  octave_idx_type nr = val;
539  octave_idx_type nc = 0;
540 
541  if (nr < 0 || ! extract_keyword (is, "columns", nc) || nc < 0)
542  error ("load: failed to extract number of rows and columns");
543 
544  if (nr > 0 && nc > 0)
545  {
546  Matrix tmp (nr, nc);
547  is >> tmp;
548  if (! is)
549  error ("load: failed to load matrix constant");
550 
551  matrix = tmp;
552  }
553  else if (nr == 0 || nc == 0)
554  matrix = Matrix (nr, nc);
555  else
556  panic_impossible ();
557  }
558  else
559  panic_impossible ();
560 
561  return true;
562 }
563 
564 bool
566 {
567 
568  dim_vector dv = dims ();
569  if (dv.ndims () < 1)
570  return false;
571 
572  // Use negative value for ndims to differentiate with old format!!
573  int32_t tmp = - dv.ndims ();
574  os.write (reinterpret_cast<char *> (&tmp), 4);
575  for (int i = 0; i < dv.ndims (); i++)
576  {
577  tmp = dv(i);
578  os.write (reinterpret_cast<char *> (&tmp), 4);
579  }
580 
581  NDArray m = array_value ();
582  save_type st = LS_DOUBLE;
583  if (save_as_floats)
584  {
585  if (m.too_large_for_float ())
586  {
587  warning ("save: some values too large to save as floats --");
588  warning ("save: saving as doubles instead");
589  }
590  else
591  st = LS_FLOAT;
592  }
593  else if (dv.numel () > 8192) // FIXME: make this configurable.
594  {
595  double max_val, min_val;
596  if (m.all_integers (max_val, min_val))
597  st = get_save_type (max_val, min_val);
598  }
599 
600  const double *mtmp = m.data ();
601  write_doubles (os, mtmp, st, dv.numel ());
602 
603  return true;
604 }
605 
606 bool
607 octave_matrix::load_binary (std::istream& is, bool swap,
609 {
610  char tmp;
611  int32_t mdims;
612  if (! is.read (reinterpret_cast<char *> (&mdims), 4))
613  return false;
614  if (swap)
615  swap_bytes<4> (&mdims);
616  if (mdims < 0)
617  {
618  mdims = - mdims;
619  int32_t di;
620  dim_vector dv;
621  dv.resize (mdims);
622 
623  for (int i = 0; i < mdims; i++)
624  {
625  if (! is.read (reinterpret_cast<char *> (&di), 4))
626  return false;
627  if (swap)
628  swap_bytes<4> (&di);
629  dv(i) = di;
630  }
631 
632  // Convert an array with a single dimension to be a row vector.
633  // Octave should never write files like this, other software
634  // might.
635 
636  if (mdims == 1)
637  {
638  mdims = 2;
639  dv.resize (mdims);
640  dv(1) = dv(0);
641  dv(0) = 1;
642  }
643 
644  if (! is.read (reinterpret_cast<char *> (&tmp), 1))
645  return false;
646 
647  NDArray m(dv);
648  double *re = m.fortran_vec ();
649  read_doubles (is, re, static_cast<save_type> (tmp), dv.numel (),
650  swap, fmt);
651 
652  if (! is)
653  return false;
654 
655  matrix = m;
656  }
657  else
658  {
659  int32_t nr, nc;
660  nr = mdims;
661  if (! is.read (reinterpret_cast<char *> (&nc), 4))
662  return false;
663  if (swap)
664  swap_bytes<4> (&nc);
665  if (! is.read (reinterpret_cast<char *> (&tmp), 1))
666  return false;
667  Matrix m (nr, nc);
668  double *re = m.fortran_vec ();
669  octave_idx_type len = nr * nc;
670  read_doubles (is, re, static_cast<save_type> (tmp), len, swap, fmt);
671 
672  if (! is)
673  return false;
674 
675  matrix = m;
676  }
677  return true;
678 }
679 
680 bool
682  bool save_as_floats)
683 {
684  bool retval = false;
685 
686 #if defined (HAVE_HDF5)
687 
688  dim_vector dv = dims ();
689  int empty = save_hdf5_empty (loc_id, name, dv);
690  if (empty)
691  return (empty > 0);
692 
693  int rank = dv.ndims ();
694  hid_t space_hid, data_hid;
695  space_hid = data_hid = -1;
696  NDArray m = array_value ();
697 
698  OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
699 
700  // Octave uses column-major, while HDF5 uses row-major ordering
701  for (int i = 0; i < rank; i++)
702  hdims[i] = dv(rank-i-1);
703 
704  space_hid = H5Screate_simple (rank, hdims, 0);
705 
706  if (space_hid < 0) return false;
707 
708  hid_t save_type_hid = H5T_NATIVE_DOUBLE;
709 
710  if (save_as_floats)
711  {
712  if (m.too_large_for_float ())
713  {
714  warning ("save: some values too large to save as floats --");
715  warning ("save: saving as doubles instead");
716  }
717  else
718  save_type_hid = H5T_NATIVE_FLOAT;
719  }
720 #if defined (HAVE_HDF5_INT2FLOAT_CONVERSIONS)
721  // hdf5 currently doesn't support float/integer conversions
722  else
723  {
724  double max_val, min_val;
725 
726  if (m.all_integers (max_val, min_val))
727  save_type_hid
728  = save_type_to_hdf5 (get_save_type (max_val, min_val));
729  }
730 #endif
731 
732 #if defined (HAVE_HDF5_18)
733  data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
735 #else
736  data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
738 #endif
739  if (data_hid < 0)
740  {
741  H5Sclose (space_hid);
742  return false;
743  }
744 
745  double *mtmp = m.fortran_vec ();
746  retval = H5Dwrite (data_hid, H5T_NATIVE_DOUBLE, octave_H5S_ALL, octave_H5S_ALL,
747  octave_H5P_DEFAULT, mtmp) >= 0;
748 
749  H5Dclose (data_hid);
750  H5Sclose (space_hid);
751 
752 #else
753  octave_unused_parameter (loc_id);
754  octave_unused_parameter (name);
755  octave_unused_parameter (save_as_floats);
756 
757  warn_save ("hdf5");
758 #endif
759 
760  return retval;
761 }
762 
763 bool
765 {
766  bool retval = false;
767 
768 #if defined (HAVE_HDF5)
769 
770  dim_vector dv;
771  int empty = load_hdf5_empty (loc_id, name, dv);
772  if (empty > 0)
773  matrix.resize (dv);
774  if (empty)
775  return (empty > 0);
776 
777 #if defined (HAVE_HDF5_18)
778  hid_t data_hid = H5Dopen (loc_id, name, octave_H5P_DEFAULT);
779 #else
780  hid_t data_hid = H5Dopen (loc_id, name);
781 #endif
782  hid_t space_id = H5Dget_space (data_hid);
783 
784  hsize_t rank = H5Sget_simple_extent_ndims (space_id);
785 
786  if (rank < 1)
787  {
788  H5Sclose (space_id);
789  H5Dclose (data_hid);
790  return false;
791  }
792 
793  OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
794  OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank);
795 
796  H5Sget_simple_extent_dims (space_id, hdims, maxdims);
797 
798  // Octave uses column-major, while HDF5 uses row-major ordering
799  if (rank == 1)
800  {
801  dv.resize (2);
802  dv(0) = 1;
803  dv(1) = hdims[0];
804  }
805  else
806  {
807  dv.resize (rank);
808  for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
809  dv(j) = hdims[i];
810  }
811 
812  NDArray m (dv);
813  double *re = m.fortran_vec ();
814  if (H5Dread (data_hid, H5T_NATIVE_DOUBLE, octave_H5S_ALL, octave_H5S_ALL,
815  octave_H5P_DEFAULT, re) >= 0)
816  {
817  retval = true;
818  matrix = m;
819  }
820 
821  H5Sclose (space_id);
822  H5Dclose (data_hid);
823 
824 #else
825  octave_unused_parameter (loc_id);
826  octave_unused_parameter (name);
827 
828  warn_load ("hdf5");
829 #endif
830 
831  return retval;
832 }
833 
834 void
835 octave_matrix::print_raw (std::ostream& os,
836  bool pr_as_read_syntax) const
837 {
838  octave_print_internal (os, matrix, pr_as_read_syntax,
840 }
841 
842 mxArray *
844 {
846 
847  double *pr = static_cast<double *> (retval->get_data ());
848 
849  mwSize nel = numel ();
850 
851  const double *p = matrix.data ();
852 
853  for (mwIndex i = 0; i < nel; i++)
854  pr[i] = p[i];
855 
856  return retval;
857 }
858 
859 // This uses a smarter strategy for doing the complex->real mappers. We
860 // allocate an array for a real result and keep filling it until a complex
861 // result is produced.
862 static octave_value
863 do_rc_map (const NDArray& a, Complex (&fcn) (double))
864 {
865  octave_idx_type n = a.numel ();
866  NoAlias<NDArray> rr (a.dims ());
867 
868  for (octave_idx_type i = 0; i < n; i++)
869  {
870  octave_quit ();
871 
872  Complex tmp = fcn (a(i));
873  if (tmp.imag () == 0.0)
874  rr(i) = tmp.real ();
875  else
876  {
877  NoAlias<ComplexNDArray> rc (a.dims ());
878 
879  for (octave_idx_type j = 0; j < i; j++)
880  rc(j) = rr(j);
881 
882  rc(i) = tmp;
883 
884  for (octave_idx_type j = i+1; j < n; j++)
885  {
886  octave_quit ();
887 
888  rc(j) = fcn (a(j));
889  }
890 
891  return new octave_complex_matrix (rc);
892  }
893  }
894 
895  return rr;
896 }
897 
900 {
901  switch (umap)
902  {
903  case umap_imag:
904  return NDArray (matrix.dims (), 0.0);
905 
906  case umap_real:
907  case umap_conj:
908  return matrix;
909 
910  // Mappers handled specially.
911 #define ARRAY_METHOD_MAPPER(UMAP, FCN) \
912  case umap_ ## UMAP: \
913  return octave_value (matrix.FCN ())
914 
918  ARRAY_METHOD_MAPPER (isfinite, isfinite);
919 
920 #define ARRAY_MAPPER(UMAP, TYPE, FCN) \
921  case umap_ ## UMAP: \
922  return octave_value (matrix.map<TYPE> (FCN))
923 
924 #define RC_ARRAY_MAPPER(UMAP, TYPE, FCN) \
925  case umap_ ## UMAP: \
926  return do_rc_map (matrix, FCN)
927 
930  ARRAY_MAPPER (angle, double, octave::math::arg);
934  ARRAY_MAPPER (atan, double, ::atan);
946  ARRAY_MAPPER (ceil, double, ::ceil);
947  ARRAY_MAPPER (cos, double, ::cos);
948  ARRAY_MAPPER (cosh, double, ::cosh);
949  ARRAY_MAPPER (exp, double, ::exp);
952  ARRAY_MAPPER (floor, double, ::floor);
960  ARRAY_MAPPER (sin, double, ::sin);
961  ARRAY_MAPPER (sinh, double, ::sinh);
963  ARRAY_MAPPER (tan, double, ::tan);
964  ARRAY_MAPPER (tanh, double, ::tanh);
965  ARRAY_MAPPER (isna, bool, octave::math::is_NA);
966  ARRAY_MAPPER (xsignbit, double, octave::math::signbit);
967 
968  // Special cases for Matlab compatibility.
969  case umap_xtolower:
970  case umap_xtoupper:
971  return matrix;
972 
973  case umap_xisalnum:
974  case umap_xisalpha:
975  case umap_xisascii:
976  case umap_xiscntrl:
977  case umap_xisdigit:
978  case umap_xisgraph:
979  case umap_xislower:
980  case umap_xisprint:
981  case umap_xispunct:
982  case umap_xisspace:
983  case umap_xisupper:
984  case umap_xisxdigit:
985  case umap_xtoascii:
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
Matrix diag(octave_idx_type k=0) const
Definition: dMatrix.cc:2471
octave_value as_uint16(void) const
Definition: ov-re-mat.cc:290
Complex rc_log10(double x)
Definition: lo-mappers.cc:536
intNDArray< octave_int64 > int64NDArray
Definition: int64NDArray.h:33
octave_value squeeze(void) const
Definition: ov-base-mat.h:74
NDArray array_value(bool=false) const
Definition: ov-re-mat.h:172
charNDArray char_array_value(bool=false) const
Definition: ov-re-mat.cc:220
sortmode is_sorted(sortmode mode=UNSORTED) const
Definition: ov-base-mat.h:144
float erfcx(float x)
Definition: lo-specfun.cc:271
sortmode is_sorted(sortmode mode=UNSORTED) const
Definition: ov-re-mat.cc:388
octave_idx_type columns(void) const
Definition: ov-base.h:319
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
Definition: ov-re-mat.cc:607
function erf(X)
Definition: erf.f:2
octave_value convert_to_str_internal(bool pad, bool force, char type) const
Definition: ov-re-mat.cc:426
int ndims(void) const
Definition: Array.h:590
Complex rc_acosh(double x)
Definition: lo-mappers.cc:468
Complex rc_sqrt(double x)
Definition: lo-mappers.cc:551
sortmode
Definition: oct-sort.h:105
std::complex< double > erfi(std::complex< double > z, double relerr=0)
octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:363
void warn_logical_conversion(void)
Definition: errwarn.cc:353
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:5068
const octave_hdf5_id octave_H5S_ALL
int save_hdf5_empty(octave_hdf5_id loc_id, const char *name, const dim_vector d)
Definition: ls-hdf5.cc:897
FloatNDArray float_array_value(bool=false) const
Definition: ov-re-mat.h:174
intNDArray< octave_uint32 > uint32NDArray
Definition: uint32NDArray.h:33
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:6386
static octave_value do_rc_map(const NDArray &a, Complex(&fcn)(double))
Definition: ov-re-mat.cc:863
save_type get_save_type(double, double)
Definition: ls-utils.cc:35
octave_value reshape(const dim_vector &new_dims) const
Definition: ov-re-mat.cc:335
intNDArray< octave_uint8 > uint8NDArray
Definition: uint8NDArray.h:33
intNDArray< octave_uint16 > uint16NDArray
Definition: uint16NDArray.h:33
bool isnan(double x)
Definition: lo-mappers.cc:347
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
Definition: ov-base-mat.h:150
for large enough k
Definition: lu.cc:606
octave_idx_type numel(void) const
Definition: ov-base-mat.h:112
void resize(int n, int fill_value=0)
Definition: dim-vector.h:316
Complex rc_lgamma(double x)
Definition: lo-specfun.cc:373
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)
octave_value as_int8(void) const
Definition: ov-re-mat.cc:260
double ceil(double x)
Definition: lo-mappers.h:138
octave_value as_uint8(void) const
Definition: ov-re-mat.cc:284
function atanh(X)
Definition: atanh.f:2
octave_value as_int64(void) const
Definition: ov-re-mat.cc:278
void error(const char *fmt,...)
Definition: error.cc:570
octave_value diag(octave_idx_type k=0) const
Definition: ov-re-mat.cc:308
double double_value(bool=false) const
Definition: ov-re-mat.cc:115
void * get_data(void) const
Definition: mxarray.h:449
octave_value map(octave_base_value::unary_mapper_t umap) const
Definition: ov.h:1413
octave_value diag(octave_idx_type k=0) const
Definition: ov-base-mat.h:132
static octave_base_value * default_numeric_demotion_function(const octave_base_value &a)
Definition: ov-re-mat.cc:88
void write_doubles(std::ostream &os, const double *data, save_type type, octave_idx_type len)
Definition: data-conv.cc:886
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
Definition: ov-base.h:169
octave_matrix(void)
Definition: ov-re-mat.h:57
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:482
Complex acos(const Complex &x)
Definition: lo-mappers.cc:90
Matrix matrix_value(bool=false) const
Definition: ov-re-mat.cc:141
double expm1(double x)
Definition: lo-specfun.cc:473
intNDArray< octave_int16 > int16NDArray
Definition: int16NDArray.h:33
double asinh(double x)
Definition: lo-specfun.cc:105
bool any_element_is_nan(void) const
Definition: dNDArray.cc:555
double fix(double x)
Definition: lo-mappers.h:158
FloatMatrix float_matrix_value(bool=false) const
Definition: ov-re-mat.cc:147
FloatComplexMatrix float_complex_matrix_value(bool=false) const
Definition: ov-re-mat.cc:191
FloatComplex float_complex_value(bool=false) const
Definition: ov-re-mat.cc:165
Complex asin(const Complex &x)
Definition: lo-mappers.cc:150
void err_nan_to_logical_conversion(void)
#define RC_ARRAY_MAPPER(UMAP, TYPE, FCN)
double cbrt(double x)
Definition: lo-specfun.cc:648
FloatComplexNDArray float_complex_array_value(bool=false) const
Definition: ov-re-mat.cc:203
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
Definition: ov-re-mat.cc:400
double arg(double x)
Definition: lo-mappers.h:83
type_conv_info numeric_demotion_function(void) const
Definition: ov-re-mat.cc:96
bool is_empty(void) const
Definition: ov-base.h:355
octave_idx_type rows(void) const
Definition: Array.h:401
octave_value arg
Definition: pr-output.cc:3440
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
Definition: dim-vector.h:389
double round(double x)
Definition: lo-mappers.cc:333
octave_function * fcn
Definition: ov-class.cc:1743
bool is_NA(double x)
Definition: lo-mappers.cc:54
octave_value as_uint32(void) const
Definition: ov-re-mat.cc:296
octave_value as_double(void) const
Definition: ov-re-mat.cc:248
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &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 F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
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:398
bool swap
Definition: load-save.cc:725
octave_value map(unary_mapper_t umap) const
Definition: ov-re-mat.cc:899
Complex rc_atanh(double x)
Definition: lo-mappers.cc:493
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
Definition: ov-re-mat.cc:835
bool any_element_not_one_or_zero(void) const
Definition: dNDArray.cc:567
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
Definition: ov-re-mat.cc:764
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
Definition: Array.h:439
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
Definition: ov-lazy-idx.cc:104
float erfi(float x)
Definition: lo-specfun.cc:289
void warn_load(const char *type) const
Definition: ov-base.cc:1151
octave_base_value * try_narrowing_conversion(void)
Definition: ov-re-mat.cc:104
bool all_integers(double &max_val, double &min_val) const
Definition: dNDArray.cc:588
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:1688
OCTAVE_EXPORT octave_value_list any number nd example oindent prints the prompt xample Pick a any number!nd example oindent and waits for the user to enter a value The string entered by the user is evaluated as an so it may be a literal a variable name
Definition: input.cc:871
double gamma(double x)
Definition: lo-specfun.cc:325
void swap_bytes< 4 >(void *ptr)
Definition: byte-swap.h:60
Complex atan(const Complex &x)
Definition: lo-mappers.cc:210
NDArray squeeze(void) const
Definition: dNDArray.h:142
intNDArray< octave_int8 > int8NDArray
Definition: int8NDArray.h:33
SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
Definition: ov-re-mat.cc:239
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
Definition: ls-oct-text.cc:80
function asinh(X)
Definition: asinh.f:2
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:771
nd deftypefn *octave_map m
Definition: ov-struct.cc:2058
octave_value as_single(void) const
Definition: ov-re-mat.cc:254
boolNDArray bool_array_value(bool warn=false) const
Definition: ov-re-mat.cc:209
double signum(double x)
Definition: lo-mappers.h:259
float dawson(float x)
Definition: lo-specfun.cc:307
const T * data(void) const
Definition: Array.h:582
bool save_as_floats
Definition: load-save.cc:1581
Complex rc_log2(double x)
Definition: lo-mappers.cc:521
void resize(const dim_vector &dv, const T &rfv)
Definition: Array.cc:1028
Array< T > squeeze(void) const
Chop off leading singleton dimensions.
Definition: Array.cc:125
octave_hdf5_id save_type_to_hdf5(save_type st)
Definition: ls-hdf5.cc:997
double tmp
Definition: data.cc:6300
octave_value retval
Definition: data.cc:6294
Complex rc_log(double x)
Definition: lo-mappers.cc:506
#define panic_impossible()
Definition: error.h:40
double signbit(double x)
Definition: lo-mappers.cc:321
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:469
octave_value reshape(const dim_vector &new_dims) const
Definition: ov-base-mat.h:118
idx type
Definition: ov.cc:3129
Complex complex_value(bool=false) const
Definition: ov-re-mat.cc:153
Definition: dMatrix.h:37
octave_value as_uint64(void) const
Definition: ov-re-mat.cc:302
ComplexMatrix complex_matrix_value(bool=false) const
Definition: ov-re-mat.cc:185
float lo_ieee_float_nan_value(void)
Definition: lo-ieee.cc:202
void warn_save(const char *type) const
Definition: ov-base.cc:1160
double erfcinv(double x)
Definition: lo-specfun.cc:3049
void mxArray
Definition: mex.h:55
bool isinf(double x)
Definition: lo-mappers.cc:387
function acosh(X)
Definition: acosh.f:2
Array< octave_idx_type > as_array(void) const
Definition: idx-vector.cc:1267
friend class octave_value
Definition: ov-base.h:211
Complex rc_acos(double x)
Definition: lo-mappers.cc:455
void warning(const char *fmt,...)
Definition: error.cc:788
dim_vector dims(void) const
Definition: ov-base-mat.h:110
sortmode is_sorted(sortmode mode=UNSORTED) const
Ordering is auto-detected or can be specified.
Definition: Array.cc:2052
double erf(double x)
Definition: lo-specfun.cc:193
charNDArray max(char d, const charNDArray &m)
Definition: chNDArray.cc:228
octave_idx_type extent(octave_idx_type n) const
Definition: idx-vector.h:544
intNDArray< octave_int32 > int32NDArray
Definition: int32NDArray.h:33
This is a simple wrapper template that will subclass an Array type or any later type derived from ...
Definition: Array.h:888
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:681
=val(i)}if ode{val(i)}occurs in table i
Definition: lookup.cc:239
double log1p(double x)
Definition: lo-specfun.cc:587
OCTAVE_EXPORT octave_value_list return the value of the option it must match the dimension of the state and the relative tolerance must also be a vector of the same length tem it must match the dimension of the state and the absolute tolerance must also be a vector of the same length The local error test applied at each integration step is xample roup abs(local error in x(i))<
int current_print_indent_level(void) const
Definition: ov-base.h:830
p
Definition: lu.cc:138
function gamma(X)
Definition: gamma.f:2
bool save_binary(std::ostream &os, bool &save_as_floats)
Definition: ov-re-mat.cc:565
void octave_print_internal(std::ostream &, char, bool)
Definition: pr-output.cc:1722
void warn_implicit_conversion(const char *id, const char *from, const char *to)
Definition: errwarn.cc:332
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
Definition: ov-re-mat.cc:361
Complex rc_asin(double x)
Definition: lo-mappers.cc:480
octave_value as_int16(void) const
Definition: ov-re-mat.cc:266
double roundb(double x)
Definition: lo-mappers.h:189
octave_idx_type ndims(void) const
Number of dimensions.
Definition: dim-vector.h:301
Complex rc_log1p(double x)
Definition: lo-specfun.cc:2872
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Definition: oct-locbuf.h:200
virtual octave_value map(unary_mapper_t) const
Definition: ov-base.cc:1175
mxArray * as_mxArray(void) const
Definition: ov-re-mat.cc:843
Array< T > reshape(octave_idx_type nr, octave_idx_type nc) const
Definition: Array.h:563
double erfinv(double x)
Definition: lo-specfun.cc:2960
float float_value(bool=false) const
Definition: ov-re-mat.cc:127
static int static_type_id(void)
double floor(double x)
Definition: lo-mappers.cc:330
const octave_hdf5_id octave_H5P_DEFAULT
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
Definition: ov-re-mat.cc:413
double erfc(double x)
Definition: lo-specfun.cc:232
octave_value sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
Definition: ov-base-mat.h:138
std::complex< float > FloatComplex
Definition: oct-cmplx.h:32
#define ARRAY_MAPPER(UMAP, TYPE, FCN)
double lgamma(double x)
Definition: lo-specfun.cc:353
Definition: mxarray.h:76
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
Definition: ov-base-mat.h:147
std::complex< double > Complex
Definition: oct-cmplx.h:31
Array< octave_idx_type > sort_rows_idx(sortmode mode=ASCENDING) const
Definition: ov-lazy-idx.cc:149
const T * fortran_vec(void) const
Definition: Array.h:584
bool load_ascii(std::istream &is)
Definition: ov-re-mat.cc:498
MArray< T > reshape(const dim_vector &new_dims) const
Definition: MArray.h:91
#define ARRAY_METHOD_MAPPER(UMAP, FCN)
static const char *const keywords[]
Definition: help.cc:147
write the output to stdout if nargout is
Definition: load-save.cc:1576
void err_nan_to_character_conversion(void)
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
ComplexNDArray complex_array_value(bool=false) const
Definition: ov-re-mat.cc:197
virtual octave_value convert_to_str(bool pad=false, bool force=false, char type= '\'') const
Definition: ov-base.cc:418
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:854
dim_vector dv
Definition: sub2ind.cc:263
sortmode is_sorted_rows(sortmode mode=UNSORTED) const
Ordering is auto-detected or can be specified.
Definition: Array.cc:2105
octave_value squeeze(void) const
Definition: ov-re-mat.cc:348
octave_idx_type columns(void) const
Definition: Array.h:410
double log2(double x)
Definition: lo-mappers.cc:233
octave_value as_int32(void) const
Definition: ov-re-mat.cc:272
octave_idx_type rows(void) const
Definition: ov-base.h:312
bool too_large_for_float(void) const
Definition: dNDArray.cc:624
SparseMatrix sparse_matrix_value(bool=false) const
Definition: ov-re-mat.cc:233
intNDArray< octave_uint64 > uint64NDArray
Definition: uint64NDArray.h:33
int nint(double x)
Definition: lo-mappers.cc:433
std::complex< double > erfc(std::complex< double > z, double relerr=0)