Skip to content

Commit a46b86f

Browse files
committed
add Syntax section
1 parent 819f2b2 commit a46b86f

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

doc/specs/stdlib_linalg.md

+49-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,55 @@ macros = ["STDLIB_EXTERNAL_BLAS", "STDLIB_EXTERNAL_LAPACK"]
4949

5050
or directly via compiler flags:
5151

52-
`fpm build --flag "-DSTDLIB_EXTERNAL_BLAS -DSTDLIB_EXTERNAL_LAPACK -framework Accelerate"`.
52+
`fpm build --flag "-DSTDLIB_EXTERNAL_BLAS -DSTDLIB_EXTERNAL_LAPACK -lblas -llapack"`.
53+
54+
### Syntax
55+
56+
All procedures in the `BLAS` and `LAPACK` backends follow the standard interfaces from the
57+
[Reference LAPACK](https://www.netlib.org/lapack/). So, the online [Users Guide](https://www.netlib.org/lapack/explore-html/)
58+
should be consulted for the full API and descriptions of procedure arguments and their usage.
59+
60+
The `stdlib` implementation makes both kind-agnostic and specific procedure interfaces available via modules
61+
[stdlib_linalg_blas(module)] and [stdlib_linalg_lapack(module)]. Because all procedures start with a letter
62+
[that indicates the base datatype](https://www.netlib.org/lapack/lug/node24.html), the `stdlib` generic
63+
interface drops the heading letter and contains all kind-dependent implementations. For example, the generic
64+
interface to the `axpy` function looks like:
65+
66+
```fortran
67+
!> AXPY: constant times a vector plus a vector.
68+
interface axpy
69+
module procedure stdlib_saxpy
70+
module procedure stdlib_daxpy
71+
module procedure stdlib_qaxpy
72+
module procedure stdlib_caxpy
73+
module procedure stdlib_zaxpy
74+
module procedure stdlib_waxpy
75+
end interface axpy
76+
```
77+
78+
The generic interface is the endpoint for using an external library. Whenever the latter is used, references
79+
to the internal `module procedure`s are replaced with interfaces to the external library,
80+
for example:
81+
82+
```fortran
83+
!> AXPY: constant times a vector plus a vector.
84+
interface axpy
85+
pure subroutine caxpy(n,ca,cx,incx,cy,incy)
86+
import sp,dp,qp,ilp,lk
87+
implicit none(type,external)
88+
complex(sp), intent(in) :: ca,cx(*)
89+
integer(ilp), intent(in) :: incx,incy,n
90+
complex(sp), intent(inout) :: cy(*)
91+
end subroutine caxpy
92+
! [....]
93+
module procedure stdlib_qaxpy
94+
end interface axpy
95+
```
96+
97+
Note that the 128-bit functions are only provided by `stdlib` and always point to the internal implementation.
98+
Because 128-bit precision is identified as [stdlib_kinds(module):qp], initials for 128-bit procedures were
99+
labelled as `q` (quadruple-precision reals) and `w` ("wide" or quadruple-precision complex numbers).
100+
Extended precision ([stdlib_kinds(module):xdp]) calculations are currently not supported.
53101

54102
### Example
55103

0 commit comments

Comments
 (0)