26 #if ! defined (octave_MArray_h)
27 #define octave_MArray_h 1
29 #include "octave-config.h"
72 :
Array<T> (dv, val) { }
91 bool inv =
false)
const
122 OCTARRAY_API
void changesign ();
125 OCTARRAY_API
static void instantiation_guard ();
130 #define MARRAY_FORWARD_DEFS(B, R, T) \
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 T& y) \
145 return R (operator /= (dynamic_cast<B<T>&> (x), (y))); \
147 inline R operator += (R& x, const R& y) \
149 return R (operator += (dynamic_cast<B<T>&> (x), \
150 dynamic_cast<const B<T>&> (y))); \
152 inline R operator -= (R& x, const R& y) \
154 return R (operator -= (dynamic_cast<B<T>&> (x), \
155 dynamic_cast<const B<T>&> (y))); \
157 inline R product_eq (R& x, const R& y) \
159 return R (product_eq (dynamic_cast<B<T>&> (x), \
160 dynamic_cast<const B<T>&> (y))); \
162 inline R quotient_eq (R& x, const R& y) \
164 return R (quotient_eq (dynamic_cast<B<T>&> (x), \
165 dynamic_cast<const B<T>&> (y))); \
167 inline R operator + (const R& x) \
169 return R (operator + (dynamic_cast<const B<T>&> (x))); \
171 inline R operator - (const R& x) \
173 return R (operator - (dynamic_cast<const B<T>&> (x))); \
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 R& x, const T& y) \
189 return R (operator / (dynamic_cast<const B<T>&> (x), (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 T& x, const R& y) \
205 return R (operator / ( (x), dynamic_cast<const B<T>&> (y))); \
207 inline R operator + (const R& x, const R& y) \
209 return R (operator + (dynamic_cast<const B<T>&> (x), \
210 dynamic_cast<const B<T>&> (y))); \
212 inline R operator - (const R& x, const R& y) \
214 return R (operator - (dynamic_cast<const B<T>&> (x), \
215 dynamic_cast<const B<T>&> (y))); \
217 inline R product (const R& x, const R& y) \
219 return R (product (dynamic_cast<const B<T>&> (x), \
220 dynamic_cast<const B<T>&> (y))); \
222 inline R quotient (const R& x, const R& y) \
224 return R (quotient (dynamic_cast<const B<T>&> (x), \
225 dynamic_cast<const B<T>&> (y))); \
229 #define INSTANTIATE_MARRAY_FRIENDS(T, API) \
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 T&); \
233 template API MArray<T>& operator /= (MArray<T>&, const T&); \
234 template API MArray<T>& operator += (MArray<T>&, const MArray<T>&); \
235 template API MArray<T>& operator -= (MArray<T>&, const MArray<T>&); \
236 template API MArray<T>& product_eq (MArray<T>&, const MArray<T>&); \
237 template API MArray<T>& quotient_eq (MArray<T>&, const MArray<T>&); \
238 template API MArray<T> operator + (const MArray<T>&); \
239 template API MArray<T> operator - (const MArray<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 MArray<T>&, const T&); \
243 template API MArray<T> operator / (const MArray<T>&, const 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 T&, const MArray<T>&); \
247 template API MArray<T> operator / (const T&, const MArray<T>&); \
248 template API MArray<T> operator + (const MArray<T>&, const MArray<T>&); \
249 template API MArray<T> operator - (const MArray<T>&, const MArray<T>&); \
250 template API MArray<T> quotient (const MArray<T>&, const MArray<T>&); \
251 template API MArray<T> product (const MArray<T>&, const MArray<T>&);
254 #define INSTANTIATE_MDIAGARRAY2_FRIENDS(T, API) \
255 template API MDiagArray2<T> operator + (const MDiagArray2<T>&); \
256 template API MDiagArray2<T> operator - (const MDiagArray2<T>&); \
257 template API MDiagArray2<T> operator * (const MDiagArray2<T>&, const T&); \
258 template API MDiagArray2<T> operator / (const MDiagArray2<T>&, const T&); \
259 template API MDiagArray2<T> operator * (const T&, const MDiagArray2<T>&); \
260 template API MDiagArray2<T> operator + (const MDiagArray2<T>&, \
261 const MDiagArray2<T>&); \
262 template API MDiagArray2<T> operator - (const MDiagArray2<T>&, \
263 const MDiagArray2<T>&); \
264 template API MDiagArray2<T> product (const MDiagArray2<T>&, \
265 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 > &)
Array< T, Alloc > transpose() const
Size of the specified dimension.
Array< T, Alloc > hermitian(T(*fcn)(const T &)=nullptr) const
Size of the specified dimension.
Array< T, Alloc > ipermute(const Array< octave_idx_type > &vec) const
Size of the specified dimension.
Array< T, Alloc > squeeze() const
Chop off leading singleton dimensions.
Array< T, Alloc > & operator=(const Array< T, Alloc > &a)
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 > hermitian(T(*fcn)(const T &)=nullptr) const
MArray< T > permute(const Array< octave_idx_type > &vec, bool inv=false) const
MArray< T > transpose() const
MArray< T > reshape(const dim_vector &new_dims) const
MArray(const Array< U > &a)
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.
octave::idx_vector idx_vector