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-range.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2017 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if defined (HAVE_CONFIG_H)
24 # include "config.h"
25 #endif
26 
27 #include <iostream>
28 
29 #include "dNDArray.h"
30 #include "fNDArray.h"
31 #include "int8NDArray.h"
32 #include "int16NDArray.h"
33 #include "int32NDArray.h"
34 #include "int64NDArray.h"
35 #include "uint8NDArray.h"
36 #include "uint16NDArray.h"
37 #include "uint32NDArray.h"
38 #include "uint64NDArray.h"
39 
40 #include "lo-ieee.h"
41 #include "lo-utils.h"
42 
43 #include "defun.h"
44 #include "variables.h"
45 #include "errwarn.h"
46 #include "mxarray.h"
47 #include "ops.h"
48 #include "ovl.h"
49 #include "oct-hdf5.h"
50 #include "ov-range.h"
51 #include "ov-re-mat.h"
52 #include "ov-scalar.h"
53 #include "pr-output.h"
54 
55 #include "byte-swap.h"
56 #include "ls-ascii-helper.h"
57 #include "ls-hdf5.h"
58 #include "ls-utils.h"
59 
60 // If TRUE, allow ranges with non-integer elements as array indices.
62 
64 
65 static octave_base_value *
67 {
68  const octave_range& v = dynamic_cast<const octave_range&> (a);
69 
70  return new octave_matrix (v.matrix_value ());
71 }
72 
75 {
78 }
79 
82 {
84 
85  switch (range.numel ())
86  {
87  case 1:
88  retval = new octave_scalar (range.base ());
89  break;
90 
91  case 0:
92  retval = new octave_matrix (Matrix (1, 0));
93  break;
94 
95  case -2:
96  retval = new octave_matrix (range.matrix_value ());
97  break;
98 
99  default:
100  break;
101  }
102 
103  return retval;
104 }
105 
108  const std::list<octave_value_list>& idx)
109 {
111 
112  switch (type[0])
113  {
114  case '(':
115  retval = do_index_op (idx.front ());
116  break;
117 
118  case '{':
119  case '.':
120  {
121  std::string nm = type_name ();
122  error ("%s cannot be indexed with %c", nm.c_str (), type[0]);
123  }
124  break;
125 
126  default:
127  panic_impossible ();
128  }
129 
130  return retval.next_subsref (type, idx);
131 }
132 
134 octave_range::do_index_op (const octave_value_list& idx, bool resize_ok)
135 {
136  if (idx.length () == 1 && ! resize_ok)
137  {
139 
140  // The range can handle a single subscript.
141 
142  try
143  {
144  idx_vector i = idx(0).index_vector ();
145 
146  if (i.is_scalar () && i(0) < range.numel ())
147  retval = range.elem (i(0));
148  else
149  retval = range.index (i);
150  }
151  catch (octave::index_exception& e)
152  {
153  // More info may be added later before displaying error.
154 
155  e.set_pos_if_unset (1, 1);
156  throw;
157  }
158 
159  return retval;
160  }
161  else
162  {
164 
165  return tmp.do_index_op (idx, resize_ok);
166  }
167 }
168 
170 octave_range::index_vector (bool require_integers) const
171 {
172  if (idx_cache)
173  return *idx_cache;
174  else
175  {
176  if (require_integers
177  || ! Vallow_noninteger_range_as_index
179  return set_idx_cache (idx_vector (range));
180  else
181  {
182  warning_with_id ("Octave:noninteger-range-as-index",
183  "non-integer range used as index");
184 
185  return octave_value (matrix_value ()).round ().index_vector ();
186  }
187  }
188 }
189 
190 double
192 {
193  octave_idx_type nel = range.numel ();
194 
195  if (nel == 0)
196  err_invalid_conversion ("range", "real scalar");
197 
198  warn_implicit_conversion ("Octave:array-to-scalar",
199  "range", "real scalar");
200 
201  return range.base ();
202 }
203 
204 float
206 {
207  octave_idx_type nel = range.numel ();
208 
209  if (nel == 0)
210  err_invalid_conversion ("range", "real scalar");
211 
212  warn_implicit_conversion ("Octave:array-to-scalar",
213  "range", "real scalar");
214 
215  return range.base ();
216 }
217 
220 {
221  const Matrix matrix = range.matrix_value ();
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 
233 octave_range::all (int dim) const
234 {
235  // FIXME: this is a potential waste of memory.
236 
237  Matrix m = range.matrix_value ();
238 
239  return m.all (dim);
240 }
241 
243 octave_range::any (int dim) const
244 {
245  // FIXME: this is a potential waste of memory.
246 
247  Matrix m = range.matrix_value ();
248 
249  return m.any (dim);
250 }
251 
254 {
255  return
256  (k == 0
258  : octave_value (range.diag (k)));
259 }
260 
263 {
264  Matrix mat = range.matrix_value ();
265 
266  return mat.diag (m, n);
267 }
268 
269 // Return true if this range has all true elements (non-zero, not NaN/NA).
270 // A range cannot have NaN/NA.
271 bool
273 {
274  bool retval = false;
275 
276  if (! range.is_empty ())
277  {
278  if (dims ().numel () > 1)
280 
281  Range r = range_value ();
282  double base = r.base ();
283  double limit = r.limit ();
284 
285  // Can't be zero if we start and finish on the same size of 0
286  if (((base > 0 && limit > 0) || (base < 0 && limit < 0)) && numel () > 0)
287  retval = true;
288  else
289  {
290  /*
291  // This tells us whether one element is 0, if arithmetic is exact.
292  double steps_to_zero = base / r.inc ();
293 
294  retval = (steps_to_zero != floor (steps_to_zero));
295  */
296 
297  // FIXME: this is a waste of memory.
298  Matrix m ((range.matrix_value ().all ()).all ());
299 
300  retval = ! m.is_empty () && m(0, 0) != 0.0;
301  }
302  }
303 
304  return retval;
305 }
306 
307 Complex
309 {
310  octave_idx_type nel = range.numel ();
311 
312  if (nel == 0)
313  err_invalid_conversion ("range", "complex scalar");
314 
315  warn_implicit_conversion ("Octave:array-to-scalar",
316  "range", "complex scalar");
317 
318  return Complex (range.base (), 0);
319 }
320 
323 {
324  float tmp = lo_ieee_float_nan_value ();
325 
326  FloatComplex retval (tmp, tmp);
327 
328  octave_idx_type nel = range.numel ();
329 
330  if (nel == 0)
331  err_invalid_conversion ("range", "complex scalar");
332 
333  warn_implicit_conversion ("Octave:array-to-scalar",
334  "range", "complex scalar");
335 
336  retval = range.base ();
337 
338  return retval;
339 }
340 
343 {
344  Matrix m = range.matrix_value ();
345 
346  if (m.any_element_is_nan ())
348  if (warn && m.any_element_not_one_or_zero ())
350 
351  return boolNDArray (m);
352 }
353 
355 octave_range::resize (const dim_vector& dv, bool fill) const
356 {
358  if (fill)
359  retval.resize (dv, 0);
360  else
361  retval.resize (dv);
362  return retval;
363 }
364 
366 octave_range::convert_to_str_internal (bool pad, bool force, char type) const
367 {
369  return tmp.convert_to_str (pad, force, type);
370 }
371 
374 {
375  return range;
376 }
377 
380 {
381  return FloatMatrix (range.matrix_value ());
382 }
383 
386 {
387  return int8NDArray (range.matrix_value ());
388 }
389 
392 {
393  return int16NDArray (range.matrix_value ());
394 }
395 
398 {
399  return int32NDArray (range.matrix_value ());
400 }
401 
404 {
405  return int64NDArray (range.matrix_value ());
406 }
407 
410 {
411  return uint8NDArray (range.matrix_value ());
412 }
413 
416 {
417  return uint16NDArray (range.matrix_value ());
418 }
419 
422 {
423  return uint32NDArray (range.matrix_value ());
424 }
425 
428 {
429  return uint64NDArray (range.matrix_value ());
430 }
431 
432 void
433 octave_range::print (std::ostream& os, bool pr_as_read_syntax)
434 {
435  print_raw (os, pr_as_read_syntax);
436  newline (os);
437 }
438 
439 void
440 octave_range::print_raw (std::ostream& os, bool pr_as_read_syntax) const
441 {
442  octave_print_internal (os, range, pr_as_read_syntax,
444 }
445 
446 bool
447 octave_range::print_name_tag (std::ostream& os, const std::string& name) const
448 {
449  bool retval = false;
450 
451  octave_idx_type n = range.numel ();
452 
453  indent (os);
454 
455  if (n == 0 || n == 1)
456  os << name << " = ";
457  else
458  {
459  os << name << " =";
460  newline (os);
461  if (! Vcompact_format)
462  newline (os);
463 
464  retval = true;
465  }
466 
467  return retval;
468 }
469 
470 void
471 octave_range::short_disp (std::ostream& os) const
472 {
473  octave_idx_type len = range.numel ();
474 
475  if (len == 0)
476  os << "[]";
477  else
478  {
479  os << range.base () << ":";
480 
481  if (len > 1)
482  {
483  if (range.inc () != 1)
484  os << range.inc () << ":";
485 
486  os << range.limit ();
487  }
488  }
489 }
490 
491 // Skip white space and comments on stream IS.
492 
493 static void
494 skip_comments (std::istream& is)
495 {
496  char c = '\0';
497  while (is.get (c))
498  {
499  if (c == ' ' || c == '\t' || c == '\n')
500  ; // Skip whitespace on way to beginning of next line.
501  else
502  break;
503  }
504 
505  skip_until_newline (is, false);
506 }
507 
508 bool
509 octave_range::save_ascii (std::ostream& os)
510 {
511  Range r = range_value ();
512  double base = r.base ();
513  double limit = r.limit ();
514  double inc = r.inc ();
515  octave_idx_type len = r.numel ();
516 
517  if (inc != 0)
518  os << "# base, limit, increment\n";
519  else
520  os << "# base, length, increment\n";
521 
522  octave_write_double (os, base);
523  os << " ";
524  if (inc != 0)
525  octave_write_double (os, limit);
526  else
527  os << len;
528  os << " ";
529  octave_write_double (os, inc);
530  os << "\n";
531 
532  return true;
533 }
534 
535 bool
537 {
538  // # base, limit, range comment added by save ().
539  skip_comments (is);
540 
541  double base, limit, inc;
542  is >> base >> limit >> inc;
543 
544  if (! is)
545  error ("load: failed to load range constant");
546 
547  if (inc != 0)
548  range = Range (base, limit, inc);
549  else
550  range = Range (base, inc, static_cast<octave_idx_type> (limit));
551 
552  return true;
553 }
554 
555 bool
556 octave_range::save_binary (std::ostream& os, bool& /* save_as_floats */)
557 {
558  char tmp = LS_DOUBLE;
559  os.write (reinterpret_cast<char *> (&tmp), 1);
560  Range r = range_value ();
561  double bas = r.base ();
562  double lim = r.limit ();
563  double inc = r.inc ();
564  if (inc == 0)
565  lim = r.numel ();
566 
567  os.write (reinterpret_cast<char *> (&bas), 8);
568  os.write (reinterpret_cast<char *> (&lim), 8);
569  os.write (reinterpret_cast<char *> (&inc), 8);
570 
571  return true;
572 }
573 
574 bool
575 octave_range::load_binary (std::istream& is, bool swap,
577 {
578  char tmp;
579  if (! is.read (reinterpret_cast<char *> (&tmp), 1))
580  return false;
581  double bas, lim, inc;
582  if (! is.read (reinterpret_cast<char *> (&bas), 8))
583  return false;
584  if (swap)
585  swap_bytes<8> (&bas);
586  if (! is.read (reinterpret_cast<char *> (&lim), 8))
587  return false;
588  if (swap)
589  swap_bytes<8> (&lim);
590  if (! is.read (reinterpret_cast<char *> (&inc), 8))
591  return false;
592  if (swap)
593  swap_bytes<8> (&inc);
594  if (inc != 0)
595  range = Range (bas, lim, inc);
596  else
597  range = Range (bas, inc, static_cast<octave_idx_type> (lim));
598 
599  return true;
600 }
601 
602 #if defined (HAVE_HDF5)
603 
604 // The following subroutines creates an HDF5 representation of the way
605 // we will store Octave range types (triplets of floating-point numbers).
606 // NUM_TYPE is the HDF5 numeric type to use for storage (e.g.
607 // H5T_NATIVE_DOUBLE to save as 'double'). Note that any necessary
608 // conversions are handled automatically by HDF5.
609 
610 static hid_t
611 hdf5_make_range_type (hid_t num_type)
612 {
613  hid_t type_id = H5Tcreate (H5T_COMPOUND, sizeof (double) * 3);
614 
615  H5Tinsert (type_id, "base", 0 * sizeof (double), num_type);
616  H5Tinsert (type_id, "limit", 1 * sizeof (double), num_type);
617  H5Tinsert (type_id, "increment", 2 * sizeof (double), num_type);
618 
619  return type_id;
620 }
621 
622 #endif
623 
624 bool
626  bool /* save_as_floats */)
627 {
628  bool retval = false;
629 
630 #if defined (HAVE_HDF5)
631 
632  hsize_t dimens[3];
633  hid_t space_hid, type_hid, data_hid;
634  space_hid = type_hid = data_hid = -1;
635 
636  space_hid = H5Screate_simple (0, dimens, 0);
637  if (space_hid < 0) return false;
638 
639  type_hid = hdf5_make_range_type (H5T_NATIVE_DOUBLE);
640  if (type_hid < 0)
641  {
642  H5Sclose (space_hid);
643  return false;
644  }
645 #if defined (HAVE_HDF5_18)
646  data_hid = H5Dcreate (loc_id, name, type_hid, space_hid,
648 #else
649  data_hid = H5Dcreate (loc_id, name, type_hid, space_hid, octave_H5P_DEFAULT);
650 #endif
651  if (data_hid < 0)
652  {
653  H5Sclose (space_hid);
654  H5Tclose (type_hid);
655  return false;
656  }
657 
658  Range r = range_value ();
659  double range_vals[3];
660  range_vals[0] = r.base ();
661  range_vals[1] = r.inc () != 0 ? r.limit () : r.numel ();
662  range_vals[2] = r.inc ();
663 
664  if (H5Dwrite (data_hid, type_hid, octave_H5S_ALL, octave_H5S_ALL,
665  octave_H5P_DEFAULT, range_vals)
666  >= 0)
667  {
668  octave_idx_type nel = r.numel ();
669  retval = hdf5_add_scalar_attr (data_hid, H5T_NATIVE_IDX,
670  "OCTAVE_RANGE_NELEM", &nel) >= 0;
671  }
672  else
673  retval = false;
674 
675  H5Dclose (data_hid);
676  H5Tclose (type_hid);
677  H5Sclose (space_hid);
678 
679 #else
680  octave_unused_parameter (loc_id);
681  octave_unused_parameter (name);
682 
683  warn_save ("hdf5");
684 #endif
685 
686  return retval;
687 }
688 
689 bool
691 {
692  bool retval = false;
693 
694 #if defined (HAVE_HDF5)
695 
696 #if defined (HAVE_HDF5_18)
697  hid_t data_hid = H5Dopen (loc_id, name, octave_H5P_DEFAULT);
698 #else
699  hid_t data_hid = H5Dopen (loc_id, name);
700 #endif
701  hid_t type_hid = H5Dget_type (data_hid);
702 
703  hid_t range_type = hdf5_make_range_type (H5T_NATIVE_DOUBLE);
704 
705  if (! hdf5_types_compatible (type_hid, range_type))
706  {
707  H5Tclose (range_type);
708  H5Dclose (data_hid);
709  return false;
710  }
711 
712  hid_t space_hid = H5Dget_space (data_hid);
713  hsize_t rank = H5Sget_simple_extent_ndims (space_hid);
714 
715  if (rank != 0)
716  {
717  H5Tclose (range_type);
718  H5Sclose (space_hid);
719  H5Dclose (data_hid);
720  return false;
721  }
722 
723  double rangevals[3];
724  if (H5Dread (data_hid, range_type, octave_H5S_ALL, octave_H5S_ALL,
725  octave_H5P_DEFAULT, rangevals)
726  >= 0)
727  {
728  retval = true;
729  octave_idx_type nel;
730  if (hdf5_get_scalar_attr (data_hid, H5T_NATIVE_IDX,
731  "OCTAVE_RANGE_NELEM", &nel))
732  range = Range (rangevals[0], rangevals[2], nel);
733  else
734  {
735  if (rangevals[2] != 0)
736  range = Range (rangevals[0], rangevals[1], rangevals[2]);
737  else
738  range = Range (rangevals[0], rangevals[2],
739  static_cast<octave_idx_type> (rangevals[1]));
740  }
741  }
742 
743  H5Tclose (range_type);
744  H5Sclose (space_hid);
745  H5Dclose (data_hid);
746 
747 #else
748  octave_unused_parameter (loc_id);
749  octave_unused_parameter (name);
750 
751  warn_load ("hdf5");
752 #endif
753 
754  return retval;
755 }
756 
757 mxArray *
759 {
761 
762  double *pr = static_cast<double *> (retval->get_data ());
763 
764  mwSize nel = numel ();
765 
766  Matrix m = matrix_value ();
767 
768  const double *p = m.data ();
769 
770  for (mwSize i = 0; i < nel; i++)
771  pr[i] = p[i];
772 
773  return retval;
774 }
775 
778 {
779  return (n < range.numel ()) ? octave_value (range.elem (n))
780  : octave_value ();
781 }
782 
783 DEFUN (allow_noninteger_range_as_index, args, nargout,
784  doc: /* -*- texinfo -*-
785 @deftypefn {} {@var{val} =} allow_noninteger_range_as_index ()
786 @deftypefnx {} {@var{old_val} =} allow_noninteger_range_as_index (@var{new_val})
787 @deftypefnx {} {} allow_noninteger_range_as_index (@var{new_val}, "local")
788 Query or set the internal variable that controls whether non-integer
789 ranges are allowed as indices.
790 
791 This might be useful for @sc{matlab} compatibility; however, it is still not
792 entirely compatible because @sc{matlab} treats the range expression
793 differently in different contexts.
794 
795 When called from inside a function with the @qcode{"local"} option, the
796 variable is changed locally for the function and any subroutines it calls.
797 The original variable value is restored when exiting the function.
798 @end deftypefn */)
799 {
800  static bool warned = false;
801  if (! warned)
802  {
803  warned = true;
804  warning_with_id ("Octave:deprecated-function",
805  "allow_noninteger_range_as_index is obsolete and will be removed from a future version of Octave");
806  }
807 
808  return SET_INTERNAL_VARIABLE (allow_noninteger_range_as_index);
809 }
810 
811 /*
812 %!test
813 %! x = 0:10;
814 %! warning ("off", "Octave:deprecated-function", "local");
815 %! save = allow_noninteger_range_as_index ();
816 %! warn_state = warning ("query", "Octave:noninteger-range-as-index");
817 %! unwind_protect
818 %! allow_noninteger_range_as_index (false);
819 %! fail ("x(2.1:5)");
820 %! assert (x(2:5), 1:4);
821 %! allow_noninteger_range_as_index (true);
822 %! warning ("off", "Octave:noninteger-range-as-index");
823 %! assert (x(2.49:5), 1:3);
824 %! assert (x(2.5:5), 2:4);
825 %! assert (x(2.51:5), 2:4);
826 %! unwind_protect_cleanup
827 %! allow_noninteger_range_as_index (save);
828 %! warning (warn_state.state, warn_state.identifier);
829 %! end_unwind_protect
830 */
Matrix diag(octave_idx_type k=0) const
Definition: dMatrix.cc:2471
void octave_write_double(std::ostream &os, double d)
Definition: lo-utils.cc:388
type_conv_info numeric_conversion_function(void) const
Definition: ov-range.cc:74
bool load_hdf5(octave_hdf5_id loc_id, const char *name)
Definition: ov-range.cc:690
void warning_with_id(const char *id, const char *fmt,...)
Definition: error.cc:803
octave_value convert_to_str_internal(bool pad, bool force, char type) const
Definition: ov-range.cc:366
static hid_t hdf5_make_range_type(hid_t num_type)
Definition: ov-range.cc:611
octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
Definition: ov-range.cc:107
octave_hdf5_err hdf5_add_scalar_attr(octave_hdf5_id loc_id, octave_hdf5_id type_id, const char *attr_name, void *buf)
Definition: ls-hdf5.cc:853
mxArray * as_mxArray(void) const
Definition: ov-range.cc:758
intNDArray< octave_int64 > int64NDArray
Definition: int64NDArray.h:33
boolMatrix any(int dim=-1) const
Definition: dMatrix.cc:2429
dim_vector dims(void) const
Definition: ov-range.h:110
Range range_value(void) const
Definition: ov-range.h:248
static void skip_comments(std::istream &is)
Definition: ov-range.cc:494
void warn_logical_conversion(void)
Definition: errwarn.cc:353
const octave_hdf5_id octave_H5S_ALL
void set_pos_if_unset(octave_idx_type nd_arg, octave_idx_type dim_arg)
NDArray array_value(bool=false) const
Definition: ov-range.h:188
octave_idx_type length(void) const
Definition: ovl.h:96
intNDArray< octave_uint32 > uint32NDArray
Definition: uint32NDArray.h:33
intNDArray< octave_uint8 > uint8NDArray
Definition: uint8NDArray.h:33
intNDArray< octave_uint16 > uint16NDArray
Definition: uint16NDArray.h:33
void skip_until_newline(std::istream &is, bool keep_newline)
for large enough k
Definition: lu.cc:606
Range range
Definition: ov-range.h:308
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the then the first element defines the pivoting tolerance for the unsymmetric the values defined such that for full matrix
Definition: lu.cc:138
Definition: Range.h:33
charNDArray char_array_value(bool=false) const
Definition: ov-range.cc:219
void swap_bytes< 8 >(void *ptr)
Definition: byte-swap.h:68
#define DEFUN(name, args_name, nargout_name, doc)
Definition: defun.h:46
std::string type_name(void) const
Definition: ov-range.h:328
void error(const char *fmt,...)
Definition: error.cc:570
octave_base_value * try_narrowing_conversion(void)
Definition: ov-range.cc:81
#define SET_INTERNAL_VARIABLE(NM)
Definition: variables.h:126
float float_value(bool=false) const
Definition: ov-range.cc:205
void indent(std::ostream &os) const
Definition: ov-base.cc:1362
bool load_ascii(std::istream &is)
Definition: ov-range.cc:536
void * get_data(void) const
Definition: mxarray.h:449
bool save_binary(std::ostream &os, bool &save_as_floats)
Definition: ov-range.cc:556
#define DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA(t, n, c)
Definition: ov-base.h:169
T & elem(octave_idx_type n)
Definition: Array.h:482
octave_value as_int8(void) const
Definition: ov-range.cc:385
octave_value as_uint16(void) const
Definition: ov-range.cc:415
intNDArray< octave_int16 > int16NDArray
Definition: int16NDArray.h:33
bool any_element_is_nan(void) const
Definition: dNDArray.cc:555
void err_nan_to_logical_conversion(void)
i e
Definition: data.cc:2724
void newline(std::ostream &os) const
Definition: ov-base.cc:1381
static octave_base_value * default_numeric_conversion_function(const octave_base_value &a)
Definition: ov-range.cc:66
double double_value(bool=false) const
Definition: ov-range.cc:191
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
Definition: dim-vector.h:389
bool hdf5_get_scalar_attr(octave_hdf5_id loc_id, octave_hdf5_id type_id, const char *attr_name, void *buf)
Definition: ls-hdf5.cc:270
bool save_ascii(std::ostream &os)
Definition: ov-range.cc:509
virtual octave_idx_type numel(void) const
Definition: ov-base.h:329
idx_vector * idx_cache
Definition: ov-range.h:322
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 any(int dim=0) const
Definition: ov-range.cc:243
JNIEnv void * args
Definition: ov-java.cc:67
bool any_element_not_one_or_zero(void) const
Definition: dNDArray.cc:567
void warn_load(const char *type) const
Definition: ov-base.cc:1151
bool Vcompact_format
Definition: pr-output.cc:107
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
OCTAVE_EXPORT octave_value_list isdir nd deftypefn *std::string nm
Definition: utils.cc:941
octave_value as_int32(void) const
Definition: ov-range.cc:397
octave_value do_index_op(const octave_value_list &idx, bool resize_ok=false)
Definition: ov-range.cc:134
octave_value as_double(void) const
Definition: ov-range.cc:373
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
Definition: ov-usr-fcn.cc:935
intNDArray< octave_int8 > int8NDArray
Definition: int8NDArray.h:33
octave_value as_int64(void) const
Definition: ov-range.cc:403
void short_disp(std::ostream &os) const
Definition: ov-range.cc:471
double limit(void) const
Definition: Range.h:79
nd deftypefn *octave_map m
Definition: ov-struct.cc:2058
octave_value fast_elem_extract(octave_idx_type n) const
Definition: ov-range.cc:777
bool hdf5_types_compatible(octave_hdf5_id t1, octave_hdf5_id t2)
Definition: ls-hdf5.cc:192
double inc(void) const
Definition: Range.h:80
static int static_type_id(void)
Definition: ov-re-mat.h:250
bool load_binary(std::istream &is, bool swap, octave::mach_info::float_format fmt)
Definition: ov-range.cc:575
octave_idx_type numel(void) const
Definition: Range.h:85
const T * data(void) const
Definition: Array.h:582
bool is_empty(void) const
Definition: Range.h:87
Matrix diag(octave_idx_type k=0) const
Definition: Range.cc:251
Matrix matrix_value(bool=false) const
Definition: ov-range.h:182
octave_value as_int16(void) const
Definition: ov-range.cc:391
void resize(const dim_vector &dv, const T &rfv)
Definition: Array.cc:1028
double tmp
Definition: data.cc:6300
double elem(octave_idx_type i) const
Definition: Range.cc:88
octave_value retval
Definition: data.cc:6294
octave_value as_uint32(void) const
Definition: ov-range.cc:421
#define panic_impossible()
Definition: error.h:40
int64_t octave_hdf5_id
Matrix matrix_value(void) const
Definition: Range.cc:52
idx type
Definition: ov.cc:3129
bool print_name_tag(std::ostream &os, const std::string &name) const
Definition: ov-range.cc:447
Definition: dMatrix.h:37
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
Definition: lu.cc:138
octave_value as_uint64(void) const
Definition: ov-range.cc:427
boolNDArray bool_array_value(bool warn=false) const
Definition: ov-range.cc:342
float lo_ieee_float_nan_value(void)
Definition: lo-ieee.cc:202
void warn_save(const char *type) const
Definition: ov-base.cc:1160
void mxArray
Definition: mex.h:55
friend class octave_value
Definition: ov-base.h:211
bool save_hdf5(octave_hdf5_id loc_id, const char *name, bool save_as_floats)
Definition: ov-range.cc:625
bool is_true(void) const
Definition: ov-range.cc:272
Array< double > index(const idx_vector &i) const
Definition: Range.cc:127
intNDArray< octave_int32 > int32NDArray
Definition: int32NDArray.h:33
void err_invalid_conversion(const std::string &from, const std::string &to)
Definition: errwarn.cc:68
=val(i)}if ode{val(i)}occurs in table i
Definition: lookup.cc:239
boolMatrix all(int dim=-1) const
Definition: dMatrix.cc:2423
int current_print_indent_level(void) const
Definition: ov-base.h:830
p
Definition: lu.cc:138
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
bool is_scalar(void) const
Definition: idx-vector.h:568
void print(std::ostream &os, bool pr_as_read_syntax=false)
Definition: ov-range.cc:433
bool all_elements_are_ints(void) const
Definition: Range.cc:40
idx_vector index_vector(bool require_integers=false) const
Definition: ov-range.cc:170
#define H5T_NATIVE_IDX
Definition: oct-hdf5.h:39
octave_value as_single(void) const
Definition: ov-range.cc:379
static bool Vallow_noninteger_range_as_index
Definition: ov-range.cc:61
double base(void) const
Definition: Range.h:78
void warn_array_as_logical(const dim_vector &dv)
Definition: errwarn.cc:276
octave_value resize(const dim_vector &dv, bool fill=false) const
Definition: ov-range.cc:355
const octave_hdf5_id octave_H5P_DEFAULT
bool is_empty(void) const
Definition: oct-map.h:373
std::complex< float > FloatComplex
Definition: oct-cmplx.h:32
Definition: mxarray.h:76
std::complex< double > Complex
Definition: oct-cmplx.h:31
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
Definition: ov-range.cc:440
FloatComplex float_complex_value(bool=false) const
Definition: ov-range.cc:322
write the output to stdout if nargout is
Definition: load-save.cc:1576
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
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
octave_value diag(octave_idx_type k=0) const
Definition: ov-range.cc:253
dim_vector dv
Definition: sub2ind.cc:263
octave_value next_subsref(const std::string &type, const std::list< octave_value_list > &idx, size_t skip=1)
Definition: ov.cc:1462
octave_value as_uint8(void) const
Definition: ov-range.cc:409
Complex complex_value(bool=false) const
Definition: ov-range.cc:308
octave_value all(int dim=0) const
Definition: ov-range.cc:233
intNDArray< octave_uint64 > uint64NDArray
Definition: uint64NDArray.h:33
idx_vector set_idx_cache(const idx_vector &idx) const
Definition: ov-range.h:310
octave_value do_index_op(const octave_value_list &idx, bool resize_ok=false)
Definition: ov.h:454