26 #if ! defined (octave_MSparse_h)
27 #define octave_MSparse_h 1
29 #include "octave-config.h"
64 :
Sparse<T> (a,
r, c, nr, nc, sum_terms, nzm) { }
113 template <
typename U>
118 template <
typename U>
120 map (U (&fcn) (
const T&))
const
128 #define SPARSE_OP_ASSIGN_DECL(T, OP, API) \
129 template API MSparse<T>& \
130 operator OP (MSparse<T>&, const MSparse<T>&)
133 #define SPARSE_UNOP_DECL(T, OP, API) \
134 template API MSparse<T> \
135 operator OP (const MSparse<T>&)
138 #define SPARSE_BINOP_DECL(A_T, T, F, API, X_T, Y_T) \
139 template API A_T<T> \
140 F (const X_T&, const Y_T&)
144 #define SPARSE_OP_ASSIGN_FWD_FCN(R, F, T, C_X, X_T, C_Y, Y_T) \
146 F (X_T& x, const Y_T& y) \
148 return R (F (C_X (x), C_Y (y))); \
153 #define SPARSE_UNOP_FWD_FCN(R, F, T, C_X, X_T) \
157 return R (F (C_X (x))); \
162 #define SPARSE_BINOP_FWD_FCN(R, F, T, C_X, X_T, C_Y, Y_T) \
164 F (const X_T& x, const Y_T& y) \
166 return R (F (C_X (x), C_Y (y))); \
170 #define INSTANTIATE_SPARSE_FRIENDS(T, API) \
171 SPARSE_OP_ASSIGN_DECL (T, +=, API); \
172 SPARSE_OP_ASSIGN_DECL (T, -=, API); \
173 SPARSE_UNOP_DECL (T, +, API); \
174 SPARSE_UNOP_DECL (T, -, API); \
175 SPARSE_BINOP_DECL (MArray, T, operator +, API, MSparse<T>, T); \
176 SPARSE_BINOP_DECL (MArray, T, operator -, API, MSparse<T>, T); \
177 SPARSE_BINOP_DECL (MSparse, T, operator *, API, MSparse<T>, T); \
178 SPARSE_BINOP_DECL (MSparse, T, operator /, API, MSparse<T>, T); \
179 SPARSE_BINOP_DECL (MArray, T, operator +, API, T, MSparse<T>); \
180 SPARSE_BINOP_DECL (MArray, T, operator -, API, T, MSparse<T>); \
181 SPARSE_BINOP_DECL (MSparse, T, operator *, API, T, MSparse<T>); \
182 SPARSE_BINOP_DECL (MSparse, T, operator /, API, T, MSparse<T>); \
183 SPARSE_BINOP_DECL (MSparse, T, operator +, API, MSparse<T>, MSparse<T>); \
184 SPARSE_BINOP_DECL (MSparse, T, operator -, API, MSparse<T>, MSparse<T>); \
185 SPARSE_BINOP_DECL (MSparse, T, quotient, API, MSparse<T>, MSparse<T>); \
186 SPARSE_BINOP_DECL (MSparse, T, product, API, MSparse<T>, MSparse<T>);
190 #define SPARSE_FORWARD_DEFS(B, R, F, T) \
191 SPARSE_OP_ASSIGN_FWD_FCN (R, operator +=, T, dynamic_cast<B<T>&>, \
192 R, dynamic_cast<const B<T>&>, R) \
193 SPARSE_OP_ASSIGN_FWD_FCN (R, operator -=, T, dynamic_cast<B<T>&>, \
194 R, dynamic_cast<const B<T>&>, R) \
195 SPARSE_UNOP_FWD_FCN (R, operator +, T, dynamic_cast<const B<T>&>, R) \
196 SPARSE_UNOP_FWD_FCN (R, operator -, T, dynamic_cast<const B<T>&>, R) \
197 SPARSE_BINOP_FWD_FCN (F, operator +, T, dynamic_cast<const B<T>&>, R, , T) \
198 SPARSE_BINOP_FWD_FCN (F, operator -, T, dynamic_cast<const B<T>&>, R, , T) \
199 SPARSE_BINOP_FWD_FCN (R, operator *, T, dynamic_cast<const B<T>&>, R, , T) \
200 SPARSE_BINOP_FWD_FCN (R, operator /, T, dynamic_cast<const B<T>&>, R, , T) \
201 SPARSE_BINOP_FWD_FCN (F, operator +, T, , T, dynamic_cast<const B<T>&>, R) \
202 SPARSE_BINOP_FWD_FCN (F, operator -, T, , T, dynamic_cast<const B<T>&>, R) \
203 SPARSE_BINOP_FWD_FCN (R, operator *, T, , T, dynamic_cast<const B<T>&>, R) \
204 SPARSE_BINOP_FWD_FCN (R, operator /, T, , T, dynamic_cast<const B<T>&>, R) \
205 SPARSE_BINOP_FWD_FCN (R, operator +, T, dynamic_cast<const B<T>&>, \
206 R, dynamic_cast<const B<T>&>, R) \
207 SPARSE_BINOP_FWD_FCN (R, operator -, T, dynamic_cast<const B<T>&>, \
208 R, dynamic_cast<const B<T>&>, R) \
209 SPARSE_BINOP_FWD_FCN (R, product, T, dynamic_cast<const B<T>&>, \
210 R, dynamic_cast<const B<T>&>, R) \
211 SPARSE_BINOP_FWD_FCN (R, quotient, T, dynamic_cast<const B<T>&>, \
212 R, dynamic_cast<const B<T>&>, R)
N Dimensional Array with copy-on-write semantics.
MSparse(const MSparse< T > &a)
MSparse(octave_idx_type n, octave_idx_type m)
MSparse< T > transpose(void) const
MSparse< T > permute(const Array< octave_idx_type > &vec, bool inv=false) const
MSparse< T > squeeze(void) const
MSparse(octave_idx_type r, octave_idx_type c, T val)
MSparse(const Array< T > &a, const idx_vector &r, const idx_vector &c, octave_idx_type nr=-1, octave_idx_type nc=-1, bool sum_terms=true, octave_idx_type nzm=-1)
MSparse< T > ipermute(const Array< octave_idx_type > &vec) const
MSparse< T > reshape(const dim_vector &new_dims) const
MSparse< T > & insert(const Sparse< T > &a, octave_idx_type r, octave_idx_type c)
MSparse< T > diag(octave_idx_type k=0) const
MSparse< T > & insert(const Sparse< T > &a, const Array< octave_idx_type > &indx)
MSparse< U > map(U(&fcn)(const T &)) const
MSparse(const Sparse< U > &a)
MSparse(const Sparse< T > &a)
MSparse(octave_idx_type r, octave_idx_type c, octave_idx_type num_nz)
MSparse(const MSparse< T > &a, const dim_vector &dv)
MSparse< U > map(U(&fcn)(T)) const
MSparse(const dim_vector &dv, octave_idx_type nz=0)
MSparse(const PermMatrix &a)
Sparse< T > transpose(void) const
Sparse< T > squeeze(void) const
Sparse< T > & insert(const Sparse< T > &a, octave_idx_type r, octave_idx_type c)
Sparse< T > permute(const Array< octave_idx_type > &vec, bool inv=false) const
Sparse< T > diag(octave_idx_type k=0) const
Sparse< T > ipermute(const Array< octave_idx_type > &vec) const
Sparse< T > reshape(const dim_vector &new_dims) const
Sparse< T > & operator=(const Sparse< T > &a)
Vector representing the dimensions (size) of an Array.