Dear Fortran Enthusiasts, we’re pleased to announce the release of Fortran Standard Library v0.6.0.
This release introduces major updates concerning the Linear Algebra APIs and the build system.
I would like to stress the invaluable help from @jeremie.vandenplas @hkvzjal and all the stdlib enthusiasts that made this release possible!
Linear Algebra
I’ve been developing high-level APIs that leverage the modernized, any-precision BLAS/LAPACK backends introduced in v0.5.0. Eager to receive community support and feedback on them!
Matrix determinant:
d = det(a [, overwrite_a, err])
d = .det.a
comes with:
pure
interface- no-allocation interface (
overwrite_a=.true.
) with error control (err
) and pure
operator interface
Linear system solver:
x = solve(a,b) ! pure interface
x = solve(a,b,overwrite_a=.true.,err=err) ! expert interface
call solve_lu(a, b, x [, pivot, overwrite_a, err]) ! pure expert no-allocate interface
Least-squares solver
Least squares solver for 1-rhs (b(:)
) or N-rhs (b(:,:)
) cases
x = lstsq(a,b) ! simple interface
x = lstsq(a,b,cond,overwrite_a,rank,err) ! expert interface
call solve_lstsq(a,b,x, [, real_storage, int_storage, [cmpl_storage, ] cond, singvals, overwrite_a, rank, err]) ! no-allocation option
Optional arguments involve:
- cond
= optional cutoff for rank evaluation: singular values s(i)<=cond*maxval(s)
are considered 0. Default: 0.0
- overwrite_a
= option to avoid internal allocation, but destroy input matrix a
. Default: .false.
- rank
= return rank of A
, if requested
- err
= return state variable
- real_storage
, int_storage
, cmpl_storage
: provide pre-allocated storage arrays to avoid internal allocation. get minimum sizes using lstsq_space
Expert error control
All procedures are pure
where possible, and if something goes wrong, the code will raise an error stop
with the error code and a full description of what happened.
All of them also accept an optional argument:
`type(linalg_state_type), intent(out), optional :: err`
that contains state information. In this case, the code will never stop, so the developer has full control on the algorithm. Typical errors are:
LINALG_ERROR
if something in the algorithm failed, i.e., it did not converge, or the matrix is singular, etc.LINALG_VALUE_ERROR
on input issues (wrong matrix sizes, …).
Build system
@hkvzjal developed a new pre-processing system that allows to preprocess all fypp files and generate pure-Fortran sources with full customization of the fypp
and cpp
macros.
Using this new approach, stdlib can now be directly built using fpm from the root folder, for instance:
python config/fypp_deployment.py
fpm build --profile release
The stdlib-fpm
branch can be created with the option (new approach for the fpm github ci)
python config/fypp_deployment.py --deploy_stdlib_fpm
Current fypp options supported by the script are:
--njob NJOB Number of parallel jobs for preprocessing
--maxrank MAXRANK Set the maximum allowed rank for arrays
--with_qp Include WITH_QP in the command
--with_xdp Include WITH_XDP in the command
--lnumbering Add line numbering in preprocessed files
For more details refer to the README section Build with fortran-lang/fpm
Up Next
More linear-algebra functions will follow (svd, qr, cholesky, matrix inverse, …), along with the option to automatically detect and link against high-performance BLAS and LAPACK libraries on the local system. If you like NumPy, you will love the Fortran Standard Library!