24 #if ! defined (octave_MSparse_h)
25 #define octave_MSparse_h 1
27 #include "octave-config.h"
62 :
Sparse<T> (a, r, c, nr, nc, sum_terms, nzm) { }
65 :
Sparse<T> (r, c, val) { }
70 :
Sparse<T> (r, c, num_nz) { }
111 template <
typename U>
116 template <
typename U>
126 #define SPARSE_OP_ASSIGN_DECL(T, OP, API) \
127 template API MSparse<T>& \
128 operator OP (MSparse<T>&, const MSparse<T>&)
131 #define SPARSE_UNOP_DECL(T, OP, API) \
132 template API MSparse<T> \
133 operator OP (const MSparse<T>&)
136 #define SPARSE_BINOP_DECL(A_T, T, F, API, X_T, Y_T) \
137 template API A_T<T> \
138 F (const X_T&, const Y_T&)
142 #define SPARSE_OP_ASSIGN_FWD_FCN(R, F, T, C_X, X_T, C_Y, Y_T) \
144 F (X_T& x, const Y_T& y) \
146 return R (F (C_X (x), C_Y (y))); \
151 #define SPARSE_UNOP_FWD_FCN(R, F, T, C_X, X_T) \
155 return R (F (C_X (x))); \
160 #define SPARSE_BINOP_FWD_FCN(R, F, T, C_X, X_T, C_Y, Y_T) \
162 F (const X_T& x, const Y_T& y) \
164 return R (F (C_X (x), C_Y (y))); \
168 #define INSTANTIATE_SPARSE_FRIENDS(T, API) \
169 SPARSE_OP_ASSIGN_DECL (T, +=, API); \
170 SPARSE_OP_ASSIGN_DECL (T, -=, API); \
171 SPARSE_UNOP_DECL (T, +, API); \
172 SPARSE_UNOP_DECL (T, -, API); \
173 SPARSE_BINOP_DECL (MArray, T, operator +, API, MSparse<T>, T); \
174 SPARSE_BINOP_DECL (MArray, T, operator -, API, MSparse<T>, T); \
175 SPARSE_BINOP_DECL (MSparse, T, operator *, API, MSparse<T>, T); \
176 SPARSE_BINOP_DECL (MSparse, T, operator /, API, MSparse<T>, T); \
177 SPARSE_BINOP_DECL (MArray, T, operator +, API, T, MSparse<T>); \
178 SPARSE_BINOP_DECL (MArray, T, operator -, API, T, MSparse<T>); \
179 SPARSE_BINOP_DECL (MSparse, T, operator *, API, T, MSparse<T>); \
180 SPARSE_BINOP_DECL (MSparse, T, operator /, API, T, MSparse<T>); \
181 SPARSE_BINOP_DECL (MSparse, T, operator +, API, MSparse<T>, MSparse<T>); \
182 SPARSE_BINOP_DECL (MSparse, T, operator -, API, MSparse<T>, MSparse<T>); \
183 SPARSE_BINOP_DECL (MSparse, T, quotient, API, MSparse<T>, MSparse<T>); \
184 SPARSE_BINOP_DECL (MSparse, T, product, API, MSparse<T>, MSparse<T>);
188 #define SPARSE_FORWARD_DEFS(B, R, F, T) \
189 SPARSE_OP_ASSIGN_FWD_FCN (R, operator +=, T, dynamic_cast<B<T>&>, \
190 R, dynamic_cast<const B<T>&>, R) \
191 SPARSE_OP_ASSIGN_FWD_FCN (R, operator -=, T, dynamic_cast<B<T>&>, \
192 R, dynamic_cast<const B<T>&>, R) \
193 SPARSE_UNOP_FWD_FCN (R, operator +, T, dynamic_cast<const B<T>&>, R) \
194 SPARSE_UNOP_FWD_FCN (R, operator -, T, dynamic_cast<const B<T>&>, R) \
195 SPARSE_BINOP_FWD_FCN (F, operator +, T, dynamic_cast<const B<T>&>, R, , T) \
196 SPARSE_BINOP_FWD_FCN (F, operator -, T, dynamic_cast<const B<T>&>, R, , T) \
197 SPARSE_BINOP_FWD_FCN (R, operator *, T, dynamic_cast<const B<T>&>, R, , T) \
198 SPARSE_BINOP_FWD_FCN (R, operator /, T, dynamic_cast<const B<T>&>, R, , T) \
199 SPARSE_BINOP_FWD_FCN (F, operator +, T, , T, dynamic_cast<const B<T>&>, R) \
200 SPARSE_BINOP_FWD_FCN (F, operator -, T, , T, dynamic_cast<const B<T>&>, R) \
201 SPARSE_BINOP_FWD_FCN (R, operator *, T, , T, dynamic_cast<const B<T>&>, R) \
202 SPARSE_BINOP_FWD_FCN (R, operator /, T, , T, dynamic_cast<const B<T>&>, R) \
203 SPARSE_BINOP_FWD_FCN (R, operator +, T, dynamic_cast<const B<T>&>, \
204 R, 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, product, T, dynamic_cast<const B<T>&>, \
208 R, dynamic_cast<const B<T>&>, R) \
209 SPARSE_BINOP_FWD_FCN (R, quotient, T, dynamic_cast<const B<T>&>, \
210 R, dynamic_cast<const B<T>&>, R)
MSparse< U > map(U(&fcn)(const T &)) const
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 > & insert(const Sparse< T > &a, const Array< octave_idx_type > &indx)
Sparse< T > ipermute(const Array< octave_idx_type > &vec) const
MSparse< T > ipermute(const Array< octave_idx_type > &vec) const
MSparse< T > & insert(const Sparse< T > &a, octave_idx_type r, octave_idx_type c)
MSparse(const Sparse< U > &a)
MSparse(const PermMatrix &a)
Sparse< T > & operator=(const Sparse< T > &a)
identity matrix If supplied two scalar respectively For allows like xample val
MDiagArray2< T > & operator=(const MDiagArray2< T > &a)
MSparse< T > squeeze(void) const
MSparse(octave_idx_type r, octave_idx_type c, octave_idx_type num_nz)
Sparse< T > permute(const Array< octave_idx_type > &vec, bool inv=false) const
Sparse< T > & insert(const Sparse< T > &a, octave_idx_type r, octave_idx_type c)
Sparse< T > squeeze(void) const
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
MSparse(const MSparse< T > &a, const dim_vector &dv)
MSparse(const Sparse< T > &a)
MSparse(const MSparse< T > &a)
nd deftypefn *octave_map m
Sparse< T > reshape(const dim_vector &new_dims) const
MSparse< T > permute(const Array< octave_idx_type > &vec, bool inv=false) const
MSparse< T > reshape(const dim_vector &new_dims) const
MSparse(const dim_vector &dv, octave_idx_type nz=0)
MSparse(octave_idx_type r, octave_idx_type c, T val)
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
MSparse< T > transpose(void) const
N Dimensional Array with copy-on-write semantics.
MSparse(octave_idx_type n, octave_idx_type m)
MSparse< T > diag(octave_idx_type k=0) const
Vector representing the dimensions (size) of an Array.
MSparse< U > map(U(&fcn)(T)) const
Sparse< T > diag(octave_idx_type k=0) const
Sparse< T > transpose(void) const