23 #if !defined (octave_Sparse_diag_op_defs_h)
24 #define octave_Sparse_diag_op_defs_h 1
28 template <
typename RT,
typename DM,
typename SM>
44 RT r (nr, a_nc, a.nnz ());
56 r.xdata (l) = d.dgelem (i) * a.data (k);
64 r.maybe_compress (
true);
69 template <
typename RT,
typename SM,
typename DM>
87 RT r (a_nr, nc, a.cidx (mnc));
91 const typename DM::element_type s = d.dgelem (j);
93 r.xcidx (j) = a.cidx (j);
96 r.xdata (k) = s * a.data (k);
97 r.xridx (k) = a.ridx (k);
101 r.xcidx (j) = a.cidx (mnc);
103 r.maybe_compress (
true);
109 template <
typename T>
111 :
public std::unary_function <T, T>
118 template <
typename RT,
typename SM,
typename DM,
typename OpA,
typename OpD>
130 RT r (a_nr, a_nc, nz + n);
140 for (k_split = k_src; k_split < colend; k_split++)
141 if (a.ridx (k_split) >= j)
144 for (; k_src < k_split; k_src++, k++)
146 r.xridx (k) = a.ridx (k_src);
147 r.xdata (k) = opa (a.data (k_src));
150 if (k_src < colend && a.ridx (k_src) == j)
153 r.xdata (k) = opa (a.data (k_src)) + opd (d.dgelem (j));
159 r.xdata (k) = opd (d.dgelem (j));
163 for (; k_src < colend; k_src++, k++)
165 r.xridx (k) = a.ridx (k_src);
166 r.xdata (k) = opa (a.data (k_src));
172 r.maybe_compress (
true);
176 template <
typename RT,
typename DM,
typename SM>
180 return inner_do_add_sm_dm<RT> (a,
d,
185 template <
typename RT,
typename DM,
typename SM>
188 if (a.rows () != d.rows () || a.cols () != d.cols ())
194 return do_commutative_add_dm_sm<RT> (
d, a);
197 template <
typename RT,
typename DM,
typename SM>
200 if (a.rows () != d.rows () || a.cols () != d.cols ())
206 return inner_do_add_sm_dm<RT> (a,
d, std::negate<typename SM::element_type> (),
210 template <
typename RT,
typename SM,
typename DM>
213 if (a.rows () != d.rows () || a.cols () != d.cols ())
219 return do_commutative_add_dm_sm<RT> (
d, a);
222 template <
typename RT,
typename SM,
typename DM>
225 if (a.rows () != d.rows () || a.cols () != d.cols ())
231 return inner_do_add_sm_dm<RT> (a,
d,
233 std::negate<typename DM::element_type> ());
236 #endif // octave_Sparse_diag_op_defs_h