Module: Numo::Linalg::Blas
- Defined in:
- ext/numo/linalg/blas/blas.c,
ext/numo/linalg/blas/blas_c.c,
ext/numo/linalg/blas/blas_d.c,
ext/numo/linalg/blas/blas_s.c,
ext/numo/linalg/blas/blas_z.c,
lib/numo/linalg/function.rb
Constant Summary
- FIXNAME =
{ cnrm2: :csnrm2, znrm2: :dznrm2, }
Class Method Summary collapse
-
.call(func, *args) ⇒ Object
Call BLAS function prefixed with BLAS char ([sdcz]) defined from data-types of arguments.
-
.caxpy(x, y, [alpha: 1]) ⇒ Numo::SComplex
CAXPY constant times a vector plus a vector.
-
.ccopy(x, y) ⇒ nil
CCOPY copies a vector x to a vector y.
-
.cdotc(x, y) ⇒ Numo::SComplex
CDOTC forms the dot product of two complex vectors.
-
.cdotu(x, y) ⇒ Numo::SComplex
CDOTU forms the dot product of two complex vectors.
-
.cgemm(a, b, [c, alpha: 1, beta:0, transa:'N', transb:'N', order:'R']) ⇒ Numo::SComplex
CGEMM performs one of the matrix-matrix operations.
-
.cgemv(a, x, [y, alpha: 1, beta:0, trans:'N', order:'R']) ⇒ Numo::SComplex
CGEMV performs one of the matrix-vector operations.
-
.cgerc(x, y, [a, alpha: 1, order:'R']) ⇒ Numo::SComplex
CGERC performs the rank 1 operation.
-
.cgeru(x, y, [a, alpha: 1, order:'R']) ⇒ Numo::SComplex
CGERU performs the rank 1 operation.
-
.chemm(a, b, [c, alpha: 1, beta:0, side:'L', uplo:'U', order:'R']) ⇒ Numo::SComplex
CHEMM performs one of the matrix-matrix operations.
-
.chemv(a, x, [y, alpha: 1, beta:0, uplo:'U', order:'R']) ⇒ Numo::SComplex
CHEMV performs the matrix-vector operation.
-
.cher(x, [a, alpha: 1, uplo:'U', order:'R']) ⇒ Numo::SComplex
CHER performs the hermitian rank 1 operation.
-
.cher2(x, y, [a, alpha: 1, uplo:'U', order:'R']) ⇒ Numo::SComplex
CHER2 performs the hermitian rank 2 operation.
-
.cherk(a, [c, alpha: 1, beta:0, uplo:'U', trans:'N', order:'R']) ⇒ Numo::SComplex
CHERK performs one of the hermitian rank k operations.
-
.cscal(a, x) ⇒ Numo::SComplex
CSCAL scales a vector by a constant.
-
.csscal(a, x) ⇒ Numo::SComplex
CSSCAL scales a complex vector by a real constant.
-
.cswap(x, y) ⇒ nil
CSWAP interchanges two vectors.
-
.csymm(a, b, [c, alpha: 1, beta:0, side:'L', uplo:'U', order:'R']) ⇒ Numo::SComplex
CSYMM performs one of the matrix-matrix operations.
-
.csyr2k(a, b, [c, alpha: 1, beta:0, uplo:'U', trans:'N', order:'R']) ⇒ Numo::SComplex
CSYR2K performs one of the symmetric rank 2k operations.
-
.csyrk(a, [c, alpha: 1, beta:0, uplo:'U', trans:'N', order:'R']) ⇒ Numo::SComplex
CSYRK performs one of the symmetric rank k operations.
-
.ctrmm(a, b, [alpha: 1, side:'L', uplo:'U', transa:'N', diag:'U', order:'R']) ⇒ Numo::SComplex
CTRMM performs one of the matrix-matrix operations.
-
.ctrmv(a, x, [uplo: 'U', trans:'N', diag:'U', order:'R']) ⇒ Numo::SComplex
CTRMV performs one of the matrix-vector operations.
-
.dasum(x) ⇒ Numo::DFloat
DASUM takes the sum of the absolute values.
-
.daxpy(x, y, [alpha: 1]) ⇒ Numo::DFloat
DAXPY constant times a vector plus a vector.
-
.dcopy(x, y) ⇒ nil
DCOPY copies a vector, x, to a vector, y.
-
.ddot(x, y) ⇒ Numo::DFloat
DDOT forms the dot product of two vectors.
-
.dgemm(a, b, [c, alpha: 1, beta:0, transa:'N', transb:'N', order:'R']) ⇒ Numo::DFloat
DGEMM performs one of the matrix-matrix operations.
-
.dgemv(a, x, [y, alpha: 1, beta:0, trans:'N', order:'R']) ⇒ Numo::DFloat
DGEMV performs one of the matrix-vector operations.
-
.dger(x, y, [a, alpha: 1, order:'R']) ⇒ Numo::DFloat
DGER performs the rank 1 operation.
-
.dlopen(*args) ⇒ Object
-
.dnrm2(x) ⇒ Numo::DFloat
DNRM2 returns the euclidean norm of a vector via the function name, so that.
-
.drot(x, y, c, s) ⇒ Array<Numo::DFloat,Numo::DFloat>
DROT applies a plane rotation.
-
.drotm(x, y, param) ⇒ Array<Numo::DFloat,Numo::DFloat>
Apply the modified givens transformation, H, to the 2 by N matrix (X**T), where **T indicates transpose.
-
.dscal(a, x) ⇒ Numo::DFloat
DSCAL scales a vector by a constant.
-
.dsdot(x, y) ⇒ Numo::DFloat
Compute the inner product of two vectors with extended precision accumulation and result.
-
.dswap(x, y) ⇒ nil
interchanges two vectors.
-
.dsymm(a, b, [c, alpha: 1, beta:0, side:'L', uplo:'U', order:'R']) ⇒ Numo::DFloat
DSYMM performs one of the matrix-matrix operations.
-
.dsymv(a, x, [y, alpha: 1, beta:0, uplo:'U', order:'R']) ⇒ Numo::DFloat
DSYMV performs the matrix-vector operation.
-
.dsyr(x, [a, alpha: 1, uplo:'U', order:'R']) ⇒ Numo::DFloat
DSYR performs the symmetric rank 1 operation.
-
.dsyr2(x, y, [a, alpha: 1, uplo:'U', order:'R']) ⇒ Numo::DFloat
DSYR2 performs the symmetric rank 2 operation.
-
.dsyr2k(a, b, [c, alpha: 1, beta:0, uplo:'U', trans:'N', order:'R']) ⇒ Numo::DFloat
DSYR2K performs one of the symmetric rank 2k operations.
-
.dsyrk(a, [c, alpha: 1, beta:0, uplo:'U', trans:'N', order:'R']) ⇒ Numo::DFloat
DSYRK performs one of the symmetric rank k operations.
-
.dtrmm(a, b, [alpha: 1, side:'L', uplo:'U', transa:'N', diag:'U', order:'R']) ⇒ Numo::DFloat
DTRMM performs one of the matrix-matrix operations.
-
.dtrmv(a, x, [uplo: 'U', trans:'N', diag:'U', order:'R']) ⇒ Numo::DFloat
DTRMV performs one of the matrix-vector operations.
-
.dzasum(x) ⇒ Numo::DFloat
DZASUM takes the sum of the ( Re(.) + Im(.) )’s of a complex vector and returns a single precision result. -
.dznrm2(x) ⇒ Numo::DFloat
DZNRM2 returns the euclidean norm of a vector via the function name, so that.
-
.prefix=(prefix) ⇒ Object
-
.sasum(x) ⇒ Numo::SFloat
SASUM takes the sum of the absolute values.
-
.saxpy(x, y, [alpha: 1]) ⇒ Numo::SFloat
SAXPY constant times a vector plus a vector.
-
.scasum(x) ⇒ Numo::SFloat
SCASUM takes the sum of the ( Re(.) + Im(.) )’s of a complex vector and returns a single precision result. -
.scnrm2(x) ⇒ Numo::SFloat
SCNRM2 returns the euclidean norm of a vector via the function name, so that.
-
.scopy(x, y) ⇒ nil
SCOPY copies a vector, x, to a vector, y.
-
.sdot(x, y) ⇒ Numo::SFloat
SDOT forms the dot product of two vectors.
-
.sdsdot(sx, sy, [sb: 0]) ⇒ Numo::SFloat
Compute the inner product of two vectors with extended precision accumulation.
-
.sgemm(a, b, [c, alpha: 1, beta:0, transa:'N', transb:'N', order:'R']) ⇒ Numo::SFloat
SGEMM performs one of the matrix-matrix operations.
-
.sgemv(a, x, [y, alpha: 1, beta:0, trans:'N', order:'R']) ⇒ Numo::SFloat
SGEMV performs one of the matrix-vector operations.
-
.sger(x, y, [a, alpha: 1, order:'R']) ⇒ Numo::SFloat
SGER performs the rank 1 operation.
-
.snrm2(x) ⇒ Numo::SFloat
SNRM2 returns the euclidean norm of a vector via the function name, so that.
-
.srot(x, y, c, s) ⇒ Array<Numo::SFloat,Numo::SFloat>
applies a plane rotation.
-
.srotm(x, y, param) ⇒ Array<Numo::SFloat,Numo::SFloat>
Apply the modified givens transformation, H, to the 2 by N matrix (X**T), where **T indicates transpose.
-
.sscal(a, x) ⇒ Numo::SFloat
scales a vector by a constant.
-
.sswap(x, y) ⇒ nil
interchanges two vectors.
-
.ssymm(a, b, [c, alpha: 1, beta:0, side:'L', uplo:'U', order:'R']) ⇒ Numo::SFloat
SSYMM performs one of the matrix-matrix operations.
-
.ssymv(a, x, [y, alpha: 1, beta:0, uplo:'U', order:'R']) ⇒ Numo::SFloat
SSYMV performs the matrix-vector operation.
-
.ssyr(x, [a, alpha: 1, uplo:'U', order:'R']) ⇒ Numo::SFloat
SSYR performs the symmetric rank 1 operation.
-
.ssyr2(x, y, [a, alpha: 1, uplo:'U', order:'R']) ⇒ Numo::SFloat
SSYR2 performs the symmetric rank 2 operation.
-
.ssyr2k(a, b, [c, alpha: 1, beta:0, uplo:'U', trans:'N', order:'R']) ⇒ Numo::SFloat
SSYR2K performs one of the symmetric rank 2k operations.
-
.ssyrk(a, [c, alpha: 1, beta:0, uplo:'U', trans:'N', order:'R']) ⇒ Numo::SFloat
SSYRK performs one of the symmetric rank k operations.
-
.strmm(a, b, [alpha: 1, side:'L', uplo:'U', transa:'N', diag:'U', order:'R']) ⇒ Numo::SFloat
STRMM performs one of the matrix-matrix operations.
-
.strmv(a, x, [uplo: 'U', trans:'N', diag:'U', order:'R']) ⇒ Numo::SFloat
STRMV performs one of the matrix-vector operations.
-
.zaxpy(x, y, [alpha: 1]) ⇒ Numo::DComplex
ZAXPY constant times a vector plus a vector.
-
.zcopy(x, y) ⇒ nil
ZCOPY copies a vector, x, to a vector, y.
-
.zdotc(x, y) ⇒ Numo::DComplex
ZDOTC forms the dot product of two complex vectors.
-
.zdotu(x, y) ⇒ Numo::DComplex
ZDOTU forms the dot product of two complex vectors.
-
.zdscal(a, x) ⇒ Numo::DComplex
ZDSCAL scales a vector by a constant.
-
.zgemm(a, b, [c, alpha: 1, beta:0, transa:'N', transb:'N', order:'R']) ⇒ Numo::DComplex
ZGEMM performs one of the matrix-matrix operations.
-
.zgemv(a, x, [y, alpha: 1, beta:0, trans:'N', order:'R']) ⇒ Numo::DComplex
ZGEMV performs one of the matrix-vector operations.
-
.zgerc(x, y, [a, alpha: 1, order:'R']) ⇒ Numo::DComplex
ZGERC performs the rank 1 operation.
-
.zgeru(x, y, [a, alpha: 1, order:'R']) ⇒ Numo::DComplex
ZGERU performs the rank 1 operation.
-
.zhemm(a, b, [c, alpha: 1, beta:0, side:'L', uplo:'U', order:'R']) ⇒ Numo::DComplex
ZHEMM performs one of the matrix-matrix operations.
-
.zhemv(a, x, [y, alpha: 1, beta:0, uplo:'U', order:'R']) ⇒ Numo::DComplex
ZHEMV performs the matrix-vector operation.
-
.zher(x, [a, alpha: 1, uplo:'U', order:'R']) ⇒ Numo::DComplex
ZHER performs the hermitian rank 1 operation.
-
.zher2(x, y, [a, alpha: 1, uplo:'U', order:'R']) ⇒ Numo::DComplex
ZHER2 performs the hermitian rank 2 operation.
-
.zherk(a, [c, alpha: 1, beta:0, uplo:'U', trans:'N', order:'R']) ⇒ Numo::DComplex
ZHERK performs one of the hermitian rank k operations.
-
.zscal(a, x) ⇒ Numo::DComplex
ZSCAL scales a vector by a constant.
-
.zswap(x, y) ⇒ nil
ZSWAP interchanges two vectors.
-
.zsymm(a, b, [c, alpha: 1, beta:0, side:'L', uplo:'U', order:'R']) ⇒ Numo::DComplex
ZSYMM performs one of the matrix-matrix operations.
-
.zsyr2k(a, b, [c, alpha: 1, beta:0, uplo:'U', trans:'N', order:'R']) ⇒ Numo::DComplex
ZSYR2K performs one of the symmetric rank 2k operations.
-
.zsyrk(a, [c, alpha: 1, beta:0, uplo:'U', trans:'N', order:'R']) ⇒ Numo::DComplex
ZSYRK performs one of the symmetric rank k operations.
-
.ztrmm(a, b, [alpha: 1, side:'L', uplo:'U', transa:'N', diag:'U', order:'R']) ⇒ Numo::DComplex
ZTRMM performs one of the matrix-matrix operations.
-
.ztrmv(a, x, [uplo: 'U', trans:'N', diag:'U', order:'R']) ⇒ Numo::DComplex
ZTRMV performs one of the matrix-vector operations.
Class Method Details
.call(func, *args) ⇒ Object
Call BLAS function prefixed with BLAS char ([sdcz]) defined from data-types of arguments.
17 18 19 20 21 |
# File 'lib/numo/linalg/function.rb', line 17 def self.call(func,*args) fn = (Linalg.blas_char(*args) + func.to_s).to_sym fn = FIXNAME[fn] || fn send(fn,*args) end |
.caxpy(x, y, [alpha: 1]) ⇒ Numo::SComplex
CAXPY constant times a vector plus a vector.
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 |
# File 'ext/numo/linalg/blas/blas_c.c', line 481
static VALUE
blas_s_caxpy(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE x, y, alpha;
narray_t *na1, *na2;
ndfunc_arg_in_t ain[2] = {{cT,0},{OVERWRITE,0}};
ndfunc_t ndf = {iter_blas_s_caxpy, STRIDE_LOOP, 2, 0, ain, 0};
dtype g;
VALUE kw_hash = Qnil;
ID kw_table[1] = {id_alpha};
VALUE opts[1] = {Qundef};
CHECK_FUNC(func_p,"caxpy");
rb_scan_args(argc, argv, "2:", &x, &y, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 1, opts);
alpha = option_value(opts[0],Qnil);
g = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
COPY_OR_CAST_TO(y,cT);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
CHECK_NON_EMPTY(na1);
CHECK_NON_EMPTY(na2);
CHECK_SAME_SHAPE(na1,na2);
na_ndloop3(&ndf, &g, 2, x, y);
return y;
}
|
.ccopy(x, y) ⇒ nil
CCOPY copies a vector x to a vector y.
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 |
# File 'ext/numo/linalg/blas/blas_c.c', line 417
static VALUE
blas_s_ccopy(VALUE UNUSED(mod), VALUE x, VALUE y)
{
narray_t *na1, *na2;
ndfunc_arg_in_t ain[2] = {{cT,0},{OVERWRITE,0}};
ndfunc_t ndf = {iter_blas_s_ccopy, STRIDE_LOOP, 2,0, ain,0};
CHECK_FUNC(func_p,"ccopy");
CHECK_NARRAY_TYPE(x,cT);
CHECK_NARRAY_TYPE(y,cT);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
CHECK_NON_EMPTY(na1);
CHECK_NON_EMPTY(na2);
CHECK_SAME_SHAPE(na1,na2);
na_ndloop(&ndf, 2, x, y);
return Qnil;
}
|
.cdotc(x, y) ⇒ Numo::SComplex
CDOTC forms the dot product of two complex vectors
CDOTC = X^H * Y
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'ext/numo/linalg/blas/blas_c.c', line 98
static VALUE
blas_s_cdotc(VALUE mod, VALUE x, VALUE y)
{
VALUE ans;
narray_t *na1, *na2;
size_t nx, ny, shape[1]={1};
ndfunc_arg_in_t ain[2] = {{cT,1},{cT,1}};
ndfunc_arg_out_t aout[1] = {{numo_cSComplex,0,shape}};
ndfunc_t ndf = {iter_blas_s_cdotc, NDF_EXTRACT, 2,1, ain,aout};
CHECK_FUNC(func_p,"cdotc_sub");
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
CHECK_NON_EMPTY(na1);
CHECK_NON_EMPTY(na2);
nx = COL_SIZE(na1);
ny = COL_SIZE(na2);
CHECK_SIZE_EQ(nx,ny);
ans = na_ndloop(&ndf, 2, x, y);
return ans;
}
|
.cdotu(x, y) ⇒ Numo::SComplex
CDOTU forms the dot product of two complex vectors
CDOTU = X^T * Y
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'ext/numo/linalg/blas/blas_c.c', line 165
static VALUE
blas_s_cdotu(VALUE mod, VALUE x, VALUE y)
{
VALUE ans;
narray_t *na1, *na2;
size_t nx, ny, shape[1]={1};
ndfunc_arg_in_t ain[2] = {{cT,1},{cT,1}};
ndfunc_arg_out_t aout[1] = {{numo_cSComplex,0,shape}};
ndfunc_t ndf = {iter_blas_s_cdotu, NDF_EXTRACT, 2,1, ain,aout};
CHECK_FUNC(func_p,"cdotu_sub");
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
CHECK_NON_EMPTY(na1);
CHECK_NON_EMPTY(na2);
nx = COL_SIZE(na1);
ny = COL_SIZE(na2);
CHECK_SIZE_EQ(nx,ny);
ans = na_ndloop(&ndf, 2, x, y);
return ans;
}
|
.cgemm(a, b, [c, alpha: 1, beta:0, transa:'N', transb:'N', order:'R']) ⇒ Numo::SComplex
CGEMM performs one of the matrix-matrix operations
C := alpha*op( A )*op( B ) + beta*C,
where op( X ) is one of
op( X ) = X or op( X ) = X**T or op( X ) = X**H,
alpha and beta are scalars, and A, B and C are matrices, with op( A ) an m by k matrix, op( B ) a k by n matrix and C an m by n matrix.
1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 |
# File 'ext/numo/linalg/blas/blas_c.c', line 1881
static VALUE
blas_s_cgemm(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, b, c=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, ka, kb, nb, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[3] = {{cT,2},{cT,2},{OVERWRITE,2}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_cgemm, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[5] = {id_alpha,id_beta,id_order,id_transa,id_transb};
#elif TR
ID kw_table[7] = {id_alpha,id_beta,id_order,id_side,id_uplo,id_transa,id_diag};
#else
ID kw_table[5] = {id_alpha,id_beta,id_order,id_side,id_uplo};
#endif
VALUE opts[7] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"cgemm");
rb_scan_args(argc, argv, "21:", &a, &b, &c, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 5+TR*2, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.transa = option_trans(opts[3]);
g.transb = option_trans(opts[4]);
#else
g.side = option_side(opts[3]);
g.uplo = option_uplo(opts[4]);
#endif
#if TR
g.transa = option_trans(opts[5]);
g.diag = option_diag(opts[6]);
#endif
GetNArray(a,na1);
GetNArray(b,na2);
CHECK_DIM_GE(na1,2);
CHECK_DIM_GE(na2,2);
ma = ROW_SIZE(na1); // m
ka = COL_SIZE(na1); // k (lda)
kb = ROW_SIZE(na2); // k
nb = COL_SIZE(na2); // n (ldb)
#if GE
SWAP_IFCOLTR(g.order,g.transa, ma,ka, tmp);
SWAP_IFCOLTR(g.order,g.transb, kb,nb, tmp);
CHECK_INT_EQ("ka",ka,"kb",kb);
g.m = ma;
g.n = nb;
g.k = ka;
#else
CHECK_SQUARE("a",na1); // ma == ka
SWAP_IFCOL(g.order, kb,nb, tmp);
// row major L R
//ma = ROW_SIZE(na1); // m or n
//ka = COL_SIZE(na1); // m or n (lda)
g.m = kb; // m
g.n = nb; // n (ldb)
if (g.side == CblasLeft) {
CHECK_SIZE_EQ(ka, g.m);
} else {
CHECK_SIZE_EQ(ka, g.n);
}
#endif
SWAP_IFROW(g.order, ma,nb, tmp);
#if TR
if (c != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(b,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, b);
return b;
#else
if (c == Qnil) { // c is not given.
ndfunc_arg_in_t ain_init = {sym_init,0};
ain[2] = ain_init;
ndf.nout = 1;
c = INT2FIX(0);
shape[0] = nb;
shape[1] = ma;
} else {
narray_t *na3;
int nc;
COPY_OR_CAST_TO(c,cT);
GetNArray(c,na3);
CHECK_DIM_GE(na3,2);
nc = ROW_SIZE(na3);
if (nc < nb) {
rb_raise(nary_eShapeError,"nc=%d must be >= nb=%d",nc,nb);
}
//CHECK_LEADING_GE("ldc",g.ldc,"m",ma);
}
{
VALUE ans = na_ndloop3(&ndf, &g, 3, a, b, c);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return c;
}
}
#endif
}
|
.cgemv(a, x, [y, alpha: 1, beta:0, trans:'N', order:'R']) ⇒ Numo::SComplex
CGEMV performs one of the matrix-vector operations
y := alpha*A*x + beta*y, or y := alpha*A**T*x + beta*y, or
y := alpha*A**H*x + beta*y,
where alpha and beta are scalars, x and y are vectors and A is an m by n matrix.
728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 |
# File 'ext/numo/linalg/blas/blas_c.c', line 728
static VALUE
blas_s_cgemv(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, x, y=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, na, nx;
#if GE
blasint tmp;
#endif
size_t shape[1];
ndfunc_arg_in_t ain[4] = {{cT,2},{cT,1},{OVERWRITE,1},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,1,shape}};
ndfunc_t ndf = {iter_blas_s_cgemv, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[4] = {id_alpha,id_beta,id_order,id_trans};
#elif TR
ID kw_table[6] = {id_alpha,id_beta,id_order,id_uplo,id_trans,id_diag};
#else
ID kw_table[4] = {id_alpha,id_beta,id_order,id_uplo};
#endif
VALUE opts[6] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"cgemv");
rb_scan_args(argc, argv, "21:", &a, &x, &y, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 4+2*TR, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.trans = option_trans(opts[3]);
#else
g.uplo = option_uplo(opts[3]);
#endif
#if TR
g.trans = option_trans(opts[4]);
g.diag = option_diag(opts[5]);
#endif
GetNArray(a,na1);
CHECK_DIM_GE(na1,2);
ma = ROW_SIZE(na1);
na = COL_SIZE(na1);
GetNArray(x,na2);
CHECK_DIM_GE(na2,1);
nx = COL_SIZE(na2);
#if GE
SWAP_IFCOL(g.order, ma, na, tmp);
g.m = ma;
g.n = na;
SWAP_IFTRANS(g.trans, ma, na, tmp);
#else
CHECK_SQUARE("a",na1);
#endif
CHECK_INT_EQ("na",na,"nx",nx);
shape[0] = ma;
#if TR
if (y != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(x,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, x);
return x;
#else // GE,SY,HE
if (y == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
y = INT2FIX(0);
shape[0] = ma;
} else {
narray_t *na3;
COPY_OR_CAST_TO(y,cT);
GetNArray(y,na3);
CHECK_DIM_GE(na3,1);
CHECK_SIZE_GE(na3,nx);
}
{
VALUE ans;
ans = na_ndloop3(&ndf, &g, 3, a, x, y);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return y;
}
}
#endif
}
|
.cgerc(x, y, [a, alpha: 1, order:'R']) ⇒ Numo::SComplex
CGERC performs the rank 1 operation
A := alpha*x*y**H + A,
where alpha is a scalar, x is an m element vector, y is an n element vector and A is an m by n matrix.
1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 |
# File 'ext/numo/linalg/blas/blas_c.c', line 1259
static VALUE
blas_s_cgerc(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE ans;
VALUE x, y, a=Qnil, alpha;
narray_t *na1, *na2;
blasint mx, ny, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[4] = {{cT,1},{cT,1},{OVERWRITE,2},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_cgerc, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
ID kw_table[2] = {id_alpha,id_order};
VALUE opts[2] = {Qundef};
CHECK_FUNC(func_p,"cgerc");
rb_scan_args(argc, argv, "21:", &x, &y, &a, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 2, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
g.order = option_order(opts[1]);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
mx = COL_SIZE(na1); // m
ny = COL_SIZE(na2); // n
g.m = mx;
g.n = ny;
SWAP_IFCOL(g.order, mx,ny, tmp);
if (a == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
a = INT2FIX(0);
shape[0] = mx;
shape[1] = ny;
} else {
narray_t *na3;
blasint ma, na;
COPY_OR_CAST_TO(a,cT);
GetNArray(a,na3);
CHECK_DIM_GE(na3,2);
ma = ROW_SIZE(na3); // m
na = COL_SIZE(na3); // n (lda)
CHECK_SIZE_EQ(ma,mx);
CHECK_SIZE_EQ(na,ny);
}
ans = na_ndloop3(&ndf, &g, 3, x, y, a);
if (ndf.nout = 1) { // a is not given.
return ans;
} else {
return a;
}
}
|
.cgeru(x, y, [a, alpha: 1, order:'R']) ⇒ Numo::SComplex
CGERU performs the rank 1 operation
A := alpha*x*y**T + A,
where alpha is a scalar, x is an m element vector, y is an n element vector and A is an m by n matrix.
1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 |
# File 'ext/numo/linalg/blas/blas_c.c', line 1378
static VALUE
blas_s_cgeru(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE ans;
VALUE x, y, a=Qnil, alpha;
narray_t *na1, *na2;
blasint mx, ny, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[4] = {{cT,1},{cT,1},{OVERWRITE,2},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_cgeru, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
ID kw_table[2] = {id_alpha,id_order};
VALUE opts[2] = {Qundef};
CHECK_FUNC(func_p,"cgeru");
rb_scan_args(argc, argv, "21:", &x, &y, &a, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 2, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
g.order = option_order(opts[1]);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
mx = COL_SIZE(na1); // m
ny = COL_SIZE(na2); // n
g.m = mx;
g.n = ny;
SWAP_IFCOL(g.order, mx,ny, tmp);
if (a == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
a = INT2FIX(0);
shape[0] = mx;
shape[1] = ny;
} else {
narray_t *na3;
blasint ma, na;
COPY_OR_CAST_TO(a,cT);
GetNArray(a,na3);
CHECK_DIM_GE(na3,2);
ma = ROW_SIZE(na3); // m
na = COL_SIZE(na3); // n (lda)
CHECK_SIZE_EQ(ma,mx);
CHECK_SIZE_EQ(na,ny);
}
ans = na_ndloop3(&ndf, &g, 3, x, y, a);
if (ndf.nout = 1) { // a is not given.
return ans;
} else {
return a;
}
}
|
.chemm(a, b, [c, alpha: 1, beta:0, side:'L', uplo:'U', order:'R']) ⇒ Numo::SComplex
CHEMM performs one of the matrix-matrix operations
C := alpha*A*B + beta*C,
or
C := alpha*B*A + beta*C,
where alpha and beta are scalars, A is an hermitian matrix and B and C are m by n matrices.
2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 |
# File 'ext/numo/linalg/blas/blas_c.c', line 2500
static VALUE
blas_s_chemm(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, b, c=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, ka, kb, nb, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[3] = {{cT,2},{cT,2},{OVERWRITE,2}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_chemm, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[5] = {id_alpha,id_beta,id_order,id_transa,id_transb};
#elif TR
ID kw_table[7] = {id_alpha,id_beta,id_order,id_side,id_uplo,id_transa,id_diag};
#else
ID kw_table[5] = {id_alpha,id_beta,id_order,id_side,id_uplo};
#endif
VALUE opts[7] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"chemm");
rb_scan_args(argc, argv, "21:", &a, &b, &c, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 5+TR*2, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.transa = option_trans(opts[3]);
g.transb = option_trans(opts[4]);
#else
g.side = option_side(opts[3]);
g.uplo = option_uplo(opts[4]);
#endif
#if TR
g.transa = option_trans(opts[5]);
g.diag = option_diag(opts[6]);
#endif
GetNArray(a,na1);
GetNArray(b,na2);
CHECK_DIM_GE(na1,2);
CHECK_DIM_GE(na2,2);
ma = ROW_SIZE(na1); // m
ka = COL_SIZE(na1); // k (lda)
kb = ROW_SIZE(na2); // k
nb = COL_SIZE(na2); // n (ldb)
#if GE
SWAP_IFCOLTR(g.order,g.transa, ma,ka, tmp);
SWAP_IFCOLTR(g.order,g.transb, kb,nb, tmp);
CHECK_INT_EQ("ka",ka,"kb",kb);
g.m = ma;
g.n = nb;
g.k = ka;
#else
CHECK_SQUARE("a",na1); // ma == ka
SWAP_IFCOL(g.order, kb,nb, tmp);
// row major L R
//ma = ROW_SIZE(na1); // m or n
//ka = COL_SIZE(na1); // m or n (lda)
g.m = kb; // m
g.n = nb; // n (ldb)
if (g.side == CblasLeft) {
CHECK_SIZE_EQ(ka, g.m);
} else {
CHECK_SIZE_EQ(ka, g.n);
}
#endif
SWAP_IFROW(g.order, ma,nb, tmp);
#if TR
if (c != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(b,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, b);
return b;
#else
if (c == Qnil) { // c is not given.
ndfunc_arg_in_t ain_init = {sym_init,0};
ain[2] = ain_init;
ndf.nout = 1;
c = INT2FIX(0);
shape[0] = nb;
shape[1] = ma;
} else {
narray_t *na3;
int nc;
COPY_OR_CAST_TO(c,cT);
GetNArray(c,na3);
CHECK_DIM_GE(na3,2);
nc = ROW_SIZE(na3);
if (nc < nb) {
rb_raise(nary_eShapeError,"nc=%d must be >= nb=%d",nc,nb);
}
//CHECK_LEADING_GE("ldc",g.ldc,"m",ma);
}
{
VALUE ans = na_ndloop3(&ndf, &g, 3, a, b, c);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return c;
}
}
#endif
}
|
.chemv(a, x, [y, alpha: 1, beta:0, uplo:'U', order:'R']) ⇒ Numo::SComplex
CHEMV performs the matrix-vector operation
y := alpha*A*x + beta*y,
where alpha and beta are scalars, x and y are n element vectors and A is an n by n hermitian matrix.
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 |
# File 'ext/numo/linalg/blas/blas_c.c', line 1102
static VALUE
blas_s_chemv(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, x, y=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, na, nx;
#if GE
blasint tmp;
#endif
size_t shape[1];
ndfunc_arg_in_t ain[4] = {{cT,2},{cT,1},{OVERWRITE,1},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,1,shape}};
ndfunc_t ndf = {iter_blas_s_chemv, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[4] = {id_alpha,id_beta,id_order,id_trans};
#elif TR
ID kw_table[6] = {id_alpha,id_beta,id_order,id_uplo,id_trans,id_diag};
#else
ID kw_table[4] = {id_alpha,id_beta,id_order,id_uplo};
#endif
VALUE opts[6] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"chemv");
rb_scan_args(argc, argv, "21:", &a, &x, &y, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 4+2*TR, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.trans = option_trans(opts[3]);
#else
g.uplo = option_uplo(opts[3]);
#endif
#if TR
g.trans = option_trans(opts[4]);
g.diag = option_diag(opts[5]);
#endif
GetNArray(a,na1);
CHECK_DIM_GE(na1,2);
ma = ROW_SIZE(na1);
na = COL_SIZE(na1);
GetNArray(x,na2);
CHECK_DIM_GE(na2,1);
nx = COL_SIZE(na2);
#if GE
SWAP_IFCOL(g.order, ma, na, tmp);
g.m = ma;
g.n = na;
SWAP_IFTRANS(g.trans, ma, na, tmp);
#else
CHECK_SQUARE("a",na1);
#endif
CHECK_INT_EQ("na",na,"nx",nx);
shape[0] = ma;
#if TR
if (y != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(x,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, x);
return x;
#else // GE,SY,HE
if (y == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
y = INT2FIX(0);
shape[0] = ma;
} else {
narray_t *na3;
COPY_OR_CAST_TO(y,cT);
GetNArray(y,na3);
CHECK_DIM_GE(na3,1);
CHECK_SIZE_GE(na3,nx);
}
{
VALUE ans;
ans = na_ndloop3(&ndf, &g, 3, a, x, y);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return y;
}
}
#endif
}
|
.cher(x, [a, alpha: 1, uplo:'U', order:'R']) ⇒ Numo::SComplex
CHER performs the hermitian rank 1 operation
A := alpha*x*x**H + A,
where alpha is a real scalar, x is an n element vector and A is an n by n hermitian matrix.
1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 |
# File 'ext/numo/linalg/blas/blas_c.c', line 1494
static VALUE
blas_s_cher(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE ans;
VALUE x, a, alpha;
narray_t *na1, *na3;
blasint nx, na;
size_t shape[2];
ndfunc_arg_in_t ain[3] = {{cT,1},{OVERWRITE,2},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_cher, NO_LOOP, 2, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
ID kw_table[3] = {id_alpha,id_order,id_uplo};
VALUE opts[3] = {Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"cher");
rb_scan_args(argc, argv, "11:", &x, &a, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 3, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? NUM2DBL(alpha) : 1;
g.order = option_order(opts[1]);
g.uplo = option_uplo(opts[2]);
GetNArray(x,na1);
CHECK_DIM_GE(na1,1);
nx = COL_SIZE(na1); // n
if (a == Qnil) { // c is not given.
ndf.nout = 1;
ain[1] = ain[2];
a = INT2FIX(0);
shape[0] = shape[1] = nx;
} else {
COPY_OR_CAST_TO(a,cT);
GetNArray(a,na3);
CHECK_DIM_GE(na3,2);
CHECK_SQUARE("a",na3);
na = COL_SIZE(na3); // n (lda)
CHECK_SIZE_EQ(na,nx);
}
ans = na_ndloop3(&ndf, &g, 2, x, a);
if (ndf.nout == 1) { // a is not given.
return ans;
} else {
return a;
}
}
|
.cher2(x, y, [a, alpha: 1, uplo:'U', order:'R']) ⇒ Numo::SComplex
CHER2 performs the hermitian rank 2 operation
A := alpha*x*y**H + conjg( alpha )*y*x**H + A,
where alpha is a scalar, x and y are n element vectors and A is an n by n hermitian matrix.
1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 |
# File 'ext/numo/linalg/blas/blas_c.c', line 1604
static VALUE
blas_s_cher2(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE ans;
VALUE x, y, a, alpha;
narray_t *na1, *na2, *na3;
blasint nx, ny, na;
size_t shape[2];
ndfunc_arg_in_t ain[4] = {{cT,1},{cT,1},{OVERWRITE,2},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_cher2, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
ID kw_table[3] = {id_alpha,id_order,id_uplo};
VALUE opts[3] = {Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"cher2");
rb_scan_args(argc, argv, "21:", &x, &y, &a, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 3, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
g.order = option_order(opts[1]);
g.uplo = option_uplo(opts[2]);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
nx = COL_SIZE(na1); // n
ny = COL_SIZE(na2); // n
CHECK_INT_EQ("nx",nx,"ny",ny);
if (a == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
a = INT2FIX(0);
shape[0] = shape[1] = nx;
} else {
COPY_OR_CAST_TO(a,cT);
GetNArray(a,na3);
CHECK_DIM_GE(na3,2);
CHECK_SQUARE("a",na3);
na = COL_SIZE(na3); // n (lda)
CHECK_SIZE_EQ(na,nx);
}
ans = na_ndloop3(&ndf, &g, 3, x, y, a);
if (ndf.nout == 1) { // a is not given.
return ans;
} else {
return a;
}
}
|
.cherk(a, [c, alpha: 1, beta:0, uplo:'U', trans:'N', order:'R']) ⇒ Numo::SComplex
CHERK performs one of the hermitian rank k operations
C := alpha*A*A**H + beta*C,
or
C := alpha*A**H*A + beta*C,
where alpha and beta are real scalars, C is an n by n hermitian matrix and A is an n by k matrix in the first case and a k by n matrix in the second case.
1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 |
# File 'ext/numo/linalg/blas/blas_c.c', line 1727
static VALUE
blas_s_cherk(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE ans;
VALUE a, c, alpha, beta;
narray_t *na1, *na3;
blasint na, ka, nc, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[3] = {{cT,2},{OVERWRITE,2},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_cherk, NO_LOOP, 2, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
ID kw_table[5] = {id_alpha,id_beta,id_order,id_uplo,id_trans};
VALUE opts[5] = {Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"cherk");
rb_scan_args(argc, argv, "11:", &a, &c, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 5, opts);
alpha = option_value(opts[0],Qnil);
beta = option_value(opts[1],Qnil);
#line 85 "gen/../tmpl/syrk.c"
g.alpha = RTEST(alpha) ? DBL2NUM(alpha) : 1;
g.beta = RTEST(beta) ? DBL2NUM(beta) : 0;
#line 91 "gen/../tmpl/syrk.c"
g.order = option_order(opts[2]);
g.uplo = option_uplo(opts[3]);
g.trans = option_trans(opts[4]);
GetNArray(a,na1);
CHECK_DIM_GE(na1,2);
na = ROW_SIZE(na1); // n
ka = COL_SIZE(na1); // k (lda)
SWAP_IFCOLTR(g.order,g.trans, na,ka, tmp);
g.n = na;
g.k = ka;
if (c == Qnil) { // c is not given.
ndf.nout = 1;
ain[1] = ain[2];
c = INT2FIX(0);
shape[0] = na;
shape[1] = na;
} else {
COPY_OR_CAST_TO(c,cT);
GetNArray(c,na3);
CHECK_DIM_GE(na3,2);
nc = ROW_SIZE(na3);
if (nc < na) {
rb_raise(nary_eShapeError,"nc=%d must be >= na=%d",nc,na);
}
//CHECK_LEADING_GE("ldc",g.ldc,"n",na);
}
ans = na_ndloop3(&ndf, &g, 2, a, c);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return c;
}
}
|
.cscal(a, x) ⇒ Numo::SComplex
CSCAL scales a vector by a constant.
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 |
# File 'ext/numo/linalg/blas/blas_c.c', line 554
static VALUE
blas_s_cscal(VALUE mod, VALUE a, VALUE x)
{
scal_t g[1];
narray_t *na1;
ndfunc_arg_in_t ain[1] = {{OVERWRITE,0}};
ndfunc_t ndf = {iter_blas_s_cscal, STRIDE_LOOP, 1,0, ain,0};
CHECK_FUNC(func_p,"cscal");
#line 56 "gen/../tmpl/scal.c"
if (RTEST(a)) {g[0] = m_num_to_data(a);} else {g[0]=m_one;}
COPY_OR_CAST_TO(x,cT);
GetNArray(x,na1);
CHECK_DIM_GE(na1,1);
CHECK_NON_EMPTY(na1);
na_ndloop3(&ndf, g, 1, x);
return x;
}
|
.csscal(a, x) ⇒ Numo::SComplex
CSSCAL scales a complex vector by a real constant.
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 |
# File 'ext/numo/linalg/blas/blas_c.c', line 618
static VALUE
blas_s_csscal(VALUE mod, VALUE a, VALUE x)
{
scal_t g[1];
narray_t *na1;
ndfunc_arg_in_t ain[1] = {{OVERWRITE,0}};
ndfunc_t ndf = {iter_blas_s_csscal, STRIDE_LOOP, 1,0, ain,0};
CHECK_FUNC(func_p,"csscal");
if (RTEST(a)) {g[0] = NUM2DBL(a);} else {g[0]=1;}
#line 58 "gen/../tmpl/scal.c"
COPY_OR_CAST_TO(x,cT);
GetNArray(x,na1);
CHECK_DIM_GE(na1,1);
CHECK_NON_EMPTY(na1);
na_ndloop3(&ndf, g, 1, x);
return x;
}
|
.cswap(x, y) ⇒ nil
CSWAP interchanges two vectors.
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
# File 'ext/numo/linalg/blas/blas_c.c', line 361
static VALUE
blas_s_cswap(VALUE UNUSED(mod), VALUE x, VALUE y)
{
narray_t *na1, *na2;
ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{OVERWRITE,0}};
ndfunc_t ndf = {iter_blas_s_cswap, STRIDE_LOOP, 2,0, ain,0};
CHECK_FUNC(func_p,"cswap");
CHECK_NARRAY_TYPE(x,cT);
CHECK_NARRAY_TYPE(y,cT);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
CHECK_NON_EMPTY(na1);
CHECK_NON_EMPTY(na2);
CHECK_SAME_SHAPE(na1,na2);
na_ndloop(&ndf, 2, x, y);
return Qnil;
}
|
.csymm(a, b, [c, alpha: 1, beta:0, side:'L', uplo:'U', order:'R']) ⇒ Numo::SComplex
CSYMM performs one of the matrix-matrix operations
C := alpha*A*B + beta*C,
or
C := alpha*B*A + beta*C,
where alpha and beta are scalars, A is a symmetric matrix and B and C are m by n matrices.
2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 |
# File 'ext/numo/linalg/blas/blas_c.c', line 2088
static VALUE
blas_s_csymm(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, b, c=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, ka, kb, nb, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[3] = {{cT,2},{cT,2},{OVERWRITE,2}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_csymm, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[5] = {id_alpha,id_beta,id_order,id_transa,id_transb};
#elif TR
ID kw_table[7] = {id_alpha,id_beta,id_order,id_side,id_uplo,id_transa,id_diag};
#else
ID kw_table[5] = {id_alpha,id_beta,id_order,id_side,id_uplo};
#endif
VALUE opts[7] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"csymm");
rb_scan_args(argc, argv, "21:", &a, &b, &c, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 5+TR*2, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.transa = option_trans(opts[3]);
g.transb = option_trans(opts[4]);
#else
g.side = option_side(opts[3]);
g.uplo = option_uplo(opts[4]);
#endif
#if TR
g.transa = option_trans(opts[5]);
g.diag = option_diag(opts[6]);
#endif
GetNArray(a,na1);
GetNArray(b,na2);
CHECK_DIM_GE(na1,2);
CHECK_DIM_GE(na2,2);
ma = ROW_SIZE(na1); // m
ka = COL_SIZE(na1); // k (lda)
kb = ROW_SIZE(na2); // k
nb = COL_SIZE(na2); // n (ldb)
#if GE
SWAP_IFCOLTR(g.order,g.transa, ma,ka, tmp);
SWAP_IFCOLTR(g.order,g.transb, kb,nb, tmp);
CHECK_INT_EQ("ka",ka,"kb",kb);
g.m = ma;
g.n = nb;
g.k = ka;
#else
CHECK_SQUARE("a",na1); // ma == ka
SWAP_IFCOL(g.order, kb,nb, tmp);
// row major L R
//ma = ROW_SIZE(na1); // m or n
//ka = COL_SIZE(na1); // m or n (lda)
g.m = kb; // m
g.n = nb; // n (ldb)
if (g.side == CblasLeft) {
CHECK_SIZE_EQ(ka, g.m);
} else {
CHECK_SIZE_EQ(ka, g.n);
}
#endif
SWAP_IFROW(g.order, ma,nb, tmp);
#if TR
if (c != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(b,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, b);
return b;
#else
if (c == Qnil) { // c is not given.
ndfunc_arg_in_t ain_init = {sym_init,0};
ain[2] = ain_init;
ndf.nout = 1;
c = INT2FIX(0);
shape[0] = nb;
shape[1] = ma;
} else {
narray_t *na3;
int nc;
COPY_OR_CAST_TO(c,cT);
GetNArray(c,na3);
CHECK_DIM_GE(na3,2);
nc = ROW_SIZE(na3);
if (nc < nb) {
rb_raise(nary_eShapeError,"nc=%d must be >= nb=%d",nc,nb);
}
//CHECK_LEADING_GE("ldc",g.ldc,"m",ma);
}
{
VALUE ans = na_ndloop3(&ndf, &g, 3, a, b, c);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return c;
}
}
#endif
}
|
.csyr2k(a, b, [c, alpha: 1, beta:0, uplo:'U', trans:'N', order:'R']) ⇒ Numo::SComplex
CSYR2K performs one of the symmetric rank 2k operations
C := alpha*A*B**T + alpha*B*A**T + beta*C,
or
C := alpha*A**T*B + alpha*B**T*A + beta*C,
where alpha and beta are scalars, C is an n by n symmetric matrix and A and B are n by k matrices in the first case and k by n matrices in the second case.
2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 |
# File 'ext/numo/linalg/blas/blas_c.c', line 2817
static VALUE
blas_s_csyr2k(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE ans;
VALUE a, b, c=Qnil, alpha, beta;
narray_t *na1, *na2, *na3;
blasint na, ka, kb, nb, nc, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[4] = {{cT,2},{cT,2},{OVERWRITE,2},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_csyr2k, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
ID kw_table[5] = {id_alpha,id_beta,id_order,id_uplo,id_trans};
VALUE opts[5] = {Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"csyr2k");
rb_scan_args(argc, argv, "21:", &a, &b, &c, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 5, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
g.uplo = option_uplo(opts[3]);
g.trans = option_trans(opts[4]);
GetNArray(a,na1);
GetNArray(b,na2);
CHECK_DIM_GE(na1,2);
CHECK_DIM_GE(na2,2);
na = ROW_SIZE(na1); // n
ka = COL_SIZE(na1); // k (lda)
SWAP_IFCOLTR(g.order, g.trans, na, ka, tmp);
nb = ROW_SIZE(na2); // n
kb = COL_SIZE(na2); // k (ldb)
SWAP_IFCOLTR(g.order, g.trans, kb, nb, tmp);
CHECK_INT_EQ("na",na,"nb",nb);
CHECK_INT_EQ("ka",ka,"kb",kb);
g.n = nb;
g.k = kb;
SWAP_IFROW(g.order, na, nb, tmp);
if (c == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
c = INT2FIX(0);
shape[0] = nb;
shape[1] = na;
} else {
COPY_OR_CAST_TO(c,cT);
GetNArray(c,na3);
CHECK_DIM_GE(na3,2);
nc = ROW_SIZE(na3); // n
if (nc < nb) {
rb_raise(nary_eShapeError,"nc=%d must be >= nb=%d",nc,nb);
}
//CHECK_LEADING_GE("ldc",g.ldc,"n",na);
}
ans = na_ndloop3(&ndf, &g, 3, a, b, c);
if (ndf.nout = 1) { // c is not given.
return ans;
} else {
return c;
}
}
|
.csyrk(a, [c, alpha: 1, beta:0, uplo:'U', trans:'N', order:'R']) ⇒ Numo::SComplex
CSYRK performs one of the symmetric rank k operations
C := alpha*A*A**T + beta*C,
or
C := alpha*A**T*A + beta*C,
where alpha and beta are scalars, C is an n by n symmetric matrix and A is an n by k matrix in the first case and a k by n matrix in the second case.
2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 |
# File 'ext/numo/linalg/blas/blas_c.c', line 2686
static VALUE
blas_s_csyrk(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE ans;
VALUE a, c, alpha, beta;
narray_t *na1, *na3;
blasint na, ka, nc, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[3] = {{cT,2},{OVERWRITE,2},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_csyrk, NO_LOOP, 2, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
ID kw_table[5] = {id_alpha,id_beta,id_order,id_uplo,id_trans};
VALUE opts[5] = {Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"csyrk");
rb_scan_args(argc, argv, "11:", &a, &c, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 5, opts);
alpha = option_value(opts[0],Qnil);
beta = option_value(opts[1],Qnil);
#line 88 "gen/../tmpl/syrk.c"
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
#line 91 "gen/../tmpl/syrk.c"
g.order = option_order(opts[2]);
g.uplo = option_uplo(opts[3]);
g.trans = option_trans(opts[4]);
GetNArray(a,na1);
CHECK_DIM_GE(na1,2);
na = ROW_SIZE(na1); // n
ka = COL_SIZE(na1); // k (lda)
SWAP_IFCOLTR(g.order,g.trans, na,ka, tmp);
g.n = na;
g.k = ka;
if (c == Qnil) { // c is not given.
ndf.nout = 1;
ain[1] = ain[2];
c = INT2FIX(0);
shape[0] = na;
shape[1] = na;
} else {
COPY_OR_CAST_TO(c,cT);
GetNArray(c,na3);
CHECK_DIM_GE(na3,2);
nc = ROW_SIZE(na3);
if (nc < na) {
rb_raise(nary_eShapeError,"nc=%d must be >= na=%d",nc,na);
}
//CHECK_LEADING_GE("ldc",g.ldc,"n",na);
}
ans = na_ndloop3(&ndf, &g, 2, a, c);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return c;
}
}
|
.ctrmm(a, b, [alpha: 1, side:'L', uplo:'U', transa:'N', diag:'U', order:'R']) ⇒ Numo::SComplex
CTRMM performs one of the matrix-matrix operations
B := alpha*op( A )*B, or B := alpha*B*op( A )
where alpha is a scalar, B is an m by n matrix, A is a unit, or non-unit, upper or lower triangular matrix and op( A ) is one of
op( A ) = A or op( A ) = A**T or op( A ) = A**H.
2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 |
# File 'ext/numo/linalg/blas/blas_c.c', line 2293
static VALUE
blas_s_ctrmm(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, b, c=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, ka, kb, nb, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[3] = {{cT,2},{cT,2},{OVERWRITE,2}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_ctrmm, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[5] = {id_alpha,id_beta,id_order,id_transa,id_transb};
#elif TR
ID kw_table[7] = {id_alpha,id_beta,id_order,id_side,id_uplo,id_transa,id_diag};
#else
ID kw_table[5] = {id_alpha,id_beta,id_order,id_side,id_uplo};
#endif
VALUE opts[7] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"ctrmm");
rb_scan_args(argc, argv, "21:", &a, &b, &c, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 5+TR*2, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.transa = option_trans(opts[3]);
g.transb = option_trans(opts[4]);
#else
g.side = option_side(opts[3]);
g.uplo = option_uplo(opts[4]);
#endif
#if TR
g.transa = option_trans(opts[5]);
g.diag = option_diag(opts[6]);
#endif
GetNArray(a,na1);
GetNArray(b,na2);
CHECK_DIM_GE(na1,2);
CHECK_DIM_GE(na2,2);
ma = ROW_SIZE(na1); // m
ka = COL_SIZE(na1); // k (lda)
kb = ROW_SIZE(na2); // k
nb = COL_SIZE(na2); // n (ldb)
#if GE
SWAP_IFCOLTR(g.order,g.transa, ma,ka, tmp);
SWAP_IFCOLTR(g.order,g.transb, kb,nb, tmp);
CHECK_INT_EQ("ka",ka,"kb",kb);
g.m = ma;
g.n = nb;
g.k = ka;
#else
CHECK_SQUARE("a",na1); // ma == ka
SWAP_IFCOL(g.order, kb,nb, tmp);
// row major L R
//ma = ROW_SIZE(na1); // m or n
//ka = COL_SIZE(na1); // m or n (lda)
g.m = kb; // m
g.n = nb; // n (ldb)
if (g.side == CblasLeft) {
CHECK_SIZE_EQ(ka, g.m);
} else {
CHECK_SIZE_EQ(ka, g.n);
}
#endif
SWAP_IFROW(g.order, ma,nb, tmp);
#if TR
if (c != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(b,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, b);
return b;
#else
if (c == Qnil) { // c is not given.
ndfunc_arg_in_t ain_init = {sym_init,0};
ain[2] = ain_init;
ndf.nout = 1;
c = INT2FIX(0);
shape[0] = nb;
shape[1] = ma;
} else {
narray_t *na3;
int nc;
COPY_OR_CAST_TO(c,cT);
GetNArray(c,na3);
CHECK_DIM_GE(na3,2);
nc = ROW_SIZE(na3);
if (nc < nb) {
rb_raise(nary_eShapeError,"nc=%d must be >= nb=%d",nc,nb);
}
//CHECK_LEADING_GE("ldc",g.ldc,"m",ma);
}
{
VALUE ans = na_ndloop3(&ndf, &g, 3, a, b, c);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return c;
}
}
#endif
}
|
.ctrmv(a, x, [uplo: 'U', trans:'N', diag:'U', order:'R']) ⇒ Numo::SComplex
CTRMV performs one of the matrix-vector operations
x := A*x, or x := A**T*x, or x := A**H*x,
where x is an n element vector and A is an n by n unit, or non-unit, upper or lower triangular matrix.
915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 |
# File 'ext/numo/linalg/blas/blas_c.c', line 915
static VALUE
blas_s_ctrmv(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, x, y=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, na, nx;
#if GE
blasint tmp;
#endif
size_t shape[1];
ndfunc_arg_in_t ain[4] = {{cT,2},{cT,1},{OVERWRITE,1},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,1,shape}};
ndfunc_t ndf = {iter_blas_s_ctrmv, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[4] = {id_alpha,id_beta,id_order,id_trans};
#elif TR
ID kw_table[6] = {id_alpha,id_beta,id_order,id_uplo,id_trans,id_diag};
#else
ID kw_table[4] = {id_alpha,id_beta,id_order,id_uplo};
#endif
VALUE opts[6] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"ctrmv");
rb_scan_args(argc, argv, "21:", &a, &x, &y, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 4+2*TR, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.trans = option_trans(opts[3]);
#else
g.uplo = option_uplo(opts[3]);
#endif
#if TR
g.trans = option_trans(opts[4]);
g.diag = option_diag(opts[5]);
#endif
GetNArray(a,na1);
CHECK_DIM_GE(na1,2);
ma = ROW_SIZE(na1);
na = COL_SIZE(na1);
GetNArray(x,na2);
CHECK_DIM_GE(na2,1);
nx = COL_SIZE(na2);
#if GE
SWAP_IFCOL(g.order, ma, na, tmp);
g.m = ma;
g.n = na;
SWAP_IFTRANS(g.trans, ma, na, tmp);
#else
CHECK_SQUARE("a",na1);
#endif
CHECK_INT_EQ("na",na,"nx",nx);
shape[0] = ma;
#if TR
if (y != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(x,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, x);
return x;
#else // GE,SY,HE
if (y == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
y = INT2FIX(0);
shape[0] = ma;
} else {
narray_t *na3;
COPY_OR_CAST_TO(y,cT);
GetNArray(y,na3);
CHECK_DIM_GE(na3,1);
CHECK_SIZE_GE(na3,nx);
}
{
VALUE ans;
ans = na_ndloop3(&ndf, &g, 3, a, x, y);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return y;
}
}
#endif
}
|
.dasum(x) ⇒ Numo::DFloat
DASUM takes the sum of the absolute values.
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# File 'ext/numo/linalg/blas/blas_d.c', line 226
static VALUE
blas_s_dasum(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE x, keepdims, ans;
narray_t *na1;
ndfunc_arg_in_t ain[1] = {{cT,1}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_blas_s_dasum, NDF_EXTRACT, 1,1, ain,aout};
VALUE opts[1] = {Qundef};
ID kw_table[1] = {id_keepdims};
VALUE kw_hash = Qnil;
CHECK_FUNC(func_p,"dasum");
rb_scan_args(argc, argv, "1:", &x, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 1, opts);
keepdims = option_value(opts[0],Qfalse);
if (RTEST(keepdims)) {
ndf.flag |= NDF_KEEP_DIM;
}
GetNArray(x,na1);
CHECK_DIM_GE(na1,1);
CHECK_NON_EMPTY(na1);
ans = na_ndloop(&ndf, 1, x);
return ans;
}
|
.daxpy(x, y, [alpha: 1]) ⇒ Numo::DFloat
DAXPY constant times a vector plus a vector. uses unrolled loops for increments equal to one.
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 |
# File 'ext/numo/linalg/blas/blas_d.c', line 413
static VALUE
blas_s_daxpy(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE x, y, alpha;
narray_t *na1, *na2;
ndfunc_arg_in_t ain[2] = {{cT,0},{OVERWRITE,0}};
ndfunc_t ndf = {iter_blas_s_daxpy, STRIDE_LOOP, 2, 0, ain, 0};
dtype g;
VALUE kw_hash = Qnil;
ID kw_table[1] = {id_alpha};
VALUE opts[1] = {Qundef};
CHECK_FUNC(func_p,"daxpy");
rb_scan_args(argc, argv, "2:", &x, &y, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 1, opts);
alpha = option_value(opts[0],Qnil);
g = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
COPY_OR_CAST_TO(y,cT);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
CHECK_NON_EMPTY(na1);
CHECK_NON_EMPTY(na2);
CHECK_SAME_SHAPE(na1,na2);
na_ndloop3(&ndf, &g, 2, x, y);
return y;
}
|
.dcopy(x, y) ⇒ nil
DCOPY copies a vector, x, to a vector, y. uses unrolled loops for increments equal to one.
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
# File 'ext/numo/linalg/blas/blas_d.c', line 348
static VALUE
blas_s_dcopy(VALUE UNUSED(mod), VALUE x, VALUE y)
{
narray_t *na1, *na2;
ndfunc_arg_in_t ain[2] = {{cT,0},{OVERWRITE,0}};
ndfunc_t ndf = {iter_blas_s_dcopy, STRIDE_LOOP, 2,0, ain,0};
CHECK_FUNC(func_p,"dcopy");
CHECK_NARRAY_TYPE(x,cT);
CHECK_NARRAY_TYPE(y,cT);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
CHECK_NON_EMPTY(na1);
CHECK_NON_EMPTY(na2);
CHECK_SAME_SHAPE(na1,na2);
na_ndloop(&ndf, 2, x, y);
return Qnil;
}
|
.ddot(x, y) ⇒ Numo::DFloat
DDOT forms the dot product of two vectors. uses unrolled loops for increments equal to one.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'ext/numo/linalg/blas/blas_d.c', line 95
static VALUE
blas_s_ddot(VALUE mod, VALUE x, VALUE y)
{
VALUE ans;
narray_t *na1, *na2;
size_t nx, ny, shape[1]={1};
ndfunc_arg_in_t ain[2] = {{cT,1},{cT,1}};
ndfunc_arg_out_t aout[1] = {{numo_cDFloat,0,shape}};
ndfunc_t ndf = {iter_blas_s_ddot, NDF_EXTRACT, 2,1, ain,aout};
CHECK_FUNC(func_p,"ddot");
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
CHECK_NON_EMPTY(na1);
CHECK_NON_EMPTY(na2);
nx = COL_SIZE(na1);
ny = COL_SIZE(na2);
CHECK_SIZE_EQ(nx,ny);
ans = na_ndloop(&ndf, 2, x, y);
return ans;
}
|
.dgemm(a, b, [c, alpha: 1, beta:0, transa:'N', transb:'N', order:'R']) ⇒ Numo::DFloat
DGEMM performs one of the matrix-matrix operations
C := alpha*op( A )*op( B ) + beta*C,
where op( X ) is one of
op( X ) = X or op( X ) = X**T,
alpha and beta are scalars, and A, B and C are matrices, with op( A ) an m by k matrix, op( B ) a k by n matrix and C an m by n matrix.
1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 |
# File 'ext/numo/linalg/blas/blas_d.c', line 1642
static VALUE
blas_s_dgemm(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, b, c=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, ka, kb, nb, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[3] = {{cT,2},{cT,2},{OVERWRITE,2}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_dgemm, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[5] = {id_alpha,id_beta,id_order,id_transa,id_transb};
#elif TR
ID kw_table[7] = {id_alpha,id_beta,id_order,id_side,id_uplo,id_transa,id_diag};
#else
ID kw_table[5] = {id_alpha,id_beta,id_order,id_side,id_uplo};
#endif
VALUE opts[7] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"dgemm");
rb_scan_args(argc, argv, "21:", &a, &b, &c, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 5+TR*2, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.transa = option_trans(opts[3]);
g.transb = option_trans(opts[4]);
#else
g.side = option_side(opts[3]);
g.uplo = option_uplo(opts[4]);
#endif
#if TR
g.transa = option_trans(opts[5]);
g.diag = option_diag(opts[6]);
#endif
GetNArray(a,na1);
GetNArray(b,na2);
CHECK_DIM_GE(na1,2);
CHECK_DIM_GE(na2,2);
ma = ROW_SIZE(na1); // m
ka = COL_SIZE(na1); // k (lda)
kb = ROW_SIZE(na2); // k
nb = COL_SIZE(na2); // n (ldb)
#if GE
SWAP_IFCOLTR(g.order,g.transa, ma,ka, tmp);
SWAP_IFCOLTR(g.order,g.transb, kb,nb, tmp);
CHECK_INT_EQ("ka",ka,"kb",kb);
g.m = ma;
g.n = nb;
g.k = ka;
#else
CHECK_SQUARE("a",na1); // ma == ka
SWAP_IFCOL(g.order, kb,nb, tmp);
// row major L R
//ma = ROW_SIZE(na1); // m or n
//ka = COL_SIZE(na1); // m or n (lda)
g.m = kb; // m
g.n = nb; // n (ldb)
if (g.side == CblasLeft) {
CHECK_SIZE_EQ(ka, g.m);
} else {
CHECK_SIZE_EQ(ka, g.n);
}
#endif
SWAP_IFROW(g.order, ma,nb, tmp);
#if TR
if (c != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(b,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, b);
return b;
#else
if (c == Qnil) { // c is not given.
ndfunc_arg_in_t ain_init = {sym_init,0};
ain[2] = ain_init;
ndf.nout = 1;
c = INT2FIX(0);
shape[0] = nb;
shape[1] = ma;
} else {
narray_t *na3;
int nc;
COPY_OR_CAST_TO(c,cT);
GetNArray(c,na3);
CHECK_DIM_GE(na3,2);
nc = ROW_SIZE(na3);
if (nc < nb) {
rb_raise(nary_eShapeError,"nc=%d must be >= nb=%d",nc,nb);
}
//CHECK_LEADING_GE("ldc",g.ldc,"m",ma);
}
{
VALUE ans = na_ndloop3(&ndf, &g, 3, a, b, c);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return c;
}
}
#endif
}
|
.dgemv(a, x, [y, alpha: 1, beta:0, trans:'N', order:'R']) ⇒ Numo::DFloat
DGEMV performs one of the matrix-vector operations
y := alpha*A*x + beta*y, or y := alpha*A**T*x + beta*y,
where alpha and beta are scalars, x and y are vectors and A is an m by n matrix.
741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 |
# File 'ext/numo/linalg/blas/blas_d.c', line 741
static VALUE
blas_s_dgemv(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, x, y=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, na, nx;
#if GE
blasint tmp;
#endif
size_t shape[1];
ndfunc_arg_in_t ain[4] = {{cT,2},{cT,1},{OVERWRITE,1},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,1,shape}};
ndfunc_t ndf = {iter_blas_s_dgemv, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[4] = {id_alpha,id_beta,id_order,id_trans};
#elif TR
ID kw_table[6] = {id_alpha,id_beta,id_order,id_uplo,id_trans,id_diag};
#else
ID kw_table[4] = {id_alpha,id_beta,id_order,id_uplo};
#endif
VALUE opts[6] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"dgemv");
rb_scan_args(argc, argv, "21:", &a, &x, &y, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 4+2*TR, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.trans = option_trans(opts[3]);
#else
g.uplo = option_uplo(opts[3]);
#endif
#if TR
g.trans = option_trans(opts[4]);
g.diag = option_diag(opts[5]);
#endif
GetNArray(a,na1);
CHECK_DIM_GE(na1,2);
ma = ROW_SIZE(na1);
na = COL_SIZE(na1);
GetNArray(x,na2);
CHECK_DIM_GE(na2,1);
nx = COL_SIZE(na2);
#if GE
SWAP_IFCOL(g.order, ma, na, tmp);
g.m = ma;
g.n = na;
SWAP_IFTRANS(g.trans, ma, na, tmp);
#else
CHECK_SQUARE("a",na1);
#endif
CHECK_INT_EQ("na",na,"nx",nx);
shape[0] = ma;
#if TR
if (y != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(x,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, x);
return x;
#else // GE,SY,HE
if (y == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
y = INT2FIX(0);
shape[0] = ma;
} else {
narray_t *na3;
COPY_OR_CAST_TO(y,cT);
GetNArray(y,na3);
CHECK_DIM_GE(na3,1);
CHECK_SIZE_GE(na3,nx);
}
{
VALUE ans;
ans = na_ndloop3(&ndf, &g, 3, a, x, y);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return y;
}
}
#endif
}
|
.dger(x, y, [a, alpha: 1, order:'R']) ⇒ Numo::DFloat
DGER performs the rank 1 operation
A := alpha*x*y**T + A,
where alpha is a scalar, x is an m element vector, y is an n element vector and A is an m by n matrix.
1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 |
# File 'ext/numo/linalg/blas/blas_d.c', line 1378
static VALUE
blas_s_dger(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE ans;
VALUE x, y, a=Qnil, alpha;
narray_t *na1, *na2;
blasint mx, ny, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[4] = {{cT,1},{cT,1},{OVERWRITE,2},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_dger, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
ID kw_table[2] = {id_alpha,id_order};
VALUE opts[2] = {Qundef};
CHECK_FUNC(func_p,"dger");
rb_scan_args(argc, argv, "21:", &x, &y, &a, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 2, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
g.order = option_order(opts[1]);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
mx = COL_SIZE(na1); // m
ny = COL_SIZE(na2); // n
g.m = mx;
g.n = ny;
SWAP_IFCOL(g.order, mx,ny, tmp);
if (a == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
a = INT2FIX(0);
shape[0] = mx;
shape[1] = ny;
} else {
narray_t *na3;
blasint ma, na;
COPY_OR_CAST_TO(a,cT);
GetNArray(a,na3);
CHECK_DIM_GE(na3,2);
ma = ROW_SIZE(na3); // m
na = COL_SIZE(na3); // n (lda)
CHECK_SIZE_EQ(ma,mx);
CHECK_SIZE_EQ(na,ny);
}
ans = na_ndloop3(&ndf, &g, 3, x, y, a);
if (ndf.nout = 1) { // a is not given.
return ans;
} else {
return a;
}
}
|
.dlopen(*args) ⇒ Object
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
# File 'ext/numo/linalg/blas/blas.c', line 288
static VALUE
blas_s_dlopen(int argc, VALUE *argv, VALUE mod)
{
int i, f;
VALUE lib, flag;
char *error;
void *handle;
i = rb_scan_args(argc, argv, "11", &lib, &flag);
if (i==2) {
f = NUM2INT(flag);
} else {
f = RTLD_LAZY;
}
#if defined(HAVE_DLFCN_H)
dlerror();
#endif
handle = dlopen(StringValueCStr(lib), f);
#if defined(HAVE_DLFCN_H)
if ( !handle && (error = dlerror()) ) {
rb_raise(rb_eRuntimeError, "%s", error);
}
#else
if ( !handle ) {
error = dlerror();
rb_raise(rb_eRuntimeError, "%s", error);
}
#endif
blas_handle = handle;
return Qnil;
}
|
.dnrm2(x) ⇒ Numo::DFloat
DNRM2 returns the euclidean norm of a vector via the function name, so that
DNRM2 := sqrt( x'*x )
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'ext/numo/linalg/blas/blas_d.c', line 159
static VALUE
blas_s_dnrm2(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE x, keepdims, ans;
narray_t *na1;
ndfunc_arg_in_t ain[1] = {{cT,1}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_blas_s_dnrm2, NDF_EXTRACT, 1,1, ain,aout};
VALUE opts[1] = {Qundef};
ID kw_table[1] = {id_keepdims};
VALUE kw_hash = Qnil;
CHECK_FUNC(func_p,"dnrm2");
rb_scan_args(argc, argv, "1:", &x, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 1, opts);
keepdims = option_value(opts[0],Qfalse);
if (RTEST(keepdims)) {
ndf.flag |= NDF_KEEP_DIM;
}
GetNArray(x,na1);
CHECK_DIM_GE(na1,1);
CHECK_NON_EMPTY(na1);
ans = na_ndloop(&ndf, 1, x);
return ans;
}
|
.drot(x, y, c, s) ⇒ Array<Numo::DFloat,Numo::DFloat>
DROT applies a plane rotation.
483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 |
# File 'ext/numo/linalg/blas/blas_d.c', line 483
static VALUE
blas_s_drot(VALUE UNUSED(mod), VALUE x, VALUE y, VALUE c, VALUE s)
{
rtype g[2] = {0,0};
narray_t *na1, *na2;
ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{OVERWRITE,0}};
ndfunc_t ndf = {iter_blas_s_drot, STRIDE_LOOP, 2,0, ain,0};
CHECK_FUNC(func_p,"drot");
if (RTEST(c)) {g[0] = NUM2DBL(c);}
if (RTEST(s)) {g[1] = NUM2DBL(s);}
COPY_OR_CAST_TO(x,cT);
COPY_OR_CAST_TO(y,cT);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
CHECK_NON_EMPTY(na1);
CHECK_NON_EMPTY(na2);
CHECK_SAME_SHAPE(na1,na2);
na_ndloop3(&ndf, g, 2, x, y);
return rb_assoc_new(x,y);
}
|
.drotm(x, y, param) ⇒ Array<Numo::DFloat,Numo::DFloat>
Apply the modified givens transformation, H, to the 2 by N matrix (X**T), where **T indicates transpose. The elements of X are in (Y**T)
X(LX+I*INCX), I = 0 to N-1, where LX = 1 if INCX .GE. 0, else LX = (-INCX)*N, and similarly for Y using LY and INCY. With PARAM(1)=FLAG, H has one of the following forms..
FLAG=-1.0 FLAG=0.0 FLAG=1.0 FLAG=-2.0
(H11 H12) (1.0 H12) (H11 1.0) (1.0 0.0)
H=( ) ( ) ( ) ( )
(H21 H22), (H21 1.0), (-1.0 H22), (0.0 1.0).
see DROTMG for a description of data storage in param.
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 |
# File 'ext/numo/linalg/blas/blas_d.c', line 560
static VALUE
blas_s_drotm(VALUE UNUSED(mod), VALUE x, VALUE y, VALUE param)
{
dtype *g;
narray_t *na1, *na2, *nap;
ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{OVERWRITE,0}};
ndfunc_t ndf = {iter_blas_s_drotm, STRIDE_LOOP, 2,0, ain,0};
CHECK_FUNC(func_p,"drotm");
COPY_OR_CAST_TO(x,cT);
COPY_OR_CAST_TO(y,cT);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
CHECK_NON_EMPTY(na1);
CHECK_NON_EMPTY(na2);
CHECK_SAME_SHAPE(na1,na2);
param = rb_funcall(cT,rb_intern("cast"),1,param);
GetNArray(param,nap);
CHECK_DIM_EQ(nap,1);
CHECK_SIZE_GE(nap,5);
g = (dtype*)nary_get_pointer_for_read(param);
na_ndloop3(&ndf, g, 2, x, y);
RB_GC_GUARD(param);
return rb_assoc_new(x,y);
}
|
.dscal(a, x) ⇒ Numo::DFloat
DSCAL scales a vector by a constant. uses unrolled loops for increment equal to one.
632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 |
# File 'ext/numo/linalg/blas/blas_d.c', line 632
static VALUE
blas_s_dscal(VALUE mod, VALUE a, VALUE x)
{
scal_t g[1];
narray_t *na1;
ndfunc_arg_in_t ain[1] = {{OVERWRITE,0}};
ndfunc_t ndf = {iter_blas_s_dscal, STRIDE_LOOP, 1,0, ain,0};
CHECK_FUNC(func_p,"dscal");
#line 56 "gen/../tmpl/scal.c"
if (RTEST(a)) {g[0] = m_num_to_data(a);} else {g[0]=m_one;}
COPY_OR_CAST_TO(x,cT);
GetNArray(x,na1);
CHECK_DIM_GE(na1,1);
CHECK_NON_EMPTY(na1);
na_ndloop3(&ndf, g, 1, x);
return x;
}
|
.dsdot(x, y) ⇒ Numo::DFloat
Compute the inner product of two vectors with extended precision accumulation and result. Returns D.P. dot product accumulated in D.P., for S.P. SX and SY DSDOT = sum for I = 0 to N-1 of SX(LX+I*INCX) * SY(LY+I*INCY), where LX = 1 if INCX .GE. 0, else LX = 1+(1-N)*INCX, and LY is defined in a similar way using INCY.
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
# File 'ext/numo/linalg/blas/blas_s.c', line 303
static VALUE
blas_s_dsdot(VALUE mod, VALUE x, VALUE y)
{
VALUE ans;
narray_t *na1, *na2;
size_t nx, ny, shape[1]={1};
ndfunc_arg_in_t ain[2] = {{cT,1},{cT,1}};
ndfunc_arg_out_t aout[1] = {{numo_cDFloat,0,shape}};
ndfunc_t ndf = {iter_blas_s_dsdot, NDF_EXTRACT, 2,1, ain,aout};
CHECK_FUNC(func_p,"dsdot");
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
CHECK_NON_EMPTY(na1);
CHECK_NON_EMPTY(na2);
nx = COL_SIZE(na1);
ny = COL_SIZE(na2);
CHECK_SIZE_EQ(nx,ny);
ans = na_ndloop(&ndf, 2, x, y);
return ans;
}
|
.dswap(x, y) ⇒ nil
interchanges two vectors. uses unrolled loops for increments equal one.
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
# File 'ext/numo/linalg/blas/blas_d.c', line 291
static VALUE
blas_s_dswap(VALUE UNUSED(mod), VALUE x, VALUE y)
{
narray_t *na1, *na2;
ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{OVERWRITE,0}};
ndfunc_t ndf = {iter_blas_s_dswap, STRIDE_LOOP, 2,0, ain,0};
CHECK_FUNC(func_p,"dswap");
CHECK_NARRAY_TYPE(x,cT);
CHECK_NARRAY_TYPE(y,cT);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
CHECK_NON_EMPTY(na1);
CHECK_NON_EMPTY(na2);
CHECK_SAME_SHAPE(na1,na2);
na_ndloop(&ndf, 2, x, y);
return Qnil;
}
|
.dsymm(a, b, [c, alpha: 1, beta:0, side:'L', uplo:'U', order:'R']) ⇒ Numo::DFloat
DSYMM performs one of the matrix-matrix operations
C := alpha*A*B + beta*C,
or
C := alpha*B*A + beta*C,
where alpha and beta are scalars, A is a symmetric matrix and B and C are m by n matrices.
1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 |
# File 'ext/numo/linalg/blas/blas_d.c', line 1849
static VALUE
blas_s_dsymm(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, b, c=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, ka, kb, nb, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[3] = {{cT,2},{cT,2},{OVERWRITE,2}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_dsymm, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[5] = {id_alpha,id_beta,id_order,id_transa,id_transb};
#elif TR
ID kw_table[7] = {id_alpha,id_beta,id_order,id_side,id_uplo,id_transa,id_diag};
#else
ID kw_table[5] = {id_alpha,id_beta,id_order,id_side,id_uplo};
#endif
VALUE opts[7] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"dsymm");
rb_scan_args(argc, argv, "21:", &a, &b, &c, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 5+TR*2, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.transa = option_trans(opts[3]);
g.transb = option_trans(opts[4]);
#else
g.side = option_side(opts[3]);
g.uplo = option_uplo(opts[4]);
#endif
#if TR
g.transa = option_trans(opts[5]);
g.diag = option_diag(opts[6]);
#endif
GetNArray(a,na1);
GetNArray(b,na2);
CHECK_DIM_GE(na1,2);
CHECK_DIM_GE(na2,2);
ma = ROW_SIZE(na1); // m
ka = COL_SIZE(na1); // k (lda)
kb = ROW_SIZE(na2); // k
nb = COL_SIZE(na2); // n (ldb)
#if GE
SWAP_IFCOLTR(g.order,g.transa, ma,ka, tmp);
SWAP_IFCOLTR(g.order,g.transb, kb,nb, tmp);
CHECK_INT_EQ("ka",ka,"kb",kb);
g.m = ma;
g.n = nb;
g.k = ka;
#else
CHECK_SQUARE("a",na1); // ma == ka
SWAP_IFCOL(g.order, kb,nb, tmp);
// row major L R
//ma = ROW_SIZE(na1); // m or n
//ka = COL_SIZE(na1); // m or n (lda)
g.m = kb; // m
g.n = nb; // n (ldb)
if (g.side == CblasLeft) {
CHECK_SIZE_EQ(ka, g.m);
} else {
CHECK_SIZE_EQ(ka, g.n);
}
#endif
SWAP_IFROW(g.order, ma,nb, tmp);
#if TR
if (c != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(b,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, b);
return b;
#else
if (c == Qnil) { // c is not given.
ndfunc_arg_in_t ain_init = {sym_init,0};
ain[2] = ain_init;
ndf.nout = 1;
c = INT2FIX(0);
shape[0] = nb;
shape[1] = ma;
} else {
narray_t *na3;
int nc;
COPY_OR_CAST_TO(c,cT);
GetNArray(c,na3);
CHECK_DIM_GE(na3,2);
nc = ROW_SIZE(na3);
if (nc < nb) {
rb_raise(nary_eShapeError,"nc=%d must be >= nb=%d",nc,nb);
}
//CHECK_LEADING_GE("ldc",g.ldc,"m",ma);
}
{
VALUE ans = na_ndloop3(&ndf, &g, 3, a, b, c);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return c;
}
}
#endif
}
|
.dsymv(a, x, [y, alpha: 1, beta:0, uplo:'U', order:'R']) ⇒ Numo::DFloat
DSYMV performs the matrix-vector operation
y := alpha*A*x + beta*y,
where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix.
1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 |
# File 'ext/numo/linalg/blas/blas_d.c', line 1115
static VALUE
blas_s_dsymv(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, x, y=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, na, nx;
#if GE
blasint tmp;
#endif
size_t shape[1];
ndfunc_arg_in_t ain[4] = {{cT,2},{cT,1},{OVERWRITE,1},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,1,shape}};
ndfunc_t ndf = {iter_blas_s_dsymv, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[4] = {id_alpha,id_beta,id_order,id_trans};
#elif TR
ID kw_table[6] = {id_alpha,id_beta,id_order,id_uplo,id_trans,id_diag};
#else
ID kw_table[4] = {id_alpha,id_beta,id_order,id_uplo};
#endif
VALUE opts[6] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"dsymv");
rb_scan_args(argc, argv, "21:", &a, &x, &y, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 4+2*TR, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.trans = option_trans(opts[3]);
#else
g.uplo = option_uplo(opts[3]);
#endif
#if TR
g.trans = option_trans(opts[4]);
g.diag = option_diag(opts[5]);
#endif
GetNArray(a,na1);
CHECK_DIM_GE(na1,2);
ma = ROW_SIZE(na1);
na = COL_SIZE(na1);
GetNArray(x,na2);
CHECK_DIM_GE(na2,1);
nx = COL_SIZE(na2);
#if GE
SWAP_IFCOL(g.order, ma, na, tmp);
g.m = ma;
g.n = na;
SWAP_IFTRANS(g.trans, ma, na, tmp);
#else
CHECK_SQUARE("a",na1);
#endif
CHECK_INT_EQ("na",na,"nx",nx);
shape[0] = ma;
#if TR
if (y != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(x,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, x);
return x;
#else // GE,SY,HE
if (y == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
y = INT2FIX(0);
shape[0] = ma;
} else {
narray_t *na3;
COPY_OR_CAST_TO(y,cT);
GetNArray(y,na3);
CHECK_DIM_GE(na3,1);
CHECK_SIZE_GE(na3,nx);
}
{
VALUE ans;
ans = na_ndloop3(&ndf, &g, 3, a, x, y);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return y;
}
}
#endif
}
|
.dsyr(x, [a, alpha: 1, uplo:'U', order:'R']) ⇒ Numo::DFloat
DSYR performs the symmetric rank 1 operation
A := alpha*x*x**T + A,
where alpha is a real scalar, x is an n element vector and A is an n by n symmetric matrix.
1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 |
# File 'ext/numo/linalg/blas/blas_d.c', line 1269
static VALUE
blas_s_dsyr(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE ans;
VALUE x, a, alpha;
narray_t *na1, *na3;
blasint nx, na;
size_t shape[2];
ndfunc_arg_in_t ain[3] = {{cT,1},{OVERWRITE,2},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_dsyr, NO_LOOP, 2, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
ID kw_table[3] = {id_alpha,id_order,id_uplo};
VALUE opts[3] = {Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"dsyr");
rb_scan_args(argc, argv, "11:", &x, &a, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 3, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? NUM2DBL(alpha) : 1;
g.order = option_order(opts[1]);
g.uplo = option_uplo(opts[2]);
GetNArray(x,na1);
CHECK_DIM_GE(na1,1);
nx = COL_SIZE(na1); // n
if (a == Qnil) { // c is not given.
ndf.nout = 1;
ain[1] = ain[2];
a = INT2FIX(0);
shape[0] = shape[1] = nx;
} else {
COPY_OR_CAST_TO(a,cT);
GetNArray(a,na3);
CHECK_DIM_GE(na3,2);
CHECK_SQUARE("a",na3);
na = COL_SIZE(na3); // n (lda)
CHECK_SIZE_EQ(na,nx);
}
ans = na_ndloop3(&ndf, &g, 2, x, a);
if (ndf.nout == 1) { // a is not given.
return ans;
} else {
return a;
}
}
|
.dsyr2(x, y, [a, alpha: 1, uplo:'U', order:'R']) ⇒ Numo::DFloat
DSYR2 performs the symmetric rank 2 operation
A := alpha*x*y**T + alpha*y*x**T + A,
where alpha is a scalar, x and y are n element vectors and A is an n by n symmetric matrix.
1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 |
# File 'ext/numo/linalg/blas/blas_d.c', line 1498
static VALUE
blas_s_dsyr2(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE ans;
VALUE x, y, a, alpha;
narray_t *na1, *na2, *na3;
blasint nx, ny, na;
size_t shape[2];
ndfunc_arg_in_t ain[4] = {{cT,1},{cT,1},{OVERWRITE,2},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_dsyr2, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
ID kw_table[3] = {id_alpha,id_order,id_uplo};
VALUE opts[3] = {Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"dsyr2");
rb_scan_args(argc, argv, "21:", &x, &y, &a, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 3, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
g.order = option_order(opts[1]);
g.uplo = option_uplo(opts[2]);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
nx = COL_SIZE(na1); // n
ny = COL_SIZE(na2); // n
CHECK_INT_EQ("nx",nx,"ny",ny);
if (a == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
a = INT2FIX(0);
shape[0] = shape[1] = nx;
} else {
COPY_OR_CAST_TO(a,cT);
GetNArray(a,na3);
CHECK_DIM_GE(na3,2);
CHECK_SQUARE("a",na3);
na = COL_SIZE(na3); // n (lda)
CHECK_SIZE_EQ(na,nx);
}
ans = na_ndloop3(&ndf, &g, 3, x, y, a);
if (ndf.nout == 1) { // a is not given.
return ans;
} else {
return a;
}
}
|
.dsyr2k(a, b, [c, alpha: 1, beta:0, uplo:'U', trans:'N', order:'R']) ⇒ Numo::DFloat
DSYR2K performs one of the symmetric rank 2k operations
C := alpha*A*B**T + alpha*B*A**T + beta*C,
or
C := alpha*A**T*B + alpha*B**T*A + beta*C,
where alpha and beta are scalars, C is an n by n symmetric matrix and A and B are n by k matrices in the first case and k by n matrices in the second case.
2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 |
# File 'ext/numo/linalg/blas/blas_d.c', line 2371
static VALUE
blas_s_dsyr2k(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE ans;
VALUE a, b, c=Qnil, alpha, beta;
narray_t *na1, *na2, *na3;
blasint na, ka, kb, nb, nc, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[4] = {{cT,2},{cT,2},{OVERWRITE,2},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_dsyr2k, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
ID kw_table[5] = {id_alpha,id_beta,id_order,id_uplo,id_trans};
VALUE opts[5] = {Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"dsyr2k");
rb_scan_args(argc, argv, "21:", &a, &b, &c, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 5, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
g.uplo = option_uplo(opts[3]);
g.trans = option_trans(opts[4]);
GetNArray(a,na1);
GetNArray(b,na2);
CHECK_DIM_GE(na1,2);
CHECK_DIM_GE(na2,2);
na = ROW_SIZE(na1); // n
ka = COL_SIZE(na1); // k (lda)
SWAP_IFCOLTR(g.order, g.trans, na, ka, tmp);
nb = ROW_SIZE(na2); // n
kb = COL_SIZE(na2); // k (ldb)
SWAP_IFCOLTR(g.order, g.trans, kb, nb, tmp);
CHECK_INT_EQ("na",na,"nb",nb);
CHECK_INT_EQ("ka",ka,"kb",kb);
g.n = nb;
g.k = kb;
SWAP_IFROW(g.order, na, nb, tmp);
if (c == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
c = INT2FIX(0);
shape[0] = nb;
shape[1] = na;
} else {
COPY_OR_CAST_TO(c,cT);
GetNArray(c,na3);
CHECK_DIM_GE(na3,2);
nc = ROW_SIZE(na3); // n
if (nc < nb) {
rb_raise(nary_eShapeError,"nc=%d must be >= nb=%d",nc,nb);
}
//CHECK_LEADING_GE("ldc",g.ldc,"n",na);
}
ans = na_ndloop3(&ndf, &g, 3, a, b, c);
if (ndf.nout = 1) { // c is not given.
return ans;
} else {
return c;
}
}
|
.dsyrk(a, [c, alpha: 1, beta:0, uplo:'U', trans:'N', order:'R']) ⇒ Numo::DFloat
DSYRK performs one of the symmetric rank k operations
C := alpha*A*A**T + beta*C,
or
C := alpha*A**T*A + beta*C,
where alpha and beta are scalars, C is an n by n symmetric matrix and A is an n by k matrix in the first case and a k by n matrix in the second case.
2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 |
# File 'ext/numo/linalg/blas/blas_d.c', line 2240
static VALUE
blas_s_dsyrk(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE ans;
VALUE a, c, alpha, beta;
narray_t *na1, *na3;
blasint na, ka, nc, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[3] = {{cT,2},{OVERWRITE,2},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_dsyrk, NO_LOOP, 2, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
ID kw_table[5] = {id_alpha,id_beta,id_order,id_uplo,id_trans};
VALUE opts[5] = {Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"dsyrk");
rb_scan_args(argc, argv, "11:", &a, &c, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 5, opts);
alpha = option_value(opts[0],Qnil);
beta = option_value(opts[1],Qnil);
#line 88 "gen/../tmpl/syrk.c"
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
#line 91 "gen/../tmpl/syrk.c"
g.order = option_order(opts[2]);
g.uplo = option_uplo(opts[3]);
g.trans = option_trans(opts[4]);
GetNArray(a,na1);
CHECK_DIM_GE(na1,2);
na = ROW_SIZE(na1); // n
ka = COL_SIZE(na1); // k (lda)
SWAP_IFCOLTR(g.order,g.trans, na,ka, tmp);
g.n = na;
g.k = ka;
if (c == Qnil) { // c is not given.
ndf.nout = 1;
ain[1] = ain[2];
c = INT2FIX(0);
shape[0] = na;
shape[1] = na;
} else {
COPY_OR_CAST_TO(c,cT);
GetNArray(c,na3);
CHECK_DIM_GE(na3,2);
nc = ROW_SIZE(na3);
if (nc < na) {
rb_raise(nary_eShapeError,"nc=%d must be >= na=%d",nc,na);
}
//CHECK_LEADING_GE("ldc",g.ldc,"n",na);
}
ans = na_ndloop3(&ndf, &g, 2, a, c);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return c;
}
}
|
.dtrmm(a, b, [alpha: 1, side:'L', uplo:'U', transa:'N', diag:'U', order:'R']) ⇒ Numo::DFloat
DTRMM performs one of the matrix-matrix operations
B := alpha*op( A )*B, or B := alpha*B*op( A ),
where alpha is a scalar, B is an m by n matrix, A is a unit, or non-unit, upper or lower triangular matrix and op( A ) is one of
op( A ) = A or op( A ) = A**T.
2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 |
# File 'ext/numo/linalg/blas/blas_d.c', line 2054
static VALUE
blas_s_dtrmm(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, b, c=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, ka, kb, nb, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[3] = {{cT,2},{cT,2},{OVERWRITE,2}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_dtrmm, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[5] = {id_alpha,id_beta,id_order,id_transa,id_transb};
#elif TR
ID kw_table[7] = {id_alpha,id_beta,id_order,id_side,id_uplo,id_transa,id_diag};
#else
ID kw_table[5] = {id_alpha,id_beta,id_order,id_side,id_uplo};
#endif
VALUE opts[7] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"dtrmm");
rb_scan_args(argc, argv, "21:", &a, &b, &c, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 5+TR*2, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.transa = option_trans(opts[3]);
g.transb = option_trans(opts[4]);
#else
g.side = option_side(opts[3]);
g.uplo = option_uplo(opts[4]);
#endif
#if TR
g.transa = option_trans(opts[5]);
g.diag = option_diag(opts[6]);
#endif
GetNArray(a,na1);
GetNArray(b,na2);
CHECK_DIM_GE(na1,2);
CHECK_DIM_GE(na2,2);
ma = ROW_SIZE(na1); // m
ka = COL_SIZE(na1); // k (lda)
kb = ROW_SIZE(na2); // k
nb = COL_SIZE(na2); // n (ldb)
#if GE
SWAP_IFCOLTR(g.order,g.transa, ma,ka, tmp);
SWAP_IFCOLTR(g.order,g.transb, kb,nb, tmp);
CHECK_INT_EQ("ka",ka,"kb",kb);
g.m = ma;
g.n = nb;
g.k = ka;
#else
CHECK_SQUARE("a",na1); // ma == ka
SWAP_IFCOL(g.order, kb,nb, tmp);
// row major L R
//ma = ROW_SIZE(na1); // m or n
//ka = COL_SIZE(na1); // m or n (lda)
g.m = kb; // m
g.n = nb; // n (ldb)
if (g.side == CblasLeft) {
CHECK_SIZE_EQ(ka, g.m);
} else {
CHECK_SIZE_EQ(ka, g.n);
}
#endif
SWAP_IFROW(g.order, ma,nb, tmp);
#if TR
if (c != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(b,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, b);
return b;
#else
if (c == Qnil) { // c is not given.
ndfunc_arg_in_t ain_init = {sym_init,0};
ain[2] = ain_init;
ndf.nout = 1;
c = INT2FIX(0);
shape[0] = nb;
shape[1] = ma;
} else {
narray_t *na3;
int nc;
COPY_OR_CAST_TO(c,cT);
GetNArray(c,na3);
CHECK_DIM_GE(na3,2);
nc = ROW_SIZE(na3);
if (nc < nb) {
rb_raise(nary_eShapeError,"nc=%d must be >= nb=%d",nc,nb);
}
//CHECK_LEADING_GE("ldc",g.ldc,"m",ma);
}
{
VALUE ans = na_ndloop3(&ndf, &g, 3, a, b, c);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return c;
}
}
#endif
}
|
.dtrmv(a, x, [uplo: 'U', trans:'N', diag:'U', order:'R']) ⇒ Numo::DFloat
DTRMV performs one of the matrix-vector operations
x := A*x, or x := A**T*x,
where x is an n element vector and A is an n by n unit, or non-unit, upper or lower triangular matrix.
928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 |
# File 'ext/numo/linalg/blas/blas_d.c', line 928
static VALUE
blas_s_dtrmv(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, x, y=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, na, nx;
#if GE
blasint tmp;
#endif
size_t shape[1];
ndfunc_arg_in_t ain[4] = {{cT,2},{cT,1},{OVERWRITE,1},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,1,shape}};
ndfunc_t ndf = {iter_blas_s_dtrmv, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[4] = {id_alpha,id_beta,id_order,id_trans};
#elif TR
ID kw_table[6] = {id_alpha,id_beta,id_order,id_uplo,id_trans,id_diag};
#else
ID kw_table[4] = {id_alpha,id_beta,id_order,id_uplo};
#endif
VALUE opts[6] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"dtrmv");
rb_scan_args(argc, argv, "21:", &a, &x, &y, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 4+2*TR, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.trans = option_trans(opts[3]);
#else
g.uplo = option_uplo(opts[3]);
#endif
#if TR
g.trans = option_trans(opts[4]);
g.diag = option_diag(opts[5]);
#endif
GetNArray(a,na1);
CHECK_DIM_GE(na1,2);
ma = ROW_SIZE(na1);
na = COL_SIZE(na1);
GetNArray(x,na2);
CHECK_DIM_GE(na2,1);
nx = COL_SIZE(na2);
#if GE
SWAP_IFCOL(g.order, ma, na, tmp);
g.m = ma;
g.n = na;
SWAP_IFTRANS(g.trans, ma, na, tmp);
#else
CHECK_SQUARE("a",na1);
#endif
CHECK_INT_EQ("na",na,"nx",nx);
shape[0] = ma;
#if TR
if (y != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(x,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, x);
return x;
#else // GE,SY,HE
if (y == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
y = INT2FIX(0);
shape[0] = ma;
} else {
narray_t *na3;
COPY_OR_CAST_TO(y,cT);
GetNArray(y,na3);
CHECK_DIM_GE(na3,1);
CHECK_SIZE_GE(na3,nx);
}
{
VALUE ans;
ans = na_ndloop3(&ndf, &g, 3, a, x, y);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return y;
}
}
#endif
}
|
.dzasum(x) ⇒ Numo::DFloat
DZASUM takes the sum of the (|Re(.)| + |Im(.)|)’s of a complex vector and returns a single precision result.
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
# File 'ext/numo/linalg/blas/blas_z.c', line 297
static VALUE
blas_s_dzasum(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE x, keepdims, ans;
narray_t *na1;
ndfunc_arg_in_t ain[1] = {{cT,1}};
ndfunc_arg_out_t aout[1] = {{cRT,0}};
ndfunc_t ndf = {iter_blas_s_dzasum, NDF_EXTRACT, 1,1, ain,aout};
VALUE opts[1] = {Qundef};
ID kw_table[1] = {id_keepdims};
VALUE kw_hash = Qnil;
CHECK_FUNC(func_p,"dzasum");
rb_scan_args(argc, argv, "1:", &x, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 1, opts);
keepdims = option_value(opts[0],Qfalse);
if (RTEST(keepdims)) {
ndf.flag |= NDF_KEEP_DIM;
}
GetNArray(x,na1);
CHECK_DIM_GE(na1,1);
CHECK_NON_EMPTY(na1);
ans = na_ndloop(&ndf, 1, x);
return ans;
}
|
.dznrm2(x) ⇒ Numo::DFloat
DZNRM2 returns the euclidean norm of a vector via the function name, so that
DZNRM2 := sqrt( x**H*x )
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'ext/numo/linalg/blas/blas_z.c', line 229
static VALUE
blas_s_dznrm2(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE x, keepdims, ans;
narray_t *na1;
ndfunc_arg_in_t ain[1] = {{cT,1}};
ndfunc_arg_out_t aout[1] = {{cRT,0}};
ndfunc_t ndf = {iter_blas_s_dznrm2, NDF_EXTRACT, 1,1, ain,aout};
VALUE opts[1] = {Qundef};
ID kw_table[1] = {id_keepdims};
VALUE kw_hash = Qnil;
CHECK_FUNC(func_p,"dznrm2");
rb_scan_args(argc, argv, "1:", &x, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 1, opts);
keepdims = option_value(opts[0],Qfalse);
if (RTEST(keepdims)) {
ndf.flag |= NDF_KEEP_DIM;
}
GetNArray(x,na1);
CHECK_DIM_GE(na1,1);
CHECK_NON_EMPTY(na1);
ans = na_ndloop(&ndf, 1, x);
return ans;
}
|
.prefix=(prefix) ⇒ Object
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'ext/numo/linalg/blas/blas.c', line 321
static VALUE
blas_s_prefix_set(VALUE mod, VALUE prefix)
{
long len;
if (TYPE(prefix) != T_STRING) {
rb_raise(rb_eTypeError,"argument must be string");
}
if (blas_prefix) {
free(blas_prefix);
}
len = RSTRING_LEN(prefix);
blas_prefix = malloc(len+1);
strcpy(blas_prefix, StringValueCStr(prefix));
return prefix;
}
|
.sasum(x) ⇒ Numo::SFloat
SASUM takes the sum of the absolute values. uses unrolled loops for increment equal to one.
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'ext/numo/linalg/blas/blas_s.c', line 227
static VALUE
blas_s_sasum(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE x, keepdims, ans;
narray_t *na1;
ndfunc_arg_in_t ain[1] = {{cT,1}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_blas_s_sasum, NDF_EXTRACT, 1,1, ain,aout};
VALUE opts[1] = {Qundef};
ID kw_table[1] = {id_keepdims};
VALUE kw_hash = Qnil;
CHECK_FUNC(func_p,"sasum");
rb_scan_args(argc, argv, "1:", &x, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 1, opts);
keepdims = option_value(opts[0],Qfalse);
if (RTEST(keepdims)) {
ndf.flag |= NDF_KEEP_DIM;
}
GetNArray(x,na1);
CHECK_DIM_GE(na1,1);
CHECK_NON_EMPTY(na1);
ans = na_ndloop(&ndf, 1, x);
return ans;
}
|
.saxpy(x, y, [alpha: 1]) ⇒ Numo::SFloat
SAXPY constant times a vector plus a vector. uses unrolled loops for increments equal to one.
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 |
# File 'ext/numo/linalg/blas/blas_s.c', line 560
static VALUE
blas_s_saxpy(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE x, y, alpha;
narray_t *na1, *na2;
ndfunc_arg_in_t ain[2] = {{cT,0},{OVERWRITE,0}};
ndfunc_t ndf = {iter_blas_s_saxpy, STRIDE_LOOP, 2, 0, ain, 0};
dtype g;
VALUE kw_hash = Qnil;
ID kw_table[1] = {id_alpha};
VALUE opts[1] = {Qundef};
CHECK_FUNC(func_p,"saxpy");
rb_scan_args(argc, argv, "2:", &x, &y, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 1, opts);
alpha = option_value(opts[0],Qnil);
g = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
COPY_OR_CAST_TO(y,cT);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
CHECK_NON_EMPTY(na1);
CHECK_NON_EMPTY(na2);
CHECK_SAME_SHAPE(na1,na2);
na_ndloop3(&ndf, &g, 2, x, y);
return y;
}
|
.scasum(x) ⇒ Numo::SFloat
SCASUM takes the sum of the (|Re(.)| + |Im(.)|)’s of a complex vector and returns a single precision result.
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 |
# File 'ext/numo/linalg/blas/blas_c.c', line 297
static VALUE
blas_s_scasum(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE x, keepdims, ans;
narray_t *na1;
ndfunc_arg_in_t ain[1] = {{cT,1}};
ndfunc_arg_out_t aout[1] = {{cRT,0}};
ndfunc_t ndf = {iter_blas_s_scasum, NDF_EXTRACT, 1,1, ain,aout};
VALUE opts[1] = {Qundef};
ID kw_table[1] = {id_keepdims};
VALUE kw_hash = Qnil;
CHECK_FUNC(func_p,"scasum");
rb_scan_args(argc, argv, "1:", &x, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 1, opts);
keepdims = option_value(opts[0],Qfalse);
if (RTEST(keepdims)) {
ndf.flag |= NDF_KEEP_DIM;
}
GetNArray(x,na1);
CHECK_DIM_GE(na1,1);
CHECK_NON_EMPTY(na1);
ans = na_ndloop(&ndf, 1, x);
return ans;
}
|
.scnrm2(x) ⇒ Numo::SFloat
SCNRM2 returns the euclidean norm of a vector via the function name, so that
SCNRM2 := sqrt( x**H*x )
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
# File 'ext/numo/linalg/blas/blas_c.c', line 229
static VALUE
blas_s_scnrm2(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE x, keepdims, ans;
narray_t *na1;
ndfunc_arg_in_t ain[1] = {{cT,1}};
ndfunc_arg_out_t aout[1] = {{cRT,0}};
ndfunc_t ndf = {iter_blas_s_scnrm2, NDF_EXTRACT, 1,1, ain,aout};
VALUE opts[1] = {Qundef};
ID kw_table[1] = {id_keepdims};
VALUE kw_hash = Qnil;
CHECK_FUNC(func_p,"scnrm2");
rb_scan_args(argc, argv, "1:", &x, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 1, opts);
keepdims = option_value(opts[0],Qfalse);
if (RTEST(keepdims)) {
ndf.flag |= NDF_KEEP_DIM;
}
GetNArray(x,na1);
CHECK_DIM_GE(na1,1);
CHECK_NON_EMPTY(na1);
ans = na_ndloop(&ndf, 1, x);
return ans;
}
|
.scopy(x, y) ⇒ nil
SCOPY copies a vector, x, to a vector, y. uses unrolled loops for increments equal to 1.
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 |
# File 'ext/numo/linalg/blas/blas_s.c', line 495
static VALUE
blas_s_scopy(VALUE UNUSED(mod), VALUE x, VALUE y)
{
narray_t *na1, *na2;
ndfunc_arg_in_t ain[2] = {{cT,0},{OVERWRITE,0}};
ndfunc_t ndf = {iter_blas_s_scopy, STRIDE_LOOP, 2,0, ain,0};
CHECK_FUNC(func_p,"scopy");
CHECK_NARRAY_TYPE(x,cT);
CHECK_NARRAY_TYPE(y,cT);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
CHECK_NON_EMPTY(na1);
CHECK_NON_EMPTY(na2);
CHECK_SAME_SHAPE(na1,na2);
na_ndloop(&ndf, 2, x, y);
return Qnil;
}
|
.sdot(x, y) ⇒ Numo::SFloat
SDOT forms the dot product of two vectors. uses unrolled loops for increments equal to one.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'ext/numo/linalg/blas/blas_s.c', line 95
static VALUE
blas_s_sdot(VALUE mod, VALUE x, VALUE y)
{
VALUE ans;
narray_t *na1, *na2;
size_t nx, ny, shape[1]={1};
ndfunc_arg_in_t ain[2] = {{cT,1},{cT,1}};
ndfunc_arg_out_t aout[1] = {{numo_cSFloat,0,shape}};
ndfunc_t ndf = {iter_blas_s_sdot, NDF_EXTRACT, 2,1, ain,aout};
CHECK_FUNC(func_p,"sdot");
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
CHECK_NON_EMPTY(na1);
CHECK_NON_EMPTY(na2);
nx = COL_SIZE(na1);
ny = COL_SIZE(na2);
CHECK_SIZE_EQ(nx,ny);
ans = na_ndloop(&ndf, 2, x, y);
return ans;
}
|
.sdsdot(sx, sy, [sb: 0]) ⇒ Numo::SFloat
Compute the inner product of two vectors with extended precision accumulation.
Returns S.P. result with dot product accumulated in D.P. SDSDOT = SB + sum for I = 0 to N-1 of SX(LX+IINCX)SY(LY+IINCY), where LX = 1 if INCX .GE. 0, else LX = 1+(1-N)INCX, and LY is defined in a similar way using INCY.
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
# File 'ext/numo/linalg/blas/blas_s.c', line 371
static VALUE
blas_s_sdsdot(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE x, y, sb;
dtype g[1];
narray_t *na1, *na2;
size_t nx, ny;
ndfunc_arg_in_t ain[2] = {{cT,1},{cT,1}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_blas_s_sdsdot, NDF_EXTRACT, 2,1, ain,aout};
VALUE kw_hash = Qnil;
ID kw_table[1] = {id_sb};
VALUE opts[1] = {Qundef};
CHECK_FUNC(func_p,"sdsdot");
rb_scan_args(argc, argv, "2:", &x, &y, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 1, opts);
sb = option_value(opts[0],Qnil);
g[0] = RTEST(sb) ? m_num_to_data(sb) : m_zero;
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
CHECK_NON_EMPTY(na1);
CHECK_NON_EMPTY(na2);
nx = na1->shape[na1->ndim-1];
ny = na2->shape[na2->ndim-1];
CHECK_SIZE_EQ(nx,ny);
return na_ndloop3(&ndf, g, 2, x, y);
}
|
.sgemm(a, b, [c, alpha: 1, beta:0, transa:'N', transb:'N', order:'R']) ⇒ Numo::SFloat
SGEMM performs one of the matrix-matrix operations
C := alpha*op( A )*op( B ) + beta*C,
where op( X ) is one of
op( X ) = X or op( X ) = X**T,
alpha and beta are scalars, and A, B and C are matrices, with op( A ) an m by k matrix, op( B ) a k by n matrix and C an m by n matrix.
1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 |
# File 'ext/numo/linalg/blas/blas_s.c', line 1789
static VALUE
blas_s_sgemm(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, b, c=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, ka, kb, nb, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[3] = {{cT,2},{cT,2},{OVERWRITE,2}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_sgemm, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[5] = {id_alpha,id_beta,id_order,id_transa,id_transb};
#elif TR
ID kw_table[7] = {id_alpha,id_beta,id_order,id_side,id_uplo,id_transa,id_diag};
#else
ID kw_table[5] = {id_alpha,id_beta,id_order,id_side,id_uplo};
#endif
VALUE opts[7] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"sgemm");
rb_scan_args(argc, argv, "21:", &a, &b, &c, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 5+TR*2, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.transa = option_trans(opts[3]);
g.transb = option_trans(opts[4]);
#else
g.side = option_side(opts[3]);
g.uplo = option_uplo(opts[4]);
#endif
#if TR
g.transa = option_trans(opts[5]);
g.diag = option_diag(opts[6]);
#endif
GetNArray(a,na1);
GetNArray(b,na2);
CHECK_DIM_GE(na1,2);
CHECK_DIM_GE(na2,2);
ma = ROW_SIZE(na1); // m
ka = COL_SIZE(na1); // k (lda)
kb = ROW_SIZE(na2); // k
nb = COL_SIZE(na2); // n (ldb)
#if GE
SWAP_IFCOLTR(g.order,g.transa, ma,ka, tmp);
SWAP_IFCOLTR(g.order,g.transb, kb,nb, tmp);
CHECK_INT_EQ("ka",ka,"kb",kb);
g.m = ma;
g.n = nb;
g.k = ka;
#else
CHECK_SQUARE("a",na1); // ma == ka
SWAP_IFCOL(g.order, kb,nb, tmp);
// row major L R
//ma = ROW_SIZE(na1); // m or n
//ka = COL_SIZE(na1); // m or n (lda)
g.m = kb; // m
g.n = nb; // n (ldb)
if (g.side == CblasLeft) {
CHECK_SIZE_EQ(ka, g.m);
} else {
CHECK_SIZE_EQ(ka, g.n);
}
#endif
SWAP_IFROW(g.order, ma,nb, tmp);
#if TR
if (c != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(b,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, b);
return b;
#else
if (c == Qnil) { // c is not given.
ndfunc_arg_in_t ain_init = {sym_init,0};
ain[2] = ain_init;
ndf.nout = 1;
c = INT2FIX(0);
shape[0] = nb;
shape[1] = ma;
} else {
narray_t *na3;
int nc;
COPY_OR_CAST_TO(c,cT);
GetNArray(c,na3);
CHECK_DIM_GE(na3,2);
nc = ROW_SIZE(na3);
if (nc < nb) {
rb_raise(nary_eShapeError,"nc=%d must be >= nb=%d",nc,nb);
}
//CHECK_LEADING_GE("ldc",g.ldc,"m",ma);
}
{
VALUE ans = na_ndloop3(&ndf, &g, 3, a, b, c);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return c;
}
}
#endif
}
|
.sgemv(a, x, [y, alpha: 1, beta:0, trans:'N', order:'R']) ⇒ Numo::SFloat
SGEMV performs one of the matrix-vector operations
y := alpha*A*x + beta*y, or y := alpha*A**T*x + beta*y,
where alpha and beta are scalars, x and y are vectors and A is an m by n matrix.
888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 |
# File 'ext/numo/linalg/blas/blas_s.c', line 888
static VALUE
blas_s_sgemv(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, x, y=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, na, nx;
#if GE
blasint tmp;
#endif
size_t shape[1];
ndfunc_arg_in_t ain[4] = {{cT,2},{cT,1},{OVERWRITE,1},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,1,shape}};
ndfunc_t ndf = {iter_blas_s_sgemv, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[4] = {id_alpha,id_beta,id_order,id_trans};
#elif TR
ID kw_table[6] = {id_alpha,id_beta,id_order,id_uplo,id_trans,id_diag};
#else
ID kw_table[4] = {id_alpha,id_beta,id_order,id_uplo};
#endif
VALUE opts[6] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"sgemv");
rb_scan_args(argc, argv, "21:", &a, &x, &y, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 4+2*TR, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.trans = option_trans(opts[3]);
#else
g.uplo = option_uplo(opts[3]);
#endif
#if TR
g.trans = option_trans(opts[4]);
g.diag = option_diag(opts[5]);
#endif
GetNArray(a,na1);
CHECK_DIM_GE(na1,2);
ma = ROW_SIZE(na1);
na = COL_SIZE(na1);
GetNArray(x,na2);
CHECK_DIM_GE(na2,1);
nx = COL_SIZE(na2);
#if GE
SWAP_IFCOL(g.order, ma, na, tmp);
g.m = ma;
g.n = na;
SWAP_IFTRANS(g.trans, ma, na, tmp);
#else
CHECK_SQUARE("a",na1);
#endif
CHECK_INT_EQ("na",na,"nx",nx);
shape[0] = ma;
#if TR
if (y != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(x,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, x);
return x;
#else // GE,SY,HE
if (y == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
y = INT2FIX(0);
shape[0] = ma;
} else {
narray_t *na3;
COPY_OR_CAST_TO(y,cT);
GetNArray(y,na3);
CHECK_DIM_GE(na3,1);
CHECK_SIZE_GE(na3,nx);
}
{
VALUE ans;
ans = na_ndloop3(&ndf, &g, 3, a, x, y);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return y;
}
}
#endif
}
|
.sger(x, y, [a, alpha: 1, order:'R']) ⇒ Numo::SFloat
SGER performs the rank 1 operation
A := alpha*x*y**T + A,
where alpha is a scalar, x is an m element vector, y is an n element vector and A is an m by n matrix.
1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 |
# File 'ext/numo/linalg/blas/blas_s.c', line 1525
static VALUE
blas_s_sger(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE ans;
VALUE x, y, a=Qnil, alpha;
narray_t *na1, *na2;
blasint mx, ny, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[4] = {{cT,1},{cT,1},{OVERWRITE,2},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_sger, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
ID kw_table[2] = {id_alpha,id_order};
VALUE opts[2] = {Qundef};
CHECK_FUNC(func_p,"sger");
rb_scan_args(argc, argv, "21:", &x, &y, &a, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 2, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
g.order = option_order(opts[1]);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
mx = COL_SIZE(na1); // m
ny = COL_SIZE(na2); // n
g.m = mx;
g.n = ny;
SWAP_IFCOL(g.order, mx,ny, tmp);
if (a == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
a = INT2FIX(0);
shape[0] = mx;
shape[1] = ny;
} else {
narray_t *na3;
blasint ma, na;
COPY_OR_CAST_TO(a,cT);
GetNArray(a,na3);
CHECK_DIM_GE(na3,2);
ma = ROW_SIZE(na3); // m
na = COL_SIZE(na3); // n (lda)
CHECK_SIZE_EQ(ma,mx);
CHECK_SIZE_EQ(na,ny);
}
ans = na_ndloop3(&ndf, &g, 3, x, y, a);
if (ndf.nout = 1) { // a is not given.
return ans;
} else {
return a;
}
}
|
.snrm2(x) ⇒ Numo::SFloat
SNRM2 returns the euclidean norm of a vector via the function name, so that
SNRM2 := sqrt( x'*x ).
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'ext/numo/linalg/blas/blas_s.c', line 159
static VALUE
blas_s_snrm2(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE x, keepdims, ans;
narray_t *na1;
ndfunc_arg_in_t ain[1] = {{cT,1}};
ndfunc_arg_out_t aout[1] = {{cT,0}};
ndfunc_t ndf = {iter_blas_s_snrm2, NDF_EXTRACT, 1,1, ain,aout};
VALUE opts[1] = {Qundef};
ID kw_table[1] = {id_keepdims};
VALUE kw_hash = Qnil;
CHECK_FUNC(func_p,"snrm2");
rb_scan_args(argc, argv, "1:", &x, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 1, opts);
keepdims = option_value(opts[0],Qfalse);
if (RTEST(keepdims)) {
ndf.flag |= NDF_KEEP_DIM;
}
GetNArray(x,na1);
CHECK_DIM_GE(na1,1);
CHECK_NON_EMPTY(na1);
ans = na_ndloop(&ndf, 1, x);
return ans;
}
|
.srot(x, y, c, s) ⇒ Array<Numo::SFloat,Numo::SFloat>
applies a plane rotation.
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 |
# File 'ext/numo/linalg/blas/blas_s.c', line 630
static VALUE
blas_s_srot(VALUE UNUSED(mod), VALUE x, VALUE y, VALUE c, VALUE s)
{
rtype g[2] = {0,0};
narray_t *na1, *na2;
ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{OVERWRITE,0}};
ndfunc_t ndf = {iter_blas_s_srot, STRIDE_LOOP, 2,0, ain,0};
CHECK_FUNC(func_p,"srot");
if (RTEST(c)) {g[0] = NUM2DBL(c);}
if (RTEST(s)) {g[1] = NUM2DBL(s);}
COPY_OR_CAST_TO(x,cT);
COPY_OR_CAST_TO(y,cT);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
CHECK_NON_EMPTY(na1);
CHECK_NON_EMPTY(na2);
CHECK_SAME_SHAPE(na1,na2);
na_ndloop3(&ndf, g, 2, x, y);
return rb_assoc_new(x,y);
}
|
.srotm(x, y, param) ⇒ Array<Numo::SFloat,Numo::SFloat>
Apply the modified givens transformation, H, to the 2 by N matrix (X**T), where **T indicates transpose. The elements of X are in (Y**T)
X(LX+I*INCX), I = 0 to N-1, where LX = 1 if INCX .GE. 0, else LX = (-INCX)*N, and similarly for Y using LY and INCY. With PARAM(1)=FLAG, H has one of the following forms..
FLAG=-1.0 FLAG=0.0 FLAG=1.0 FLAG=-2.0
(H11 H12) (1.0 H12) (H11 1.0) (1.0 0.0)
H=( ) ( ) ( ) ( )
(H21 H22), (H21 1.0), (-1.0 H22), (0.0 1.0).
see SROTMG for a description of data storage in param.
707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 |
# File 'ext/numo/linalg/blas/blas_s.c', line 707
static VALUE
blas_s_srotm(VALUE UNUSED(mod), VALUE x, VALUE y, VALUE param)
{
dtype *g;
narray_t *na1, *na2, *nap;
ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{OVERWRITE,0}};
ndfunc_t ndf = {iter_blas_s_srotm, STRIDE_LOOP, 2,0, ain,0};
CHECK_FUNC(func_p,"srotm");
COPY_OR_CAST_TO(x,cT);
COPY_OR_CAST_TO(y,cT);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
CHECK_NON_EMPTY(na1);
CHECK_NON_EMPTY(na2);
CHECK_SAME_SHAPE(na1,na2);
param = rb_funcall(cT,rb_intern("cast"),1,param);
GetNArray(param,nap);
CHECK_DIM_EQ(nap,1);
CHECK_SIZE_GE(nap,5);
g = (dtype*)nary_get_pointer_for_read(param);
na_ndloop3(&ndf, g, 2, x, y);
RB_GC_GUARD(param);
return rb_assoc_new(x,y);
}
|
.sscal(a, x) ⇒ Numo::SFloat
scales a vector by a constant. uses unrolled loops for increment equal to 1.
779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 |
# File 'ext/numo/linalg/blas/blas_s.c', line 779
static VALUE
blas_s_sscal(VALUE mod, VALUE a, VALUE x)
{
scal_t g[1];
narray_t *na1;
ndfunc_arg_in_t ain[1] = {{OVERWRITE,0}};
ndfunc_t ndf = {iter_blas_s_sscal, STRIDE_LOOP, 1,0, ain,0};
CHECK_FUNC(func_p,"sscal");
#line 56 "gen/../tmpl/scal.c"
if (RTEST(a)) {g[0] = m_num_to_data(a);} else {g[0]=m_one;}
COPY_OR_CAST_TO(x,cT);
GetNArray(x,na1);
CHECK_DIM_GE(na1,1);
CHECK_NON_EMPTY(na1);
na_ndloop3(&ndf, g, 1, x);
return x;
}
|
.sswap(x, y) ⇒ nil
interchanges two vectors. uses unrolled loops for increments equal to 1.
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
# File 'ext/numo/linalg/blas/blas_s.c', line 438
static VALUE
blas_s_sswap(VALUE UNUSED(mod), VALUE x, VALUE y)
{
narray_t *na1, *na2;
ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{OVERWRITE,0}};
ndfunc_t ndf = {iter_blas_s_sswap, STRIDE_LOOP, 2,0, ain,0};
CHECK_FUNC(func_p,"sswap");
CHECK_NARRAY_TYPE(x,cT);
CHECK_NARRAY_TYPE(y,cT);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
CHECK_NON_EMPTY(na1);
CHECK_NON_EMPTY(na2);
CHECK_SAME_SHAPE(na1,na2);
na_ndloop(&ndf, 2, x, y);
return Qnil;
}
|
.ssymm(a, b, [c, alpha: 1, beta:0, side:'L', uplo:'U', order:'R']) ⇒ Numo::SFloat
SSYMM performs one of the matrix-matrix operations
C := alpha*A*B + beta*C,
or
C := alpha*B*A + beta*C,
where alpha and beta are scalars, A is a symmetric matrix and B and C are m by n matrices.
1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 |
# File 'ext/numo/linalg/blas/blas_s.c', line 1996
static VALUE
blas_s_ssymm(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, b, c=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, ka, kb, nb, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[3] = {{cT,2},{cT,2},{OVERWRITE,2}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_ssymm, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[5] = {id_alpha,id_beta,id_order,id_transa,id_transb};
#elif TR
ID kw_table[7] = {id_alpha,id_beta,id_order,id_side,id_uplo,id_transa,id_diag};
#else
ID kw_table[5] = {id_alpha,id_beta,id_order,id_side,id_uplo};
#endif
VALUE opts[7] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"ssymm");
rb_scan_args(argc, argv, "21:", &a, &b, &c, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 5+TR*2, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.transa = option_trans(opts[3]);
g.transb = option_trans(opts[4]);
#else
g.side = option_side(opts[3]);
g.uplo = option_uplo(opts[4]);
#endif
#if TR
g.transa = option_trans(opts[5]);
g.diag = option_diag(opts[6]);
#endif
GetNArray(a,na1);
GetNArray(b,na2);
CHECK_DIM_GE(na1,2);
CHECK_DIM_GE(na2,2);
ma = ROW_SIZE(na1); // m
ka = COL_SIZE(na1); // k (lda)
kb = ROW_SIZE(na2); // k
nb = COL_SIZE(na2); // n (ldb)
#if GE
SWAP_IFCOLTR(g.order,g.transa, ma,ka, tmp);
SWAP_IFCOLTR(g.order,g.transb, kb,nb, tmp);
CHECK_INT_EQ("ka",ka,"kb",kb);
g.m = ma;
g.n = nb;
g.k = ka;
#else
CHECK_SQUARE("a",na1); // ma == ka
SWAP_IFCOL(g.order, kb,nb, tmp);
// row major L R
//ma = ROW_SIZE(na1); // m or n
//ka = COL_SIZE(na1); // m or n (lda)
g.m = kb; // m
g.n = nb; // n (ldb)
if (g.side == CblasLeft) {
CHECK_SIZE_EQ(ka, g.m);
} else {
CHECK_SIZE_EQ(ka, g.n);
}
#endif
SWAP_IFROW(g.order, ma,nb, tmp);
#if TR
if (c != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(b,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, b);
return b;
#else
if (c == Qnil) { // c is not given.
ndfunc_arg_in_t ain_init = {sym_init,0};
ain[2] = ain_init;
ndf.nout = 1;
c = INT2FIX(0);
shape[0] = nb;
shape[1] = ma;
} else {
narray_t *na3;
int nc;
COPY_OR_CAST_TO(c,cT);
GetNArray(c,na3);
CHECK_DIM_GE(na3,2);
nc = ROW_SIZE(na3);
if (nc < nb) {
rb_raise(nary_eShapeError,"nc=%d must be >= nb=%d",nc,nb);
}
//CHECK_LEADING_GE("ldc",g.ldc,"m",ma);
}
{
VALUE ans = na_ndloop3(&ndf, &g, 3, a, b, c);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return c;
}
}
#endif
}
|
.ssymv(a, x, [y, alpha: 1, beta:0, uplo:'U', order:'R']) ⇒ Numo::SFloat
SSYMV performs the matrix-vector operation
y := alpha*A*x + beta*y,
where alpha and beta are scalars, x and y are n element vectors and A is an n by n symmetric matrix.
1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 |
# File 'ext/numo/linalg/blas/blas_s.c', line 1262
static VALUE
blas_s_ssymv(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, x, y=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, na, nx;
#if GE
blasint tmp;
#endif
size_t shape[1];
ndfunc_arg_in_t ain[4] = {{cT,2},{cT,1},{OVERWRITE,1},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,1,shape}};
ndfunc_t ndf = {iter_blas_s_ssymv, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[4] = {id_alpha,id_beta,id_order,id_trans};
#elif TR
ID kw_table[6] = {id_alpha,id_beta,id_order,id_uplo,id_trans,id_diag};
#else
ID kw_table[4] = {id_alpha,id_beta,id_order,id_uplo};
#endif
VALUE opts[6] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"ssymv");
rb_scan_args(argc, argv, "21:", &a, &x, &y, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 4+2*TR, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.trans = option_trans(opts[3]);
#else
g.uplo = option_uplo(opts[3]);
#endif
#if TR
g.trans = option_trans(opts[4]);
g.diag = option_diag(opts[5]);
#endif
GetNArray(a,na1);
CHECK_DIM_GE(na1,2);
ma = ROW_SIZE(na1);
na = COL_SIZE(na1);
GetNArray(x,na2);
CHECK_DIM_GE(na2,1);
nx = COL_SIZE(na2);
#if GE
SWAP_IFCOL(g.order, ma, na, tmp);
g.m = ma;
g.n = na;
SWAP_IFTRANS(g.trans, ma, na, tmp);
#else
CHECK_SQUARE("a",na1);
#endif
CHECK_INT_EQ("na",na,"nx",nx);
shape[0] = ma;
#if TR
if (y != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(x,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, x);
return x;
#else // GE,SY,HE
if (y == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
y = INT2FIX(0);
shape[0] = ma;
} else {
narray_t *na3;
COPY_OR_CAST_TO(y,cT);
GetNArray(y,na3);
CHECK_DIM_GE(na3,1);
CHECK_SIZE_GE(na3,nx);
}
{
VALUE ans;
ans = na_ndloop3(&ndf, &g, 3, a, x, y);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return y;
}
}
#endif
}
|
.ssyr(x, [a, alpha: 1, uplo:'U', order:'R']) ⇒ Numo::SFloat
SSYR performs the symmetric rank 1 operation
A := alpha*x*x**T + A,
where alpha is a real scalar, x is an n element vector and A is an n by n symmetric matrix.
1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 |
# File 'ext/numo/linalg/blas/blas_s.c', line 1416
static VALUE
blas_s_ssyr(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE ans;
VALUE x, a, alpha;
narray_t *na1, *na3;
blasint nx, na;
size_t shape[2];
ndfunc_arg_in_t ain[3] = {{cT,1},{OVERWRITE,2},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_ssyr, NO_LOOP, 2, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
ID kw_table[3] = {id_alpha,id_order,id_uplo};
VALUE opts[3] = {Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"ssyr");
rb_scan_args(argc, argv, "11:", &x, &a, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 3, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? NUM2DBL(alpha) : 1;
g.order = option_order(opts[1]);
g.uplo = option_uplo(opts[2]);
GetNArray(x,na1);
CHECK_DIM_GE(na1,1);
nx = COL_SIZE(na1); // n
if (a == Qnil) { // c is not given.
ndf.nout = 1;
ain[1] = ain[2];
a = INT2FIX(0);
shape[0] = shape[1] = nx;
} else {
COPY_OR_CAST_TO(a,cT);
GetNArray(a,na3);
CHECK_DIM_GE(na3,2);
CHECK_SQUARE("a",na3);
na = COL_SIZE(na3); // n (lda)
CHECK_SIZE_EQ(na,nx);
}
ans = na_ndloop3(&ndf, &g, 2, x, a);
if (ndf.nout == 1) { // a is not given.
return ans;
} else {
return a;
}
}
|
.ssyr2(x, y, [a, alpha: 1, uplo:'U', order:'R']) ⇒ Numo::SFloat
SSYR2 performs the symmetric rank 2 operation
A := alpha*x*y**T + alpha*y*x**T + A,
where alpha is a scalar, x and y are n element vectors and A is an n by n symmetric matrix.
1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 |
# File 'ext/numo/linalg/blas/blas_s.c', line 1645
static VALUE
blas_s_ssyr2(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE ans;
VALUE x, y, a, alpha;
narray_t *na1, *na2, *na3;
blasint nx, ny, na;
size_t shape[2];
ndfunc_arg_in_t ain[4] = {{cT,1},{cT,1},{OVERWRITE,2},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_ssyr2, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
ID kw_table[3] = {id_alpha,id_order,id_uplo};
VALUE opts[3] = {Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"ssyr2");
rb_scan_args(argc, argv, "21:", &x, &y, &a, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 3, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
g.order = option_order(opts[1]);
g.uplo = option_uplo(opts[2]);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
nx = COL_SIZE(na1); // n
ny = COL_SIZE(na2); // n
CHECK_INT_EQ("nx",nx,"ny",ny);
if (a == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
a = INT2FIX(0);
shape[0] = shape[1] = nx;
} else {
COPY_OR_CAST_TO(a,cT);
GetNArray(a,na3);
CHECK_DIM_GE(na3,2);
CHECK_SQUARE("a",na3);
na = COL_SIZE(na3); // n (lda)
CHECK_SIZE_EQ(na,nx);
}
ans = na_ndloop3(&ndf, &g, 3, x, y, a);
if (ndf.nout == 1) { // a is not given.
return ans;
} else {
return a;
}
}
|
.ssyr2k(a, b, [c, alpha: 1, beta:0, uplo:'U', trans:'N', order:'R']) ⇒ Numo::SFloat
SSYR2K performs one of the symmetric rank 2k operations
C := alpha*A*B**T + alpha*B*A**T + beta*C,
or
C := alpha*A**T*B + alpha*B**T*A + beta*C,
where alpha and beta are scalars, C is an n by n symmetric matrix and A and B are n by k matrices in the first case and k by n matrices in the second case.
2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 |
# File 'ext/numo/linalg/blas/blas_s.c', line 2518
static VALUE
blas_s_ssyr2k(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE ans;
VALUE a, b, c=Qnil, alpha, beta;
narray_t *na1, *na2, *na3;
blasint na, ka, kb, nb, nc, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[4] = {{cT,2},{cT,2},{OVERWRITE,2},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_ssyr2k, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
ID kw_table[5] = {id_alpha,id_beta,id_order,id_uplo,id_trans};
VALUE opts[5] = {Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"ssyr2k");
rb_scan_args(argc, argv, "21:", &a, &b, &c, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 5, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
g.uplo = option_uplo(opts[3]);
g.trans = option_trans(opts[4]);
GetNArray(a,na1);
GetNArray(b,na2);
CHECK_DIM_GE(na1,2);
CHECK_DIM_GE(na2,2);
na = ROW_SIZE(na1); // n
ka = COL_SIZE(na1); // k (lda)
SWAP_IFCOLTR(g.order, g.trans, na, ka, tmp);
nb = ROW_SIZE(na2); // n
kb = COL_SIZE(na2); // k (ldb)
SWAP_IFCOLTR(g.order, g.trans, kb, nb, tmp);
CHECK_INT_EQ("na",na,"nb",nb);
CHECK_INT_EQ("ka",ka,"kb",kb);
g.n = nb;
g.k = kb;
SWAP_IFROW(g.order, na, nb, tmp);
if (c == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
c = INT2FIX(0);
shape[0] = nb;
shape[1] = na;
} else {
COPY_OR_CAST_TO(c,cT);
GetNArray(c,na3);
CHECK_DIM_GE(na3,2);
nc = ROW_SIZE(na3); // n
if (nc < nb) {
rb_raise(nary_eShapeError,"nc=%d must be >= nb=%d",nc,nb);
}
//CHECK_LEADING_GE("ldc",g.ldc,"n",na);
}
ans = na_ndloop3(&ndf, &g, 3, a, b, c);
if (ndf.nout = 1) { // c is not given.
return ans;
} else {
return c;
}
}
|
.ssyrk(a, [c, alpha: 1, beta:0, uplo:'U', trans:'N', order:'R']) ⇒ Numo::SFloat
SSYRK performs one of the symmetric rank k operations
C := alpha*A*A**T + beta*C,
or
C := alpha*A**T*A + beta*C,
where alpha and beta are scalars, C is an n by n symmetric matrix and A is an n by k matrix in the first case and a k by n matrix in the second case.
2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 |
# File 'ext/numo/linalg/blas/blas_s.c', line 2387
static VALUE
blas_s_ssyrk(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE ans;
VALUE a, c, alpha, beta;
narray_t *na1, *na3;
blasint na, ka, nc, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[3] = {{cT,2},{OVERWRITE,2},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_ssyrk, NO_LOOP, 2, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
ID kw_table[5] = {id_alpha,id_beta,id_order,id_uplo,id_trans};
VALUE opts[5] = {Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"ssyrk");
rb_scan_args(argc, argv, "11:", &a, &c, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 5, opts);
alpha = option_value(opts[0],Qnil);
beta = option_value(opts[1],Qnil);
#line 88 "gen/../tmpl/syrk.c"
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
#line 91 "gen/../tmpl/syrk.c"
g.order = option_order(opts[2]);
g.uplo = option_uplo(opts[3]);
g.trans = option_trans(opts[4]);
GetNArray(a,na1);
CHECK_DIM_GE(na1,2);
na = ROW_SIZE(na1); // n
ka = COL_SIZE(na1); // k (lda)
SWAP_IFCOLTR(g.order,g.trans, na,ka, tmp);
g.n = na;
g.k = ka;
if (c == Qnil) { // c is not given.
ndf.nout = 1;
ain[1] = ain[2];
c = INT2FIX(0);
shape[0] = na;
shape[1] = na;
} else {
COPY_OR_CAST_TO(c,cT);
GetNArray(c,na3);
CHECK_DIM_GE(na3,2);
nc = ROW_SIZE(na3);
if (nc < na) {
rb_raise(nary_eShapeError,"nc=%d must be >= na=%d",nc,na);
}
//CHECK_LEADING_GE("ldc",g.ldc,"n",na);
}
ans = na_ndloop3(&ndf, &g, 2, a, c);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return c;
}
}
|
.strmm(a, b, [alpha: 1, side:'L', uplo:'U', transa:'N', diag:'U', order:'R']) ⇒ Numo::SFloat
STRMM performs one of the matrix-matrix operations
B := alpha*op( A )*B, or B := alpha*B*op( A ),
where alpha is a scalar, B is an m by n matrix, A is a unit, or non-unit, upper or lower triangular matrix and op( A ) is one of
op( A ) = A or op( A ) = A**T.
2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 |
# File 'ext/numo/linalg/blas/blas_s.c', line 2201
static VALUE
blas_s_strmm(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, b, c=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, ka, kb, nb, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[3] = {{cT,2},{cT,2},{OVERWRITE,2}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_strmm, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[5] = {id_alpha,id_beta,id_order,id_transa,id_transb};
#elif TR
ID kw_table[7] = {id_alpha,id_beta,id_order,id_side,id_uplo,id_transa,id_diag};
#else
ID kw_table[5] = {id_alpha,id_beta,id_order,id_side,id_uplo};
#endif
VALUE opts[7] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"strmm");
rb_scan_args(argc, argv, "21:", &a, &b, &c, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 5+TR*2, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.transa = option_trans(opts[3]);
g.transb = option_trans(opts[4]);
#else
g.side = option_side(opts[3]);
g.uplo = option_uplo(opts[4]);
#endif
#if TR
g.transa = option_trans(opts[5]);
g.diag = option_diag(opts[6]);
#endif
GetNArray(a,na1);
GetNArray(b,na2);
CHECK_DIM_GE(na1,2);
CHECK_DIM_GE(na2,2);
ma = ROW_SIZE(na1); // m
ka = COL_SIZE(na1); // k (lda)
kb = ROW_SIZE(na2); // k
nb = COL_SIZE(na2); // n (ldb)
#if GE
SWAP_IFCOLTR(g.order,g.transa, ma,ka, tmp);
SWAP_IFCOLTR(g.order,g.transb, kb,nb, tmp);
CHECK_INT_EQ("ka",ka,"kb",kb);
g.m = ma;
g.n = nb;
g.k = ka;
#else
CHECK_SQUARE("a",na1); // ma == ka
SWAP_IFCOL(g.order, kb,nb, tmp);
// row major L R
//ma = ROW_SIZE(na1); // m or n
//ka = COL_SIZE(na1); // m or n (lda)
g.m = kb; // m
g.n = nb; // n (ldb)
if (g.side == CblasLeft) {
CHECK_SIZE_EQ(ka, g.m);
} else {
CHECK_SIZE_EQ(ka, g.n);
}
#endif
SWAP_IFROW(g.order, ma,nb, tmp);
#if TR
if (c != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(b,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, b);
return b;
#else
if (c == Qnil) { // c is not given.
ndfunc_arg_in_t ain_init = {sym_init,0};
ain[2] = ain_init;
ndf.nout = 1;
c = INT2FIX(0);
shape[0] = nb;
shape[1] = ma;
} else {
narray_t *na3;
int nc;
COPY_OR_CAST_TO(c,cT);
GetNArray(c,na3);
CHECK_DIM_GE(na3,2);
nc = ROW_SIZE(na3);
if (nc < nb) {
rb_raise(nary_eShapeError,"nc=%d must be >= nb=%d",nc,nb);
}
//CHECK_LEADING_GE("ldc",g.ldc,"m",ma);
}
{
VALUE ans = na_ndloop3(&ndf, &g, 3, a, b, c);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return c;
}
}
#endif
}
|
.strmv(a, x, [uplo: 'U', trans:'N', diag:'U', order:'R']) ⇒ Numo::SFloat
STRMV performs one of the matrix-vector operations
x := A*x, or x := A**T*x,
where x is an n element vector and A is an n by n unit, or non-unit, upper or lower triangular matrix.
1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 |
# File 'ext/numo/linalg/blas/blas_s.c', line 1075
static VALUE
blas_s_strmv(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, x, y=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, na, nx;
#if GE
blasint tmp;
#endif
size_t shape[1];
ndfunc_arg_in_t ain[4] = {{cT,2},{cT,1},{OVERWRITE,1},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,1,shape}};
ndfunc_t ndf = {iter_blas_s_strmv, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[4] = {id_alpha,id_beta,id_order,id_trans};
#elif TR
ID kw_table[6] = {id_alpha,id_beta,id_order,id_uplo,id_trans,id_diag};
#else
ID kw_table[4] = {id_alpha,id_beta,id_order,id_uplo};
#endif
VALUE opts[6] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"strmv");
rb_scan_args(argc, argv, "21:", &a, &x, &y, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 4+2*TR, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.trans = option_trans(opts[3]);
#else
g.uplo = option_uplo(opts[3]);
#endif
#if TR
g.trans = option_trans(opts[4]);
g.diag = option_diag(opts[5]);
#endif
GetNArray(a,na1);
CHECK_DIM_GE(na1,2);
ma = ROW_SIZE(na1);
na = COL_SIZE(na1);
GetNArray(x,na2);
CHECK_DIM_GE(na2,1);
nx = COL_SIZE(na2);
#if GE
SWAP_IFCOL(g.order, ma, na, tmp);
g.m = ma;
g.n = na;
SWAP_IFTRANS(g.trans, ma, na, tmp);
#else
CHECK_SQUARE("a",na1);
#endif
CHECK_INT_EQ("na",na,"nx",nx);
shape[0] = ma;
#if TR
if (y != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(x,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, x);
return x;
#else // GE,SY,HE
if (y == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
y = INT2FIX(0);
shape[0] = ma;
} else {
narray_t *na3;
COPY_OR_CAST_TO(y,cT);
GetNArray(y,na3);
CHECK_DIM_GE(na3,1);
CHECK_SIZE_GE(na3,nx);
}
{
VALUE ans;
ans = na_ndloop3(&ndf, &g, 3, a, x, y);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return y;
}
}
#endif
}
|
.zaxpy(x, y, [alpha: 1]) ⇒ Numo::DComplex
ZAXPY constant times a vector plus a vector.
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 |
# File 'ext/numo/linalg/blas/blas_z.c', line 481
static VALUE
blas_s_zaxpy(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE x, y, alpha;
narray_t *na1, *na2;
ndfunc_arg_in_t ain[2] = {{cT,0},{OVERWRITE,0}};
ndfunc_t ndf = {iter_blas_s_zaxpy, STRIDE_LOOP, 2, 0, ain, 0};
dtype g;
VALUE kw_hash = Qnil;
ID kw_table[1] = {id_alpha};
VALUE opts[1] = {Qundef};
CHECK_FUNC(func_p,"zaxpy");
rb_scan_args(argc, argv, "2:", &x, &y, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 1, opts);
alpha = option_value(opts[0],Qnil);
g = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
COPY_OR_CAST_TO(y,cT);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
CHECK_NON_EMPTY(na1);
CHECK_NON_EMPTY(na2);
CHECK_SAME_SHAPE(na1,na2);
na_ndloop3(&ndf, &g, 2, x, y);
return y;
}
|
.zcopy(x, y) ⇒ nil
ZCOPY copies a vector, x, to a vector, y.
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 |
# File 'ext/numo/linalg/blas/blas_z.c', line 417
static VALUE
blas_s_zcopy(VALUE UNUSED(mod), VALUE x, VALUE y)
{
narray_t *na1, *na2;
ndfunc_arg_in_t ain[2] = {{cT,0},{OVERWRITE,0}};
ndfunc_t ndf = {iter_blas_s_zcopy, STRIDE_LOOP, 2,0, ain,0};
CHECK_FUNC(func_p,"zcopy");
CHECK_NARRAY_TYPE(x,cT);
CHECK_NARRAY_TYPE(y,cT);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
CHECK_NON_EMPTY(na1);
CHECK_NON_EMPTY(na2);
CHECK_SAME_SHAPE(na1,na2);
na_ndloop(&ndf, 2, x, y);
return Qnil;
}
|
.zdotc(x, y) ⇒ Numo::DComplex
ZDOTC forms the dot product of two complex vectors
ZDOTC = X^H * Y
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'ext/numo/linalg/blas/blas_z.c', line 98
static VALUE
blas_s_zdotc(VALUE mod, VALUE x, VALUE y)
{
VALUE ans;
narray_t *na1, *na2;
size_t nx, ny, shape[1]={1};
ndfunc_arg_in_t ain[2] = {{cT,1},{cT,1}};
ndfunc_arg_out_t aout[1] = {{numo_cDComplex,0,shape}};
ndfunc_t ndf = {iter_blas_s_zdotc, NDF_EXTRACT, 2,1, ain,aout};
CHECK_FUNC(func_p,"zdotc_sub");
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
CHECK_NON_EMPTY(na1);
CHECK_NON_EMPTY(na2);
nx = COL_SIZE(na1);
ny = COL_SIZE(na2);
CHECK_SIZE_EQ(nx,ny);
ans = na_ndloop(&ndf, 2, x, y);
return ans;
}
|
.zdotu(x, y) ⇒ Numo::DComplex
ZDOTU forms the dot product of two complex vectors
ZDOTU = X^T * Y
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'ext/numo/linalg/blas/blas_z.c', line 165
static VALUE
blas_s_zdotu(VALUE mod, VALUE x, VALUE y)
{
VALUE ans;
narray_t *na1, *na2;
size_t nx, ny, shape[1]={1};
ndfunc_arg_in_t ain[2] = {{cT,1},{cT,1}};
ndfunc_arg_out_t aout[1] = {{numo_cDComplex,0,shape}};
ndfunc_t ndf = {iter_blas_s_zdotu, NDF_EXTRACT, 2,1, ain,aout};
CHECK_FUNC(func_p,"zdotu_sub");
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
CHECK_NON_EMPTY(na1);
CHECK_NON_EMPTY(na2);
nx = COL_SIZE(na1);
ny = COL_SIZE(na2);
CHECK_SIZE_EQ(nx,ny);
ans = na_ndloop(&ndf, 2, x, y);
return ans;
}
|
.zdscal(a, x) ⇒ Numo::DComplex
ZDSCAL scales a vector by a constant.
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 |
# File 'ext/numo/linalg/blas/blas_z.c', line 618
static VALUE
blas_s_zdscal(VALUE mod, VALUE a, VALUE x)
{
scal_t g[1];
narray_t *na1;
ndfunc_arg_in_t ain[1] = {{OVERWRITE,0}};
ndfunc_t ndf = {iter_blas_s_zdscal, STRIDE_LOOP, 1,0, ain,0};
CHECK_FUNC(func_p,"zdscal");
if (RTEST(a)) {g[0] = NUM2DBL(a);} else {g[0]=1;}
#line 58 "gen/../tmpl/scal.c"
COPY_OR_CAST_TO(x,cT);
GetNArray(x,na1);
CHECK_DIM_GE(na1,1);
CHECK_NON_EMPTY(na1);
na_ndloop3(&ndf, g, 1, x);
return x;
}
|
.zgemm(a, b, [c, alpha: 1, beta:0, transa:'N', transb:'N', order:'R']) ⇒ Numo::DComplex
ZGEMM performs one of the matrix-matrix operations
C := alpha*op( A )*op( B ) + beta*C,
where op( X ) is one of
op( X ) = X or op( X ) = X**T or op( X ) = X**H,
alpha and beta are scalars, and A, B and C are matrices, with op( A ) an m by k matrix, op( B ) a k by n matrix and C an m by n matrix.
1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 |
# File 'ext/numo/linalg/blas/blas_z.c', line 1881
static VALUE
blas_s_zgemm(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, b, c=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, ka, kb, nb, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[3] = {{cT,2},{cT,2},{OVERWRITE,2}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_zgemm, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[5] = {id_alpha,id_beta,id_order,id_transa,id_transb};
#elif TR
ID kw_table[7] = {id_alpha,id_beta,id_order,id_side,id_uplo,id_transa,id_diag};
#else
ID kw_table[5] = {id_alpha,id_beta,id_order,id_side,id_uplo};
#endif
VALUE opts[7] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"zgemm");
rb_scan_args(argc, argv, "21:", &a, &b, &c, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 5+TR*2, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.transa = option_trans(opts[3]);
g.transb = option_trans(opts[4]);
#else
g.side = option_side(opts[3]);
g.uplo = option_uplo(opts[4]);
#endif
#if TR
g.transa = option_trans(opts[5]);
g.diag = option_diag(opts[6]);
#endif
GetNArray(a,na1);
GetNArray(b,na2);
CHECK_DIM_GE(na1,2);
CHECK_DIM_GE(na2,2);
ma = ROW_SIZE(na1); // m
ka = COL_SIZE(na1); // k (lda)
kb = ROW_SIZE(na2); // k
nb = COL_SIZE(na2); // n (ldb)
#if GE
SWAP_IFCOLTR(g.order,g.transa, ma,ka, tmp);
SWAP_IFCOLTR(g.order,g.transb, kb,nb, tmp);
CHECK_INT_EQ("ka",ka,"kb",kb);
g.m = ma;
g.n = nb;
g.k = ka;
#else
CHECK_SQUARE("a",na1); // ma == ka
SWAP_IFCOL(g.order, kb,nb, tmp);
// row major L R
//ma = ROW_SIZE(na1); // m or n
//ka = COL_SIZE(na1); // m or n (lda)
g.m = kb; // m
g.n = nb; // n (ldb)
if (g.side == CblasLeft) {
CHECK_SIZE_EQ(ka, g.m);
} else {
CHECK_SIZE_EQ(ka, g.n);
}
#endif
SWAP_IFROW(g.order, ma,nb, tmp);
#if TR
if (c != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(b,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, b);
return b;
#else
if (c == Qnil) { // c is not given.
ndfunc_arg_in_t ain_init = {sym_init,0};
ain[2] = ain_init;
ndf.nout = 1;
c = INT2FIX(0);
shape[0] = nb;
shape[1] = ma;
} else {
narray_t *na3;
int nc;
COPY_OR_CAST_TO(c,cT);
GetNArray(c,na3);
CHECK_DIM_GE(na3,2);
nc = ROW_SIZE(na3);
if (nc < nb) {
rb_raise(nary_eShapeError,"nc=%d must be >= nb=%d",nc,nb);
}
//CHECK_LEADING_GE("ldc",g.ldc,"m",ma);
}
{
VALUE ans = na_ndloop3(&ndf, &g, 3, a, b, c);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return c;
}
}
#endif
}
|
.zgemv(a, x, [y, alpha: 1, beta:0, trans:'N', order:'R']) ⇒ Numo::DComplex
ZGEMV performs one of the matrix-vector operations
y := alpha*A*x + beta*y, or y := alpha*A**T*x + beta*y, or
y := alpha*A**H*x + beta*y,
where alpha and beta are scalars, x and y are vectors and A is an m by n matrix.
728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 |
# File 'ext/numo/linalg/blas/blas_z.c', line 728
static VALUE
blas_s_zgemv(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, x, y=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, na, nx;
#if GE
blasint tmp;
#endif
size_t shape[1];
ndfunc_arg_in_t ain[4] = {{cT,2},{cT,1},{OVERWRITE,1},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,1,shape}};
ndfunc_t ndf = {iter_blas_s_zgemv, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[4] = {id_alpha,id_beta,id_order,id_trans};
#elif TR
ID kw_table[6] = {id_alpha,id_beta,id_order,id_uplo,id_trans,id_diag};
#else
ID kw_table[4] = {id_alpha,id_beta,id_order,id_uplo};
#endif
VALUE opts[6] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"zgemv");
rb_scan_args(argc, argv, "21:", &a, &x, &y, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 4+2*TR, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.trans = option_trans(opts[3]);
#else
g.uplo = option_uplo(opts[3]);
#endif
#if TR
g.trans = option_trans(opts[4]);
g.diag = option_diag(opts[5]);
#endif
GetNArray(a,na1);
CHECK_DIM_GE(na1,2);
ma = ROW_SIZE(na1);
na = COL_SIZE(na1);
GetNArray(x,na2);
CHECK_DIM_GE(na2,1);
nx = COL_SIZE(na2);
#if GE
SWAP_IFCOL(g.order, ma, na, tmp);
g.m = ma;
g.n = na;
SWAP_IFTRANS(g.trans, ma, na, tmp);
#else
CHECK_SQUARE("a",na1);
#endif
CHECK_INT_EQ("na",na,"nx",nx);
shape[0] = ma;
#if TR
if (y != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(x,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, x);
return x;
#else // GE,SY,HE
if (y == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
y = INT2FIX(0);
shape[0] = ma;
} else {
narray_t *na3;
COPY_OR_CAST_TO(y,cT);
GetNArray(y,na3);
CHECK_DIM_GE(na3,1);
CHECK_SIZE_GE(na3,nx);
}
{
VALUE ans;
ans = na_ndloop3(&ndf, &g, 3, a, x, y);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return y;
}
}
#endif
}
|
.zgerc(x, y, [a, alpha: 1, order:'R']) ⇒ Numo::DComplex
ZGERC performs the rank 1 operation
A := alpha*x*y**H + A,
where alpha is a scalar, x is an m element vector, y is an n element vector and A is an m by n matrix.
1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 |
# File 'ext/numo/linalg/blas/blas_z.c', line 1259
static VALUE
blas_s_zgerc(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE ans;
VALUE x, y, a=Qnil, alpha;
narray_t *na1, *na2;
blasint mx, ny, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[4] = {{cT,1},{cT,1},{OVERWRITE,2},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_zgerc, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
ID kw_table[2] = {id_alpha,id_order};
VALUE opts[2] = {Qundef};
CHECK_FUNC(func_p,"zgerc");
rb_scan_args(argc, argv, "21:", &x, &y, &a, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 2, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
g.order = option_order(opts[1]);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
mx = COL_SIZE(na1); // m
ny = COL_SIZE(na2); // n
g.m = mx;
g.n = ny;
SWAP_IFCOL(g.order, mx,ny, tmp);
if (a == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
a = INT2FIX(0);
shape[0] = mx;
shape[1] = ny;
} else {
narray_t *na3;
blasint ma, na;
COPY_OR_CAST_TO(a,cT);
GetNArray(a,na3);
CHECK_DIM_GE(na3,2);
ma = ROW_SIZE(na3); // m
na = COL_SIZE(na3); // n (lda)
CHECK_SIZE_EQ(ma,mx);
CHECK_SIZE_EQ(na,ny);
}
ans = na_ndloop3(&ndf, &g, 3, x, y, a);
if (ndf.nout = 1) { // a is not given.
return ans;
} else {
return a;
}
}
|
.zgeru(x, y, [a, alpha: 1, order:'R']) ⇒ Numo::DComplex
ZGERU performs the rank 1 operation
A := alpha*x*y**T + A,
where alpha is a scalar, x is an m element vector, y is an n element vector and A is an m by n matrix.
1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 |
# File 'ext/numo/linalg/blas/blas_z.c', line 1378
static VALUE
blas_s_zgeru(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE ans;
VALUE x, y, a=Qnil, alpha;
narray_t *na1, *na2;
blasint mx, ny, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[4] = {{cT,1},{cT,1},{OVERWRITE,2},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_zgeru, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
ID kw_table[2] = {id_alpha,id_order};
VALUE opts[2] = {Qundef};
CHECK_FUNC(func_p,"zgeru");
rb_scan_args(argc, argv, "21:", &x, &y, &a, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 2, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
g.order = option_order(opts[1]);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
mx = COL_SIZE(na1); // m
ny = COL_SIZE(na2); // n
g.m = mx;
g.n = ny;
SWAP_IFCOL(g.order, mx,ny, tmp);
if (a == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
a = INT2FIX(0);
shape[0] = mx;
shape[1] = ny;
} else {
narray_t *na3;
blasint ma, na;
COPY_OR_CAST_TO(a,cT);
GetNArray(a,na3);
CHECK_DIM_GE(na3,2);
ma = ROW_SIZE(na3); // m
na = COL_SIZE(na3); // n (lda)
CHECK_SIZE_EQ(ma,mx);
CHECK_SIZE_EQ(na,ny);
}
ans = na_ndloop3(&ndf, &g, 3, x, y, a);
if (ndf.nout = 1) { // a is not given.
return ans;
} else {
return a;
}
}
|
.zhemm(a, b, [c, alpha: 1, beta:0, side:'L', uplo:'U', order:'R']) ⇒ Numo::DComplex
ZHEMM performs one of the matrix-matrix operations
C := alpha*A*B + beta*C,
or
C := alpha*B*A + beta*C,
where alpha and beta are scalars, A is an hermitian matrix and B and C are m by n matrices.
2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 |
# File 'ext/numo/linalg/blas/blas_z.c', line 2500
static VALUE
blas_s_zhemm(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, b, c=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, ka, kb, nb, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[3] = {{cT,2},{cT,2},{OVERWRITE,2}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_zhemm, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[5] = {id_alpha,id_beta,id_order,id_transa,id_transb};
#elif TR
ID kw_table[7] = {id_alpha,id_beta,id_order,id_side,id_uplo,id_transa,id_diag};
#else
ID kw_table[5] = {id_alpha,id_beta,id_order,id_side,id_uplo};
#endif
VALUE opts[7] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"zhemm");
rb_scan_args(argc, argv, "21:", &a, &b, &c, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 5+TR*2, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.transa = option_trans(opts[3]);
g.transb = option_trans(opts[4]);
#else
g.side = option_side(opts[3]);
g.uplo = option_uplo(opts[4]);
#endif
#if TR
g.transa = option_trans(opts[5]);
g.diag = option_diag(opts[6]);
#endif
GetNArray(a,na1);
GetNArray(b,na2);
CHECK_DIM_GE(na1,2);
CHECK_DIM_GE(na2,2);
ma = ROW_SIZE(na1); // m
ka = COL_SIZE(na1); // k (lda)
kb = ROW_SIZE(na2); // k
nb = COL_SIZE(na2); // n (ldb)
#if GE
SWAP_IFCOLTR(g.order,g.transa, ma,ka, tmp);
SWAP_IFCOLTR(g.order,g.transb, kb,nb, tmp);
CHECK_INT_EQ("ka",ka,"kb",kb);
g.m = ma;
g.n = nb;
g.k = ka;
#else
CHECK_SQUARE("a",na1); // ma == ka
SWAP_IFCOL(g.order, kb,nb, tmp);
// row major L R
//ma = ROW_SIZE(na1); // m or n
//ka = COL_SIZE(na1); // m or n (lda)
g.m = kb; // m
g.n = nb; // n (ldb)
if (g.side == CblasLeft) {
CHECK_SIZE_EQ(ka, g.m);
} else {
CHECK_SIZE_EQ(ka, g.n);
}
#endif
SWAP_IFROW(g.order, ma,nb, tmp);
#if TR
if (c != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(b,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, b);
return b;
#else
if (c == Qnil) { // c is not given.
ndfunc_arg_in_t ain_init = {sym_init,0};
ain[2] = ain_init;
ndf.nout = 1;
c = INT2FIX(0);
shape[0] = nb;
shape[1] = ma;
} else {
narray_t *na3;
int nc;
COPY_OR_CAST_TO(c,cT);
GetNArray(c,na3);
CHECK_DIM_GE(na3,2);
nc = ROW_SIZE(na3);
if (nc < nb) {
rb_raise(nary_eShapeError,"nc=%d must be >= nb=%d",nc,nb);
}
//CHECK_LEADING_GE("ldc",g.ldc,"m",ma);
}
{
VALUE ans = na_ndloop3(&ndf, &g, 3, a, b, c);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return c;
}
}
#endif
}
|
.zhemv(a, x, [y, alpha: 1, beta:0, uplo:'U', order:'R']) ⇒ Numo::DComplex
ZHEMV performs the matrix-vector operation
y := alpha*A*x + beta*y,
where alpha and beta are scalars, x and y are n element vectors and A is an n by n hermitian matrix.
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 |
# File 'ext/numo/linalg/blas/blas_z.c', line 1102
static VALUE
blas_s_zhemv(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, x, y=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, na, nx;
#if GE
blasint tmp;
#endif
size_t shape[1];
ndfunc_arg_in_t ain[4] = {{cT,2},{cT,1},{OVERWRITE,1},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,1,shape}};
ndfunc_t ndf = {iter_blas_s_zhemv, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[4] = {id_alpha,id_beta,id_order,id_trans};
#elif TR
ID kw_table[6] = {id_alpha,id_beta,id_order,id_uplo,id_trans,id_diag};
#else
ID kw_table[4] = {id_alpha,id_beta,id_order,id_uplo};
#endif
VALUE opts[6] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"zhemv");
rb_scan_args(argc, argv, "21:", &a, &x, &y, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 4+2*TR, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.trans = option_trans(opts[3]);
#else
g.uplo = option_uplo(opts[3]);
#endif
#if TR
g.trans = option_trans(opts[4]);
g.diag = option_diag(opts[5]);
#endif
GetNArray(a,na1);
CHECK_DIM_GE(na1,2);
ma = ROW_SIZE(na1);
na = COL_SIZE(na1);
GetNArray(x,na2);
CHECK_DIM_GE(na2,1);
nx = COL_SIZE(na2);
#if GE
SWAP_IFCOL(g.order, ma, na, tmp);
g.m = ma;
g.n = na;
SWAP_IFTRANS(g.trans, ma, na, tmp);
#else
CHECK_SQUARE("a",na1);
#endif
CHECK_INT_EQ("na",na,"nx",nx);
shape[0] = ma;
#if TR
if (y != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(x,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, x);
return x;
#else // GE,SY,HE
if (y == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
y = INT2FIX(0);
shape[0] = ma;
} else {
narray_t *na3;
COPY_OR_CAST_TO(y,cT);
GetNArray(y,na3);
CHECK_DIM_GE(na3,1);
CHECK_SIZE_GE(na3,nx);
}
{
VALUE ans;
ans = na_ndloop3(&ndf, &g, 3, a, x, y);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return y;
}
}
#endif
}
|
.zher(x, [a, alpha: 1, uplo:'U', order:'R']) ⇒ Numo::DComplex
ZHER performs the hermitian rank 1 operation
A := alpha*x*x**H + A,
where alpha is a real scalar, x is an n element vector and A is an n by n hermitian matrix.
1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 |
# File 'ext/numo/linalg/blas/blas_z.c', line 1494
static VALUE
blas_s_zher(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE ans;
VALUE x, a, alpha;
narray_t *na1, *na3;
blasint nx, na;
size_t shape[2];
ndfunc_arg_in_t ain[3] = {{cT,1},{OVERWRITE,2},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_zher, NO_LOOP, 2, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
ID kw_table[3] = {id_alpha,id_order,id_uplo};
VALUE opts[3] = {Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"zher");
rb_scan_args(argc, argv, "11:", &x, &a, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 3, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? NUM2DBL(alpha) : 1;
g.order = option_order(opts[1]);
g.uplo = option_uplo(opts[2]);
GetNArray(x,na1);
CHECK_DIM_GE(na1,1);
nx = COL_SIZE(na1); // n
if (a == Qnil) { // c is not given.
ndf.nout = 1;
ain[1] = ain[2];
a = INT2FIX(0);
shape[0] = shape[1] = nx;
} else {
COPY_OR_CAST_TO(a,cT);
GetNArray(a,na3);
CHECK_DIM_GE(na3,2);
CHECK_SQUARE("a",na3);
na = COL_SIZE(na3); // n (lda)
CHECK_SIZE_EQ(na,nx);
}
ans = na_ndloop3(&ndf, &g, 2, x, a);
if (ndf.nout == 1) { // a is not given.
return ans;
} else {
return a;
}
}
|
.zher2(x, y, [a, alpha: 1, uplo:'U', order:'R']) ⇒ Numo::DComplex
ZHER2 performs the hermitian rank 2 operation
A := alpha*x*y**H + conjg( alpha )*y*x**H + A,
where alpha is a scalar, x and y are n element vectors and A is an n by n hermitian matrix.
1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 |
# File 'ext/numo/linalg/blas/blas_z.c', line 1604
static VALUE
blas_s_zher2(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE ans;
VALUE x, y, a, alpha;
narray_t *na1, *na2, *na3;
blasint nx, ny, na;
size_t shape[2];
ndfunc_arg_in_t ain[4] = {{cT,1},{cT,1},{OVERWRITE,2},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_zher2, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
ID kw_table[3] = {id_alpha,id_order,id_uplo};
VALUE opts[3] = {Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"zher2");
rb_scan_args(argc, argv, "21:", &x, &y, &a, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 3, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
g.order = option_order(opts[1]);
g.uplo = option_uplo(opts[2]);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
nx = COL_SIZE(na1); // n
ny = COL_SIZE(na2); // n
CHECK_INT_EQ("nx",nx,"ny",ny);
if (a == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
a = INT2FIX(0);
shape[0] = shape[1] = nx;
} else {
COPY_OR_CAST_TO(a,cT);
GetNArray(a,na3);
CHECK_DIM_GE(na3,2);
CHECK_SQUARE("a",na3);
na = COL_SIZE(na3); // n (lda)
CHECK_SIZE_EQ(na,nx);
}
ans = na_ndloop3(&ndf, &g, 3, x, y, a);
if (ndf.nout == 1) { // a is not given.
return ans;
} else {
return a;
}
}
|
.zherk(a, [c, alpha: 1, beta:0, uplo:'U', trans:'N', order:'R']) ⇒ Numo::DComplex
ZHERK performs one of the hermitian rank k operations
C := alpha*A*A**H + beta*C,
or
C := alpha*A**H*A + beta*C,
where alpha and beta are real scalars, C is an n by n hermitian matrix and A is an n by k matrix in the first case and a k by n matrix in the second case.
1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 |
# File 'ext/numo/linalg/blas/blas_z.c', line 1727
static VALUE
blas_s_zherk(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE ans;
VALUE a, c, alpha, beta;
narray_t *na1, *na3;
blasint na, ka, nc, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[3] = {{cT,2},{OVERWRITE,2},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_zherk, NO_LOOP, 2, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
ID kw_table[5] = {id_alpha,id_beta,id_order,id_uplo,id_trans};
VALUE opts[5] = {Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"zherk");
rb_scan_args(argc, argv, "11:", &a, &c, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 5, opts);
alpha = option_value(opts[0],Qnil);
beta = option_value(opts[1],Qnil);
#line 85 "gen/../tmpl/syrk.c"
g.alpha = RTEST(alpha) ? DBL2NUM(alpha) : 1;
g.beta = RTEST(beta) ? DBL2NUM(beta) : 0;
#line 91 "gen/../tmpl/syrk.c"
g.order = option_order(opts[2]);
g.uplo = option_uplo(opts[3]);
g.trans = option_trans(opts[4]);
GetNArray(a,na1);
CHECK_DIM_GE(na1,2);
na = ROW_SIZE(na1); // n
ka = COL_SIZE(na1); // k (lda)
SWAP_IFCOLTR(g.order,g.trans, na,ka, tmp);
g.n = na;
g.k = ka;
if (c == Qnil) { // c is not given.
ndf.nout = 1;
ain[1] = ain[2];
c = INT2FIX(0);
shape[0] = na;
shape[1] = na;
} else {
COPY_OR_CAST_TO(c,cT);
GetNArray(c,na3);
CHECK_DIM_GE(na3,2);
nc = ROW_SIZE(na3);
if (nc < na) {
rb_raise(nary_eShapeError,"nc=%d must be >= na=%d",nc,na);
}
//CHECK_LEADING_GE("ldc",g.ldc,"n",na);
}
ans = na_ndloop3(&ndf, &g, 2, a, c);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return c;
}
}
|
.zscal(a, x) ⇒ Numo::DComplex
ZSCAL scales a vector by a constant.
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 |
# File 'ext/numo/linalg/blas/blas_z.c', line 554
static VALUE
blas_s_zscal(VALUE mod, VALUE a, VALUE x)
{
scal_t g[1];
narray_t *na1;
ndfunc_arg_in_t ain[1] = {{OVERWRITE,0}};
ndfunc_t ndf = {iter_blas_s_zscal, STRIDE_LOOP, 1,0, ain,0};
CHECK_FUNC(func_p,"zscal");
#line 56 "gen/../tmpl/scal.c"
if (RTEST(a)) {g[0] = m_num_to_data(a);} else {g[0]=m_one;}
COPY_OR_CAST_TO(x,cT);
GetNArray(x,na1);
CHECK_DIM_GE(na1,1);
CHECK_NON_EMPTY(na1);
na_ndloop3(&ndf, g, 1, x);
return x;
}
|
.zswap(x, y) ⇒ nil
ZSWAP interchanges two vectors.
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
# File 'ext/numo/linalg/blas/blas_z.c', line 361
static VALUE
blas_s_zswap(VALUE UNUSED(mod), VALUE x, VALUE y)
{
narray_t *na1, *na2;
ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{OVERWRITE,0}};
ndfunc_t ndf = {iter_blas_s_zswap, STRIDE_LOOP, 2,0, ain,0};
CHECK_FUNC(func_p,"zswap");
CHECK_NARRAY_TYPE(x,cT);
CHECK_NARRAY_TYPE(y,cT);
GetNArray(x,na1);
GetNArray(y,na2);
CHECK_DIM_GE(na1,1);
CHECK_DIM_GE(na2,1);
CHECK_NON_EMPTY(na1);
CHECK_NON_EMPTY(na2);
CHECK_SAME_SHAPE(na1,na2);
na_ndloop(&ndf, 2, x, y);
return Qnil;
}
|
.zsymm(a, b, [c, alpha: 1, beta:0, side:'L', uplo:'U', order:'R']) ⇒ Numo::DComplex
ZSYMM performs one of the matrix-matrix operations
C := alpha*A*B + beta*C,
or
C := alpha*B*A + beta*C,
where alpha and beta are scalars, A is a symmetric matrix and B and C are m by n matrices.
2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 |
# File 'ext/numo/linalg/blas/blas_z.c', line 2088
static VALUE
blas_s_zsymm(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, b, c=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, ka, kb, nb, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[3] = {{cT,2},{cT,2},{OVERWRITE,2}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_zsymm, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[5] = {id_alpha,id_beta,id_order,id_transa,id_transb};
#elif TR
ID kw_table[7] = {id_alpha,id_beta,id_order,id_side,id_uplo,id_transa,id_diag};
#else
ID kw_table[5] = {id_alpha,id_beta,id_order,id_side,id_uplo};
#endif
VALUE opts[7] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"zsymm");
rb_scan_args(argc, argv, "21:", &a, &b, &c, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 5+TR*2, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.transa = option_trans(opts[3]);
g.transb = option_trans(opts[4]);
#else
g.side = option_side(opts[3]);
g.uplo = option_uplo(opts[4]);
#endif
#if TR
g.transa = option_trans(opts[5]);
g.diag = option_diag(opts[6]);
#endif
GetNArray(a,na1);
GetNArray(b,na2);
CHECK_DIM_GE(na1,2);
CHECK_DIM_GE(na2,2);
ma = ROW_SIZE(na1); // m
ka = COL_SIZE(na1); // k (lda)
kb = ROW_SIZE(na2); // k
nb = COL_SIZE(na2); // n (ldb)
#if GE
SWAP_IFCOLTR(g.order,g.transa, ma,ka, tmp);
SWAP_IFCOLTR(g.order,g.transb, kb,nb, tmp);
CHECK_INT_EQ("ka",ka,"kb",kb);
g.m = ma;
g.n = nb;
g.k = ka;
#else
CHECK_SQUARE("a",na1); // ma == ka
SWAP_IFCOL(g.order, kb,nb, tmp);
// row major L R
//ma = ROW_SIZE(na1); // m or n
//ka = COL_SIZE(na1); // m or n (lda)
g.m = kb; // m
g.n = nb; // n (ldb)
if (g.side == CblasLeft) {
CHECK_SIZE_EQ(ka, g.m);
} else {
CHECK_SIZE_EQ(ka, g.n);
}
#endif
SWAP_IFROW(g.order, ma,nb, tmp);
#if TR
if (c != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(b,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, b);
return b;
#else
if (c == Qnil) { // c is not given.
ndfunc_arg_in_t ain_init = {sym_init,0};
ain[2] = ain_init;
ndf.nout = 1;
c = INT2FIX(0);
shape[0] = nb;
shape[1] = ma;
} else {
narray_t *na3;
int nc;
COPY_OR_CAST_TO(c,cT);
GetNArray(c,na3);
CHECK_DIM_GE(na3,2);
nc = ROW_SIZE(na3);
if (nc < nb) {
rb_raise(nary_eShapeError,"nc=%d must be >= nb=%d",nc,nb);
}
//CHECK_LEADING_GE("ldc",g.ldc,"m",ma);
}
{
VALUE ans = na_ndloop3(&ndf, &g, 3, a, b, c);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return c;
}
}
#endif
}
|
.zsyr2k(a, b, [c, alpha: 1, beta:0, uplo:'U', trans:'N', order:'R']) ⇒ Numo::DComplex
ZSYR2K performs one of the symmetric rank 2k operations
C := alpha*A*B**T + alpha*B*A**T + beta*C,
or
C := alpha*A**T*B + alpha*B**T*A + beta*C,
where alpha and beta are scalars, C is an n by n symmetric matrix and A and B are n by k matrices in the first case and k by n matrices in the second case.
2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 |
# File 'ext/numo/linalg/blas/blas_z.c', line 2817
static VALUE
blas_s_zsyr2k(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE ans;
VALUE a, b, c=Qnil, alpha, beta;
narray_t *na1, *na2, *na3;
blasint na, ka, kb, nb, nc, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[4] = {{cT,2},{cT,2},{OVERWRITE,2},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_zsyr2k, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
ID kw_table[5] = {id_alpha,id_beta,id_order,id_uplo,id_trans};
VALUE opts[5] = {Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"zsyr2k");
rb_scan_args(argc, argv, "21:", &a, &b, &c, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 5, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
g.uplo = option_uplo(opts[3]);
g.trans = option_trans(opts[4]);
GetNArray(a,na1);
GetNArray(b,na2);
CHECK_DIM_GE(na1,2);
CHECK_DIM_GE(na2,2);
na = ROW_SIZE(na1); // n
ka = COL_SIZE(na1); // k (lda)
SWAP_IFCOLTR(g.order, g.trans, na, ka, tmp);
nb = ROW_SIZE(na2); // n
kb = COL_SIZE(na2); // k (ldb)
SWAP_IFCOLTR(g.order, g.trans, kb, nb, tmp);
CHECK_INT_EQ("na",na,"nb",nb);
CHECK_INT_EQ("ka",ka,"kb",kb);
g.n = nb;
g.k = kb;
SWAP_IFROW(g.order, na, nb, tmp);
if (c == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
c = INT2FIX(0);
shape[0] = nb;
shape[1] = na;
} else {
COPY_OR_CAST_TO(c,cT);
GetNArray(c,na3);
CHECK_DIM_GE(na3,2);
nc = ROW_SIZE(na3); // n
if (nc < nb) {
rb_raise(nary_eShapeError,"nc=%d must be >= nb=%d",nc,nb);
}
//CHECK_LEADING_GE("ldc",g.ldc,"n",na);
}
ans = na_ndloop3(&ndf, &g, 3, a, b, c);
if (ndf.nout = 1) { // c is not given.
return ans;
} else {
return c;
}
}
|
.zsyrk(a, [c, alpha: 1, beta:0, uplo:'U', trans:'N', order:'R']) ⇒ Numo::DComplex
ZSYRK performs one of the symmetric rank k operations
C := alpha*A*A**T + beta*C,
or
C := alpha*A**T*A + beta*C,
where alpha and beta are scalars, C is an n by n symmetric matrix and A is an n by k matrix in the first case and a k by n matrix in the second case.
2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 |
# File 'ext/numo/linalg/blas/blas_z.c', line 2686
static VALUE
blas_s_zsyrk(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE ans;
VALUE a, c, alpha, beta;
narray_t *na1, *na3;
blasint na, ka, nc, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[3] = {{cT,2},{OVERWRITE,2},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_zsyrk, NO_LOOP, 2, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
ID kw_table[5] = {id_alpha,id_beta,id_order,id_uplo,id_trans};
VALUE opts[5] = {Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"zsyrk");
rb_scan_args(argc, argv, "11:", &a, &c, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 5, opts);
alpha = option_value(opts[0],Qnil);
beta = option_value(opts[1],Qnil);
#line 88 "gen/../tmpl/syrk.c"
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
#line 91 "gen/../tmpl/syrk.c"
g.order = option_order(opts[2]);
g.uplo = option_uplo(opts[3]);
g.trans = option_trans(opts[4]);
GetNArray(a,na1);
CHECK_DIM_GE(na1,2);
na = ROW_SIZE(na1); // n
ka = COL_SIZE(na1); // k (lda)
SWAP_IFCOLTR(g.order,g.trans, na,ka, tmp);
g.n = na;
g.k = ka;
if (c == Qnil) { // c is not given.
ndf.nout = 1;
ain[1] = ain[2];
c = INT2FIX(0);
shape[0] = na;
shape[1] = na;
} else {
COPY_OR_CAST_TO(c,cT);
GetNArray(c,na3);
CHECK_DIM_GE(na3,2);
nc = ROW_SIZE(na3);
if (nc < na) {
rb_raise(nary_eShapeError,"nc=%d must be >= na=%d",nc,na);
}
//CHECK_LEADING_GE("ldc",g.ldc,"n",na);
}
ans = na_ndloop3(&ndf, &g, 2, a, c);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return c;
}
}
|
.ztrmm(a, b, [alpha: 1, side:'L', uplo:'U', transa:'N', diag:'U', order:'R']) ⇒ Numo::DComplex
ZTRMM performs one of the matrix-matrix operations
B := alpha*op( A )*B, or B := alpha*B*op( A )
where alpha is a scalar, B is an m by n matrix, A is a unit, or non-unit, upper or lower triangular matrix and op( A ) is one of
op( A ) = A or op( A ) = A**T or op( A ) = A**H.
2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 |
# File 'ext/numo/linalg/blas/blas_z.c', line 2293
static VALUE
blas_s_ztrmm(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, b, c=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, ka, kb, nb, tmp;
size_t shape[2];
ndfunc_arg_in_t ain[3] = {{cT,2},{cT,2},{OVERWRITE,2}};
ndfunc_arg_out_t aout[1] = {{cT,2,shape}};
ndfunc_t ndf = {iter_blas_s_ztrmm, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[5] = {id_alpha,id_beta,id_order,id_transa,id_transb};
#elif TR
ID kw_table[7] = {id_alpha,id_beta,id_order,id_side,id_uplo,id_transa,id_diag};
#else
ID kw_table[5] = {id_alpha,id_beta,id_order,id_side,id_uplo};
#endif
VALUE opts[7] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"ztrmm");
rb_scan_args(argc, argv, "21:", &a, &b, &c, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 5+TR*2, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.transa = option_trans(opts[3]);
g.transb = option_trans(opts[4]);
#else
g.side = option_side(opts[3]);
g.uplo = option_uplo(opts[4]);
#endif
#if TR
g.transa = option_trans(opts[5]);
g.diag = option_diag(opts[6]);
#endif
GetNArray(a,na1);
GetNArray(b,na2);
CHECK_DIM_GE(na1,2);
CHECK_DIM_GE(na2,2);
ma = ROW_SIZE(na1); // m
ka = COL_SIZE(na1); // k (lda)
kb = ROW_SIZE(na2); // k
nb = COL_SIZE(na2); // n (ldb)
#if GE
SWAP_IFCOLTR(g.order,g.transa, ma,ka, tmp);
SWAP_IFCOLTR(g.order,g.transb, kb,nb, tmp);
CHECK_INT_EQ("ka",ka,"kb",kb);
g.m = ma;
g.n = nb;
g.k = ka;
#else
CHECK_SQUARE("a",na1); // ma == ka
SWAP_IFCOL(g.order, kb,nb, tmp);
// row major L R
//ma = ROW_SIZE(na1); // m or n
//ka = COL_SIZE(na1); // m or n (lda)
g.m = kb; // m
g.n = nb; // n (ldb)
if (g.side == CblasLeft) {
CHECK_SIZE_EQ(ka, g.m);
} else {
CHECK_SIZE_EQ(ka, g.n);
}
#endif
SWAP_IFROW(g.order, ma,nb, tmp);
#if TR
if (c != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(b,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, b);
return b;
#else
if (c == Qnil) { // c is not given.
ndfunc_arg_in_t ain_init = {sym_init,0};
ain[2] = ain_init;
ndf.nout = 1;
c = INT2FIX(0);
shape[0] = nb;
shape[1] = ma;
} else {
narray_t *na3;
int nc;
COPY_OR_CAST_TO(c,cT);
GetNArray(c,na3);
CHECK_DIM_GE(na3,2);
nc = ROW_SIZE(na3);
if (nc < nb) {
rb_raise(nary_eShapeError,"nc=%d must be >= nb=%d",nc,nb);
}
//CHECK_LEADING_GE("ldc",g.ldc,"m",ma);
}
{
VALUE ans = na_ndloop3(&ndf, &g, 3, a, b, c);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return c;
}
}
#endif
}
|
.ztrmv(a, x, [uplo: 'U', trans:'N', diag:'U', order:'R']) ⇒ Numo::DComplex
ZTRMV performs one of the matrix-vector operations
x := A*x, or x := A**T*x, or x := A**H*x,
where x is an n element vector and A is an n by n unit, or non-unit, upper or lower triangular matrix.
915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 |
# File 'ext/numo/linalg/blas/blas_z.c', line 915
static VALUE
blas_s_ztrmv(int argc, VALUE const argv[], VALUE UNUSED(mod))
{
VALUE a, x, y=Qnil, alpha, beta;
narray_t *na1, *na2;
blasint ma, na, nx;
#if GE
blasint tmp;
#endif
size_t shape[1];
ndfunc_arg_in_t ain[4] = {{cT,2},{cT,1},{OVERWRITE,1},{sym_init,0}};
ndfunc_arg_out_t aout[1] = {{cT,1,shape}};
ndfunc_t ndf = {iter_blas_s_ztrmv, NO_LOOP, 3, 0, ain, aout};
args_t g;
VALUE kw_hash = Qnil;
#if GE
ID kw_table[4] = {id_alpha,id_beta,id_order,id_trans};
#elif TR
ID kw_table[6] = {id_alpha,id_beta,id_order,id_uplo,id_trans,id_diag};
#else
ID kw_table[4] = {id_alpha,id_beta,id_order,id_uplo};
#endif
VALUE opts[6] = {Qundef,Qundef,Qundef,Qundef,Qundef,Qundef};
CHECK_FUNC(func_p,"ztrmv");
rb_scan_args(argc, argv, "21:", &a, &x, &y, &kw_hash);
rb_get_kwargs(kw_hash, kw_table, 0, 4+2*TR, opts);
alpha = option_value(opts[0],Qnil);
g.alpha = RTEST(alpha) ? m_num_to_data(alpha) : m_one;
beta = option_value(opts[1],Qnil);
g.beta = RTEST(beta) ? m_num_to_data(beta) : m_zero;
g.order = option_order(opts[2]);
#if GE
g.trans = option_trans(opts[3]);
#else
g.uplo = option_uplo(opts[3]);
#endif
#if TR
g.trans = option_trans(opts[4]);
g.diag = option_diag(opts[5]);
#endif
GetNArray(a,na1);
CHECK_DIM_GE(na1,2);
ma = ROW_SIZE(na1);
na = COL_SIZE(na1);
GetNArray(x,na2);
CHECK_DIM_GE(na2,1);
nx = COL_SIZE(na2);
#if GE
SWAP_IFCOL(g.order, ma, na, tmp);
g.m = ma;
g.n = na;
SWAP_IFTRANS(g.trans, ma, na, tmp);
#else
CHECK_SQUARE("a",na1);
#endif
CHECK_INT_EQ("na",na,"nx",nx);
shape[0] = ma;
#if TR
if (y != Qnil) {
rb_raise(rb_eArgError,"wrong number of arguments (3 for 2)");
}
COPY_OR_CAST_TO(x,cT);
ndf.nin = 2;
na_ndloop3(&ndf, &g, 2, a, x);
return x;
#else // GE,SY,HE
if (y == Qnil) { // c is not given.
ndf.nout = 1;
ain[2] = ain[3];
y = INT2FIX(0);
shape[0] = ma;
} else {
narray_t *na3;
COPY_OR_CAST_TO(y,cT);
GetNArray(y,na3);
CHECK_DIM_GE(na3,1);
CHECK_SIZE_GE(na3,nx);
}
{
VALUE ans;
ans = na_ndloop3(&ndf, &g, 3, a, x, y);
if (ndf.nout == 1) { // c is not given.
return ans;
} else {
return y;
}
}
#endif
}
|