start hacking on math.blas.vectors to switch to fortran
parent
3b83d9f760
commit
42265cbc62
|
@ -11,6 +11,14 @@ IN: alien.fortran
|
||||||
! XXX this currently only supports the gfortran/f2c abi.
|
! XXX this currently only supports the gfortran/f2c abi.
|
||||||
! XXX we should also support ifort at some point for commercial BLASes
|
! XXX we should also support ifort at some point for commercial BLASes
|
||||||
|
|
||||||
|
<<
|
||||||
|
: add-f2c-libraries ( -- )
|
||||||
|
"I77" "libI77.so" "cdecl" add-library
|
||||||
|
"F77" "libF77.so" "cdecl" add-library ;
|
||||||
|
|
||||||
|
os netbsd? [ add-f2c-libraries ] when
|
||||||
|
>>
|
||||||
|
|
||||||
: alien>nstring ( alien len encoding -- string )
|
: alien>nstring ( alien len encoding -- string )
|
||||||
[ memory>byte-array ] dip decode ;
|
[ memory>byte-array ] dip decode ;
|
||||||
|
|
||||||
|
@ -377,3 +385,5 @@ MACRO: fortran-invoke ( return library function parameters -- )
|
||||||
scan "c-library" get scan ";" parse-tokens
|
scan "c-library" get scan ";" parse-tokens
|
||||||
[ "()" subseq? not ] filter define-fortran-function ; parsing
|
[ "()" subseq? not ] filter define-fortran-function ; parsing
|
||||||
|
|
||||||
|
: LIBRARY:
|
||||||
|
scan "c-library" set ; parsing
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
USING: accessors alien alien.c-types arrays byte-arrays combinators
|
USING: accessors alien alien.c-types arrays byte-arrays combinators
|
||||||
combinators.short-circuit fry kernel math math.blas.cblas
|
combinators.short-circuit fry kernel math math.blas.ffi
|
||||||
math.complex math.functions math.order sequences.complex
|
math.complex math.functions math.order sequences.complex
|
||||||
sequences.complex-components sequences sequences.private
|
sequences.complex-components sequences sequences.private
|
||||||
functors words locals parser prettyprint.backend prettyprint.custom
|
functors words locals parser prettyprint.backend prettyprint.custom
|
||||||
specialized-arrays.float specialized-arrays.double
|
specialized-arrays.float specialized-arrays.double
|
||||||
specialized-arrays.direct.float specialized-arrays.direct.double ;
|
specialized-arrays.direct.float specialized-arrays.direct.double
|
||||||
|
specialized-arrays.complex-float specialized-arrays.complex-double
|
||||||
|
specialized-arrays.direct.complex-float
|
||||||
|
specialized-arrays.direct.complex-double ;
|
||||||
IN: math.blas.vectors
|
IN: math.blas.vectors
|
||||||
|
|
||||||
TUPLE: blas-vector-base underlying length inc ;
|
TUPLE: blas-vector-base underlying length inc ;
|
||||||
|
@ -130,9 +133,9 @@ FUNCTOR: (define-blas-vector) ( TYPE T -- )
|
||||||
|
|
||||||
<DIRECT-ARRAY> IS <direct-${TYPE}-array>
|
<DIRECT-ARRAY> IS <direct-${TYPE}-array>
|
||||||
>ARRAY IS >${TYPE}-array
|
>ARRAY IS >${TYPE}-array
|
||||||
XCOPY IS cblas_${T}copy
|
XCOPY IS ${T}COPY
|
||||||
XSWAP IS cblas_${T}swap
|
XSWAP IS ${T}SWAP
|
||||||
IXAMAX IS cblas_i${T}amax
|
IXAMAX IS I${T}AMAX
|
||||||
|
|
||||||
VECTOR DEFINES-CLASS ${TYPE}-blas-vector
|
VECTOR DEFINES-CLASS ${TYPE}-blas-vector
|
||||||
<VECTOR> DEFINES <${TYPE}-blas-vector>
|
<VECTOR> DEFINES <${TYPE}-blas-vector>
|
||||||
|
@ -264,16 +267,14 @@ M: VECTOR n*V!
|
||||||
: define-real-blas-vector ( TYPE T -- )
|
: define-real-blas-vector ( TYPE T -- )
|
||||||
[ (define-blas-vector) ]
|
[ (define-blas-vector) ]
|
||||||
[ (define-real-blas-vector) ] 2bi ;
|
[ (define-real-blas-vector) ] 2bi ;
|
||||||
:: define-complex-blas-vector ( TYPE C S -- )
|
: define-complex-blas-vector ( TYPE C S -- )
|
||||||
TYPE (define-complex-helpers)
|
[ drop (define-blas-vector) ]
|
||||||
TYPE "-complex" append
|
[ (define-complex-blas-vector) ] 3bi ;
|
||||||
[ C (define-blas-vector) ]
|
|
||||||
[ C S (define-complex-blas-vector) ] bi ;
|
|
||||||
|
|
||||||
"float" "s" define-real-blas-vector
|
"float" "s" define-real-blas-vector
|
||||||
"double" "d" define-real-blas-vector
|
"double" "d" define-real-blas-vector
|
||||||
"float" "c" "s" define-complex-blas-vector
|
"complex-float" "c" "s" define-complex-blas-vector
|
||||||
"double" "z" "d" define-complex-blas-vector
|
"complex-double" "z" "d" define-complex-blas-vector
|
||||||
|
|
||||||
>>
|
>>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue