GNU Octave  6.2.0
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-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if defined (HAVE_CONFIG_H)
27 # include "config.h"
28 #endif
29 
30 #include <istream>
31 #include <limits>
32 #include <ostream>
33 #include <vector>
34 
35 #include "dNDArray.h"
36 #include "fNDArray.h"
37 #include "int8NDArray.h"
38 #include "int16NDArray.h"
39 #include "int32NDArray.h"
40 #include "int64NDArray.h"
41 #include "uint8NDArray.h"
42 #include "uint16NDArray.h"
43 #include "uint32NDArray.h"
44 #include "uint64NDArray.h"
45 
46 #include "data-conv.h"
47 #include "lo-ieee.h"
48 #include "lo-utils.h"
49 #include "lo-specfun.h"
50 #include "lo-mappers.h"
51 #include "mach-info.h"
52 #include "mx-base.h"
53 #include "quit.h"
54 #include "oct-locbuf.h"
55 
56 #include "defun.h"
57 #include "errwarn.h"
58 #include "mxarray.h"
59 #include "ovl.h"
60 #include "oct-lvalue.h"
61 #include "oct-hdf5.h"
62 #include "oct-stream.h"
63 #include "ops.h"
64 #include "ov-base.h"
65 #include "ov-base-mat.h"
66 #include "ov-base-mat.cc"
67 #include "ov-scalar.h"
68 #include "ov-float.h"
69 #include "ov-flt-complex.h"
70 #include "ov-re-mat.h"
71 #include "ov-flt-re-mat.h"
72 #include "ov-flt-cx-mat.h"
73 #include "ov-re-sparse.h"
74 #include "ov-flt-re-diag.h"
75 #include "ov-flt-cx-diag.h"
76 #include "pr-output.h"
77 #include "variables.h"
78 #include "ops.h"
79 
80 #include "byte-swap.h"
81 #include "ls-oct-text.h"
82 #include "ls-utils.h"
83 #include "ls-hdf5.h"
84 
85 
87 
89  "single");
90 
93 {
94  octave_base_value *retval = nullptr;
95 
96  if (matrix.numel () == 1)
97  retval = new octave_float_scalar (matrix (0));
98 
99  return retval;
100 }
101 
102 double
104 {
105  if (isempty ())
106  err_invalid_conversion ("real matrix", "real scalar");
107 
108  warn_implicit_conversion ("Octave:array-to-scalar",
109  "real matrix", "real scalar");
110 
111  return matrix(0, 0);
112 }
113 
114 float
116 {
117  if (isempty ())
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 // FIXME
127 
128 Matrix
130 {
131  return Matrix (FloatMatrix (matrix));
132 }
133 
136 {
137  return FloatMatrix (matrix);
138 }
139 
140 Complex
142 {
143  if (rows () == 0 || columns () == 0)
144  err_invalid_conversion ("real matrix", "complex scalar");
145 
146  warn_implicit_conversion ("Octave:array-to-scalar",
147  "real matrix", "complex scalar");
148 
149  return Complex (matrix(0, 0), 0);
150 }
151 
154 {
155  double tmp = lo_ieee_float_nan_value ();
156 
157  FloatComplex retval (tmp, tmp);
158 
159  if (rows () == 0 || columns () == 0)
160  err_invalid_conversion ("real matrix", "complex scalar");
161 
162  warn_implicit_conversion ("Octave:array-to-scalar",
163  "real matrix", "complex scalar");
164 
165  retval = matrix(0, 0);
166 
167  return retval;
168 }
169 
170 // FIXME
171 
174 {
175  return ComplexMatrix (FloatMatrix (matrix));
176 }
177 
180 {
182 }
183 
186 {
187  return ComplexNDArray (matrix);
188 }
189 
192 {
193  return FloatComplexNDArray (matrix);
194 }
195 
196 NDArray
198 {
199  return NDArray (matrix);
200 }
201 
204 {
205  if (matrix.any_element_is_nan ())
207  if (warn && matrix.any_element_not_one_or_zero ())
209 
210  return boolNDArray (matrix);
211 }
212 
215 {
216  charNDArray retval (dims ());
217 
218  octave_idx_type nel = numel ();
219 
220  for (octave_idx_type i = 0; i < nel; i++)
221  retval.elem (i) = static_cast<char> (matrix.elem (i));
222 
223  return retval;
224 }
225 
228 {
229  return SparseMatrix (matrix_value ());
230 }
231 
234 {
235  // FIXME: Need a SparseComplexMatrix (Matrix) constructor to make
236  // this function more efficient. Then this should become
237  // return SparseComplexMatrix (matrix.matrix_value ());
239 }
240 
243 {
244  return NDArray (matrix);
245 }
246 
249 {
250  return FloatNDArray (matrix);
251 }
252 
255 {
256  return int8NDArray (matrix);
257 }
258 
261 {
262  return int16NDArray (matrix);
263 }
264 
267 {
268  return int32NDArray (matrix);
269 }
270 
273 {
274  return int64NDArray (matrix);
275 }
276 
279 {
280  return uint8NDArray (matrix);
281 }
282 
285 {
286  return uint16NDArray (matrix);
287 }
288 
291 {
292  return uint32NDArray (matrix);
293 }
294 
297 {
298  return uint64NDArray (matrix);
299 }
300 
303 {
305  if (k == 0 && matrix.ndims () == 2
306  && (matrix.rows () == 1 || matrix.columns () == 1))
308  else
310 
311  return retval;
312 }
313 
316 {
317  if (matrix.ndims () != 2
318  || (matrix.rows () != 1 && matrix.columns () != 1))
319  error ("diag: expecting vector argument");
320 
321  FloatMatrix mat (matrix);
322 
323  return mat.diag (m, n);
324 }
325 
328 {
330  dim_vector dv = dims ();
331  octave_idx_type nel = dv.numel ();
332 
333  charNDArray chm (dv);
334 
335  bool warned = false;
336 
337  for (octave_idx_type i = 0; i < nel; i++)
338  {
339  octave_quit ();
340 
341  float d = matrix(i);
342 
343  if (octave::math::isnan (d))
345 
346  int ival = octave::math::nint (d);
347 
348  if (ival < 0 || ival > std::numeric_limits<unsigned char>::max ())
349  {
350  // FIXME: is there something better we could do?
351 
352  ival = 0;
353 
354  if (! warned)
355  {
356  ::warning ("range error for conversion to character value");
357  warned = true;
358  }
359  }
360 
361  chm(i) = static_cast<char> (ival);
362  }
363 
364  retval = octave_value (chm, type);
365 
366  return retval;
367 }
368 
369 bool
371 {
372  dim_vector dv = dims ();
373 
374  if (dv.ndims () > 2)
375  {
377 
378  os << "# ndims: " << dv.ndims () << "\n";
379 
380  for (int i=0; i < dv.ndims (); i++)
381  os << ' ' << dv(i);
382 
383  os << "\n" << tmp;
384  }
385  else
386  {
387  // Keep this case, rather than use generic code above for backward
388  // compatibility. Makes load_ascii much more complex!!
389  os << "# rows: " << rows () << "\n"
390  << "# columns: " << columns () << "\n";
391 
392  os << float_matrix_value ();
393  }
394 
395  return true;
396 }
397 
398 bool
400 {
401  string_vector keywords(2);
402 
403  keywords[0] = "ndims";
404  keywords[1] = "rows";
405 
406  std::string kw;
407  octave_idx_type val = 0;
408 
409  if (! extract_keyword (is, keywords, kw, val, true))
410  error ("load: failed to extract number of rows and columns");
411 
412  if (kw == "ndims")
413  {
414  int mdims = static_cast<int> (val);
415 
416  if (mdims < 0)
417  error ("load: failed to extract number of dimensions");
418 
419  dim_vector dv;
420  dv.resize (mdims);
421 
422  for (int i = 0; i < mdims; i++)
423  is >> dv(i);
424 
425  if (! is)
426  error ("load: failed to read dimensions");
427 
428  FloatNDArray tmp(dv);
429 
430  is >> tmp;
431 
432  if (! is)
433  error ("load: failed to load matrix constant");
434 
435  matrix = tmp;
436  }
437  else if (kw == "rows")
438  {
439  octave_idx_type nr = val;
440  octave_idx_type nc = 0;
441 
442  if (nr < 0 || ! extract_keyword (is, "columns", nc) || nc < 0)
443  error ("load: failed to extract number of rows and columns");
444 
445  if (nr > 0 && nc > 0)
446  {
447  FloatMatrix tmp (nr, nc);
448  is >> tmp;
449  if (! is)
450  error ("load: failed to load matrix constant");
451 
452  matrix = tmp;
453  }
454  else if (nr == 0 || nc == 0)
455  matrix = FloatMatrix (nr, nc);
456  else
457  panic_impossible ();
458  }
459  else
460  panic_impossible ();
461 
462  return true;
463 }
464 
465 bool
466 octave_float_matrix::save_binary (std::ostream& os, bool)
467 {
468  dim_vector dv = dims ();
469  if (dv.ndims () < 1)
470  return false;
471 
472  // Use negative value for ndims to differentiate with old format!!
473  int32_t tmp = - dv.ndims ();
474  os.write (reinterpret_cast<char *> (&tmp), 4);
475  for (int i = 0; i < dv.ndims (); i++)
476  {
477  tmp = dv(i);
478  os.write (reinterpret_cast<char *> (&tmp), 4);
479  }
480 
482  save_type st = LS_FLOAT;
483  if (dv.numel () > 8192) // FIXME: make this configurable.
484  {
485  float max_val, min_val;
486  if (m.all_integers (max_val, min_val))
487  st = get_save_type (max_val, min_val);
488  }
489 
490  const float *mtmp = m.data ();
491  write_floats (os, mtmp, st, dv.numel ());
492 
493  return true;
494 }
495 
496 bool
497 octave_float_matrix::load_binary (std::istream& is, bool swap,
499 {
500  char tmp;
501  int32_t mdims;
502  if (! is.read (reinterpret_cast<char *> (&mdims), 4))
503  return false;
504  if (swap)
505  swap_bytes<4> (&mdims);
506  if (mdims < 0)
507  {
508  mdims = - mdims;
509  int32_t di;
510  dim_vector dv;
511  dv.resize (mdims);
512 
513  for (int i = 0; i < mdims; i++)
514  {
515  if (! is.read (reinterpret_cast<char *> (&di), 4))
516  return false;
517  if (swap)
518  swap_bytes<4> (&di);
519  dv(i) = di;
520  }
521 
522  // Convert an array with a single dimension to be a row vector.
523  // Octave should never write files like this, other software
524  // might.
525 
526  if (mdims == 1)
527  {
528  mdims = 2;
529  dv.resize (mdims);
530  dv(1) = dv(0);
531  dv(0) = 1;
532  }
533 
534  if (! is.read (reinterpret_cast<char *> (&tmp), 1))
535  return false;
536 
537  FloatNDArray m(dv);
538  float *re = m.fortran_vec ();
539  read_floats (is, re, static_cast<save_type> (tmp), dv.numel (),
540  swap, fmt);
541 
542  if (! is)
543  return false;
544 
545  matrix = m;
546  }
547  else
548  {
549  int32_t nr, nc;
550  nr = mdims;
551  if (! is.read (reinterpret_cast<char *> (&nc), 4))
552  return false;
553  if (swap)
554  swap_bytes<4> (&nc);
555  if (! is.read (reinterpret_cast<char *> (&tmp), 1))
556  return false;
557  FloatMatrix m (nr, nc);
558  float *re = m.fortran_vec ();
559  octave_idx_type len = nr * nc;
560  read_floats (is, re, static_cast<save_type> (tmp), len, swap, fmt);
561 
562  if (! is)
563  return false;
564 
565  matrix = m;
566  }
567  return true;
568 }
569 
570 bool
572 {
573  bool retval = false;
574 
575 #if defined (HAVE_HDF5)
576 
577  dim_vector dv = dims ();
578  int empty = save_hdf5_empty (loc_id, name, dv);
579  if (empty)
580  return (empty > 0);
581 
582  int rank = dv.ndims ();
583  hid_t space_hid, data_hid;
584  space_hid = data_hid = -1;
586 
587  OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
588 
589  // Octave uses column-major, while HDF5 uses row-major ordering
590  for (int i = 0; i < rank; i++)
591  hdims[i] = dv(rank-i-1);
592 
593  space_hid = H5Screate_simple (rank, hdims, nullptr);
594 
595  if (space_hid < 0) return false;
596 
597  hid_t save_type_hid = H5T_NATIVE_FLOAT;
598 
599 #if defined (HAVE_HDF5_INT2FLOAT_CONVERSIONS)
600  // hdf5 currently doesn't support float/integer conversions
601  else
602  {
603  float max_val, min_val;
604 
605  if (m.all_integers (max_val, min_val))
606  save_type_hid
607  = save_type_to_hdf5 (get_save_type (max_val, min_val));
608  }
609 #endif
610 #if defined (HAVE_HDF5_18)
611  data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
613 #else
614  data_hid = H5Dcreate (loc_id, name, save_type_hid, space_hid,
616 #endif
617  if (data_hid < 0)
618  {
619  H5Sclose (space_hid);
620  return false;
621  }
622 
623  float *mtmp = m.fortran_vec ();
624  retval = H5Dwrite (data_hid, H5T_NATIVE_FLOAT, octave_H5S_ALL, octave_H5S_ALL,
625  octave_H5P_DEFAULT, mtmp) >= 0;
626 
627  H5Dclose (data_hid);
628  H5Sclose (space_hid);
629 
630 #else
631  octave_unused_parameter (loc_id);
632  octave_unused_parameter (name);
633 
634  warn_save ("hdf5");
635 #endif
636 
637  return retval;
638 }
639 
640 bool
642 {
643  bool retval = false;
644 
645 #if defined (HAVE_HDF5)
646 
647  dim_vector dv;
648  int empty = load_hdf5_empty (loc_id, name, dv);
649  if (empty > 0)
650  matrix.resize (dv);
651  if (empty)
652  return (empty > 0);
653 
654 #if defined (HAVE_HDF5_18)
655  hid_t data_hid = H5Dopen (loc_id, name, octave_H5P_DEFAULT);
656 #else
657  hid_t data_hid = H5Dopen (loc_id, name);
658 #endif
659  hid_t space_id = H5Dget_space (data_hid);
660 
661  hsize_t rank = H5Sget_simple_extent_ndims (space_id);
662 
663  if (rank < 1)
664  {
665  H5Sclose (space_id);
666  H5Dclose (data_hid);
667  return false;
668  }
669 
670  OCTAVE_LOCAL_BUFFER (hsize_t, hdims, rank);
671  OCTAVE_LOCAL_BUFFER (hsize_t, maxdims, rank);
672 
673  H5Sget_simple_extent_dims (space_id, hdims, maxdims);
674 
675  // Octave uses column-major, while HDF5 uses row-major ordering
676  if (rank == 1)
677  {
678  dv.resize (2);
679  dv(0) = 1;
680  dv(1) = hdims[0];
681  }
682  else
683  {
684  dv.resize (rank);
685  for (hsize_t i = 0, j = rank - 1; i < rank; i++, j--)
686  dv(j) = hdims[i];
687  }
688 
689  FloatNDArray m (dv);
690  float *re = m.fortran_vec ();
691  if (H5Dread (data_hid, H5T_NATIVE_FLOAT, octave_H5S_ALL, octave_H5S_ALL,
692  octave_H5P_DEFAULT, re) >= 0)
693  {
694  retval = true;
695  matrix = m;
696  }
697 
698  H5Sclose (space_id);
699  H5Dclose (data_hid);
700 
701 #else
702  octave_unused_parameter (loc_id);
703  octave_unused_parameter (name);
704 
705  warn_load ("hdf5");
706 #endif
707 
708  return retval;
709 }
710 
711 void
713  bool pr_as_read_syntax) const
714 {
715  octave_print_internal (os, matrix, pr_as_read_syntax,
717 }
718 
719 mxArray *
721 {
723 
724  float *pr = static_cast<float *> (retval->get_data ());
725 
726  mwSize nel = numel ();
727 
728  const float *p = matrix.data ();
729 
730  for (mwIndex i = 0; i < nel; i++)
731  pr[i] = p[i];
732 
733  return retval;
734 }
735 
736 // This uses a smarter strategy for doing the complex->real mappers. We
737 // allocate an array for a real result and keep filling it until a complex
738 // result is produced.
739 static octave_value
740 do_rc_map (const FloatNDArray& a, FloatComplex (&fcn) (float))
741 {
742  octave_idx_type n = a.numel ();
743  FloatNDArray rr (a.dims ());
744 
745  for (octave_idx_type i = 0; i < n; i++)
746  {
747  octave_quit ();
748 
749  FloatComplex tmp = fcn (a(i));
750  if (tmp.imag () == 0.0)
751  rr.xelem (i) = tmp.real ();
752  else
753  {
754  FloatComplexNDArray rc (a.dims ());
755 
756  for (octave_idx_type j = 0; j < i; j++)
757  rc.xelem (j) = rr.xelem (j);
758 
759  rc.xelem (i) = tmp;
760 
761  for (octave_idx_type j = i+1; j < n; j++)
762  {
763  octave_quit ();
764 
765  rc.xelem (j) = fcn (a(j));
766  }
767 
768  return new octave_float_complex_matrix (rc);
769  }
770  }
771 
772  return rr;
773 }
774 
777 {
778  switch (umap)
779  {
780  case umap_imag:
781  return FloatNDArray (matrix.dims (), 0.0);
782 
783  case umap_real:
784  case umap_conj:
785  return matrix;
786 
787  // Mappers handled specially.
788 #define ARRAY_METHOD_MAPPER(UMAP, FCN) \
789  case umap_ ## UMAP: \
790  return octave_value (matrix.FCN ())
791 
796 
797 #define ARRAY_MAPPER(UMAP, TYPE, FCN) \
798  case umap_ ## UMAP: \
799  return octave_value (matrix.map<TYPE> (FCN))
800 
801 #define RC_ARRAY_MAPPER(UMAP, TYPE, FCN) \
802  case umap_ ## UMAP: \
803  return do_rc_map (matrix, FCN)
804 
807  ARRAY_MAPPER (angle, float, std::arg);
808  ARRAY_MAPPER (arg, float, std::arg);
811  ARRAY_MAPPER (atan, float, ::atanf);
823  ARRAY_MAPPER (ceil, float, ::ceilf);
824  ARRAY_MAPPER (cos, float, ::cosf);
825  ARRAY_MAPPER (cosh, float, ::coshf);
826  ARRAY_MAPPER (exp, float, ::expf);
829  ARRAY_MAPPER (floor, float, ::floorf);
837  ARRAY_MAPPER (sin, float, ::sinf);
838  ARRAY_MAPPER (sinh, float, ::sinhf);
840  ARRAY_MAPPER (tan, float, ::tanf);
841  ARRAY_MAPPER (tanh, float, ::tanhf);
843  ARRAY_MAPPER (xsignbit, float, octave::math::signbit);
844 
845  // Special cases for Matlab compatibility.
846  case umap_xtolower:
847  case umap_xtoupper:
848  return matrix;
849 
850  case umap_xisalnum:
851  case umap_xisalpha:
852  case umap_xisascii:
853  case umap_xiscntrl:
854  case umap_xisdigit:
855  case umap_xisgraph:
856  case umap_xislower:
857  case umap_xisprint:
858  case umap_xispunct:
859  case umap_xisspace:
860  case umap_xisupper:
861  case umap_xisxdigit:
862  {
863  octave_value str_conv = convert_to_str (true, true);
864  return str_conv.map (umap);
865  }
866 
867  default:
868  return octave_base_value::map (umap);
869  }
870 }
void swap_bytes< 4 >(void *ptr)
Definition: byte-swap.h:63
charNDArray max(char d, const charNDArray &m)
Definition: chNDArray.cc:230
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
Definition: Array.cc:1011
octave_idx_type columns(void) const
Definition: Array.h:424
T & xelem(octave_idx_type n)
Size of the specified dimension.
Definition: Array.h:469
octave_idx_type numel(void) const
Number of elements in the array.
Definition: Array.h:377
T & elem(octave_idx_type n)
Size of the specified dimension.
Definition: Array.h:499
const T * data(void) const
Size of the specified dimension.
Definition: Array.h:581
octave_idx_type rows(void) const
Definition: Array.h:415
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
Definition: Array.h:453
int ndims(void) const
Size of the specified dimension.
Definition: Array.h:589
FloatMatrix diag(octave_idx_type k=0) const
Definition: fMatrix.cc:2401
bool any_element_is_nan(void) const
Definition: fNDArray.cc:275
bool any_element_not_one_or_zero(void) const
Definition: fNDArray.cc:287
Definition: dMatrix.h:42
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:95
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
Definition: dim-vector.h:401
void resize(int n, int fill_value=0)
Definition: dim-vector.h:349
octave_idx_type ndims(void) const
Number of dimensions.
Definition: dim-vector.h:334
octave_idx_type numel(void) const
Definition: ov-base-mat.h:114
octave_value diag(octave_idx_type k=0) const
Definition: ov-base-mat.h:134
dim_vector dims(void) const
Definition: ov-base-mat.h:112
octave_idx_type columns(void) const
Definition: ov-base.h:325
int current_print_indent_level(void) const
Definition: ov-base.h:847
virtual octave_value map(unary_mapper_t) const
Definition: ov-base.cc:1114
virtual octave_value convert_to_str(bool pad=false, bool force=false, char type='\'') const
Definition: ov-base.cc:377
void warn_load(const char *type) const
Definition: ov-base.cc:1090
octave_idx_type rows(void) const
Definition: ov-base.h:318
friend class octave_value
Definition: ov-base.h:228
void warn_save(const char *type) const
Definition: ov-base.cc:1099
bool isempty(void) const
Definition: ov-base.h:357
FloatNDArray float_array_value(bool=false) const
ComplexNDArray complex_array_value(bool=false) const
charNDArray char_array_value(bool=false) const
octave_value as_int64(void) const
bool save_binary(std::ostream &os, bool save_as_floats)
mxArray * as_mxArray(void) const
octave_value as_uint8(void) const
octave_value map(unary_mapper_t umap) const
ComplexMatrix complex_matrix_value(bool=false) const
FloatComplex float_complex_value(bool=false) const
octave_value as_int16(void) const
FloatMatrix float_matrix_value(bool=false) const
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
octave_value as_uint64(void) const
octave_value as_uint16(void) const
bool save_ascii(std::ostream &os)
octave_value as_int8(void) const
double double_value(bool=false) const
FloatComplexNDArray float_complex_array_value(bool=false) const
Complex complex_value(bool=false) const
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
SparseComplexMatrix sparse_complex_matrix_value(bool=false) const
Matrix matrix_value(bool=false) const
octave_value as_uint32(void) const
octave_value convert_to_str_internal(bool pad, bool force, char type) const
octave_value diag(octave_idx_type k=0) const
octave_value as_int32(void) const
octave_value as_double(void) const
octave_base_value * try_narrowing_conversion(void)
octave_value as_single(void) const
boolNDArray bool_array_value(bool warn=false) const
float float_value(bool=false) const
SparseMatrix sparse_matrix_value(bool=false) const
bool load_ascii(std::istream &is)
NDArray array_value(bool=false) const
FloatComplexMatrix float_complex_matrix_value(bool=false) const
octave_value map(octave_base_value::unary_mapper_t umap) const
Definition: ov.h:1436
const octave_hdf5_id octave_H5P_DEFAULT
const octave_hdf5_id octave_H5S_ALL
void write_floats(std::ostream &os, const float *data, save_type type, octave_idx_type len)
Definition: data-conv.cc:941
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:835
save_type
Definition: data-conv.h:87
@ LS_FLOAT
Definition: data-conv.h:94
void warning(const char *fmt,...)
Definition: error.cc:1050
void error(const char *fmt,...)
Definition: error.cc:968
#define panic_impossible()
Definition: error.h:380
void err_invalid_conversion(const std::string &from, const std::string &to)
Definition: errwarn.cc:71
void warn_logical_conversion(void)
Definition: errwarn.cc:365
void warn_implicit_conversion(const char *id, const char *from, const char *to)
Definition: errwarn.cc:344
function gamma(X)
Definition: gamma.f:3
QString name
intNDArray< octave_int16 > int16NDArray
Definition: int16NDArray.h:36
intNDArray< octave_int32 > int32NDArray
Definition: int32NDArray.h:36
intNDArray< octave_int64 > int64NDArray
Definition: int64NDArray.h:36
intNDArray< octave_int8 > int8NDArray
Definition: int8NDArray.h:36
float lo_ieee_float_nan_value(void)
Definition: lo-ieee.cc:126
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
int save_hdf5_empty(octave_hdf5_id loc_id, const char *name, const dim_vector &d)
Definition: ls-hdf5.cc:1224
int load_hdf5_empty(octave_hdf5_id loc_id, const char *name, dim_vector &d)
Definition: ls-hdf5.cc:1280
octave_hdf5_id save_type_to_hdf5(save_type st)
Definition: ls-hdf5.cc:1324
std::string extract_keyword(std::istream &is, const char *keyword, const bool next_only)
Definition: ls-oct-text.cc:84
save_type get_save_type(double, double)
Definition: ls-utils.cc:38
void mxArray
Definition: mex.h:58
T octave_idx_type m
Definition: mx-inlines.cc:773
octave_idx_type n
Definition: mx-inlines.cc:753
OCTAVE_IDX_TYPE mwSize
Definition: mxarray.in.h:97
@ mxSINGLE_CLASS
Definition: mxarray.in.h:65
OCTAVE_IDX_TYPE mwIndex
Definition: mxarray.in.h:98
@ mxREAL
Definition: mxarray.in.h:80
std::complex< double > erfc(std::complex< double > z, double relerr=0)
std::complex< double > erfcx(std::complex< double > z, double relerr=0)
std::complex< double > erfi(std::complex< double > z, double relerr=0)
std::complex< double > erf(std::complex< double > z, double relerr=0)
double fix(double x)
Definition: lo-mappers.h:118
Complex atan(const Complex &x)
Definition: lo-mappers.h:71
double signum(double x)
Definition: lo-mappers.h:222
double asinh(double x)
Definition: lo-specfun.h:69
double gamma(double x)
Definition: lo-specfun.cc:1912
bool isna(double x)
Definition: lo-mappers.cc:47
Complex rc_acos(double x)
Definition: lo-mappers.cc:230
double signbit(double x)
Definition: lo-mappers.h:54
double atanh(double x)
Definition: lo-specfun.h:74
bool isfinite(double x)
Definition: lo-mappers.h:192
int nint(double x)
Definition: lo-mappers.cc:208
double roundb(double x)
Definition: lo-mappers.h:147
bool isnan(bool)
Definition: lo-mappers.h:178
Complex log1p(const Complex &x)
Definition: lo-specfun.cc:1958
bool isinf(double x)
Definition: lo-mappers.h:203
Complex acos(const Complex &x)
Definition: lo-mappers.cc:85
double round(double x)
Definition: lo-mappers.h:136
Complex asin(const Complex &x)
Definition: lo-mappers.cc:107
double erfcx(double x)
Definition: lo-specfun.cc:1755
Complex rc_log2(double x)
Definition: lo-mappers.cc:294
Complex rc_log(double x)
Definition: lo-mappers.cc:281
Complex erfc(const Complex &x)
Definition: lo-specfun.cc:1652
double acosh(double x)
Definition: lo-specfun.h:51
Complex rc_sqrt(double x)
Definition: lo-mappers.cc:324
double erfcinv(double x)
Definition: lo-specfun.cc:1744
Complex rc_atanh(double x)
Definition: lo-mappers.cc:268
std::complex< T > ceil(const std::complex< T > &x)
Definition: lo-mappers.h:103
Complex rc_acosh(double x)
Definition: lo-mappers.cc:243
double erfi(double x)
Definition: lo-specfun.cc:1774
Complex rc_log1p(double x)
Definition: lo-specfun.cc:2247
double lgamma(double x)
Definition: lo-specfun.h:347
double erfinv(double x)
Definition: lo-specfun.cc:1863
Complex rc_log10(double x)
Definition: lo-mappers.cc:309
Complex rc_lgamma(double x)
Definition: lo-specfun.cc:2210
double dawson(double x)
Definition: lo-specfun.cc:1517
double cbrt(double x)
Definition: lo-specfun.h:300
Complex rc_asin(double x)
Definition: lo-mappers.cc:255
Complex log2(const Complex &x)
Definition: lo-mappers.cc:139
std::complex< T > floor(const std::complex< T > &x)
Definition: lo-mappers.h:130
Complex erf(const Complex &x)
Definition: lo-specfun.cc:1637
Complex expm1(const Complex &x)
Definition: lo-specfun.cc:1874
void err_nan_to_logical_conversion(void)
void err_nan_to_character_conversion(void)
std::complex< double > Complex
Definition: oct-cmplx.h:33
std::complex< float > FloatComplex
Definition: oct-cmplx.h:34
int64_t octave_hdf5_id
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
Definition: oct-locbuf.h:44
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
Definition: ov-base.h:180
static octave_value do_rc_map(const FloatNDArray &a, FloatComplex(&fcn)(float))
#define RC_ARRAY_MAPPER(UMAP, TYPE, FCN)
#define ARRAY_MAPPER(UMAP, TYPE, FCN)
#define ARRAY_METHOD_MAPPER(UMAP, FCN)
octave_value::octave_value(const Array< char > &chm, char type) return retval
Definition: ov.cc:811
void octave_print_internal(std::ostream &os, const float_display_format &fmt, bool d, bool pr_as_read_syntax)
Definition: pr-output.cc:1762
static T abs(T x)
Definition: pr-output.cc:1678
intNDArray< octave_uint16 > uint16NDArray
Definition: uint16NDArray.h:36
intNDArray< octave_uint32 > uint32NDArray
Definition: uint32NDArray.h:36
intNDArray< octave_uint64 > uint64NDArray
Definition: uint64NDArray.h:36
intNDArray< octave_uint8 > uint8NDArray
Definition: uint8NDArray.h:36
F77_RET_T len
Definition: xerbla.cc:61