26 #if ! defined (octave_MSparse_h)
27 #define octave_MSparse_h 1
29 #include "octave-config.h"
68 :
Sparse<T> (a,
r, c, nr, nc, sum_terms, nzm) { }
117 template <
typename U>
122 template <
typename U>
124 map (U (&fcn) (
const T&))
const
132 #define SPARSE_OP_ASSIGN_DECL(T, OP, API) \
133 template API MSparse<T>& \
134 operator OP (MSparse<T>&, const MSparse<T>&)
137 #define SPARSE_UNOP_DECL(T, OP, API) \
138 template API MSparse<T> \
139 operator OP (const MSparse<T>&)
142 #define SPARSE_BINOP_DECL(A_T, T, F, API, X_T, Y_T) \
143 template API A_T<T> \
144 F (const X_T&, const Y_T&)
148 #define SPARSE_OP_ASSIGN_FWD_FCN(R, F, T, C_X, X_T, C_Y, Y_T) \
150 F (X_T& x, const Y_T& y) \
152 return R (F (C_X (x), C_Y (y))); \
157 #define SPARSE_UNOP_FWD_FCN(R, F, T, C_X, X_T) \
161 return R (F (C_X (x))); \
166 #define SPARSE_BINOP_FWD_FCN(R, F, T, C_X, X_T, C_Y, Y_T) \
168 F (const X_T& x, const Y_T& y) \
170 return R (F (C_X (x), C_Y (y))); \
174 #define INSTANTIATE_SPARSE_FRIENDS(T, API) \
175 SPARSE_OP_ASSIGN_DECL (T, +=, API); \
176 SPARSE_OP_ASSIGN_DECL (T, -=, API); \
177 SPARSE_UNOP_DECL (T, +, API); \
178 SPARSE_UNOP_DECL (T, -, API); \
179 SPARSE_BINOP_DECL (MArray, T, operator +, API, MSparse<T>, T); \
180 SPARSE_BINOP_DECL (MArray, T, operator -, API, MSparse<T>, T); \
181 SPARSE_BINOP_DECL (MSparse, T, operator *, API, MSparse<T>, T); \
182 SPARSE_BINOP_DECL (MSparse, T, operator /, API, MSparse<T>, T); \
183 SPARSE_BINOP_DECL (MArray, T, operator +, API, T, MSparse<T>); \
184 SPARSE_BINOP_DECL (MArray, T, operator -, API, T, MSparse<T>); \
185 SPARSE_BINOP_DECL (MSparse, T, operator *, API, T, MSparse<T>); \
186 SPARSE_BINOP_DECL (MSparse, T, operator /, API, T, MSparse<T>); \
187 SPARSE_BINOP_DECL (MSparse, T, operator +, API, MSparse<T>, MSparse<T>); \
188 SPARSE_BINOP_DECL (MSparse, T, operator -, API, MSparse<T>, MSparse<T>); \
189 SPARSE_BINOP_DECL (MSparse, T, quotient, API, MSparse<T>, MSparse<T>); \
190 SPARSE_BINOP_DECL (MSparse, T, product, API, MSparse<T>, MSparse<T>);
194 #define SPARSE_FORWARD_DEFS(B, R, F, T) \
195 SPARSE_OP_ASSIGN_FWD_FCN (R, operator +=, T, dynamic_cast<B<T>&>, \
196 R, dynamic_cast<const B<T>&>, R) \
197 SPARSE_OP_ASSIGN_FWD_FCN (R, operator -=, T, dynamic_cast<B<T>&>, \
198 R, dynamic_cast<const B<T>&>, R) \
199 SPARSE_UNOP_FWD_FCN (R, operator +, T, dynamic_cast<const B<T>&>, R) \
200 SPARSE_UNOP_FWD_FCN (R, operator -, T, dynamic_cast<const B<T>&>, R) \
201 SPARSE_BINOP_FWD_FCN (F, operator +, T, dynamic_cast<const B<T>&>, R, , T) \
202 SPARSE_BINOP_FWD_FCN (F, operator -, T, dynamic_cast<const B<T>&>, R, , T) \
203 SPARSE_BINOP_FWD_FCN (R, operator *, T, dynamic_cast<const B<T>&>, R, , T) \
204 SPARSE_BINOP_FWD_FCN (R, operator /, T, dynamic_cast<const B<T>&>, R, , T) \
205 SPARSE_BINOP_FWD_FCN (F, operator +, T, , T, dynamic_cast<const B<T>&>, R) \
206 SPARSE_BINOP_FWD_FCN (F, operator -, T, , T, dynamic_cast<const B<T>&>, R) \
207 SPARSE_BINOP_FWD_FCN (R, operator *, T, , T, dynamic_cast<const B<T>&>, R) \
208 SPARSE_BINOP_FWD_FCN (R, operator /, T, , T, dynamic_cast<const B<T>&>, R) \
209 SPARSE_BINOP_FWD_FCN (R, operator +, T, dynamic_cast<const B<T>&>, \
210 R, dynamic_cast<const B<T>&>, R) \
211 SPARSE_BINOP_FWD_FCN (R, operator -, T, dynamic_cast<const B<T>&>, \
212 R, dynamic_cast<const B<T>&>, R) \
213 SPARSE_BINOP_FWD_FCN (R, product, T, dynamic_cast<const B<T>&>, \
214 R, dynamic_cast<const B<T>&>, R) \
215 SPARSE_BINOP_FWD_FCN (R, quotient, T, dynamic_cast<const B<T>&>, \
216 R, dynamic_cast<const B<T>&>, R)
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< 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(const Sparse< U > &a)
MSparse(const Sparse< T > &a)
MSparse(octave_idx_type r, octave_idx_type c, octave_idx_type num_nz)
Sparse< U > map(U(&fcn)(T)) const
MSparse(const Array< T > &a, const octave::idx_vector &r, const octave::idx_vector &c, octave_idx_type nr=-1, octave_idx_type nc=-1, bool sum_terms=true, octave_idx_type nzm=-1)
Sparse< U > map(U(&fcn)(const T &)) const
MSparse(const MSparse< T > &a, const dim_vector &dv)
MSparse(const dim_vector &dv, octave_idx_type nz=0)
MSparse(const PermMatrix &a)
OCTAVE_API Sparse< T, Alloc > & insert(const Sparse< T, Alloc > &a, octave_idx_type r, octave_idx_type c)
OCTAVE_API Sparse< T, Alloc > transpose(void) const
OCTAVE_API Sparse< T, Alloc > permute(const Array< octave_idx_type > &vec, bool inv=false) const
Sparse< T, Alloc > squeeze(void) const
OCTAVE_API Sparse< T, Alloc > reshape(const dim_vector &new_dims) const
OCTAVE_API Sparse< T, Alloc > diag(octave_idx_type k=0) const
OCTAVE_API Sparse< T, Alloc > & operator=(const Sparse< T, Alloc > &a)
Sparse< T, Alloc > ipermute(const Array< octave_idx_type > &vec) const
Vector representing the dimensions (size) of an Array.
octave::idx_vector idx_vector