This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
(set 'af (map float a))
> (file? "/usr/")
true
> (directory? "/usr/")
true
int sm(int m, int n, double * p)
{
double *p_end;
p_end = p + (m * n) - 1;
for (;p <= p_end; p++)
(*p) = (* p) + 1;
return 0;
}
(set 'LIB "scalam.so")
(import LIB "sm" "int" "int" "int" "void*")
(set 'a '(1 1 1 2 3 4 3 5 2 4 2 5 5 4 3))
(setq m 5 n 3)
(set 'ap (pack (dup "lf" (* m n)) a))
(set 'info (sm m n ap))
> (unpack (dup "lf" 15) ap)
(2 2 2 3 4 5 4 6 3 5 3 6 6 5 4)
>(set 'bp (pack (dup "lf" 10) b)
>(set 'info (sm 5 2 (address bp)))
> (unpack (dup "lf" 10) bp)
(1.844674407e+19 1.844674407e+19 13 15 15 13 17 17 19 17)
> (set 'b '(-10 -3 -12 -14 -14 12 16 16 18 16))
(-10 -3 -12 -14 -14 12 16 16 18 16)
> (set 'bp (pack (dup "lf" 10) b))
" 00 00 00 00 00 00�C 00 00 00 00 00 00�C 00 00 00 00 00 00�C 00 00 00 00 00 00�C 00 00 00 00 00 00�C 00 00 00 00 00 00(@ 00 00 00 00 00 000@ 00 00 00 00 00 000@ 00 00 00 00 00 002@ 00 00 00 00 00 000@"
> (set 'info (sm 5 2 (address bp)))
0
> (unpack (dup "lf" 10) bp)
(1.844674407e+19 1.844674407e+19 1.844674407e+19 1.844674407e+19 1.844674407e+19
13 17 17 19 17)
lapack_int LAPACKE_dgels( int matrix_order, char trans, lapack_int m,
lapack_int n, lapack_int nrhs, double* a,
lapack_int lda, double* b, lapack_int ldb );
#ifndef lapack_int
#if defined(LAPACK_ILP64)
#define lapack_int long
#else
#define lapack_int int
#endif
#endif
#define LAPACK_ROW_MAJOR 101
#define LAPACK_COL_MAJOR 102
*> DGELS solves overdetermined or underdetermined real linear systems
*> involving an M-by-N matrix A, or its transpose, using a QR or LQ
*> factorization of A. It is assumed that A has full rank.
*>
*> The following options are provided:
*>
*> 1. If TRANS = 'N' and m >= n: find the least squares solution of
*> an overdetermined system, i.e., solve the least squares problem
*> minimize || B - A*X ||.
*>
*> 2. If TRANS = 'N' and m < n: find the minimum norm solution of
*> an underdetermined system A * X = B.
*>
*> 3. If TRANS = 'T' and m >= n: find the minimum norm solution of
*> an undetermined system A**T * X = B.
*>
*> 4. If TRANS = 'T' and m < n: find the least squares solution of
*> an overdetermined system, i.e., solve the least squares problem
*> minimize || B - A**T * X ||.
*>
(set 'LAPACKE "/usr/local/lib/liblapacke.so")
(import LAPACKE "LAPACKE_dgels" "int" "int" "char" "int" "int" "int" "void*" "int" "void*" "int")
(set 'a '(1 1 1 2 3 4 3 5 2 4 2 5 5 4 3))
(set 'b '(-10 -3 12 14 14 12 16 16 18 16))
(setq m 5 n 3 nrhs 2 lda 3 ldb 2)
(set 'aptr (pack (dup "lf" (* m n)) a))
(set 'bptr (pack (dup "lf" (* m nrhs)) b))
(set 'info (LAPACKE_dgels 101 78 m n nrhs (address aptr) lda (address bptr) ldb))
(unpack (dup "lf" (* m nrhs)) bptr)
-> (1380.761318 1380.761318 1.844674407e+17 1.844674407e+17 1.844674407e+17 1.844674407e+17
-1.415684734e+19 -1.415684734e+19 -1.153518066e+19 -1.153518066e+19)
> (import LIB "gsl_complex_rect" "void*" "double" "double")
gsl_complex_rect@7FBAD0403FD0
> (unpack "lf lf" (gsl_complex_rect 2.0 3.0))
Segmentation fault (core dumped)
typedef struct
{
double dat[2];
} gsl_complex;
Quote
-- Function: gsl_complex gsl_complex_rect (double X, double Y)
This function uses the rectangular Cartesian components (X,Y) to
return the complex number z = x + i y. An inline version of this
function is used when `HAVE_INLINE' is defined.