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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
|
#include "rb_lapack.h"
extern VOID zlargv_(integer* n, doublecomplex* x, integer* incx, doublecomplex* y, integer* incy, doublereal* c, integer* incc);
static VALUE
rblapack_zlargv(int argc, VALUE *argv, VALUE self){
VALUE rblapack_n;
integer n;
VALUE rblapack_x;
doublecomplex *x;
VALUE rblapack_incx;
integer incx;
VALUE rblapack_y;
doublecomplex *y;
VALUE rblapack_incy;
integer incy;
VALUE rblapack_incc;
integer incc;
VALUE rblapack_c;
doublereal *c;
VALUE rblapack_x_out__;
doublecomplex *x_out__;
VALUE rblapack_y_out__;
doublecomplex *y_out__;
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 c, x, y = NumRu::Lapack.zlargv( n, x, incx, y, incy, incc, [:usage => usage, :help => help])\n\n\nFORTRAN MANUAL\n SUBROUTINE ZLARGV( N, X, INCX, Y, INCY, C, INCC )\n\n* Purpose\n* =======\n*\n* ZLARGV generates a vector of complex plane rotations with real\n* cosines, determined by elements of the complex vectors x and y.\n* For i = 1,2,...,n\n*\n* ( c(i) s(i) ) ( x(i) ) = ( r(i) )\n* ( -conjg(s(i)) c(i) ) ( y(i) ) = ( 0 )\n*\n* where c(i)**2 + ABS(s(i))**2 = 1\n*\n* The following conventions are used (these are the same as in ZLARTG,\n* but differ from the BLAS1 routine ZROTG):\n* If y(i)=0, then c(i)=1 and s(i)=0.\n* If x(i)=0, then c(i)=0 and s(i) is chosen so that r(i) is real.\n*\n\n* Arguments\n* =========\n*\n* N (input) INTEGER\n* The number of plane rotations to be generated.\n*\n* X (input/output) COMPLEX*16 array, dimension (1+(N-1)*INCX)\n* On entry, the vector x.\n* On exit, x(i) is overwritten by r(i), for i = 1,...,n.\n*\n* INCX (input) INTEGER\n* The increment between elements of X. INCX > 0.\n*\n* Y (input/output) COMPLEX*16 array, dimension (1+(N-1)*INCY)\n* On entry, the vector y.\n* On exit, the sines of the plane rotations.\n*\n* INCY (input) INTEGER\n* The increment between elements of Y. INCY > 0.\n*\n* C (output) DOUBLE PRECISION array, dimension (1+(N-1)*INCC)\n* The cosines of the plane rotations.\n*\n* INCC (input) INTEGER\n* The increment between elements of C. INCC > 0.\n*\n\n* Further Details\n* ======= =======\n*\n* 6-6-96 - Modified with a new algorithm by W. Kahan and J. Demmel\n*\n* This version has a few statements commented out for thread safety\n* (machine parameters are computed on each entry). 10 feb 03, SJH.\n*\n* =====================================================================\n*\n\n");
return Qnil;
}
if (rb_hash_aref(rblapack_options, sUsage) == Qtrue) {
printf("%s\n", "USAGE:\n c, x, y = NumRu::Lapack.zlargv( n, x, incx, y, incy, incc, [:usage => usage, :help => help])\n");
return Qnil;
}
} else
rblapack_options = Qnil;
if (argc != 6 && argc != 6)
rb_raise(rb_eArgError,"wrong number of arguments (%d for 6)", argc);
rblapack_n = argv[0];
rblapack_x = argv[1];
rblapack_incx = argv[2];
rblapack_y = argv[3];
rblapack_incy = argv[4];
rblapack_incc = argv[5];
if (argc == 6) {
} else if (rblapack_options != Qnil) {
} else {
}
n = NUM2INT(rblapack_n);
incx = NUM2INT(rblapack_incx);
incy = NUM2INT(rblapack_incy);
if (!NA_IsNArray(rblapack_x))
rb_raise(rb_eArgError, "x (2th argument) must be NArray");
if (NA_RANK(rblapack_x) != 1)
rb_raise(rb_eArgError, "rank of x (2th argument) must be %d", 1);
if (NA_SHAPE0(rblapack_x) != (1+(n-1)*incx))
rb_raise(rb_eRuntimeError, "shape 0 of x must be %d", 1+(n-1)*incx);
if (NA_TYPE(rblapack_x) != NA_DCOMPLEX)
rblapack_x = na_change_type(rblapack_x, NA_DCOMPLEX);
x = NA_PTR_TYPE(rblapack_x, doublecomplex*);
incc = NUM2INT(rblapack_incc);
if (!NA_IsNArray(rblapack_y))
rb_raise(rb_eArgError, "y (4th argument) must be NArray");
if (NA_RANK(rblapack_y) != 1)
rb_raise(rb_eArgError, "rank of y (4th argument) must be %d", 1);
if (NA_SHAPE0(rblapack_y) != (1+(n-1)*incy))
rb_raise(rb_eRuntimeError, "shape 0 of y must be %d", 1+(n-1)*incy);
if (NA_TYPE(rblapack_y) != NA_DCOMPLEX)
rblapack_y = na_change_type(rblapack_y, NA_DCOMPLEX);
y = NA_PTR_TYPE(rblapack_y, doublecomplex*);
{
na_shape_t shape[1];
shape[0] = 1+(n-1)*incc;
rblapack_c = na_make_object(NA_DFLOAT, 1, shape, cNArray);
}
c = NA_PTR_TYPE(rblapack_c, doublereal*);
{
na_shape_t shape[1];
shape[0] = 1+(n-1)*incx;
rblapack_x_out__ = na_make_object(NA_DCOMPLEX, 1, shape, cNArray);
}
x_out__ = NA_PTR_TYPE(rblapack_x_out__, doublecomplex*);
MEMCPY(x_out__, x, doublecomplex, NA_TOTAL(rblapack_x));
rblapack_x = rblapack_x_out__;
x = x_out__;
{
na_shape_t shape[1];
shape[0] = 1+(n-1)*incy;
rblapack_y_out__ = na_make_object(NA_DCOMPLEX, 1, shape, cNArray);
}
y_out__ = NA_PTR_TYPE(rblapack_y_out__, doublecomplex*);
MEMCPY(y_out__, y, doublecomplex, NA_TOTAL(rblapack_y));
rblapack_y = rblapack_y_out__;
y = y_out__;
zlargv_(&n, x, &incx, y, &incy, c, &incc);
return rb_ary_new3(3, rblapack_c, rblapack_x, rblapack_y);
}
void
init_lapack_zlargv(VALUE mLapack, VALUE sH, VALUE sU, VALUE zero){
sHelp = sH;
sUsage = sU;
rblapack_ZERO = zero;
rb_define_module_function(mLapack, "zlargv", rblapack_zlargv, -1);
}
|