diff --git a/src/eigens/lapack.h b/src/eigens/lapack.h index 5524d35..ba0781a 100644 --- a/src/eigens/lapack.h +++ b/src/eigens/lapack.h @@ -7,6 +7,18 @@ typedef double doublereal; r f a; \ r U(f) a +L(void, cgemm, (const char *transa, const char *transb, + const int *m, const int *n, const int *k, + const float *alpha, const float *a, + const int *lda, const float *b, const int *ldb, + const float *beta, float *c, const int *ldc)); + +L(void, dgemm, (const char *transa, const char *transb, + const int *m, const int *n, const int *k, + const double *alpha, const double *a, + const int *lda, const double *b, const int *ldb, + const double *beta, double *c, const int *ldc)); + L(void, dsterf, (integer *n, doublereal *d, doublereal *e, integer *info)); L(void, dgetrf, (integer *m, integer *n, doublereal *a, integer * lda, integer *ipiv, integer *info)); diff --git a/src/eigens/lapack.nim b/src/eigens/lapack.nim index baf0d0c..3a32ef9 100644 --- a/src/eigens/lapack.nim +++ b/src/eigens/lapack.nim @@ -3,7 +3,8 @@ const lapackLib {.strdefine.} = "-llapack -lblas" #const lapackLib {.strdefine.} = "/usr/lib/lapack/liblapack.a -lblas -lgfortran" #const lapackLib {.strdefine.} = "-L/usr/lib/lapack -llapack" {.passL: lapackLib.} -{.pragma: lapack, header: hdr.} +#{.pragma: lapack, header: hdr.} +{.pragma: lapack.} type fint* = cint @@ -102,3 +103,17 @@ proc dbdsvdx*(uplo: cstring, jobz: cstring, range: cstring, n: ptr fint, proc dlasq1*(n: ptr fint; d: ptr float64; e: ptr float64; work: ptr float64; info: ptr fint) {.lapack, importc: "dlasq1_".} + +when isMainModule: + template toPtrInt32(x: int): ptr int32 = + var t = x.int32 + addr t + template toPtrScomplex(x: int): ptr scomplex = + var t = scomplex(re: x.float32, im: 0'f32) + addr t + template `&`(x: int): untyped = toPtrInt32(x) + template `&&`(x: int): untyped = toPtrScomplex(x) + var c,a,b: ptr scomplex + var cr,cc,bc: int + + cgemm("C","N", &cc,&cr,&bc, &&1, b,&bc, a,&bc, &&0, c,&cc)