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
|
#include "rb_lapack.h"
extern VOID clacrt_(integer* n, complex* cx, integer* incx, complex* cy, integer* incy, complex* c, complex* s);
static VALUE
rblapack_clacrt(int argc, VALUE *argv, VALUE self){
VALUE rblapack_cx;
complex *cx;
VALUE rblapack_incx;
integer incx;
VALUE rblapack_cy;
complex *cy;
VALUE rblapack_incy;
integer incy;
VALUE rblapack_c;
complex c;
VALUE rblapack_s;
complex s;
VALUE rblapack_cx_out__;
complex *cx_out__;
VALUE rblapack_cy_out__;
complex *cy_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 cx, cy = NumRu::Lapack.clacrt( cx, incx, cy, incy, c, s, [:usage => usage, :help => help])\n\n\nFORTRAN MANUAL\n SUBROUTINE CLACRT( N, CX, INCX, CY, INCY, C, S )\n\n* Purpose\n* =======\n*\n* CLACRT performs the operation\n*\n* ( c s )( x ) ==> ( x )\n* ( -s c )( y ) ( y )\n*\n* where c and s are complex and the vectors x and y are complex.\n*\n\n* Arguments\n* =========\n*\n* N (input) INTEGER\n* The number of elements in the vectors CX and CY.\n*\n* CX (input/output) COMPLEX array, dimension (N)\n* On input, the vector x.\n* On output, CX is overwritten with c*x + s*y.\n*\n* INCX (input) INTEGER\n* The increment between successive values of CX. INCX <> 0.\n*\n* CY (input/output) COMPLEX array, dimension (N)\n* On input, the vector y.\n* On output, CY is overwritten with -s*x + c*y.\n*\n* INCY (input) INTEGER\n* The increment between successive values of CY. INCY <> 0.\n*\n* C (input) COMPLEX\n* S (input) COMPLEX\n* C and S define the matrix\n* [ C S ].\n* [ -S C ]\n*\n\n* =====================================================================\n*\n* .. Local Scalars ..\n INTEGER I, IX, IY\n COMPLEX CTEMP\n* ..\n\n");
return Qnil;
}
if (rb_hash_aref(rblapack_options, sUsage) == Qtrue) {
printf("%s\n", "USAGE:\n cx, cy = NumRu::Lapack.clacrt( cx, incx, cy, incy, c, s, [: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_cx = argv[0];
rblapack_incx = argv[1];
rblapack_cy = argv[2];
rblapack_incy = argv[3];
rblapack_c = argv[4];
rblapack_s = argv[5];
if (argc == 6) {
} else if (rblapack_options != Qnil) {
} else {
}
if (!NA_IsNArray(rblapack_cx))
rb_raise(rb_eArgError, "cx (1th argument) must be NArray");
if (NA_RANK(rblapack_cx) != 1)
rb_raise(rb_eArgError, "rank of cx (1th argument) must be %d", 1);
n = NA_SHAPE0(rblapack_cx);
if (NA_TYPE(rblapack_cx) != NA_SCOMPLEX)
rblapack_cx = na_change_type(rblapack_cx, NA_SCOMPLEX);
cx = NA_PTR_TYPE(rblapack_cx, complex*);
if (!NA_IsNArray(rblapack_cy))
rb_raise(rb_eArgError, "cy (3th argument) must be NArray");
if (NA_RANK(rblapack_cy) != 1)
rb_raise(rb_eArgError, "rank of cy (3th argument) must be %d", 1);
if (NA_SHAPE0(rblapack_cy) != n)
rb_raise(rb_eRuntimeError, "shape 0 of cy must be the same as shape 0 of cx");
if (NA_TYPE(rblapack_cy) != NA_SCOMPLEX)
rblapack_cy = na_change_type(rblapack_cy, NA_SCOMPLEX);
cy = NA_PTR_TYPE(rblapack_cy, complex*);
c.r = (real)NUM2DBL(rb_funcall(rblapack_c, rb_intern("real"), 0));
c.i = (real)NUM2DBL(rb_funcall(rblapack_c, rb_intern("imag"), 0));
incx = NUM2INT(rblapack_incx);
s.r = (real)NUM2DBL(rb_funcall(rblapack_s, rb_intern("real"), 0));
s.i = (real)NUM2DBL(rb_funcall(rblapack_s, rb_intern("imag"), 0));
incy = NUM2INT(rblapack_incy);
{
na_shape_t shape[1];
shape[0] = n;
rblapack_cx_out__ = na_make_object(NA_SCOMPLEX, 1, shape, cNArray);
}
cx_out__ = NA_PTR_TYPE(rblapack_cx_out__, complex*);
MEMCPY(cx_out__, cx, complex, NA_TOTAL(rblapack_cx));
rblapack_cx = rblapack_cx_out__;
cx = cx_out__;
{
na_shape_t shape[1];
shape[0] = n;
rblapack_cy_out__ = na_make_object(NA_SCOMPLEX, 1, shape, cNArray);
}
cy_out__ = NA_PTR_TYPE(rblapack_cy_out__, complex*);
MEMCPY(cy_out__, cy, complex, NA_TOTAL(rblapack_cy));
rblapack_cy = rblapack_cy_out__;
cy = cy_out__;
clacrt_(&n, cx, &incx, cy, &incy, &c, &s);
return rb_ary_new3(2, rblapack_cx, rblapack_cy);
}
void
init_lapack_clacrt(VALUE mLapack, VALUE sH, VALUE sU, VALUE zero){
sHelp = sH;
sUsage = sU;
rblapack_ZERO = zero;
rb_define_module_function(mLapack, "clacrt", rblapack_clacrt, -1);
}
|