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>
107 :
public std::unary_function <T, T>
114 template <
typename RT,
typename SM,
typename DM,
typename OpA,
typename OpD>
126 RT
r (a_nr, a_nc, nz +
n);
136 for (k_split = k_src; k_split < colend; k_split++)
137 if (a.ridx (k_split) >= j)
140 for (; k_src < k_split; k_src++, k++)
142 r.xridx (k) = a.ridx (k_src);
143 r.xdata (k) = opa (a.data (k_src));
146 if (k_src < colend && a.ridx (k_src) == j)
149 r.xdata (k) = opa (a.data (k_src)) + opd (
d.dgelem (j));
155 r.xdata (k) = opd (
d.dgelem (j));
159 for (; k_src < colend; k_src++, k++)
161 r.xridx (k) = a.ridx (k_src);
162 r.xdata (k) = opa (a.data (k_src));
168 r.maybe_compress (
true);
172 template <
typename RT,
typename DM,
typename SM>
176 return inner_do_add_sm_dm<RT> (a,
d,
181 template <
typename RT,
typename DM,
typename SM>
184 if (a.rows () !=
d.rows () || a.cols () !=
d.cols ())
186 d.rows (),
d.cols (), a.rows (), a.cols ());
188 return do_commutative_add_dm_sm<RT> (
d, a);
191 template <
typename RT,
typename DM,
typename SM>
194 if (a.rows () !=
d.rows () || a.cols () !=
d.cols ())
196 d.rows (),
d.cols (), a.rows (), a.cols ());
198 return inner_do_add_sm_dm<RT> (a,
d,
199 std::negate<typename SM::element_type> (),
203 template <
typename RT,
typename SM,
typename DM>
206 if (a.rows () !=
d.rows () || a.cols () !=
d.cols ())
208 a.rows (), a.cols (),
d.rows (),
d.cols ());
210 return do_commutative_add_dm_sm<RT> (
d, a);
213 template <
typename RT,
typename SM,
typename DM>
216 if (a.rows () !=
d.rows () || a.cols () !=
d.cols ())
218 a.rows (), a.cols (),
d.rows (),
d.cols ());
220 return inner_do_add_sm_dm<RT> (a,
d,
222 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)
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
F77_RET_T const F77_DBLE * x
void err_nonconformant(const char *op, octave_idx_type op1_len, octave_idx_type op2_len)