25 #if ! defined (octave_idx_vector_h) 26 #define octave_idx_vector_h 1 28 #include "octave-config.h" 41 template <
typename T>
class Array;
68 template <
typename T,
typename D>
friend class std::unique_ptr;
102 virtual idx_base_rep * sort_uniq_clone (
bool uniq =
false) = 0;
113 virtual std::ostream& print (std::ostream&
os)
const = 0;
148 { count++;
return this; }
154 std::ostream&
print (std::ostream&
os)
const;
184 {
return start +
i * step; }
192 return len ?
std::max (n,
start + 1 + (step < 0 ? 0 : step * (len - 1)))
203 {
return start == 0 && step == 1 && len == n; }
212 std::ostream&
print (std::ostream&
os)
const;
242 template <
typename T>
257 { count++;
return this; }
262 {
return n == 1 && data == 0; }
268 std::ostream&
print (std::ostream&
os)
const;
285 : data (nullptr), len (0), ext (0), aowner (nullptr), orig_dims ()
291 :
idx_base_rep (), data (_data), len (_len), ext (_ext),
292 aowner (nullptr), orig_dims (od)
301 template <
typename T>
337 std::ostream&
print (std::ostream&
os)
const;
371 :
idx_base_rep (), data (_data), len (_len), ext (_ext),
372 lsti (-1), lste (-1), aowner (nullptr), orig_dims (od)
399 { count++;
return this; }
406 {
return len == n && ext == n; }
408 const bool *
get_data (
void)
const {
return data; }
410 std::ostream&
print (std::ostream&
os)
const;
443 static idx_vector_rep *nil_rep (
void);
446 static idx_vector_rep *err_rep (
void);
454 if (--rep->count == 0)
470 #if OCTAVE_SIZEOF_F77_INT_TYPE != OCTAVE_SIZEOF_IDX_TYPE 505 template <
typename T>
515 template <
typename T>
538 if (--rep->count == 0)
546 if (--rep->count == 0)
558 {
return rep->length (n); }
561 {
return rep->extent (n); }
564 {
return rep->xelem (n); }
567 {
return rep->xelem (n); }
570 {
return rep->xelem (n); }
573 {
return ! rep->err; }
576 {
return rep->idx_class () == class_colon; }
579 {
return rep->idx_class () == class_scalar; }
582 {
return rep->idx_class () == class_range; }
585 {
return rep->is_colon_equiv (n); }
588 {
return idx_vector (rep->sort_uniq_clone (uniq)); }
596 {
return orig_dimensions () (0); }
599 {
return orig_dimensions () (1); }
602 {
return (! is_colon () && orig_dimensions ().any_zero ()); }
606 std::ostream&
print (std::ostream&
os)
const {
return rep->print (
os); }
609 {
return a.print (
os); }
619 template <
typename T>
625 switch (rep->idx_class ())
628 std::copy_n (src, len, dest);
636 const T *ssrc = src +
start;
638 std::copy_n (ssrc, len, dest);
640 std::reverse_copy (ssrc - len + 1, ssrc + 1, dest);
642 std::fill_n (dest, len, *ssrc);
663 dest[
i] = src[data[
i]];
673 if (data[
i]) *dest++ = src[
i];
693 template <
typename T>
699 switch (rep->idx_class ())
702 std::copy_n (src, len, dest);
710 T *sdest = dest +
start;
712 std::copy_n (src, len, sdest);
714 std::reverse_copy (src, src + len, sdest - len + 1);
735 dest[data[
i]] = src[
i];
745 if (data[
i]) dest[
i] = *src++;
765 template <
typename T>
771 switch (rep->idx_class ())
774 std::fill_n (dest, len,
val);
782 T *sdest = dest +
start;
784 std::fill_n (sdest, len,
val);
786 std::fill (sdest - len + 1, sdest + 1,
val);
817 if (data[
i]) dest[
i] =
val;
835 template <
typename Functor>
841 switch (rep->idx_class ())
858 for (
i = 0, j =
start;
i < len;
i++, j += step) body (j);
883 if (data[
i]) body (
i);
903 template <
typename Functor>
909 switch (rep->idx_class ())
914 for (
i = 0;
i < len && body (
i);
i++) ;
930 for (
i = 0, j =
start;
i < len && body (j);
i++, j += step) ;
938 ret = (body (r->
get_data ()) ? 1 : 0);
947 for (
i = 0;
i < len && body (data[
i]);
i++) ;
1014 void unconvert (idx_class_type& iclass,
1026 OCTAVE_DEPRECATED (4.4,
"use 'isvector' instead")
1034 {
return (*
this) (n); }
1037 {
return is_colon_equiv (n); }
1043 { *
this = sorted (uniq); }
idx_class_type idx_class(void) const
const octave_idx_type * get_data(void) const
virtual Array< octave_idx_type > as_array(void)
octave_idx_type checkelem(octave_idx_type n) const
dim_vector orig_dimensions(void) const
idx_base_rep * sort_uniq_clone(bool=false)
idx_class_type idx_class(void) const
idx_vector(const Array< octave_idx_type > &inda)
bool is_colon_equiv(octave_idx_type n) const
octave_idx_type extent(octave_idx_type n) const
void loop(octave_idx_type n, Functor body) const
nd group nd example oindent but is performed more efficiently If only and it is a scalar
octave_idx_type extent(octave_idx_type n) const
idx_class_type idx_class(void) const
static const idx_vector colon
bool is_colon_equiv(octave_idx_type n, int) const
identity matrix If supplied two scalar respectively For allows like xample val
octave_idx_type max(void) const
idx_vector(const Range &r)
octave_idx_type xelem(octave_idx_type n) const
idx_vector(const Array< octave_int< T >> &nda)
virtual dim_vector orig_dimensions(void) const
octave_idx_type extent(octave_idx_type n) const
void unconvert(idx_class_type &iclass, double &scalar, Range &range, Array< double > &array, Array< bool > &mask) const
dim_vector orig_dimensions(void) const
octave_idx_type extent(octave_idx_type n) const
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
virtual idx_class_type idx_class(void) const
octave_idx_type extent(octave_idx_type n) const
octave_idx_type length(octave_idx_type) const
octave_idx_type length(octave_idx_type) const
const bool * get_data(void) const
octave_idx_type elem(octave_idx_type n) const
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
dim_vector orig_dimensions(void) const
then the function must return scalars which will be concatenated into the return array(s). If code
idx_class_type idx_class(void) const
idx_class_type idx_class(void) const
octave_idx_type assign(const T *src, octave_idx_type n, T *dest) const
virtual bool is_colon_equiv(octave_idx_type) const
octave_idx_type orig_rows(void) const
octave_idx_type length(octave_idx_type) const
dim_vector orig_dimensions(void) const
bool is_range(void) const
octave_idx_type extent(octave_idx_type n) const
octave_idx_type xelem(octave_idx_type) const
bool is_colon(void) const
octave_idx_type length(octave_idx_type) const
int orig_empty(void) const
idx_range_rep(octave_idx_type _start, octave_idx_type _len, octave_idx_type _step, direct)
octave_idx_type length(octave_idx_type n=0) const
dim_vector freeze(Array< idx_vector > &ra_idx, const dim_vector &dimensions, int resize_ok)
idx_vector sorted(bool uniq=false) const
idx_vector_rep(octave_idx_type *_data, octave_idx_type _len, octave_idx_type _ext, const dim_vector &od, direct)
idx_vector(octave_idx_type i)
virtual octave_idx_type xelem(octave_idx_type i) const =0
octave_idx_type orig_columns(void) const
bool is_colon_equiv(octave_idx_type n) const
idx_mask_rep(bool *_data, octave_idx_type _len, octave_idx_type _ext, const dim_vector &od, direct)
idx_vector sorted(Array< octave_idx_type > &sidx) const
void sort(bool uniq=false)
virtual octave_idx_type checkelem(octave_idx_type i) const =0
bool isvector(const dim_vector &dim)
octave_idx_type get_step(void) const
octave::refcount< int > count
octave_idx_type get_start(void) const
octave_idx_type bloop(octave_idx_type n, Functor body) const
octave_idx_type get_data(void) const
idx_vector(const Array< float > &nda)
N Dimensional Array with copy-on-write semantics.
charNDArray max(char d, const charNDArray &m)
bool is_colon_equiv(octave_idx_type) const
dim_vector orig_dimensions(void) const
idx_vector(const Array< double > &nda)
idx_vector(const Array< octave_idx_type > &inda, octave_idx_type ext)
bool is_colon_equiv(octave_idx_type n) const
octave_idx_type index(const T *src, octave_idx_type n, T *dest) const
octave_idx_type xelem(octave_idx_type i) const
idx_base_rep * sort_uniq_clone(bool=false)
idx_scalar_rep(octave_idx_type i, direct)
idx_vector(idx_base_rep *r)
template OCTAVE_API std::ostream & operator<<(std::ostream &, const Array< bool > &)
idx_class_type idx_class(void) const
idx_vector(octave_idx_type start, octave_idx_type limit, octave_idx_type step=1)
octave_idx_type fill(const T &val, octave_idx_type n, T *dest) const
octave_idx_type xelem(octave_idx_type i) const
const octave_idx_type * data
idx_vector(octave_int< T > x)
virtual idx_base_rep * sort_idx(Array< octave_idx_type > &)=0
idx_vector(const Sparse< bool > &nda)
bool is_colon_equiv(octave_idx_type n) const
OCTAVE_EXPORT octave_value_list error nd deftypefn *const octave_scalar_map err
Array< octave_idx_type > * aowner
virtual idx_base_rep * sort_uniq_clone(bool uniq=false)=0
OCTAVE_EXPORT octave_value_list or cell arrays Arguments are concatenated vertically The returned values are padded with blanks as needed to make each row of the string array have the same length Empty input strings are significant and will concatenated in the output For numerical each element is converted to the corresponding ASCII character A range error results if an input is outside the ASCII range(0-255). For cell arrays
octave_idx_type length(octave_idx_type n) const
idx_base_rep * sort_uniq_clone(bool=false)
Vector representing the dimensions (size) of an Array.
idx_base_rep & operator=(const idx_base_rep &)=delete
bool is_scalar(void) const
octave_idx_type xelem(octave_idx_type i) const
static idx_vector make_range(octave_idx_type start, octave_idx_type step, octave_idx_type len)
virtual std::ostream & print(std::ostream &os) const =0
std::ostream & print(std::ostream &os) const
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 * x
idx_vector(const idx_vector &a)