コード例 #1
0
ファイル: linalg_complex.c プロジェクト: jakobjanot/rb-gsl
static VALUE rb_gsl_linalg_cholesky_svx(int argc, VALUE *argv, VALUE obj)
{
  gsl_matrix_complex *A = NULL, *Atmp = NULL;
  gsl_vector_complex *b = NULL;
  int flaga = 0;
  VALUE vA, vb;
  switch(TYPE(obj)) {
  case T_MODULE:  case T_CLASS:  case T_OBJECT:
    if (argc != 2) rb_raise(rb_eArgError, "wrong number of argument (%d for 2)",
			    argc);
    vA = argv[0];
    vb = argv[1];
    break;
  default:
    if (argc != 1) rb_raise(rb_eArgError, "wrong number of argument (%d for 1)",
			    argc);
    vA = obj;
    vb = argv[0];
    break;
  }
  CHECK_MATRIX_COMPLEX(vA);
  Data_Get_Struct(vA, gsl_matrix_complex, Atmp);
  CHECK_VECTOR_COMPLEX(vb);
  Data_Get_Struct(vb, gsl_vector_complex, b);
  if (CLASS_OF(vA) == cgsl_matrix_complex_C) {
    A = Atmp;
  } else {
    A = make_matrix_complex_clone(Atmp);
    flaga = 1;
    gsl_linalg_complex_cholesky_decomp(A);
  }
  gsl_linalg_complex_cholesky_svx(A, b);
  if (flaga == 1) gsl_matrix_complex_free(A);
  return vb;
}
コード例 #2
0
ファイル: linalg.hpp プロジェクト: fujiisoup/MyLibrary
 /**
  * C++ version of gsl_linalg_complex_cholesky_svx().
  * @param cholesky A Cholesky decomposition matrix
  * @param x A vector
  * @return Error code on failure
  */
 inline int complex_cholesky_svx( matrix_complex const& cholesky, vector_complex& x ){
   return gsl_linalg_complex_cholesky_svx( cholesky.get(), x.get() ); }