26#if ! defined (octave_MArray_h)
27#define octave_MArray_h 1
29#include "octave-config.h"
64 OCTAVE_OVERRIDABLE_FUNC_API
67 explicit OCTAVE_OVERRIDABLE_FUNC_API
71 explicit OCTAVE_OVERRIDABLE_FUNC_API
73 :
Array<T> (dv, val) { }
75 OCTAVE_OVERRIDABLE_FUNC_API
79 OCTAVE_OVERRIDABLE_FUNC_API
82 OCTAVE_OVERRIDABLE_FUNC_API
~MArray () =
default;
114 OCTAVE_API void idx_add (
const octave::idx_vector& idx, T val);
116 idx_add (
const octave::idx_vector& idx,
const MArray<T>& vals);
120 idx_min (
const octave::idx_vector& idx,
const MArray<T>& vals);
123 idx_max (
const octave::idx_vector& idx,
const MArray<T>& vals);
126 idx_add_nd (
const octave::idx_vector& idx,
const MArray<T>& vals,
132 OCTAVE_API static void instantiation_guard ();
137#define MARRAY_FORWARD_DEFS(B, R, T) \
138 inline R operator += (R& x, const T& y) \
140 return R (operator += (dynamic_cast<B<T>&> (x), (y))); \
142 inline R operator -= (R& x, const T& y) \
144 return R (operator -= (dynamic_cast<B<T>&> (x), (y))); \
146 inline R operator *= (R& x, const T& y) \
148 return R (operator *= (dynamic_cast<B<T>&> (x), (y))); \
150 inline R operator /= (R& x, const T& y) \
152 return R (operator /= (dynamic_cast<B<T>&> (x), (y))); \
154 inline R operator += (R& x, const R& y) \
156 return R (operator += (dynamic_cast<B<T>&> (x), \
157 dynamic_cast<const B<T>&> (y))); \
159 inline R operator -= (R& x, const R& y) \
161 return R (operator -= (dynamic_cast<B<T>&> (x), \
162 dynamic_cast<const B<T>&> (y))); \
164 inline R product_eq (R& x, const R& y) \
166 return R (product_eq (dynamic_cast<B<T>&> (x), \
167 dynamic_cast<const B<T>&> (y))); \
169 inline R quotient_eq (R& x, const R& y) \
171 return R (quotient_eq (dynamic_cast<B<T>&> (x), \
172 dynamic_cast<const B<T>&> (y))); \
174 inline R operator + (const R& x) \
176 return R (operator + (dynamic_cast<const B<T>&> (x))); \
178 inline R operator - (const R& x) \
180 return R (operator - (dynamic_cast<const B<T>&> (x))); \
182 inline R operator + (const R& x, const T& y) \
184 return R (operator + (dynamic_cast<const B<T>&> (x), (y))); \
186 inline R operator - (const R& x, const T& y) \
188 return R (operator - (dynamic_cast<const B<T>&> (x), (y))); \
190 inline R operator * (const R& x, const T& y) \
192 return R (operator * (dynamic_cast<const B<T>&> (x), (y))); \
194 inline R operator / (const R& x, const T& y) \
196 return R (operator / (dynamic_cast<const B<T>&> (x), (y))); \
198 inline R operator + (const T& x, const R& y) \
200 return R (operator + ( (x), dynamic_cast<const B<T>&> (y))); \
202 inline R operator - (const T& x, const R& y) \
204 return R (operator - ( (x), dynamic_cast<const B<T>&> (y))); \
206 inline R operator * (const T& x, const R& y) \
208 return R (operator * ( (x), dynamic_cast<const B<T>&> (y))); \
210 inline R operator / (const T& x, const R& y) \
212 return R (operator / ( (x), dynamic_cast<const B<T>&> (y))); \
214 inline R operator + (const R& x, const R& y) \
216 return R (operator + (dynamic_cast<const B<T>&> (x), \
217 dynamic_cast<const B<T>&> (y))); \
219 inline R operator - (const R& x, const R& y) \
221 return R (operator - (dynamic_cast<const B<T>&> (x), \
222 dynamic_cast<const B<T>&> (y))); \
224 inline R product (const R& x, const R& y) \
226 return R (product (dynamic_cast<const B<T>&> (x), \
227 dynamic_cast<const B<T>&> (y))); \
229 inline R quotient (const R& x, const R& y) \
231 return R (quotient (dynamic_cast<const B<T>&> (x), \
232 dynamic_cast<const B<T>&> (y))); \
236#define INSTANTIATE_MARRAY_FRIENDS(T, API) \
237 template API MArray<T>& operator += (MArray<T>&, const T&); \
238 template API MArray<T>& operator -= (MArray<T>&, const T&); \
239 template API MArray<T>& operator *= (MArray<T>&, const T&); \
240 template API MArray<T>& operator /= (MArray<T>&, const T&); \
241 template API MArray<T>& operator += (MArray<T>&, const MArray<T>&); \
242 template API MArray<T>& operator -= (MArray<T>&, const MArray<T>&); \
243 template API MArray<T>& product_eq (MArray<T>&, const MArray<T>&); \
244 template API MArray<T>& quotient_eq (MArray<T>&, const MArray<T>&); \
245 template API MArray<T> operator + (const MArray<T>&); \
246 template API MArray<T> operator - (const MArray<T>&); \
247 template API MArray<T> operator + (const MArray<T>&, const T&); \
248 template API MArray<T> operator - (const MArray<T>&, const T&); \
249 template API MArray<T> operator * (const MArray<T>&, const T&); \
250 template API MArray<T> operator / (const MArray<T>&, const T&); \
251 template API MArray<T> operator + (const T&, const MArray<T>&); \
252 template API MArray<T> operator - (const T&, const MArray<T>&); \
253 template API MArray<T> operator * (const T&, const MArray<T>&); \
254 template API MArray<T> operator / (const T&, const MArray<T>&); \
255 template API MArray<T> operator + (const MArray<T>&, const MArray<T>&); \
256 template API MArray<T> operator - (const MArray<T>&, const MArray<T>&); \
257 template API MArray<T> quotient (const MArray<T>&, const MArray<T>&); \
258 template API MArray<T> product (const MArray<T>&, const MArray<T>&);
261#define INSTANTIATE_MDIAGARRAY2_FRIENDS(T, API) \
262 template API MDiagArray2<T> operator + (const MDiagArray2<T>&); \
263 template API MDiagArray2<T> operator - (const MDiagArray2<T>&); \
264 template API MDiagArray2<T> operator * (const MDiagArray2<T>&, const T&); \
265 template API MDiagArray2<T> operator / (const MDiagArray2<T>&, const T&); \
266 template API MDiagArray2<T> operator * (const T&, const MDiagArray2<T>&); \
267 template API MDiagArray2<T> operator + (const MDiagArray2<T>&, \
268 const MDiagArray2<T>&); \
269 template API MDiagArray2<T> operator - (const MDiagArray2<T>&, \
270 const MDiagArray2<T>&); \
271 template API MDiagArray2<T> product (const MDiagArray2<T>&, \
272 const MDiagArray2<T>&);
274#if ! defined (OCTAVE_EXTERN_TEMPLATE_MARRAY)
276#define OCTAVE_EXTERN_TEMPLATE_MARRAY
289extern template class OCTAVE_EXTERN_TEMPLATE_API
MArray<float>;
293extern template class OCTAVE_EXTERN_TEMPLATE_API
MArray<int>;
294#if defined (OCTAVE_ENABLE_64)
306extern template class OCTAVE_EXTERN_TEMPLATE_API
MArray<short>;
MArray< T > operator*(const MArray< T > &, const T &)
MArray< T > & operator/=(MArray< T > &, const T &)
MArray< T > & operator-=(MArray< T > &, const T &)
MArray< T > & product_eq(MArray< T > &, const MArray< T > &)
MArray< T > operator+(const MArray< T > &)
MArray< T > & operator*=(MArray< T > &, const T &)
MArray< T > quotient(const MArray< T > &, const MArray< T > &)
MArray< T > product(const MArray< T > &, const MArray< T > &)
MArray< T > operator/(const MArray< T > &, const T &)
MArray< T > & operator+=(MArray< T > &, const T &)
MArray< T > & quotient_eq(MArray< T > &, const MArray< T > &)
MArray< T > operator-(const MArray< T > &)
N Dimensional Array with copy-on-write semantics.
Array< T, Alloc > ipermute(const Array< octave_idx_type > &vec) const
Size of the specified dimension.
Array< T, Alloc > transpose() const
Size of the specified dimension.
Array< T, Alloc > & operator=(const Array< T, Alloc > &a)
Array< T, Alloc > hermitian(T(*fcn)(const T &)=nullptr) const
Size of the specified dimension.
Array< T, Alloc > squeeze() const
Chop off leading singleton dimensions.
Array< T, Alloc > permute(const Array< octave_idx_type > &vec, bool inv=false) const
Size of the specified dimension.
Array< T, Alloc > reshape(octave_idx_type nr, octave_idx_type nc) const
Size of the specified dimension.
Template for N-dimensional array classes with like-type math operators.
MArray< T > permute(const Array< octave_idx_type > &vec, bool inv=false) const
MArray< T > transpose() const
MArray< T > hermitian(T(*fcn)(const T &)=nullptr) const
MArray(const Array< U > &a)
MArray< T > reshape(const dim_vector &new_dims) 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.