1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
#include "rb_lapack.h"
extern VOID cpttrf_(integer* n, real* d, complex* e, integer* info);
static VALUE
rblapack_cpttrf(int argc, VALUE *argv, VALUE self){
VALUE rblapack_d;
real *d;
VALUE rblapack_e;
complex *e;
VALUE rblapack_info;
integer info;
VALUE rblapack_d_out__;
real *d_out__;
VALUE rblapack_e_out__;
complex *e_out__;
integer n;
VALUE rblapack_options;
if (argc > 0 && TYPE(argv[argc-1]) == T_HASH) {
argc--;
rblapack_options = argv[argc];
if (rb_hash_aref(rblapack_options, sHelp) == Qtrue) {
printf("%s\n", "USAGE:\n info, d, e = NumRu::Lapack.cpttrf( d, e, [:usage => usage, :help => help])\n\n\nFORTRAN MANUAL\n SUBROUTINE CPTTRF( N, D, E, INFO )\n\n* Purpose\n* =======\n*\n* CPTTRF computes the L*D*L' factorization of a complex Hermitian\n* positive definite tridiagonal matrix A. The factorization may also\n* be regarded as having the form A = U'*D*U.\n*\n\n* Arguments\n* =========\n*\n* N (input) INTEGER\n* The order of the matrix A. N >= 0.\n*\n* D (input/output) REAL array, dimension (N)\n* On entry, the n diagonal elements of the tridiagonal matrix\n* A. On exit, the n diagonal elements of the diagonal matrix\n* D from the L*D*L' factorization of A.\n*\n* E (input/output) COMPLEX array, dimension (N-1)\n* On entry, the (n-1) subdiagonal elements of the tridiagonal\n* matrix A. On exit, the (n-1) subdiagonal elements of the\n* unit bidiagonal factor L from the L*D*L' factorization of A.\n* E can also be regarded as the superdiagonal of the unit\n* bidiagonal factor U from the U'*D*U factorization of A.\n*\n* INFO (output) INTEGER\n* = 0: successful exit\n* < 0: if INFO = -k, the k-th argument had an illegal value\n* > 0: if INFO = k, the leading minor of order k is not\n* positive definite; if k < N, the factorization could not\n* be completed, while if k = N, the factorization was\n* completed, but D(N) <= 0.\n*\n\n* =====================================================================\n*\n\n");
return Qnil;
}
if (rb_hash_aref(rblapack_options, sUsage) == Qtrue) {
printf("%s\n", "USAGE:\n info, d, e = NumRu::Lapack.cpttrf( d, e, [:usage => usage, :help => help])\n");
return Qnil;
}
} else
rblapack_options = Qnil;
if (argc != 2 && argc != 2)
rb_raise(rb_eArgError,"wrong number of arguments (%d for 2)", argc);
rblapack_d = argv[0];
rblapack_e = argv[1];
if (argc == 2) {
} else if (rblapack_options != Qnil) {
} else {
}
if (!NA_IsNArray(rblapack_d))
rb_raise(rb_eArgError, "d (1th argument) must be NArray");
if (NA_RANK(rblapack_d) != 1)
rb_raise(rb_eArgError, "rank of d (1th argument) must be %d", 1);
n = NA_SHAPE0(rblapack_d);
if (NA_TYPE(rblapack_d) != NA_SFLOAT)
rblapack_d = na_change_type(rblapack_d, NA_SFLOAT);
d = NA_PTR_TYPE(rblapack_d, real*);
if (!NA_IsNArray(rblapack_e))
rb_raise(rb_eArgError, "e (2th argument) must be NArray");
if (NA_RANK(rblapack_e) != 1)
rb_raise(rb_eArgError, "rank of e (2th argument) must be %d", 1);
if (NA_SHAPE0(rblapack_e) != (n-1))
rb_raise(rb_eRuntimeError, "shape 0 of e must be %d", n-1);
if (NA_TYPE(rblapack_e) != NA_SCOMPLEX)
rblapack_e = na_change_type(rblapack_e, NA_SCOMPLEX);
e = NA_PTR_TYPE(rblapack_e, complex*);
{
na_shape_t shape[1];
shape[0] = n;
rblapack_d_out__ = na_make_object(NA_SFLOAT, 1, shape, cNArray);
}
d_out__ = NA_PTR_TYPE(rblapack_d_out__, real*);
MEMCPY(d_out__, d, real, NA_TOTAL(rblapack_d));
rblapack_d = rblapack_d_out__;
d = d_out__;
{
na_shape_t shape[1];
shape[0] = n-1;
rblapack_e_out__ = na_make_object(NA_SCOMPLEX, 1, shape, cNArray);
}
e_out__ = NA_PTR_TYPE(rblapack_e_out__, complex*);
MEMCPY(e_out__, e, complex, NA_TOTAL(rblapack_e));
rblapack_e = rblapack_e_out__;
e = e_out__;
cpttrf_(&n, d, e, &info);
rblapack_info = INT2NUM(info);
return rb_ary_new3(3, rblapack_info, rblapack_d, rblapack_e);
}
void
init_lapack_cpttrf(VALUE mLapack, VALUE sH, VALUE sU, VALUE zero){
sHelp = sH;
sUsage = sU;
rblapack_ZERO = zero;
rb_define_module_function(mLapack, "cpttrf", rblapack_cpttrf, -1);
}
|