26 #if defined (HAVE_CONFIG_H)
60 T rmax = q / (2 - ct);
63 t1 = (ct / q) * (t1 < 0 ? -t1 : t1);
64 t1 = (rmax < t1 ? rmax : t1);
65 t1 = (ct > t1 ? ct : t1);
68 if (
x <= 0 || (t1 -
x) < rmax)
75 bool xteq (T u, T v, T ct = 3 * std::numeric_limits<T>::epsilon ())
80 return std::abs (u - v) < ((tu > tv ? tu : tv) * ct);
91 && ((inc > 0 && limit > 0)
92 || (inc < 0 && limit < 0)))
95 || (limit > base && inc < 0)
96 || (limit < base && inc > 0))
102 T ct = 3 * std::numeric_limits<T>::epsilon ();
104 T tmp =
xtfloor ((limit - base + inc) / inc, ct);
120 if (!
xteq (base + (n_elt - 1) * inc, limit))
122 if (
xteq (base + (n_elt - 2) * inc, limit))
124 else if (
xteq (base + n_elt * inc, limit))
135 template <
typename T>
156 template <
typename T>
167 retval = base + (nel - 1) * inc;
179 if ((inc > T (0) && retval >= limit) || (inc < T (0) && retval <= limit))
193 template <
typename T>
195 xinit (T base, T limit, T inc,
bool reverse, T& final_val,
212 || (limit < base && inc > 0)
213 || (limit > base && inc < 0))
222 if ((limit <= base && base + inc < limit)
223 || (limit >= base && base + inc > limit))
233 T dnel = (limit - base) / inc;
260 template <
typename T>
281 final_val = base - (nel - 1) * inc;
286 || (limit > base && inc < octave_int<T> (0))
292 final_val = base + (nel - 1) * inc;
296 template <
typename T>
305 range<double>::all_elements_are_ints (
void)
const
312 range<float>::all_elements_are_ints (
void)
const
319 range<double>::init (
void)
321 xinit (m_base, m_limit, m_increment, m_reverse, m_final, m_numel);
326 range<float>::init (
void)
328 xinit (m_base, m_limit, m_increment, m_reverse, m_final, m_numel);
337 range<octave_int8>::init (
void)
339 xinit (m_base, m_limit, m_increment, m_reverse, m_final, m_numel);
344 range<octave_int16>::init (
void)
346 xinit (m_base, m_limit, m_increment, m_reverse, m_final, m_numel);
351 range<octave_int32>::init (
void)
353 xinit (m_base, m_limit, m_increment, m_reverse, m_final, m_numel);
358 range<octave_int64>::init (
void)
360 xinit (m_base, m_limit, m_increment, m_reverse, m_final, m_numel);
365 range<octave_uint8>::init (
void)
367 xinit (m_base, m_limit, m_increment, m_reverse, m_final, m_numel);
372 range<octave_uint16>::init (
void)
374 xinit (m_base, m_limit, m_increment, m_reverse, m_final, m_numel);
379 range<octave_uint32>::init (
void)
381 xinit (m_base, m_limit, m_increment, m_reverse, m_final, m_numel);
386 range<octave_uint64>::init (
void)
388 xinit (m_base, m_limit, m_increment, m_reverse, m_final, m_numel);
395 range<double>::is_storable (
void)
const
402 range<float>::is_storable (
void)
const
407 template <
typename T>
418 if ((base > 0 && limit > 0) || (base < 0 && limit < 0))
428 if (base == 0 || final_val == 0)
443 range<double>::nnz (
void)
const
445 return xnnz (m_base, m_limit, m_increment, m_final, m_numel);
450 range<float>::nnz (
void)
const
452 return xnnz (m_base, m_limit, m_increment, m_final, m_numel);
481 else if (
m_inc != 0.0)
574 if (idx.extent (
n) !=
n)
584 retval.
clear (idx_dims);
659 || (! ascending && m_base < m_limit && m_inc > 0.0))
675 bool reverse =
false;
678 || (! ascending && m_base < m_limit && m_inc > 0.0))
701 Range retval = *
this;
711 (*current_liboctave_error_handler) (
"Range::sort: invalid dimension");
720 Range retval = *
this;
730 (*current_liboctave_error_handler) (
"Range::sort: invalid dimension");
784 double b = a.
base ();
793 os << b + i * increment <<
' ';
824 return Range (-
r.base (), -
r.limit (), -
r.increment (),
r.numel ());
830 return Range (
x +
r.base (),
x +
r.limit (),
r.increment (),
r.numel ());
836 return Range (
r.base () +
x,
r.limit () +
x,
r.increment (),
r.numel ());
842 return Range (
x -
r.base (),
x -
r.limit (), -
r.increment (),
r.numel ());
848 return Range (
r.base () -
x,
r.limit () -
x,
r.increment (),
r.numel ());
854 return Range (
x *
r.base (),
x *
r.limit (),
x *
r.increment (),
r.numel ());
860 return Range (
r.base () *
x,
r.limit () *
x,
r.increment () *
x,
r.numel ());
911 double rmax = q / (2.0 - ct);
914 t1 = (ct / q) * (t1 < 0.0 ? -t1 : t1);
915 t1 = (rmax < t1 ? rmax : t1);
916 t1 = (ct > t1 ? ct : t1);
919 if (
x <= 0.0 || (t1 -
x) < rmax)
927 double ct = 3.0 * std::numeric_limits<double>::epsilon ())
932 return std::abs (u - v) < ((tu > tv ? tu : tv) * ct);
949 || (m_limit < m_base && m_inc > 0))
955 double ct = 3.0 * std::numeric_limits<double>::epsilon ();
octave_idx_type xnnz(T base, T limit, T inc, T final_val, octave_idx_type nel)
bool xteq(T u, T v, T ct=3 *std::numeric_limits< T >::epsilon())
bool xis_storable(T base, T limit, octave_idx_type nel)
void xinit(T base, T limit, T inc, bool reverse, T &final_val, octave_idx_type &nel)
Range operator*(double x, const Range &r)
octave_idx_type xnumel_internal(T base, T limit, T inc)
std::ostream & operator<<(std::ostream &os, const Range &a)
T xfinal_value(T base, T limit, T inc, octave_idx_type nel)
Range operator-(const Range &r)
Range operator+(double x, const Range &r)
std::istream & operator>>(std::istream &is, Range &a)
static bool teq(double u, double v, double ct=3.0 *std::numeric_limits< double >::epsilon())
static double tfloor(double x, double ct)
bool xall_elements_are_ints(T base, T inc, T final_val, octave_idx_type nel)
charNDArray max(char d, const charNDArray &m)
OCTARRAY_API void clear(void)
OCTARRAY_API void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
OCTARRAY_API T * fortran_vec(void)
Size of the specified dimension.
OCTARRAY_OVERRIDABLE_FUNC_API T & xelem(octave_idx_type n)
Size of the specified dimension.
MArray< T > reshape(const dim_vector &new_dims) const
OCTAVE_API Matrix diag(octave_idx_type k=0) const
double increment(void) const
OCTAVE_API void set_inc(double i)
OCTAVE_API octave_idx_type numel_internal(void) const
OCTAVE_API Array< double > index(const octave::idx_vector &i) const
dim_vector dims(void) const
OCTAVE_API sortmode issorted(sortmode mode=ASCENDING) const
OCTAVE_API double elem(octave_idx_type i) const
OCTAVE_API Range sort(octave_idx_type dim=0, sortmode mode=ASCENDING) const
OCTAVE_API Matrix diag(octave_idx_type k=0) const
OCTAVE_API octave_idx_type nnz(void) const
OCTAVE_API double limit_internal(void) const
OCTAVE_API void init(void)
OCTAVE_API Matrix matrix_value(void) const
OCTAVE_API void set_base(double b)
OCTAVE_API void sort_internal(bool ascending=true)
OCTAVE_API bool all_elements_are_ints(void) const
octave_idx_type numel(void) const
OCTAVE_API double max(void) const
OCTAVE_API double min(void) const
OCTAVE_API double checkelem(octave_idx_type i) const
OCTAVE_API void set_limit(double l)
Vector representing the dimensions (size) of an Array.
bool isvector(void) const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
static OCTAVE_NORETURN void err_index_out_of_range(void)
octave::idx_vector idx_vector
octave_idx_type nint_big(double x)
std::complex< T > floor(const std::complex< T > &x)
F77_RET_T const F77_DBLE * x