24 #if ! defined (octave_MArray_h) 25 #define octave_MArray_h 1 27 #include "octave-config.h" 66 :
Array<T> (sdata, slen, adims, arep) { }
95 bool inv =
false)
const 126 #define MARRAY_FORWARD_DEFS(B, R, T) \ 127 inline R operator += (R& x, const T& y) \ 129 return R (operator += (dynamic_cast<B<T>&> (x), (y))); \ 131 inline R operator -= (R& x, const T& y) \ 133 return R (operator -= (dynamic_cast<B<T>&> (x), (y))); \ 135 inline R operator *= (R& x, const T& y) \ 137 return R (operator *= (dynamic_cast<B<T>&> (x), (y))); \ 139 inline R operator /= (R& x, const T& y) \ 141 return R (operator /= (dynamic_cast<B<T>&> (x), (y))); \ 143 inline R operator += (R& x, const R& y) \ 145 return R (operator += (dynamic_cast<B<T>&> (x), \ 146 dynamic_cast<const B<T>&> (y))); \ 148 inline R operator -= (R& x, const R& y) \ 150 return R (operator -= (dynamic_cast<B<T>&> (x), \ 151 dynamic_cast<const B<T>&> (y))); \ 153 inline R product_eq (R& x, const R& y) \ 155 return R (product_eq (dynamic_cast<B<T>&> (x), \ 156 dynamic_cast<const B<T>&> (y))); \ 158 inline R quotient_eq (R& x, const R& y) \ 160 return R (quotient_eq (dynamic_cast<B<T>&> (x), \ 161 dynamic_cast<const B<T>&> (y))); \ 163 inline R operator + (const R& x) \ 165 return R (operator + (dynamic_cast<const B<T>&> (x))); \ 167 inline R operator - (const R& x) \ 169 return R (operator - (dynamic_cast<const B<T>&> (x))); \ 171 inline R operator + (const R& x, const T& y) \ 173 return R (operator + (dynamic_cast<const B<T>&> (x), (y))); \ 175 inline R operator - (const R& x, const T& y) \ 177 return R (operator - (dynamic_cast<const B<T>&> (x), (y))); \ 179 inline R operator * (const R& x, const T& y) \ 181 return R (operator * (dynamic_cast<const B<T>&> (x), (y))); \ 183 inline R operator / (const R& x, const T& y) \ 185 return R (operator / (dynamic_cast<const B<T>&> (x), (y))); \ 187 inline R operator + (const T& x, const R& y) \ 189 return R (operator + ( (x), dynamic_cast<const B<T>&> (y))); \ 191 inline R operator - (const T& x, const R& y) \ 193 return R (operator - ( (x), dynamic_cast<const B<T>&> (y))); \ 195 inline R operator * (const T& x, const R& y) \ 197 return R (operator * ( (x), dynamic_cast<const B<T>&> (y))); \ 199 inline R operator / (const T& x, const R& y) \ 201 return R (operator / ( (x), dynamic_cast<const B<T>&> (y))); \ 203 inline R operator + (const R& x, const R& y) \ 205 return R (operator + (dynamic_cast<const B<T>&> (x), \ 206 dynamic_cast<const B<T>&> (y))); \ 208 inline R operator - (const R& x, const R& y) \ 210 return R (operator - (dynamic_cast<const B<T>&> (x), \ 211 dynamic_cast<const B<T>&> (y))); \ 213 inline R product (const R& x, const R& y) \ 215 return R (product (dynamic_cast<const B<T>&> (x), \ 216 dynamic_cast<const B<T>&> (y))); \ 218 inline R quotient (const R& x, const R& y) \ 220 return R (quotient (dynamic_cast<const B<T>&> (x), \ 221 dynamic_cast<const B<T>&> (y))); \ 225 #define INSTANTIATE_MARRAY_FRIENDS(T, API) \ 226 template API MArray<T>& operator += (MArray<T>&, const T&); \ 227 template API MArray<T>& operator -= (MArray<T>&, const T&); \ 228 template API MArray<T>& operator *= (MArray<T>&, const T&); \ 229 template API MArray<T>& operator /= (MArray<T>&, const T&); \ 230 template API MArray<T>& operator += (MArray<T>&, const MArray<T>&); \ 231 template API MArray<T>& operator -= (MArray<T>&, const MArray<T>&); \ 232 template API MArray<T>& product_eq (MArray<T>&, const MArray<T>&); \ 233 template API MArray<T>& quotient_eq (MArray<T>&, const MArray<T>&); \ 234 template API MArray<T> operator + (const MArray<T>&); \ 235 template API MArray<T> operator - (const MArray<T>&); \ 236 template API MArray<T> operator + (const MArray<T>&, const T&); \ 237 template API MArray<T> operator - (const MArray<T>&, const T&); \ 238 template API MArray<T> operator * (const MArray<T>&, const T&); \ 239 template API MArray<T> operator / (const MArray<T>&, const T&); \ 240 template API MArray<T> operator + (const T&, const MArray<T>&); \ 241 template API MArray<T> operator - (const T&, const MArray<T>&); \ 242 template API MArray<T> operator * (const T&, const MArray<T>&); \ 243 template API MArray<T> operator / (const T&, const MArray<T>&); \ 244 template API MArray<T> operator + (const MArray<T>&, const MArray<T>&); \ 245 template API MArray<T> operator - (const MArray<T>&, const MArray<T>&); \ 246 template API MArray<T> quotient (const MArray<T>&, const MArray<T>&); \ 247 template API MArray<T> product (const MArray<T>&, const MArray<T>&); 250 #define INSTANTIATE_MDIAGARRAY2_FRIENDS(T, API) \ 251 template API MDiagArray2<T> operator + (const MDiagArray2<T>&); \ 252 template API MDiagArray2<T> operator - (const MDiagArray2<T>&); \ 253 template API MDiagArray2<T> operator * (const MDiagArray2<T>&, const T&); \ 254 template API MDiagArray2<T> operator / (const MDiagArray2<T>&, const T&); \ 255 template API MDiagArray2<T> operator * (const T&, const MDiagArray2<T>&); \ 256 template API MDiagArray2<T> operator + (const MDiagArray2<T>&, \ 257 const MDiagArray2<T>&); \ 258 template API MDiagArray2<T> operator - (const MDiagArray2<T>&, \ 259 const MDiagArray2<T>&); \ 260 template API MDiagArray2<T> product (const MDiagArray2<T>&, \ 261 const MDiagArray2<T>&); void idx_min(const idx_vector &idx, const MArray< T > &vals)
Template for N-dimensional array classes with like-type math operators.
MArray< T > & operator+=(MArray< T > &, const T &)
void idx_add_nd(const idx_vector &idx, const MArray< T > &vals, int dim=-1)
MArray< T > hermitian(T(*fcn)(const T &)=nullptr) const
identity matrix If supplied two scalar respectively For allows like xample val
Array< T > squeeze(void) const
Chop off leading singleton dimensions.
MArray< T > ipermute(const Array< octave_idx_type > &vec) const
MArray< T > & operator*=(MArray< T > &, const T &)
Array< T > permute(const Array< octave_idx_type > &vec, bool inv=false) const
MArray< T > & quotient_eq(MArray< T > &, const MArray< T > &)
Array< T > ipermute(const Array< octave_idx_type > &vec) const
MArray< T > transpose(void) const
MArray< T > quotient(const MArray< T > &, const MArray< T > &)
Array< T > reshape(octave_idx_type nr, octave_idx_type nc) 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
MArray< T > permute(const Array< octave_idx_type > &vec, bool inv=false) const
MArray< T > reshape(const dim_vector &new_dims) const
MArray(const dim_vector &dv)
MArray(const dim_vector &dv, const T &val)
MArray(const Array< U > &a)
static const octave_idx_type idx_max
MArray< T > & operator/=(MArray< T > &, const T &)
MArray< T > operator*(const MArray< T > &, const T &)
MArray< T > operator-(const MArray< T > &)
MArray< T > operator/(const MArray< T > &, const T &)
Array< T > transpose(void) const
MArray< T > operator+(const MArray< T > &)
MArray< T > product(const MArray< T > &, const MArray< T > &)
MArray< T > & operator=(const MArray< T > &a)
N Dimensional Array with copy-on-write semantics.
MArray(const MArray< T > &a)
MArray squeeze(void) const
Vector representing the dimensions (size) of an Array.
Array< T > & operator=(const Array< T > &a)
void idx_add(const idx_vector &idx, T val)
Performs indexed accumulative addition.
MArray< T > & operator-=(MArray< T > &, const T &)
Array< T > hermitian(T(*fcn)(const T &)=nullptr) const
MArray(T *sdata, octave_idx_type slen, octave_idx_type *adims, void *arep)
MArray< T > & product_eq(MArray< T > &, const MArray< T > &)