static VALUE rb_gsl_linalg_complex_LU_refine(VALUE obj, VALUE vm, VALUE lu, VALUE pp, VALUE bb, VALUE xx) { gsl_matrix_complex *m = NULL, *mlu = NULL; gsl_permutation *p = NULL; gsl_vector_complex *b = NULL, *x = NULL, *r = NULL; int flagb = 0; VALUE vr; if (CLASS_OF(obj) != cgsl_matrix_complex_LU) rb_raise(rb_eRuntimeError, "Decompose first!"); CHECK_MATRIX_COMPLEX(vm); CHECK_MATRIX_COMPLEX(lu); CHECK_PERMUTATION(pp); CHECK_VECTOR_COMPLEX(xx); Data_Get_Struct(vm, gsl_matrix_complex, m); Data_Get_Struct(lu, gsl_matrix_complex, mlu); Data_Get_Struct(pp, gsl_permutation, p); CHECK_VECTOR_COMPLEX(bb); Data_Get_Struct(bb, gsl_vector_complex, b); Data_Get_Struct(xx, gsl_vector_complex, x); r = gsl_vector_complex_alloc(m->size1); gsl_linalg_complex_LU_refine(m, mlu, p, b, x, r); vr = Data_Wrap_Struct(cgsl_vector_complex, 0, gsl_vector_complex_free, r); if (flagb == 1) gsl_vector_complex_free(b); return rb_ary_new3(2, xx, vr); }
/** * C++ version of gsl_linalg_complex_LU_refine(). * @param A A matrix * @param LU An LU decomposition matrix * @param p A permutation * @param b A vector * @param x A vector * @param residual A residual vector * @return Error code on failure */ inline int complex_LU_refine( matrix_complex const& A, matrix_complex const& LU, permutation const& p, vector_complex const& b, vector_complex& x, vector_complex& residual ){ return gsl_linalg_complex_LU_refine( A.get(), LU.get(), p.get(), b.get(), x.get(), residual.get() ); }