GNU Octave  4.0.0
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-flt-re-mat.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2015 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 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27 
28 #include <iostream>
29 #include <limits>
30 #include <vector>
31 
32 #include "data-conv.h"
33 #include "lo-ieee.h"
34 #include "lo-utils.h"
35 #include "lo-specfun.h"
36 #include "lo-mappers.h"
37 #include "mach-info.h"
38 #include "mx-base.h"
39 #include "quit.h"
40 #include "oct-locbuf.h"
41 
42 #include "defun.h"
43 #include "gripes.h"
44 #include "mxarray.h"
45 #include "oct-obj.h"
46 #include "oct-lvalue.h"
47 #include "oct-hdf5.h"
48 #include "oct-stream.h"
49 #include "ops.h"
50 #include "ov-base.h"
51 #include "ov-base-mat.h"
52 #include "ov-base-mat.cc"
53 #include "ov-scalar.h"
54 #include "ov-float.h"
55 #include "ov-flt-complex.h"
56 #include "ov-re-mat.h"
57 #include "ov-flt-re-mat.h"
58 #include "ov-flt-cx-mat.h"
59 #include "ov-re-sparse.h"
60 #include "ov-flt-re-diag.h"
61 #include "ov-flt-cx-diag.h"
62 #include "ov-type-conv.h"
63 #include "pr-output.h"
64 #include "variables.h"
65 #include "ops.h"
66 
67 #include "byte-swap.h"
68 #include "ls-oct-ascii.h"
69 #include "ls-utils.h"
70 #include "ls-hdf5.h"
71 
73 
74 
76  "single");
77 
80 {
81  octave_base_value *retval = 0;
82 
83  if (matrix.nelem () == 1)
84  retval = new octave_float_scalar (matrix (0));
85 
86  return retval;
87 }
88 
89 double
91 {
92  double retval = lo_ieee_nan_value ();
93 
94  if (numel () > 0)
95  {
96  gripe_implicit_conversion ("Octave:array-to-scalar",
97  "real matrix", "real scalar");
98 
99  retval = matrix (0, 0);
100  }
101  else
102  gripe_invalid_conversion ("real matrix", "real scalar");
103 
104  return retval;
105 }
106 
107 float
109 {
110  float retval = lo_ieee_float_nan_value ();
111 
112  if (numel () > 0)
113  {
114  gripe_implicit_conversion ("Octave:array-to-scalar",
115  "real matrix", "real scalar");
116 
117  retval = matrix (0, 0);
118  }
119  else
120  gripe_invalid_conversion ("real matrix", "real scalar");
121 
122  return retval;
123 }
124 
125 // FIXME
126 
127 Matrix
129 {
130  return Matrix (FloatMatrix (matrix));
131 }
132 
135 {
136  return FloatMatrix (matrix);
137 }
138 
139 Complex
141 {
142  double tmp = lo_ieee_nan_value ();
143 
144  Complex retval (tmp, tmp);
145 
146  if (rows () > 0 && columns () > 0)
147  {
148  gripe_implicit_conversion ("Octave:array-to-scalar",
149  "real matrix", "complex scalar");
150 
151  retval = matrix (0, 0);
152  }
153  else
154  gripe_invalid_conversion ("real matrix", "complex scalar");
155 
156  return retval;
157 }
158 
161 {
162  double tmp = lo_ieee_float_nan_value ();
163 
164  FloatComplex retval (tmp, tmp);
165 
166  if (rows () > 0 && columns () > 0)
167  {
168  gripe_implicit_conversion ("Octave:array-to-scalar",
169  "real matrix", "complex scalar");
170 
171  retval = matrix (0, 0);
172  }
173  else
174  gripe_invalid_conversion ("real matrix", "complex scalar");
175 
176  return retval;
177 }
178 
179 // FIXME
180 
183 {
184  return ComplexMatrix (FloatMatrix (matrix));
185 }
186 
189 {
191 }
192 
195 {
196  return ComplexNDArray (matrix);
197 }
198 
201 {
202  return FloatComplexNDArray (matrix);
203 }
204 
205 NDArray
207 {
208  return NDArray (matrix);
209 }
210 
213 {
214  if (matrix.any_element_is_nan ())
216  else if (warn && matrix.any_element_not_one_or_zero ())
218 
219  return boolNDArray (matrix);
220 }
221 
224 {
225  charNDArray retval (dims ());
226 
227  octave_idx_type nel = numel ();
228 
229  for (octave_idx_type i = 0; i < nel; i++)
230  retval.elem (i) = static_cast<char>(matrix.elem (i));
231 
232  return retval;
233 }
234 
237 {
238  return SparseMatrix (matrix_value ());
239 }
240 
243 {
244  // FIXME: Need a SparseComplexMatrix (Matrix) constructor to make
245  // this function more efficient. Then this should become
246  // return SparseComplexMatrix (matrix.matrix_value ());
248 }
249 
252 {
253  octave_value retval;
254  if (k == 0 && matrix.ndims () == 2
255  && (matrix.rows () == 1 || matrix.columns () == 1))
257  else
259 
260  return retval;
261 }
262 
265 {
266  octave_value retval;
267 
268  if (matrix.ndims () == 2
269  && (matrix.rows () == 1 || matrix.columns () == 1))
270  {
271  FloatMatrix mat (matrix);
272 
273  retval = mat.diag (m, n);
274  }
275  else
276  error ("diag: expecting vector argument");
277 
278  return retval;
279 }
280 
283 {
284  octave_value retval;
285  dim_vector dv = dims ();
286  octave_idx_type nel = dv.numel ();
287 
288  charNDArray chm (dv);
289 
290  bool warned = false;
291 
292  for (octave_idx_type i = 0; i < nel; i++)
293  {
294  octave_quit ();
295 
296  float d = matrix (i);
297 
298  if (xisnan (d))
299  {
301  return retval;
302  }
303  else
304  {
305  int ival = NINT (d);
306 
307  if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
308  {
309  // FIXME: is there something better we could do?
310 
311  ival = 0;
312 
313  if (! warned)
314  {
315  ::warning ("range error for conversion to character value");
316  warned = true;
317  }
318  }
319 
320  chm (i) = static_cast<char> (ival);
321  }
322  }
323 
324  retval = octave_value (chm, type);
325 
326  return retval;
327 }
328 
329 bool
331 {
332  dim_vector d = dims ();
333 
334  if (d.length () > 2)
335  {
337 
338  os << "# ndims: " << d.length () << "\n";
339 
340  for (int i=0; i < d.length (); i++)
341  os << " " << d (i);
342 
343  os << "\n" << tmp;
344  }
345  else
346  {
347  // Keep this case, rather than use generic code above for backward
348  // compatiability. Makes load_ascii much more complex!!
349  os << "# rows: " << rows () << "\n"
350  << "# columns: " << columns () << "\n";
351 
352  os << float_matrix_value ();
353  }
354 
355  return true;
356 }
357 
358 bool
360 {
361  bool success = true;
362 
364 
365  keywords[0] = "ndims";
366  keywords[1] = "rows";
367 
368  std::string kw;
369  octave_idx_type val = 0;
370 
371  if (extract_keyword (is, keywords, kw, val, true))
372  {
373  if (kw == "ndims")
374  {
375  int mdims = static_cast<int> (val);
376 
377  if (mdims >= 0)
378  {
379  dim_vector dv;
380  dv.resize (mdims);
381 
382  for (int i = 0; i < mdims; i++)
383  is >> dv(i);
384 
385  if (is)
386  {
387  FloatNDArray tmp(dv);
388 
389  is >> tmp;
390 
391  if (is)
392  matrix = tmp;
393  else
394  {
395  error ("load: failed to load matrix constant");
396  success = false;
397  }
398  }
399  else
400  {
401  error ("load: failed to read dimensions");
402  success = false;
403  }
404  }
405  else
406  {
407  error ("load: failed to extract number of dimensions");
408  success = false;
409  }
410  }
411  else if (kw == "rows")
412  {
413  octave_idx_type nr = val;
414  octave_idx_type nc = 0;
415 
416  if (nr >= 0 && extract_keyword (is, "columns", nc) && nc >= 0)
417  {
418  if (nr > 0 && nc > 0)
419  {
420  FloatMatrix tmp (nr, nc);
421  is >> tmp;
422  if (is)
423  matrix = tmp;
424  else
425  {
426  error ("load: failed to load matrix constant");
427  success = false;
428  }
429  }
430  else if (nr == 0 || nc == 0)
431  matrix = FloatMatrix (nr, nc);
432  else
433  panic_impossible ();
434  }
435  else
436  {
437  error ("load: failed to extract number of rows and columns");
438  success = false;
439  }
440  }
441  else
442  panic_impossible ();
443  }
444  else
445  {
446  error ("load: failed to extract number of rows and columns");
447  success = false;
448  }
449 
450  return success;
451 }
452 
453 bool
454 octave_float_matrix::save_binary (std::ostream& os, bool&)
455 {
456 
457  dim_vector d = dims ();
458  if (d.length () < 1)
459  return false;
460 
461  // Use negative value for ndims to differentiate with old format!!
462  int32_t tmp = - d.length ();
463  os.write (reinterpret_cast<char *> (&tmp), 4);
464  for (int i = 0; i < d.length (); i++)
465  {
466  tmp = d(i);
467  os.write (reinterpret_cast<char *> (&tmp), 4);
468  }
469 
471  save_type st = LS_FLOAT;
472  if (d.numel () > 8192) // FIXME: make this configurable.
473  {
474  float max_val, min_val;
475  if (m.all_integers (max_val, min_val))
476  st = get_save_type (max_val, min_val);
477  }
478 
479  const float *mtmp = m.data ();
480  write_floats (os, mtmp, st, d.numel ());
481 
482  return true;
483 }
484 
485 bool
486 octave_float_matrix::load_binary (std::istream& is, bool swap,
488 {
489  char tmp;
490  int32_t mdims;
491  if (! is.read (reinterpret_cast<char *> (&mdims), 4))
492  return false;
493  if (swap)
494  swap_bytes<4> (&mdims);
495  if (mdims < 0)
496  {
497  mdims = - mdims;
498  int32_t di;
499  dim_vector dv;
500  dv.resize (mdims);
501 
502  for (int i = 0; i < mdims; i++)
503  {
504  if (! is.read (reinterpret_cast<char *> (&di), 4))
505  return false;
506  if (swap)
507  swap_bytes<4> (&di);
508  dv(i) = di;
509  }
510 
511  // Convert an array with a single dimension to be a row vector.
512  // Octave should never write files like this, other software
513  // might.
514 
515  if (mdims == 1)
516  {
517  mdims = 2;
518  dv.resize (mdims);
519  dv(1) = dv(0);
520  dv(0) = 1;
521  }
522 
523  if (! is.read (reinterpret_cast<char *> (&tmp), 1))
524  return false;
525 
526  FloatNDArray m(dv);
527  float *re = m.fortran_vec ();
528  read_floats (is, re, static_cast<save_type> (tmp), dv.numel (),
529  swap, fmt);
530  if (error_state || ! is)
531  return false;
532  matrix = m;
533  }
534  else
535  {
536  int32_t nr, nc;
537  nr = mdims;
538  if (! is.read (reinterpret_cast<char *> (&nc), 4))
539  return false;
540  if (swap)
541  swap_bytes<4> (&nc);
542  if (! is.read (reinterpret_cast<char *> (&tmp), 1))
543  return false;
544  FloatMatrix m (nr, nc);
545  float *re = m.fortran_vec ();
546  octave_idx_type len = nr * nc;
547  read_floats (is, re, static_cast<save_type> (tmp), len, swap, fmt);
548  if (error_state || ! is)
549  return false;
550  matrix = m;
551  }
552  return true;
553 }
554 
555 bool
556 octave_float_matrix::save_hdf5 (octave_hdf5_id loc_id, const char *name, bool)
557 {
558  bool retval = false;
559 
560 #if defined (HAVE_HDF5)
561 
562  dim_vector dv = dims ();
563  int empty = save_hdf5_empty (loc_id, name, dv);
564  if (empty)
565  return (empty > 0);
566 
567  int rank = dv.length ();
568  hid_t space_hid, data_hid;
569  space_hid = data_hid = -1;
570  FloatNDArray m = array_value ();
571 
572  OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
573 
574  // Octave uses column-major, while HDF5 uses row-major ordering
575  for (int i = 0; i < rank; i++)
576  hdims[i] = dv (rank-i-1);
577 
578  space_hid = H5Screate_simple (rank, hdims, 0);
579 
580  if (space_hid < 0) return false;
581 
582  hid_t save_type_hid = H5T_NATIVE_FLOAT;
583 
584 #if HAVE_HDF5_INT2FLOAT_CONVERSIONS
585  // hdf5 currently doesn't support float/integer conversions
586  else
587  {
588  float max_val, min_val;
589 
590  if (m.all_integers (max_val, min_val))
591  save_type_hid
592  = save_type_to_hdf5 (get_save_type (max_val, min_val));
593  }
594 #endif /* HAVE_HDF5_INT2FLOAT_CONVERSIONS */
595 #if HAVE_HDF5_18
596  data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
597  H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
598 #else
599  data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
600  H5P_DEFAULT);
601 #endif
602  if (data_hid < 0)
603  {
604  H5Sclose (space_hid);
605  return false;
606  }
607 
608  float *mtmp = m.fortran_vec ();
609  retval = H5Dwrite (data_hid, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
610  H5P_DEFAULT, mtmp) >= 0;
611 
612  H5Dclose (data_hid);
613  H5Sclose (space_hid);
614 
615 #else
616  gripe_save ("hdf5");
617 #endif
618 
619  return retval;
620 }
621 
622 bool
624 {
625  bool retval = false;
626 
627 #if defined (HAVE_HDF5)
628 
629  dim_vector dv;
630  int empty = load_hdf5_empty (loc_id, name, dv);
631  if (empty > 0)
632  matrix.resize (dv);
633  if (empty)
634  return (empty > 0);
635 
636 #if HAVE_HDF5_18
637  hid_t data_hid = H5Dopen (loc_id, name, H5P_DEFAULT);
638 #else
639  hid_t data_hid = H5Dopen (loc_id, name);
640 #endif
641  hid_t space_id = H5Dget_space (data_hid);
642 
643  hsize_t rank = H5Sget_simple_extent_ndims (space_id);
644 
645  if (rank < 1)
646  {
647  H5Sclose (space_id);
648  H5Dclose (data_hid);
649  return false;
650  }
651 
652  OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
653  OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank);
654 
655  H5Sget_simple_extent_dims (space_id, hdims, maxdims);
656 
657  // Octave uses column-major, while HDF5 uses row-major ordering
658  if (rank == 1)
659  {
660  dv.resize (2);
661  dv(0) = 1;
662  dv(1) = hdims[0];
663  }
664  else
665  {
666  dv.resize (rank);
667  for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
668  dv(j) = hdims[i];
669  }
670 
671  FloatNDArray m (dv);
672  float *re = m.fortran_vec ();
673  if (H5Dread (data_hid, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL,
674  H5P_DEFAULT, re) >= 0)
675  {
676  retval = true;
677  matrix = m;
678  }
679 
680  H5Sclose (space_id);
681  H5Dclose (data_hid);
682 
683 #else
684  gripe_load ("hdf5");
685 #endif
686 
687  return retval;
688 }
689 
690 void
692  bool pr_as_read_syntax) const
693 {
694  octave_print_internal (os, matrix, pr_as_read_syntax,
696 }
697 
698 mxArray *
700 {
701  mxArray *retval = new mxArray (mxSINGLE_CLASS, dims (), mxREAL);
702 
703  float *pr = static_cast<float *> (retval->get_data ());
704 
705  mwSize nel = numel ();
706 
707  const float *p = matrix.data ();
708 
709  for (mwIndex i = 0; i < nel; i++)
710  pr[i] = p[i];
711 
712  return retval;
713 }
714 
715 // This uses a smarter strategy for doing the complex->real mappers. We
716 // allocate an array for a real result and keep filling it until a complex
717 // result is produced.
718 static octave_value
719 do_rc_map (const FloatNDArray& a, FloatComplex (&fcn) (float))
720 {
721  octave_idx_type n = a.numel ();
722  NoAlias<FloatNDArray> rr (a.dims ());
723 
724  for (octave_idx_type i = 0; i < n; i++)
725  {
726  octave_quit ();
727 
728  FloatComplex tmp = fcn (a(i));
729  if (tmp.imag () == 0.0)
730  rr(i) = tmp.real ();
731  else
732  {
734 
735  for (octave_idx_type j = 0; j < i; j++)
736  rc(j) = rr(j);
737 
738  rc(i) = tmp;
739 
740  for (octave_idx_type j = i+1; j < n; j++)
741  {
742  octave_quit ();
743 
744  rc(j) = fcn (a(j));
745  }
746 
747  return new octave_float_complex_matrix (rc);
748  }
749  }
750 
751  return rr;
752 }
753 
756 {
757  switch (umap)
758  {
759  case umap_imag:
760  return FloatNDArray (matrix.dims (), 0.0);
761 
762  case umap_real:
763  case umap_conj:
764  return matrix;
765 
766  // Mappers handled specially.
767 #define ARRAY_METHOD_MAPPER(UMAP, FCN) \
768  case umap_ ## UMAP: \
769  return octave_value (matrix.FCN ())
770 
772  ARRAY_METHOD_MAPPER (isnan, isnan);
773  ARRAY_METHOD_MAPPER (isinf, isinf);
774  ARRAY_METHOD_MAPPER (finite, isfinite);
775 
776 #define ARRAY_MAPPER(UMAP, TYPE, FCN) \
777  case umap_ ## UMAP: \
778  return octave_value (matrix.map<TYPE> (FCN))
779 
780 #define RC_ARRAY_MAPPER(UMAP, TYPE, FCN) \
781  case umap_ ## UMAP: \
782  return do_rc_map (matrix, FCN)
783 
786  ARRAY_MAPPER (angle, float, ::arg);
787  ARRAY_MAPPER (arg, float, ::arg);
789  ARRAY_MAPPER (asinh, float, ::asinhf);
790  ARRAY_MAPPER (atan, float, ::atanf);
792  ARRAY_MAPPER (erf, float, ::erff);
793  ARRAY_MAPPER (erfinv, float, ::erfinv);
794  ARRAY_MAPPER (erfcinv, float, ::erfcinv);
795  ARRAY_MAPPER (erfc, float, ::erfcf);
796  ARRAY_MAPPER (erfcx, float, ::erfcx);
797  ARRAY_MAPPER (erfi, float, ::erfi);
798  ARRAY_MAPPER (dawson, float, ::dawson);
799  ARRAY_MAPPER (gamma, float, xgamma);
801  ARRAY_MAPPER (cbrt, float, ::cbrtf);
802  ARRAY_MAPPER (ceil, float, ::ceilf);
803  ARRAY_MAPPER (cos, float, ::cosf);
804  ARRAY_MAPPER (cosh, float, ::coshf);
805  ARRAY_MAPPER (exp, float, ::expf);
806  ARRAY_MAPPER (expm1, float, ::expm1f);
807  ARRAY_MAPPER (fix, float, ::fix);
808  ARRAY_MAPPER (floor, float, ::floorf);
813  ARRAY_MAPPER (round, float, xround);
814  ARRAY_MAPPER (roundb, float, xroundb);
815  ARRAY_MAPPER (signum, float, ::signum);
816  ARRAY_MAPPER (sin, float, ::sinf);
817  ARRAY_MAPPER (sinh, float, ::sinhf);
819  ARRAY_MAPPER (tan, float, ::tanf);
820  ARRAY_MAPPER (tanh, float, ::tanhf);
821  ARRAY_MAPPER (isna, bool, octave_is_NA);
822  ARRAY_MAPPER (xsignbit, float, xsignbit);
823 
824  // Special cases for Matlab compatibility.
825  case umap_xtolower:
826  case umap_xtoupper:
827  return matrix;
828 
829  case umap_xisalnum:
830  case umap_xisalpha:
831  case umap_xisascii:
832  case umap_xiscntrl:
833  case umap_xisdigit:
834  case umap_xisgraph:
835  case umap_xislower:
836  case umap_xisprint:
837  case umap_xispunct:
838  case umap_xisspace:
839  case umap_xisupper:
840  case umap_xisxdigit:
841  case umap_xtoascii:
842  {
843  octave_value str_conv = convert_to_str (true, true);
844  return error_state ? octave_value () : str_conv.map (umap);
845  }
846 
847  default:
848  return octave_base_value::map (umap);
849  }
850 }
851 
852 DEFUN (single, args, ,
853  "-*- texinfo -*-\n\
854 @deftypefn {Built-in Function} {} single (@var{x})\n\
855 Convert @var{x} to single precision type.\n\
856 @seealso{double}\n\
857 @end deftypefn")
858 {
859  // The OCTAVE_TYPE_CONV_BODY3 macro declares retval, so they go
860  // inside their own scopes, and we don't declare retval here to
861  // avoid a shadowed declaration warning.
862 
863  if (args.length () == 1)
864  {
865  if (args(0).is_diag_matrix ())
866  {
867  if (args(0).is_complex_type ())
868  {
871  }
872  else
873  {
876  }
877  }
878  else if (args(0).is_sparse_type ())
879  {
880  error ("single: sparse type does not support single precision");
881  }
882  else if (args(0).is_complex_type ())
883  {
886  }
887  else
888  {
891  }
892  }
893  else
894  print_usage ();
895 
896  return octave_value ();
897 }
898 
899 /*
900 %!assert (class (single (1)), "single")
901 %!assert (class (single (1 + i)), "single")
902 %!assert (class (single (int8 (1))), "single")
903 %!assert (class (single (uint8 (1))), "single")
904 %!assert (class (single (int16 (1))), "single")
905 %!assert (class (single (uint16 (1))), "single")
906 %!assert (class (single (int32 (1))), "single")
907 %!assert (class (single (uint32 (1))), "single")
908 %!assert (class (single (int64 (1))), "single")
909 %!assert (class (single (uint64 (1))), "single")
910 %!assert (class (single (true)), "single")
911 %!assert (class (single ("A")), "single")
912 %!error (single (sparse (1)))
913 %!test
914 %! x = diag ([1 3 2]);
915 %! y = single (x);
916 %! assert (class (x), "double");
917 %! assert (class (y), "single");
918 %!test
919 %! x = diag ([i 3 2]);
920 %! y = single (x);
921 %! assert (class (x), "double");
922 %! assert (class (y), "single");
923 */
save_type
Definition: data-conv.h:83
void gripe_implicit_conversion(const char *id, const char *from, const char *to)
Definition: gripes.cc:180
float erfcf(float x)
Definition: lo-specfun.cc:280
Complex rc_asin(double x)
Definition: lo-mappers.cc:536
void write_floats(std::ostream &os, const float *data, save_type type, octave_idx_type len)
Definition: data-conv.cc:943
T xsignbit(T x)
Definition: lo-mappers.h:378
octave_value convert_to_str_internal(bool pad, bool force, char type) const
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
double xround(double x)
Definition: lo-mappers.cc:63
bool xisnan(double x)
Definition: lo-mappers.cc:144
octave_idx_type columns(void) const
Definition: ov-base.h:301
double cbrt(double x)
Definition: lo-specfun.cc:662
octave_value diag(octave_idx_type k=0) const
double log1p(double x)
Definition: lo-specfun.cc:620
double erfcinv(double x)
Definition: lo-specfun.cc:3151
int ndims(void) const
Definition: Array.h:487
OCTINTERP_API void print_usage(void)
Definition: defun.cc:51
NDArray array_value(bool=false) const
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:275
void gripe_load(const char *type) const
Definition: ov-base.cc:1258
save_type get_save_type(double, double)
Definition: ls-utils.cc:35
Complex rc_acos(double x)
Definition: lo-mappers.cc:512
float erff(float x)
Definition: lo-specfun.cc:260
SparseMatrix sparse_matrix_value(bool=false) const
octave_idx_type numel(void) const
Definition: ov-base-mat.h:103
void resize(int n, int fill_value=0)
Definition: dim-vector.h:287
float cbrtf(float x)
Definition: lo-specfun.cc:721
function atanh(X)
Definition: atanh.f:2
#define DEFUN(name, args_name, nargout_name, doc)
Definition: defun.h:44
void error(const char *fmt,...)
Definition: error.cc:476
FloatMatrix diag(octave_idx_type k=0) const
Definition: fMatrix.cc:2721
void * get_data(void) const
Definition: mxarray.h:433
octave_value map(octave_base_value::unary_mapper_t umap) const
Definition: ov.h:1226
octave_value diag(octave_idx_type k=0) const
Definition: ov-base-mat.h:123
FloatMatrix float_matrix_value(bool=false) const
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
Definition: ov-base.h:164
#define ARRAY_METHOD_MAPPER(UMAP, FCN)
void gripe_save(const char *type) const
Definition: ov-base.cc:1267
#define ARRAY_MAPPER(UMAP, TYPE, FCN)
bool any_element_is_nan(void) const
Definition: fNDArray.cc:524
T & elem(octave_idx_type n)
Definition: Array.h:380
double lo_ieee_nan_value(void)
Definition: lo-ieee.cc:126
double expm1(double x)
Definition: lo-specfun.cc:510
mxArray * as_mxArray(void) const
float float_value(bool=false) const
std::complex< double > erf(std::complex< double > z, double relerr=0)
octave_idx_type rows(void) const
Definition: Array.h:313
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
Definition: dim-vector.h:361
F77_RET_T const double const double double * d
int load_hdf5_empty(hid_t loc_id, const char *name, dim_vector &d)
Definition: ls-hdf5.cc:790
subroutine xgamma(x, result)
Definition: xgamma.f:1
octave_idx_type nelem(void) const
Number of elements in the array.
Definition: Array.h:271
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
Definition: Array.h:337
double signum(double x)
Definition: lo-mappers.cc:80
Complex rc_log1p(double x)
Definition: lo-specfun.cc:2977
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
Definition: ls-oct-ascii.cc:80
void swap_bytes< 4 >(void *ptr)
Definition: byte-swap.h:59
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
Complex rc_lgamma(double x)
Definition: lo-specfun.cc:411
ComplexNDArray complex_array_value(bool=false) const
function asinh(X)
Definition: asinh.f:2
void gripe_nan_to_logical_conversion(void)
std::complex< T > ceil(const std::complex< T > &x)
Definition: lo-mappers.h:275
#define OCTAVE_TYPE_CONV_BODY3(NAME, MATRIX_RESULT_T, SCALAR_RESULT_T)
Definition: ov-type-conv.h:77
bool any_element_not_one_or_zero(void) const
Definition: fNDArray.cc:536
bool save_ascii(std::ostream &os)
const T * data(void) const
Definition: Array.h:479
int error_state
Definition: error.cc:101
SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
void resize(const dim_vector &dv, const T &rfv)
Definition: Array.cc:1033
Complex rc_sqrt(double x)
Definition: lo-mappers.cc:606
#define panic_impossible()
Definition: error.h:33
void gripe_nan_to_character_conversion(void)
Complex rc_log(double x)
Definition: lo-mappers.cc:561
Complex rc_log2(double x)
Definition: lo-mappers.cc:577
std::complex< double > erfcx(std::complex< double > z, double relerr=0)
double xroundb(double x)
Definition: lo-mappers.cc:69
bool load_ascii(std::istream &is)
Complex rc_atanh(double x)
Definition: lo-mappers.cc:548
FloatNDArray float_array_value(bool=false) const
Definition: dMatrix.h:35
boolNDArray bool_array_value(bool warn=false) const
int NINT(double x)
Definition: lo-mappers.cc:657
double double_value(bool=false) const
double erfinv(double x)
Definition: lo-specfun.cc:3063
Matrix matrix_value(bool=false) const
float lo_ieee_float_nan_value(void)
Definition: lo-ieee.cc:202
Complex rc_log10(double x)
Definition: lo-mappers.cc:591
void mxArray
Definition: mex.h:53
function acosh(X)
Definition: acosh.f:2
double arg(double x)
Definition: lo-mappers.h:37
friend class octave_value
Definition: ov-base.h:206
void warning(const char *fmt,...)
Definition: error.cc:681
dim_vector dims(void) const
Definition: ov-base-mat.h:101
charNDArray max(char d, const charNDArray &m)
Definition: chNDArray.cc:233
float expm1f(float x)
Definition: lo-specfun.cc:565
bool save_binary(std::ostream &os, bool &save_as_floats)
This is a simple wrapper template that will subclass an Array type or any later type derived from ...
Definition: Array.h:762
void gripe_logical_conversion(void)
Definition: gripes.cc:201
Complex rc_acosh(double x)
Definition: lo-mappers.cc:524
float asinhf(float x)
Definition: lo-specfun.cc:220
void gripe_invalid_conversion(const std::string &from, const std::string &to)
Definition: gripes.cc:99
octave_value map(unary_mapper_t umap) const
int current_print_indent_level(void) const
Definition: ov-base.h:805
function gamma(X)
Definition: gamma.f:2
void octave_print_internal(std::ostream &, char, bool)
Definition: pr-output.cc:1715
bool all_integers(float &max_val, float &min_val) const
Definition: fNDArray.cc:557
FloatComplex float_complex_value(bool=false) const
int save_hdf5_empty(hid_t loc_id, const char *name, const dim_vector d)
Definition: ls-hdf5.cc:740
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Definition: oct-locbuf.h:197
virtual octave_value map(unary_mapper_t) const
Definition: ov-base.cc:1276
double fix(double x)
Definition: lo-mappers.h:39
static octave_value do_rc_map(const FloatNDArray &a, FloatComplex(&fcn)(float))
float dawson(float x)
Definition: lo-specfun.cc:349
static const pair_type keywords[]
Definition: help.cc:445
Complex asin(const Complex &x)
Definition: lo-mappers.cc:204
#define RC_ARRAY_MAPPER(UMAP, TYPE, FCN)
ComplexMatrix complex_matrix_value(bool=false) const
std::complex< float > FloatComplex
Definition: oct-cmplx.h:30
std::complex< T > floor(const std::complex< T > &x)
Definition: lo-mappers.h:282
FloatComplexMatrix float_complex_matrix_value(bool=false) const
Definition: mxarray.h:52
std::complex< double > Complex
Definition: oct-cmplx.h:29
const T * fortran_vec(void) const
Definition: Array.h:481
charNDArray char_array_value(bool=false) const
Complex acos(const Complex &x)
Definition: lo-mappers.cc:177
octave_base_value * try_narrowing_conversion(void)
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
virtual octave_value convert_to_str(bool pad=false, bool force=false, char type= '\'') const
Definition: ov-base.cc:373
T abs(T x)
Definition: pr-output.cc:3062
int length(void) const
Definition: dim-vector.h:281
Complex atan(const Complex &x)
Definition: lo-mappers.cc:231
Complex complex_value(bool=false) const
octave_idx_type columns(void) const
Definition: Array.h:322
void read_floats(std::istream &is, float *data, save_type type, octave_idx_type len, bool swap, oct_mach_info::float_format fmt)
Definition: data-conv.cc:837
octave_idx_type rows(void) const
Definition: ov-base.h:294
bool load_binary(std::istream &is, bool swap, oct_mach_info::float_format fmt)
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))
FloatComplexNDArray float_complex_array_value(bool=false) const
bool octave_is_NA(double x)
Definition: lo-mappers.cc:167
std::complex< double > erfc(std::complex< double > z, double relerr=0)