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
|
#include "rb_lapack.h"
extern VOID zlapmt_(logical* forwrd, integer* m, integer* n, doublecomplex* x, integer* ldx, integer* k);
static VALUE
rblapack_zlapmt(int argc, VALUE *argv, VALUE self){
VALUE rblapack_forwrd;
logical forwrd;
VALUE rblapack_m;
integer m;
VALUE rblapack_x;
doublecomplex *x;
VALUE rblapack_k;
integer *k;
VALUE rblapack_x_out__;
doublecomplex *x_out__;
VALUE rblapack_k_out__;
integer *k_out__;
integer ldx;
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 x, k = NumRu::Lapack.zlapmt( forwrd, m, x, k, [:usage => usage, :help => help])\n\n\nFORTRAN MANUAL\n SUBROUTINE ZLAPMT( FORWRD, M, N, X, LDX, K )\n\n* Purpose\n* =======\n*\n* ZLAPMT rearranges the columns of the M by N matrix X as specified\n* by the permutation K(1),K(2),...,K(N) of the integers 1,...,N.\n* If FORWRD = .TRUE., forward permutation:\n*\n* X(*,K(J)) is moved X(*,J) for J = 1,2,...,N.\n*\n* If FORWRD = .FALSE., backward permutation:\n*\n* X(*,J) is moved to X(*,K(J)) for J = 1,2,...,N.\n*\n\n* Arguments\n* =========\n*\n* FORWRD (input) LOGICAL\n* = .TRUE., forward permutation\n* = .FALSE., backward permutation\n*\n* M (input) INTEGER\n* The number of rows of the matrix X. M >= 0.\n*\n* N (input) INTEGER\n* The number of columns of the matrix X. N >= 0.\n*\n* X (input/output) COMPLEX*16 array, dimension (LDX,N)\n* On entry, the M by N matrix X.\n* On exit, X contains the permuted matrix X.\n*\n* LDX (input) INTEGER\n* The leading dimension of the array X, LDX >= MAX(1,M).\n*\n* K (input/output) INTEGER array, dimension (N)\n* On entry, K contains the permutation vector. K is used as\n* internal workspace, but reset to its original value on\n* output.\n*\n\n* =====================================================================\n*\n* .. Local Scalars ..\n INTEGER I, II, IN, J\n COMPLEX*16 TEMP\n* ..\n\n");
return Qnil;
}
if (rb_hash_aref(rblapack_options, sUsage) == Qtrue) {
printf("%s\n", "USAGE:\n x, k = NumRu::Lapack.zlapmt( forwrd, m, x, k, [:usage => usage, :help => help])\n");
return Qnil;
}
} else
rblapack_options = Qnil;
if (argc != 4 && argc != 4)
rb_raise(rb_eArgError,"wrong number of arguments (%d for 4)", argc);
rblapack_forwrd = argv[0];
rblapack_m = argv[1];
rblapack_x = argv[2];
rblapack_k = argv[3];
if (argc == 4) {
} else if (rblapack_options != Qnil) {
} else {
}
forwrd = (rblapack_forwrd == Qtrue);
if (!NA_IsNArray(rblapack_x))
rb_raise(rb_eArgError, "x (3th argument) must be NArray");
if (NA_RANK(rblapack_x) != 2)
rb_raise(rb_eArgError, "rank of x (3th argument) must be %d", 2);
ldx = NA_SHAPE0(rblapack_x);
n = NA_SHAPE1(rblapack_x);
if (NA_TYPE(rblapack_x) != NA_DCOMPLEX)
rblapack_x = na_change_type(rblapack_x, NA_DCOMPLEX);
x = NA_PTR_TYPE(rblapack_x, doublecomplex*);
m = NUM2INT(rblapack_m);
if (!NA_IsNArray(rblapack_k))
rb_raise(rb_eArgError, "k (4th argument) must be NArray");
if (NA_RANK(rblapack_k) != 1)
rb_raise(rb_eArgError, "rank of k (4th argument) must be %d", 1);
if (NA_SHAPE0(rblapack_k) != n)
rb_raise(rb_eRuntimeError, "shape 0 of k must be the same as shape 1 of x");
if (NA_TYPE(rblapack_k) != NA_LINT)
rblapack_k = na_change_type(rblapack_k, NA_LINT);
k = NA_PTR_TYPE(rblapack_k, integer*);
{
na_shape_t shape[2];
shape[0] = ldx;
shape[1] = n;
rblapack_x_out__ = na_make_object(NA_DCOMPLEX, 2, 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] = n;
rblapack_k_out__ = na_make_object(NA_LINT, 1, shape, cNArray);
}
k_out__ = NA_PTR_TYPE(rblapack_k_out__, integer*);
MEMCPY(k_out__, k, integer, NA_TOTAL(rblapack_k));
rblapack_k = rblapack_k_out__;
k = k_out__;
zlapmt_(&forwrd, &m, &n, x, &ldx, k);
return rb_ary_new3(2, rblapack_x, rblapack_k);
}
void
init_lapack_zlapmt(VALUE mLapack, VALUE sH, VALUE sU, VALUE zero){
sHelp = sH;
sUsage = sU;
rblapack_ZERO = zero;
rb_define_module_function(mLapack, "zlapmt", rblapack_zlapmt, -1);
}
|