26 #if ! defined (octave_MArray_h)
27 #define octave_MArray_h 1
29 #include "octave-config.h"
34 template <
typename T>
class MArray;
68 :
Array<T> (sdata, slen, adims, arep) { }
78 :
Array<T> (dv, val) { }
97 bool inv =
false)
const
128 #define MARRAY_FORWARD_DEFS(B, R, T) \
129 inline R operator += (R& x, const T& y) \
131 return R (operator += (dynamic_cast<B<T>&> (x), (y))); \
133 inline R operator -= (R& x, const T& y) \
135 return R (operator -= (dynamic_cast<B<T>&> (x), (y))); \
137 inline R operator *= (R& x, const T& y) \
139 return R (operator *= (dynamic_cast<B<T>&> (x), (y))); \
141 inline R operator /= (R& x, const T& y) \
143 return R (operator /= (dynamic_cast<B<T>&> (x), (y))); \
145 inline R operator += (R& x, const R& y) \
147 return R (operator += (dynamic_cast<B<T>&> (x), \
148 dynamic_cast<const B<T>&> (y))); \
150 inline R operator -= (R& x, const R& y) \
152 return R (operator -= (dynamic_cast<B<T>&> (x), \
153 dynamic_cast<const B<T>&> (y))); \
155 inline R product_eq (R& x, const R& y) \
157 return R (product_eq (dynamic_cast<B<T>&> (x), \
158 dynamic_cast<const B<T>&> (y))); \
160 inline R quotient_eq (R& x, const R& y) \
162 return R (quotient_eq (dynamic_cast<B<T>&> (x), \
163 dynamic_cast<const B<T>&> (y))); \
165 inline R operator + (const R& x) \
167 return R (operator + (dynamic_cast<const B<T>&> (x))); \
169 inline R operator - (const R& x) \
171 return R (operator - (dynamic_cast<const B<T>&> (x))); \
173 inline R operator + (const R& x, const T& y) \
175 return R (operator + (dynamic_cast<const B<T>&> (x), (y))); \
177 inline R operator - (const R& x, const T& y) \
179 return R (operator - (dynamic_cast<const B<T>&> (x), (y))); \
181 inline R operator * (const R& x, const T& y) \
183 return R (operator * (dynamic_cast<const B<T>&> (x), (y))); \
185 inline R operator / (const R& x, const T& y) \
187 return R (operator / (dynamic_cast<const B<T>&> (x), (y))); \
189 inline R operator + (const T& x, const R& y) \
191 return R (operator + ( (x), dynamic_cast<const B<T>&> (y))); \
193 inline R operator - (const T& x, const R& y) \
195 return R (operator - ( (x), dynamic_cast<const B<T>&> (y))); \
197 inline R operator * (const T& x, const R& y) \
199 return R (operator * ( (x), dynamic_cast<const B<T>&> (y))); \
201 inline R operator / (const T& x, const R& y) \
203 return R (operator / ( (x), dynamic_cast<const B<T>&> (y))); \
205 inline R operator + (const R& x, const R& y) \
207 return R (operator + (dynamic_cast<const B<T>&> (x), \
208 dynamic_cast<const B<T>&> (y))); \
210 inline R operator - (const R& x, const R& y) \
212 return R (operator - (dynamic_cast<const B<T>&> (x), \
213 dynamic_cast<const B<T>&> (y))); \
215 inline R product (const R& x, const R& y) \
217 return R (product (dynamic_cast<const B<T>&> (x), \
218 dynamic_cast<const B<T>&> (y))); \
220 inline R quotient (const R& x, const R& y) \
222 return R (quotient (dynamic_cast<const B<T>&> (x), \
223 dynamic_cast<const B<T>&> (y))); \
227 #define INSTANTIATE_MARRAY_FRIENDS(T, API) \
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 T&); \
231 template API MArray<T>& operator /= (MArray<T>&, const T&); \
232 template API MArray<T>& operator += (MArray<T>&, const MArray<T>&); \
233 template API MArray<T>& operator -= (MArray<T>&, const MArray<T>&); \
234 template API MArray<T>& product_eq (MArray<T>&, const MArray<T>&); \
235 template API MArray<T>& quotient_eq (MArray<T>&, const MArray<T>&); \
236 template API MArray<T> operator + (const MArray<T>&); \
237 template API MArray<T> operator - (const MArray<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 MArray<T>&, const T&); \
241 template API MArray<T> operator / (const MArray<T>&, const 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 T&, const MArray<T>&); \
245 template API MArray<T> operator / (const T&, const MArray<T>&); \
246 template API MArray<T> operator + (const MArray<T>&, const MArray<T>&); \
247 template API MArray<T> operator - (const MArray<T>&, const MArray<T>&); \
248 template API MArray<T> quotient (const MArray<T>&, const MArray<T>&); \
249 template API MArray<T> product (const MArray<T>&, const MArray<T>&);
252 #define INSTANTIATE_MDIAGARRAY2_FRIENDS(T, API) \
253 template API MDiagArray2<T> operator + (const MDiagArray2<T>&); \
254 template API MDiagArray2<T> operator - (const MDiagArray2<T>&); \
255 template API MDiagArray2<T> operator * (const MDiagArray2<T>&, const T&); \
256 template API MDiagArray2<T> operator / (const MDiagArray2<T>&, const T&); \
257 template API MDiagArray2<T> operator * (const T&, const MDiagArray2<T>&); \
258 template API MDiagArray2<T> operator + (const MDiagArray2<T>&, \
259 const MDiagArray2<T>&); \
260 template API MDiagArray2<T> operator - (const MDiagArray2<T>&, \
261 const MDiagArray2<T>&); \
262 template API MDiagArray2<T> product (const MDiagArray2<T>&, \
263 const MDiagArray2<T>&);
MArray< T > & product_eq(MArray< T > &, const MArray< T > &)
MArray< T > quotient(const MArray< T > &, const MArray< T > &)
MArray< T > & quotient_eq(MArray< T > &, const MArray< T > &)
MArray< T > operator/(const MArray< T > &, const T &)
MArray< T > operator-(const MArray< T > &)
MArray< T > & operator+=(MArray< T > &, const T &)
MArray< T > & operator/=(MArray< T > &, const T &)
MArray< T > & operator*=(MArray< T > &, const T &)
MArray< T > & operator-=(MArray< T > &, const T &)
MArray< T > operator*(const MArray< T > &, const T &)
MArray< T > operator+(const MArray< T > &)
MArray< T > product(const MArray< T > &, const MArray< T > &)
N Dimensional Array with copy-on-write semantics.
Array< T > squeeze(void) const
Chop off leading singleton dimensions.
Array< T > & operator=(const Array< T > &a)
Array< T > ipermute(const Array< octave_idx_type > &vec) const
Size of the specified dimension.
Array< T > hermitian(T(*fcn)(const T &)=nullptr) const
Size of the specified dimension.
Array< T > reshape(octave_idx_type nr, octave_idx_type nc) const
Size of the specified dimension.
Array< T > transpose(void) const
Size of the specified dimension.
Array< T > permute(const Array< octave_idx_type > &vec, bool inv=false) const
Size of the specified dimension.
Template for N-dimensional array classes with like-type math operators.
MArray< T > hermitian(T(*fcn)(const T &)=nullptr) const
void idx_min(const idx_vector &idx, const MArray< T > &vals)
MArray< T > permute(const Array< octave_idx_type > &vec, bool inv=false) const
MArray(T *sdata, octave_idx_type slen, octave_idx_type *adims, void *arep)
void idx_add_nd(const idx_vector &idx, const MArray< T > &vals, int dim=-1)
MArray< T > reshape(const dim_vector &new_dims) const
MArray(const Array< U > &a)
void idx_add(const idx_vector &idx, T val)
Performs indexed accumulative addition.
MArray< T > transpose(void) const
MArray< T > & operator=(const MArray< T > &a)
MArray squeeze(void) const
MArray(const dim_vector &dv, const T &val)
MArray< T > ipermute(const Array< octave_idx_type > &vec) const
MArray(const MArray< T > &a)
MArray(const dim_vector &dv)
Vector representing the dimensions (size) of an Array.
static const octave_idx_type idx_max