Skip to content

Commit 4c40373

Browse files
committed
LU for DenseMatrix
1 parent 423259b commit 4c40373

File tree

3 files changed

+56
-0
lines changed

3 files changed

+56
-0
lines changed

ext/symengine/ruby_matrix.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,3 +397,53 @@ VALUE cmatrix_dense_mul(VALUE self, VALUE operand)
397397

398398
return result;
399399
}
400+
401+
402+
VALUE cmatrix_dense_LU(VALUE self)
403+
{
404+
CDenseMatrix *this;
405+
Data_Get_Struct(self, CDenseMatrix, this);
406+
407+
CDenseMatrix *cresult_l;
408+
VALUE result_l;
409+
cresult_l = dense_matrix_new();
410+
411+
CDenseMatrix *cresult_u;
412+
VALUE result_u;
413+
cresult_u = dense_matrix_new();
414+
415+
dense_matrix_LU(cresult_l, cresult_u, this);
416+
417+
result_l = Data_Wrap_Struct(c_dense_matrix, NULL, dense_matrix_free,
418+
cresult_l);
419+
result_u = Data_Wrap_Struct(c_dense_matrix, NULL, dense_matrix_free,
420+
cresult_u);
421+
422+
VALUE result;
423+
result = rb_ary_new();
424+
rb_ary_push(result, result_l);
425+
rb_ary_push(result, result_u);
426+
427+
return result;
428+
}
429+
430+
/*VALUE cmatrix_dense_LDL(VALUE self)
431+
{
432+
433+
}
434+
435+
VALUE cmatrix_dense_LU_solve(VALUE self, VALUE b)
436+
{
437+
438+
}
439+
440+
VALUE cmatrix_dense_FFLU(VALUE self)
441+
{
442+
443+
}
444+
445+
446+
VALUE cmatrix_dense_FFLDU(VALUE self)
447+
{
448+
449+
}*/

ext/symengine/ruby_matrix.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ VALUE cmatrix_dense_rows(VALUE self);
2222
VALUE cmatrix_dense_cols(VALUE self);
2323
VALUE cmatrix_dense_add(VALUE self, VALUE operand);
2424
VALUE cmatrix_dense_mul(VALUE self, VALUE operand);
25+
VALUE cmatrix_dense_LU(VALUE self);
26+
/*VALUE cmatrix_dense_LDL(VALUE self);
27+
VALUE cmatrix_dense_LU_solve(VALUE self, VALUE b);
28+
VALUE cmatrix_dense_FFLU(VALUE self);
29+
VALUE cmatrix_dense_FFLDU(VALUE self);*/
2530

2631
void cmatrix_sparse_free(void *ptr);
2732
VALUE cmatrix_sparse_alloc(VALUE klass);

ext/symengine/symengine.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ void Init_symengine()
247247
rb_define_method(c_dense_matrix, "cols", cmatrix_dense_cols, 0);
248248
rb_define_method(c_dense_matrix, "+", cmatrix_dense_add, 1);
249249
rb_define_method(c_dense_matrix, "*", cmatrix_dense_mul, 1);
250+
rb_define_method(c_dense_matrix, "LU", cmatrix_dense_LU, 0);
250251

251252

252253
// SparseMatrix Methods

0 commit comments

Comments
 (0)