38 _idxadds_helper (T *a, T v) : m_array (a), m_val (v) { }
41 { m_array[i] += m_val; }
52 _idxadda_helper (T *a,
const T *v) : m_array (a), m_vals (v) { }
55 { m_array[i] += *m_vals++; }
77 idx.loop (
len, _idxadds_helper<T> (this->rwdata (), val));
95 idx.loop (
len, _idxadda_helper<T> (this->rwdata (), vals.
data ()));
98template <
typename T, T op (
typename ref_param<T>::type,
99 typename ref_param<T>::type)>
100struct _idxbinop_helper
103 _idxbinop_helper (T *a,
const T *v) : m_array (a), m_vals (v) { }
106 { m_array[i] = op (m_array[i], *m_vals++); }
128 idx.loop (
len, _idxbinop_helper<T, octave::math::min> (this->rwdata (),
147 idx.loop (
len, _idxbinop_helper<T, octave::math::max> (this->rwdata (),
156 int nd = std::max (this->ndims (), vals.
ndims ());
179 sdv(dim) = ddv(dim) = 0;
181 (*current_liboctave_error_handler) (
"accumdim: dimension mismatch");
184 const T *src = vals.
data ();
193 idx.loop (
len, _idxadda_helper<T> (dst + j*n, src + j*ns));
319#define MARRAY_NDS_OP(OP, FN) \
320 template <typename T> \
322 operator OP (const MArray<T>& a, const T& s) \
324 return do_ms_binary_op<T, T, T> (a, s, FN); \
334#define MARRAY_SND_OP(OP, FN) \
335 template <typename T> \
337 operator OP (const T& s, const MArray<T>& a) \
339 return do_sm_binary_op<T, T, T> (s, a, FN); \
349#define MARRAY_NDND_OP(FCN, OP, FN) \
350 template <typename T> \
352 FCN (const MArray<T>& a, const MArray<T>& b) \
354 return do_mm_binary_op<T, T, T> (a, b, FN, FN, FN, #FCN); \
385#define INSTANTIATE_MARRAY(T, API) \
386 template <> API void \
387 MArray<T>::instantiation_guard () { } \
389 template class API MArray<T>
#define MARRAY_NDS_OP(OP, FN)
MArray< T > & operator+=(MArray< T > &a, const T &s)
MArray< T > & quotient_eq(MArray< T > &a, const MArray< T > &b)
MArray< T > & operator/=(MArray< T > &a, const T &s)
MArray< T > & operator-=(MArray< T > &a, const T &s)
MArray< T > operator-(const MArray< T > &a, const T &s)
MArray< T > product(const MArray< T > &a, const MArray< T > &b)
MArray< T > & operator*=(MArray< T > &a, const T &s)
#define MARRAY_SND_OP(OP, FN)
MArray< T > & product_eq(MArray< T > &a, const MArray< T > &b)
#define MARRAY_NDND_OP(FCN, OP, FN)
MArray< T > quotient(const MArray< T > &a, const MArray< T > &b)
N Dimensional Array with copy-on-write semantics.
const dim_vector & dims() const
Return a const-reference so that dims ()(i) works efficiently.
int ndims() const
Size of the specified dimension.
void resize(const dim_vector &dv, const T &rfv)
Size of the specified dimension.
const T * data() const
Size of the specified dimension.
bool is_shared() const
Size of the specified dimension.
T * rwdata()
Size of the specified dimension.
octave_idx_type numel() const
Number of elements in the array.
Template for N-dimensional array classes with like-type math operators.
void idx_min(const octave::idx_vector &idx, const MArray< T > &vals)
void idx_add_nd(const octave::idx_vector &idx, const MArray< T > &vals, int dim=-1)
void idx_add(const octave::idx_vector &idx, T val)
Performs indexed accumulative addition.
void idx_max(const octave::idx_vector &idx, const MArray< T > &vals)
Vector representing the dimensions (size) of an Array.
int first_non_singleton(int def=0) const
dim_vector redim(int n) const
Force certain dimensionality, preserving numel ().
void mx_inline_div2(std::size_t n, R *r, const X *x)
void mx_inline_sub2(std::size_t n, R *r, const X *x)
void mx_inline_add2(std::size_t n, R *r, const X *x)
void mx_inline_sub(std::size_t n, R *r, const X *x, const Y *y)
void mx_inline_uminus(std::size_t n, R *r, const X *x)
void mx_inline_uminus2(std::size_t n, R *r)
void mx_inline_div(std::size_t n, R *r, const X *x, const Y *y)
void mx_inline_add(std::size_t n, R *r, const X *x, const Y *y)
void mx_inline_mul2(std::size_t n, R *r, const X *x)
void mx_inline_mul(std::size_t n, R *r, const X *x, const Y *y)
void get_extent_triplet(const dim_vector &dims, int &dim, octave_idx_type &l, octave_idx_type &n, octave_idx_type &u)
T::size_type numel(const T &str)