26 #if ! defined (octave_Sparse_diag_op_defs_h)
27 #define octave_Sparse_diag_op_defs_h 1
29 #include "octave-config.h"
35 template <
typename RT,
typename DM,
typename SM>
47 RT
r (nr, a_nc, a.nnz ());
59 r.xdata (l) =
d.dgelem (i) * a.data (k);
67 r.maybe_compress (
true);
71 template <
typename RT,
typename SM,
typename DM>
84 RT
r (a_nr, nc, a.cidx (mnc));
88 const typename DM::element_type s =
d.dgelem (j);
90 r.xcidx (j) = a.cidx (j);
93 r.xdata (k) = s * a.data (k);
94 r.xridx (k) = a.ridx (k);
98 r.xcidx (j) = a.cidx (mnc);
100 r.maybe_compress (
true);
105 template <
typename T>
116 template <
typename RT,
typename SM,
typename DM,
typename OpA,
typename OpD>
128 RT
r (a_nr, a_nc, nz +
n);
138 for (k_split = k_src; k_split < colend; k_split++)
139 if (a.ridx (k_split) >= j)
142 for (; k_src < k_split; k_src++, k++)
144 r.xridx (k) = a.ridx (k_src);
145 r.xdata (k) = opa (a.data (k_src));
148 if (k_src < colend && a.ridx (k_src) == j)
151 r.xdata (k) = opa (a.data (k_src)) + opd (
d.dgelem (j));
157 r.xdata (k) = opd (
d.dgelem (j));
161 for (; k_src < colend; k_src++, k++)
163 r.xridx (k) = a.ridx (k_src);
164 r.xdata (k) = opa (a.data (k_src));
170 r.maybe_compress (
true);
174 template <
typename RT,
typename DM,
typename SM>
178 return inner_do_add_sm_dm<RT> (a,
d,
183 template <
typename RT,
typename DM,
typename SM>
186 if (a.rows () !=
d.rows () || a.cols () !=
d.cols ())
188 d.rows (),
d.cols (), a.rows (), a.cols ());
190 return do_commutative_add_dm_sm<RT> (
d, a);
193 template <
typename RT,
typename DM,
typename SM>
196 if (a.rows () !=
d.rows () || a.cols () !=
d.cols ())
198 d.rows (),
d.cols (), a.rows (), a.cols ());
200 return inner_do_add_sm_dm<RT> (a,
d,
201 std::negate<typename SM::element_type> (),
205 template <
typename RT,
typename SM,
typename DM>
208 if (a.rows () !=
d.rows () || a.cols () !=
d.cols ())
210 a.rows (), a.cols (),
d.rows (),
d.cols ());
212 return do_commutative_add_dm_sm<RT> (
d, a);
215 template <
typename RT,
typename SM,
typename DM>
218 if (a.rows () !=
d.rows () || a.cols () !=
d.cols ())
220 a.rows (), a.cols (),
d.rows (),
d.cols ());
222 return inner_do_add_sm_dm<RT> (a,
d,
224 std::negate<typename DM::element_type> ());
RT inner_do_add_sm_dm(const SM &a, const DM &d, OpA opa, OpD opd)
RT do_sub_sm_dm(const SM &a, const DM &d)
RT do_add_sm_dm(const SM &a, const DM &d)
RT do_commutative_add_dm_sm(const DM &d, const SM &a)
RT do_add_dm_sm(const DM &d, const SM &a)
RT do_sub_dm_sm(const DM &d, const SM &a)
RT do_mul_sm_dm(const SM &a, const DM &d)
RT do_mul_dm_sm(const DM &d, const SM &a)
charNDArray min(char d, const charNDArray &m)
void err_nonconformant(const char *op, octave_idx_type op1_len, octave_idx_type op2_len)
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
F77_RET_T const F77_DBLE * x