@@ -308,3 +308,55 @@ VALUE cmatrix_dense_submatrix(VALUE self, VALUE r1, VALUE c1, VALUE r2, VALUE c2
308308 cresult );
309309 return result ;
310310}
311+
312+ VALUE cmatrix_dense_rows (VALUE self )
313+ {
314+ CDenseMatrix * this ;
315+ Data_Get_Struct (self , CDenseMatrix , this );
316+ return ULONG2NUM ( dense_matrix_rows (this ));
317+ }
318+
319+
320+ VALUE cmatrix_dense_cols (VALUE self )
321+ {
322+ CDenseMatrix * this ;
323+ Data_Get_Struct (self , CDenseMatrix , this );
324+ return ULONG2NUM ( dense_matrix_cols (this ));
325+ }
326+
327+ VALUE cmatrix_dense_add (VALUE self , VALUE operand )
328+ {
329+ CDenseMatrix * this ;
330+ Data_Get_Struct (self , CDenseMatrix , this );
331+
332+ CDenseMatrix * cresult ;
333+ VALUE result ;
334+
335+ cresult = dense_matrix_new ();
336+
337+ char * s = rb_obj_classname (operand );
338+
339+ if (strcmp (s , "SymEngine::DenseMatrix" ) == 0 ) {
340+ // Matrix Addition
341+ CDenseMatrix * coperand ;
342+ Data_Get_Struct (operand , CDenseMatrix , coperand );
343+
344+ dense_matrix_add_matrix (cresult , this , coperand );
345+
346+ result = Data_Wrap_Struct (c_dense_matrix , NULL , dense_matrix_free ,
347+ cresult );
348+
349+ dense_matrix_free (coperand );
350+ } else {
351+ // Scalar Addition
352+ basic_struct * coperand = basic_new_heap ();
353+ sympify (operand , coperand );
354+
355+ dense_matrix_add_scalar (cresult , this , coperand );
356+ result = Data_Wrap_Struct (c_dense_matrix , NULL , dense_matrix_free ,
357+ cresult );
358+ basic_free_heap (coperand );
359+ }
360+
361+ return result ;
362+ }
0 commit comments