@@ -360,3 +360,40 @@ VALUE cmatrix_dense_add(VALUE self, VALUE operand)
360360
361361 return result ;
362362}
363+
364+ VALUE cmatrix_dense_mul (VALUE self , VALUE operand )
365+ {
366+ CDenseMatrix * this ;
367+ Data_Get_Struct (self , CDenseMatrix , this );
368+
369+ CDenseMatrix * cresult ;
370+ VALUE result ;
371+
372+ cresult = dense_matrix_new ();
373+
374+ char * s = rb_obj_classname (operand );
375+
376+ if (strcmp (s , "SymEngine::DenseMatrix" ) == 0 ) {
377+ // Matrix Multiplication
378+ CDenseMatrix * coperand ;
379+ Data_Get_Struct (operand , CDenseMatrix , coperand );
380+
381+ dense_matrix_mul_matrix (cresult , this , coperand );
382+
383+ result = Data_Wrap_Struct (c_dense_matrix , NULL , dense_matrix_free ,
384+ cresult );
385+
386+ dense_matrix_free (coperand );
387+ } else {
388+ // Scalar Multiplication
389+ basic_struct * coperand = basic_new_heap ();
390+ sympify (operand , coperand );
391+
392+ dense_matrix_mul_scalar (cresult , this , coperand );
393+ result = Data_Wrap_Struct (c_dense_matrix , NULL , dense_matrix_free ,
394+ cresult );
395+ basic_free_heap (coperand );
396+ }
397+
398+ return result ;
399+ }
0 commit comments