changeset 12530:a39300467722 octave-forge

spmm operation against octave_complex_matrix was missing. this is a contributed patch to introduce it. more cases to come.
author michelemartone
date Fri, 17 Oct 2014 06:44:38 +0000
parents 9ae2931c2dbf
children f39400293307
files main/sparsersb/src/sparsersb.cc
diffstat 1 files changed, 32 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/main/sparsersb/src/sparsersb.cc	Thu Oct 02 14:07:07 2014 +0000
+++ b/main/sparsersb/src/sparsersb.cc	Fri Oct 17 06:44:38 2014 +0000
@@ -1131,6 +1131,28 @@
 	}
 }
 
+#if RSBOI_WANT_DOUBLE_COMPLEX
+octave_value spmm(const octave_complex_matrix&v2, bool do_trans=false)const
+{
+	rsb_err_t errval=RSB_ERR_NO_ERROR;
+	RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG);
+	rsb_trans_t transa = do_trans ? RSB_TRANSPOSITION_T : RSB_TRANSPOSITION_N;
+	const ComplexMatrix b = v2.complex_matrix_value ();
+	octave_idx_type b_nc = b.cols ();
+	octave_idx_type b_nr = b.rows ();
+	octave_idx_type ldb=b_nr;
+	octave_idx_type ldc=do_trans?this->columns():this->rows();
+	octave_idx_type nrhs=b_nc;
+	ComplexMatrix retval(ldc,nrhs,RSBOI_ZERO);
+
+	if(( do_trans)&&(this->rows()   !=b_nr)) { error("matrix rows count does not match operand rows!\n"); return Matrix(); }
+	if((!do_trans)&&(this->columns()!=b_nr)) { error("matrix columns count does not match operand rows!\n"); return Matrix(); }
+	errval=rsb_spmm(transa,&rsboi_pone,this->mtxAp,nrhs,RSB_OI_DMTXORDER,(RSBOI_T*)b.data(),ldb,&rsboi_zero,(RSBOI_T*)retval.data(),ldc);
+	RSBOI_PERROR(errval);
+	return retval;
+}
+#endif
+
 octave_value spmsp(const octave_sparsersb_mtx&v2)const
 {
 	rsb_err_t errval=RSB_ERR_NO_ERROR;
@@ -1636,6 +1658,15 @@
 	return v1.spmm(v2, true);
 }
 
+#if RSBOI_WANT_DOUBLE_COMPLEX
+DEFBINOP(op_c_mul, sparse_rsb_mtx, matrix)
+{
+	RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG);
+	CAST_BINOP_ARGS (const octave_sparsersb_mtx&, const octave_complex_matrix&);
+	return v1.spmm(v2, false);
+}
+#endif
+
 static void install_sparsersb_ops (void)
 {
 	RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG);
@@ -1693,6 +1724,7 @@
 	INSTALL_BINOP (op_mul, octave_sparsersb_mtx, octave_scalar, rsb_s_mul);
 #if RSBOI_WANT_DOUBLE_COMPLEX
 	INSTALL_BINOP (op_mul, octave_sparsersb_mtx, octave_complex, rsb_c_mul);
+	INSTALL_BINOP (op_mul, octave_sparsersb_mtx, octave_complex_matrix, op_c_mul);
 #endif
 	//INSTALL_BINOP (op_pow, octave_sparsersb_mtx, octave_scalar, rsb_s_pow);
 	INSTALL_BINOP (op_el_div, octave_sparsersb_mtx, octave_matrix, el_div);