Skip to content

Commit

Permalink
fix lapack tests on mac
Browse files Browse the repository at this point in the history
  • Loading branch information
jcosborn committed Nov 13, 2024
1 parent 0508c8b commit db850d4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/eigens/lapack.h
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
17 changes: 16 additions & 1 deletion src/eigens/lapack.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

0 comments on commit db850d4

Please sign in to comment.