GNU Octave  4.4.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
ov-flt-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-float.h"
66 #include "ov-flt-complex.h"
67 #include "ov-re-mat.h"
68 #include "ov-flt-re-mat.h"
69 #include "ov-flt-cx-mat.h"
70 #include "ov-re-sparse.h"
71 #include "ov-flt-re-diag.h"
72 #include "ov-flt-cx-diag.h"
73 #include "pr-output.h"
74 #include "variables.h"
75 #include "ops.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 
84 
86  "single");
87 
90 {
91  octave_base_value *retval = nullptr;
92 
93  if (matrix.numel () == 1)
94  retval = new octave_float_scalar (matrix (0));
95 
96  return retval;
97 }
98 
99 double
101 {
102  if (isempty ())
103  err_invalid_conversion ("real matrix", "real scalar");
104 
105  warn_implicit_conversion ("Octave:array-to-scalar",
106  "real matrix", "real scalar");
107 
108  return matrix(0, 0);
109 }
110 
111 float
113 {
114  if (isempty ())
115  err_invalid_conversion ("real matrix", "real scalar");
116 
117  warn_implicit_conversion ("Octave:array-to-scalar",
118  "real matrix", "real scalar");
119 
120  return matrix(0, 0);
121 }
122 
123 // FIXME
124 
125 Matrix
127 {
128  return Matrix (FloatMatrix (matrix));
129 }
130 
133 {
134  return FloatMatrix (matrix);
135 }
136 
137 Complex
139 {
140  if (rows () == 0 || columns () == 0)
141  err_invalid_conversion ("real matrix", "complex scalar");
142 
143  warn_implicit_conversion ("Octave:array-to-scalar",
144  "real matrix", "complex scalar");
145 
146  return Complex (matrix(0, 0), 0);
147 }
148 
151 {
152  double tmp = lo_ieee_float_nan_value ();
153 
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  retval = matrix(0, 0);
163 
164  return retval;
165 }
166 
167 // FIXME
168 
171 {
172  return ComplexMatrix (FloatMatrix (matrix));
173 }
174 
177 {
179 }
180 
183 {
184  return ComplexNDArray (matrix);
185 }
186 
189 {
190  return FloatComplexNDArray (matrix);
191 }
192 
193 NDArray
195 {
196  return NDArray (matrix);
197 }
198 
201 {
202  if (matrix.any_element_is_nan ())
204  if (warn && matrix.any_element_not_one_or_zero ())
206 
207  return boolNDArray (matrix);
208 }
209 
212 {
213  charNDArray retval (dims ());
214 
215  octave_idx_type nel = numel ();
216 
217  for (octave_idx_type i = 0; i < nel; i++)
218  retval.elem (i) = static_cast<char>(matrix.elem (i));
219 
220  return retval;
221 }
222 
225 {
226  return SparseMatrix (matrix_value ());
227 }
228 
231 {
232  // FIXME: Need a SparseComplexMatrix (Matrix) constructor to make
233  // this function more efficient. Then this should become
234  // return SparseComplexMatrix (matrix.matrix_value ());
236 }
237 
240 {
241  return NDArray (matrix);
242 }
243 
246 {
247  return FloatNDArray (matrix);
248 }
249 
252 {
253  return int8NDArray (matrix);
254 }
255 
258 {
259  return int16NDArray (matrix);
260 }
261 
264 {
265  return int32NDArray (matrix);
266 }
267 
270 {
271  return int64NDArray (matrix);
272 }
273 
276 {
277  return uint8NDArray (matrix);
278 }
279 
282 {
283  return uint16NDArray (matrix);
284 }
285 
288 {
289  return uint32NDArray (matrix);
290 }
291 
294 {
295  return uint64NDArray (matrix);
296 }
297 
300 {
302  if (k == 0 && matrix.ndims () == 2
303  && (matrix.rows () == 1 || matrix.columns () == 1))
305  else
307 
308  return retval;
309 }
310 
313 {
314  if (matrix.ndims () != 2
315  || (matrix.rows () != 1 && matrix.columns () != 1))
316  error ("diag: expecting vector argument");
317 
318  FloatMatrix mat (matrix);
319 
320  return mat.diag (m, n);
321 }
322 
325 {
327  dim_vector dv = dims ();
328  octave_idx_type nel = dv.numel ();
329 
330  charNDArray chm (dv);
331 
332  bool warned = false;
333 
334  for (octave_idx_type i = 0; i < nel; i++)
335  {
336  octave_quit ();
337 
338  float d = matrix(i);
339 
340  if (octave::math::isnan (d))
342 
343  int ival = octave::math::nint (d);
344 
345  if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
346  {
347  // FIXME: is there something better we could do?
348 
349  ival = 0;
350 
351  if (! warned)
352  {
353  ::warning ("range error for conversion to character value");
354  warned = true;
355  }
356  }
357 
358  chm(i) = static_cast<char> (ival);
359  }
360 
361  retval = octave_value (chm, type);
362 
363  return retval;
364 }
365 
366 bool
368 {
369  dim_vector dv = dims ();
370 
371  if (dv.ndims () > 2)
372  {
374 
375  os << "# ndims: " << dv.ndims () << "\n";
376 
377  for (int i=0; i < dv.ndims (); i++)
378  os << ' ' << dv(i);
379 
380  os << "\n" << tmp;
381  }
382  else
383  {
384  // Keep this case, rather than use generic code above for backward
385  // compatibility. Makes load_ascii much more complex!!
386  os << "# rows: " << rows () << "\n"
387  << "# columns: " << columns () << "\n";
388 
389  os << float_matrix_value ();
390  }
391 
392  return true;
393 }
394 
395 bool
397 {
398  string_vector keywords(2);
399 
400  keywords[0] = "ndims";
401  keywords[1] = "rows";
402 
403  std::string kw;
404  octave_idx_type val = 0;
405 
406  if (! extract_keyword (is, keywords, kw, val, true))
407  error ("load: failed to extract number of rows and columns");
408 
409  if (kw == "ndims")
410  {
411  int mdims = static_cast<int> (val);
412 
413  if (mdims < 0)
414  error ("load: failed to extract number of dimensions");
415 
416  dim_vector dv;
417  dv.resize (mdims);
418 
419  for (int i = 0; i < mdims; i++)
420  is >> dv(i);
421 
422  if (! is)
423  error ("load: failed to read dimensions");
424 
426 
427  is >> tmp;
428 
429  if (! is)
430  error ("load: failed to load matrix constant");
431 
432  matrix = tmp;
433  }
434  else if (kw == "rows")
435  {
436  octave_idx_type nr = val;
437  octave_idx_type nc = 0;
438 
439  if (nr < 0 || ! extract_keyword (is, "columns", nc) || nc < 0)
440  error ("load: failed to extract number of rows and columns");
441 
442  if (nr > 0 && nc > 0)
443  {
444  FloatMatrix tmp (nr, nc);
445  is >> tmp;
446  if (! is)
447  error ("load: failed to load matrix constant");
448 
449  matrix = tmp;
450  }
451  else if (nr == 0 || nc == 0)
452  matrix = FloatMatrix (nr, nc);
453  else
454  panic_impossible ();
455  }
456  else
457  panic_impossible ();
458 
459  return true;
460 }
461 
462 bool
463 octave_float_matrix::save_binary (std::ostream& os, bool&)
464 {
465  dim_vector dv = dims ();
466  if (dv.ndims () < 1)
467  return false;
468 
469  // Use negative value for ndims to differentiate with old format!!
470  int32_t tmp = - dv.ndims ();
471  os.write (reinterpret_cast<char *> (&tmp), 4);
472  for (int i = 0; i < dv.ndims (); i++)
473  {
474  tmp = dv(i);
475  os.write (reinterpret_cast<char *> (&tmp), 4);
476  }
477 
479  save_type st = LS_FLOAT;
480  if (dv.numel () > 8192) // FIXME: make this configurable.
481  {
482  float max_val, min_val;
483  if (m.all_integers (max_val, min_val))
484  st = get_save_type (max_val, min_val);
485  }
486 
487  const float *mtmp = m.data ();
488  write_floats (os, mtmp, st, dv.numel ());
489 
490  return true;
491 }
492 
493 bool
496 {
497  char tmp;
498  int32_t mdims;
499  if (! is.read (reinterpret_cast<char *> (&mdims), 4))
500  return false;
501  if (swap)
502  swap_bytes<4> (&mdims);
503  if (mdims < 0)
504  {
505  mdims = - mdims;
506  int32_t di;
507  dim_vector dv;
508  dv.resize (mdims);
509 
510  for (int i = 0; i < mdims; i++)
511  {
512  if (! is.read (reinterpret_cast<char *> (&di), 4))
513  return false;
514  if (swap)
515  swap_bytes<4> (&di);
516  dv(i) = di;
517  }
518 
519  // Convert an array with a single dimension to be a row vector.
520  // Octave should never write files like this, other software
521  // might.
522 
523  if (mdims == 1)
524  {
525  mdims = 2;
526  dv.resize (mdims);
527  dv(1) = dv(0);
528  dv(0) = 1;
529  }
530 
531  if (! is.read (reinterpret_cast<char *> (&tmp), 1))
532  return false;
533 
534  FloatNDArray m(dv);
535  float *re = m.fortran_vec ();
536  read_floats (is, re, static_cast<save_type> (tmp), dv.numel (),
537  swap, fmt);
538 
539  if (! is)
540  return false;
541 
542  matrix = m;
543  }
544  else
545  {
546  int32_t nr, nc;
547  nr = mdims;
548  if (! is.read (reinterpret_cast<char *> (&nc), 4))
549  return false;
550  if (swap)
551  swap_bytes<4> (&nc);
552  if (! is.read (reinterpret_cast<char *> (&tmp), 1))
553  return false;
554  FloatMatrix m (nr, nc);
555  float *re = m.fortran_vec ();
556  octave_idx_type len = nr * nc;
557  read_floats (is, re, static_cast<save_type> (tmp), len, swap, fmt);
558 
559  if (! is)
560  return false;
561 
562  matrix = m;
563  }
564  return true;
565 }
566 
567 bool
569 {
570  bool retval = false;
571 
572 #if defined (HAVE_HDF5)
573 
574  dim_vector dv = dims ();
575  int empty = save_hdf5_empty (loc_id, name, dv);
576  if (empty)
577  return (empty > 0);
578 
579  int rank = dv.ndims ();
580  hid_t space_hid, data_hid;
581  space_hid = data_hid = -1;
582  FloatNDArray m = array_value ();
583 
584  OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
585 
586  // Octave uses column-major, while HDF5 uses row-major ordering
587  for (int i = 0; i < rank; i++)
588  hdims[i] = dv(rank-i-1);
589 
590  space_hid = H5Screate_simple (rank, hdims, nullptr);
591 
592  if (space_hid < 0) return false;
593 
594  hid_t save_type_hid = H5T_NATIVE_FLOAT;
595 
596 #if defined (HAVE_HDF5_INT2FLOAT_CONVERSIONS)
597  // hdf5 currently doesn't support float/integer conversions
598  else
599  {
600  float max_val, min_val;
601 
602  if (m.all_integers (max_val, min_val))
603  save_type_hid
604  = save_type_to_hdf5 (get_save_type (max_val, min_val));
605  }
606 #endif
607 #if defined (HAVE_HDF5_18)
608  data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
610 #else
611  data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
613 #endif
614  if (data_hid < 0)
615  {
616  H5Sclose (space_hid);
617  return false;
618  }
619 
620  float *mtmp = m.fortran_vec ();
621  retval = H5Dwrite (data_hid, H5T_NATIVE_FLOAT, octave_H5S_ALL, octave_H5S_ALL,
622  octave_H5P_DEFAULT, mtmp) >= 0;
623 
624  H5Dclose (data_hid);
625  H5Sclose (space_hid);
626 
627 #else
628  octave_unused_parameter (loc_id);
629  octave_unused_parameter (name);
630 
631  warn_save ("hdf5");
632 #endif
633 
634  return retval;
635 }
636 
637 bool
639 {
640  bool retval = false;
641 
642 #if defined (HAVE_HDF5)
643 
644  dim_vector dv;
645  int empty = load_hdf5_empty (loc_id, name, dv);
646  if (empty > 0)
647  matrix.resize (dv);
648  if (empty)
649  return (empty > 0);
650 
651 #if defined (HAVE_HDF5_18)
652  hid_t data_hid = H5Dopen (loc_id, name, octave_H5P_DEFAULT);
653 #else
654  hid_t data_hid = H5Dopen (loc_id, name);
655 #endif
656  hid_t space_id = H5Dget_space (data_hid);
657 
658  hsize_t rank = H5Sget_simple_extent_ndims (space_id);
659 
660  if (rank < 1)
661  {
662  H5Sclose (space_id);
663  H5Dclose (data_hid);
664  return false;
665  }
666 
667  OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
668  OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank);
669 
670  H5Sget_simple_extent_dims (space_id, hdims, maxdims);
671 
672  // Octave uses column-major, while HDF5 uses row-major ordering
673  if (rank == 1)
674  {
675  dv.resize (2);
676  dv(0) = 1;
677  dv(1) = hdims[0];
678  }
679  else
680  {
681  dv.resize (rank);
682  for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
683  dv(j) = hdims[i];
684  }
685 
686  FloatNDArray m (dv);
687  float *re = m.fortran_vec ();
688  if (H5Dread (data_hid, H5T_NATIVE_FLOAT, octave_H5S_ALL, octave_H5S_ALL,
689  octave_H5P_DEFAULT, re) >= 0)
690  {
691  retval = true;
692  matrix = m;
693  }
694 
695  H5Sclose (space_id);
696  H5Dclose (data_hid);
697 
698 #else
699  octave_unused_parameter (loc_id);
700  octave_unused_parameter (name);
701 
702  warn_load ("hdf5");
703 #endif
704 
705  return retval;
706 }
707 
708 void
710  bool pr_as_read_syntax) const
711 {
712  octave_print_internal (os, matrix, pr_as_read_syntax,
714 }
715 
716 mxArray *
718 {
720 
721  float *pr = static_cast<float *> (retval->get_data ());
722 
723  mwSize nel = numel ();
724 
725  const float *p = matrix.data ();
726 
727  for (mwIndex i = 0; i < nel; i++)
728  pr[i] = p[i];
729 
730  return retval;
731 }
732 
733 // This uses a smarter strategy for doing the complex->real mappers. We
734 // allocate an array for a real result and keep filling it until a complex
735 // result is produced.
736 static octave_value
738 {
739  octave_idx_type n = a.numel ();
740  NoAlias<FloatNDArray> rr (a.dims ());
741 
742  for (octave_idx_type i = 0; i < n; i++)
743  {
744  octave_quit ();
745 
746  FloatComplex tmp = fcn (a(i));
747  if (tmp.imag () == 0.0)
748  rr(i) = tmp.real ();
749  else
750  {
751  NoAlias<FloatComplexNDArray> rc (a.dims ());
752 
753  for (octave_idx_type j = 0; j < i; j++)
754  rc(j) = rr(j);
755 
756  rc(i) = tmp;
757 
758  for (octave_idx_type j = i+1; j < n; j++)
759  {
760  octave_quit ();
761 
762  rc(j) = fcn (a(j));
763  }
764 
765  return new octave_float_complex_matrix (rc);
766  }
767  }
768 
769  return rr;
770 }
771 
774 {
775  switch (umap)
776  {
777  case umap_imag:
778  return FloatNDArray (matrix.dims (), 0.0);
779 
780  case umap_real:
781  case umap_conj:
782  return matrix;
783 
784  // Mappers handled specially.
785 #define ARRAY_METHOD_MAPPER(UMAP, FCN) \
786  case umap_ ## UMAP: \
787  return octave_value (matrix.FCN ())
788 
793 
794 #define ARRAY_MAPPER(UMAP, TYPE, FCN) \
795  case umap_ ## UMAP: \
796  return octave_value (matrix.map<TYPE> (FCN))
797 
798 #define RC_ARRAY_MAPPER(UMAP, TYPE, FCN) \
799  case umap_ ## UMAP: \
800  return do_rc_map (matrix, FCN)
801 
804  ARRAY_MAPPER (angle, float, std::arg);
805  ARRAY_MAPPER (arg, float, std::arg);
808  ARRAY_MAPPER (atan, float, ::atanf);
820  ARRAY_MAPPER (ceil, float, ::ceilf);
821  ARRAY_MAPPER (cos, float, ::cosf);
822  ARRAY_MAPPER (cosh, float, ::coshf);
823  ARRAY_MAPPER (exp, float, ::expf);
826  ARRAY_MAPPER (floor, float, ::floorf);
834  ARRAY_MAPPER (sin, float, ::sinf);
835  ARRAY_MAPPER (sinh, float, ::sinhf);
837  ARRAY_MAPPER (tan, float, ::tanf);
838  ARRAY_MAPPER (tanh, float, ::tanhf);
840  ARRAY_MAPPER (xsignbit, float, octave::math::signbit);
841 
842  // Special cases for Matlab compatibility.
843  case umap_xtolower:
844  case umap_xtoupper:
845  return matrix;
846 
847  case umap_xisalnum:
848  case umap_xisalpha:
849  case umap_xisascii:
850  case umap_xiscntrl:
851  case umap_xisdigit:
852  case umap_xisgraph:
853  case umap_xislower:
854  case umap_xisprint:
855  case umap_xispunct:
856  case umap_xisspace:
857  case umap_xisupper:
858  case umap_xisxdigit:
859  {
860  octave_value str_conv = convert_to_str (true, true);
861  return str_conv.map (umap);
862  }
863 
864  default:
865  return octave_base_value::map (umap);
866  }
867 }
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
bool all_integers(float &max_val, float &min_val) const
Definition: fNDArray.cc:538
octave_value as_single(void) const
octave_value map(octave_base_value::unary_mapper_t umap) const
Definition: ov.h:1473
void write_floats(std::ostream &os, const float *data, save_type type, octave_idx_type len)
Definition: data-conv.cc:937
Complex rc_log10(double x)
Definition: lo-mappers.cc:307
intNDArray< octave_int64 > int64NDArray
Definition: int64NDArray.h:33
octave_value as_int64(void) const
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
octave_value as_double(void) const
octave_value as_int16(void) const
octave_value as_uint64(void) const
OCTAVE_IDX_TYPE mwSize
Definition: mxarray.in.h:93
charNDArray char_array_value(bool=false) const
Matrix matrix_value(bool=false) const
const T * data(void) const
Definition: Array.h:582
SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
Complex rc_acosh(double x)
Definition: lo-mappers.cc:241
Complex rc_sqrt(double x)
Definition: lo-mappers.cc:322
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
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:4986
const octave_hdf5_id octave_H5S_ALL
intNDArray< octave_uint32 > uint32NDArray
Definition: uint32NDArray.h:33
double erfi(double x)
Definition: lo-specfun.cc:1775
save_type get_save_type(double, double)
Definition: ls-utils.cc:35
FloatComplex float_complex_value(bool=false) const
intNDArray< octave_uint8 > uint8NDArray
Definition: uint8NDArray.h:33
intNDArray< octave_uint16 > uint16NDArray
Definition: uint16NDArray.h:33
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
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 load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
bool isnan(bool)
Definition: lo-mappers.h:187
std::complex< T > ceil(const std::complex< T > &x)
Definition: lo-mappers.h:112
void error(const char *fmt,...)
Definition: error.cc:578
bool isinf(double x)
Definition: lo-mappers.h:225
std::complex< T > floor(const std::complex< T > &x)
Definition: lo-mappers.h:139
bool any_element_is_nan(void) const
Definition: fNDArray.cc:505
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
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
Definition: ov-base.h:180
#define ARRAY_METHOD_MAPPER(UMAP, FCN)
#define ARRAY_MAPPER(UMAP, TYPE, FCN)
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
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
Complex atan(const Complex &x)
Definition: lo-mappers.h:80
intNDArray< octave_int16 > int16NDArray
Definition: int16NDArray.h:33
double fix(double x)
Definition: lo-mappers.h:127
void read_floats(std::istream &is, float *data, save_type type, octave_idx_type len, bool swap, octave::mach_info::float_format fmt)
Definition: data-conv.cc:831
Complex asin(const Complex &x)
Definition: lo-mappers.cc:105
void err_nan_to_logical_conversion(void)
Complex log2(const Complex &x)
Definition: lo-mappers.cc:137
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
void warn_load(const char *type) const
Definition: ov-base.cc:1097
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
double lgamma(double x)
Definition: lo-specfun.h:377
Complex expm1(const Complex &x)
Definition: lo-specfun.cc:1875
ComplexMatrix complex_matrix_value(bool=false) const
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
FloatNDArray float_array_value(bool=false) const
double gamma(double x)
Definition: lo-specfun.cc:1913
void swap_bytes< 4 >(void *ptr)
Definition: byte-swap.h:60
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
float float_value(bool=false) const
virtual octave_value convert_to_str(bool pad=false, bool force=false, char type='\'') const
Definition: ov-base.cc:375
bool any_element_not_one_or_zero(void) const
Definition: fNDArray.cc:517
octave_value diag(octave_idx_type k=0) const
Definition: ov-base-mat.h:127
intNDArray< octave_int8 > int8NDArray
Definition: int8NDArray.h:33
boolNDArray bool_array_value(bool warn=false) const
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
Definition: ls-oct-text.cc:82
Complex log1p(const Complex &x)
Definition: lo-specfun.cc:1959
FloatMatrix float_matrix_value(bool=false) const
octave_idx_type rows(void) const
Definition: ov-base.h:316
double signum(double x)
Definition: lo-mappers.h:244
octave_value map(unary_mapper_t umap) const
double dawson(double x)
Definition: lo-specfun.cc:1518
bool save_ascii(std::ostream &os)
FloatComplexNDArray float_complex_array_value(bool=false) const
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
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
NDArray array_value(bool=false) const
Complex rc_log(double x)
Definition: lo-mappers.cc:279
#define panic_impossible()
Definition: error.h:40
std::complex< double > erfcx(std::complex< double > z, double relerr=0)
int64_t octave_hdf5_id
double atanh(double x)
Definition: lo-specfun.h:72
octave_value as_uint8(void) const
bool load_ascii(std::istream &is)
void warn_save(const char *type) const
Definition: ov-base.cc:1106
idx type
Definition: ov.cc:3114
Definition: dMatrix.h:36
double double_value(bool=false) const
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
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
octave_value convert_to_str_internal(bool pad, bool force, char type) const
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
bool save_binary(std::ostream &os, bool &save_as_floats)
octave_value as_int32(void) const
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
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
Definition: dim-vector.h:362
SparseMatrix sparse_matrix_value(bool=false) const
mxArray * as_mxArray(void) const
p
Definition: lu.cc:138
FloatComplexMatrix float_complex_matrix_value(bool=false) const
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
double roundb(double x)
Definition: lo-mappers.h:156
Complex rc_log1p(double x)
Definition: lo-specfun.cc:2248
FloatMatrix diag(octave_idx_type k=0) const
Definition: fMatrix.cc:2592
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Definition: oct-locbuf.h:41
Complex complex_value(bool=false) const
static octave_value do_rc_map(const FloatNDArray &a, FloatComplex(&fcn)(float))
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
#define RC_ARRAY_MAPPER(UMAP, TYPE, FCN)
for i
Definition: data.cc:5264
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
ComplexNDArray complex_array_value(bool=false) const
octave_idx_type ndims(void) const
Number of dimensions.
Definition: dim-vector.h:295
std::complex< double > Complex
Definition: oct-cmplx.h:31
octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:366
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)
octave_value as_int8(void) const
octave_base_value * try_narrowing_conversion(void)
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
octave_value as_uint32(void) const
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_value as_uint16(void) const
octave::stream os
Definition: file-io.cc:627
int ndims(void) const
Definition: Array.h:590
intNDArray< octave_uint64 > uint64NDArray
Definition: uint64NDArray.h:33
octave_value diag(octave_idx_type k=0) const
int nint(double x)
Definition: lo-mappers.cc:206
std::complex< double > erfc(std::complex< double > z, double relerr=0)