# Linear algebra support in stdlib

**URL:** <https://fortran-lang.discourse.group/t/linear-algebra-support-in-stdlib/6917>\
**Category:** stdlib\
**Created:** [December 4, 2023, 2:24pm UTC](https://fortran-lang.discourse.group/t/linear-algebra-support-in-stdlib/6917 "2023-12-04T14:24:30Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![nja](https://avatars.discourse-cdn.com/v4/letter/n/ed8c4c/32.png) [@nja](https://fortran-lang.discourse.group/u/nja)\
**Post date:** [December 27, 2023, 10:22am UTC](https://fortran-lang.discourse.group/t/linear-algebra-support-in-stdlib/6917/21 "2023-12-27T10:22:22Z")

</div>

> [@mEm](#):
>
> Lastly, just thinking out loud.  
> Adding a 3rd point about some basic Visualisation Framework\*, then I think you covered at least half of the applications for which other well-known languages/platforms are used. Which could really launch Fortran to the stars. But yes, this is another no-joke task (maybe too much?).

That’s an interesting remark. Could you elaborate on this ? (Maybe in another thread ?) By “Visualisation Framework”, you mean a plotting library ? This being a no-joke task doesn’t prevent talking about it 🙂

---

<div class="post-metadata">

**Author:** ![fxm](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/fxm/32/5726_2.png) [@fxm](https://fortran-lang.discourse.group/u/fxm)\
**Post date:** [November 12, 2024, 12:02am UTC](https://fortran-lang.discourse.group/t/linear-algebra-support-in-stdlib/6917/22 "2024-11-12T00:02:20Z")

</div>

First of all: I appreciate the idea behind stdlib quite a bit. For relatively simple tasks, I’m usually including LAPACK and snippets of code here and there that, by the sounds of it, would be covered all in stdlib (eventually).

> [@FedericoPerini](#):
>
> We’re debating whether to develop our own Modernized BLAS/LAPACK at fortran-lang or automate the download process from netlib.

That’s a tricky one.

1. What exactly would the modernisation of BLAS/LAPACK look like?
2. The former sounds like a daunting task. While there are clear advantages, I’d fear that without sufficient time/resources/contributors, it may take quite a while to achieve. In that case, these advantages have to be weighed against the advantages (for Fortran as a language and community) of having a mature stdlib soon-ish.

---

<div class="post-metadata">

**Author:** ![hkvzjal](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/hkvzjal/32/3055_2.png) [@hkvzjal](https://fortran-lang.discourse.group/u/hkvzjal)\
**Post date:** [November 12, 2024, 7:06am UTC](https://fortran-lang.discourse.group/t/linear-algebra-support-in-stdlib/6917/23 "2024-11-12T07:06:26Z")

</div>

@fxm this thread is outdated with respect to this endeavor. You might want to look at [linalg – Fortran-lang/stdlib](https://stdlib.fortran-lang.org/page/specs/stdlib_linalg.html)

@FedericoPerini has done a brilliant work leading this effort by integrating a modernized version of BLAS/LAPACK and also developing high-level interfaces. The information is indeed a bit spread across several threads in the forum. For instance:

> [@Fortran Standard Library v0.6.0 Released](https://fortran-lang.discourse.group/t/fortran-standard-library-v0-6-0-released/8011):
>
> 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 commu…

v0.7.0 includes more features and the latest main branch even more.

---

<div class="post-metadata">

**Author:** ![FedericoPerini](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/federicoperini/32/1750_2.png) [@FedericoPerini](https://fortran-lang.discourse.group/u/FedericoPerini)\
**Post date:** [November 12, 2024, 7:16am UTC](https://fortran-lang.discourse.group/t/linear-algebra-support-in-stdlib/6917/24 "2024-11-12T07:16:21Z")

</div>

Hi @fxm, I hope it’s going come as a positive surprise to you that both those tasks have been successfully completed 🙂 As @hkvzjal pointed out, please check out the [linear algebra capability](https://stdlib.fortran-lang.org/page/specs/stdlib_linalg.html) at fortran-lang stdlib: it already has most high-level linear algebra functions that you typically find in LA packages.

We also build our modernized LAPACK version internally and expose a kind-agnostic (32- to 128-bit) interface in [`stdlib_linalg_lapack`](https://github.com/fortran-lang/stdlib/blob/master/src/stdlib_linalg_lapack.fypp) (we don’t build FORD documentation anymore because it’s too large for FORD to handle). The interface has two aims:

- Make all calls kind-agnostic, but keep the same LAPACK API. E.g., `call gesv` instead of `call sgesv`, `call dgesv`, etc.

- You can choose to build stdlib with the internal Fortran implementation or an external optimized blas. In which case, you don’t need to change anything in the code, as the generalized interface already takes care of that. Just ensure that macros `STDLIB_EXTERNAL_BLAS` and `STDLIB_EXTERNAL_LAPACK` are defined when building with an external library.

- Last but not least, thanks to @hkvzjal and others, `stdlib` is now a default package on the Compiler Explorer: so you can [play with the examples there](https://godbolt.org/z/q9PYvMKPW)

---

<div class="post-metadata">

**Author:** ![fxm](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/fxm/32/5726_2.png) [@fxm](https://fortran-lang.discourse.group/u/fxm)\
**Post date:** [November 12, 2024, 2:23pm UTC](https://fortran-lang.discourse.group/t/linear-algebra-support-in-stdlib/6917/25 "2024-11-12T14:23:42Z")

</div>

Hi @FedericoPerini and @hkvzjal,

Thanks for that update. Wow. This is great news and, frankly, quite impressive! Thanks for that immense contribution!

---

<div class="post-metadata">

**Author:** ![johnalx](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@johnalx](https://fortran-lang.discourse.group/u/johnalx)\
**Post date:** [March 27, 2025, 3:14pm UTC](https://fortran-lang.discourse.group/t/linear-algebra-support-in-stdlib/6917/26 "2025-03-27T15:14:55Z")

</div>

Where can I make a proposal to include a `cross_product_matrix()` function that takes a vector and returns the [3×3 skew-symmetric cross product operator matrix](https://en.wikipedia.org/wiki/Skew-symmetric_matrix#Cross_product) which is used in mechanics a lot to convert the cross product into a linear algebra operator?

---

<div class="post-metadata">

**Author:** ![loiseaujc](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/loiseaujc/32/4582_2.png) [@loiseaujc](https://fortran-lang.discourse.group/u/loiseaujc)\
**Post date:** [March 27, 2025, 3:21pm UTC](https://fortran-lang.discourse.group/t/linear-algebra-support-in-stdlib/6917/27 "2025-03-27T15:21:47Z")

</div>

I’d say the `stdlib_linalg` module is probably the most natural place. It already has the `cross_product(a, b)` function.

edit: I misunderstood the question, and @Beliavsky gave the correct answer. In any case, if you then wanna make a PR, I think the `stdlib_linalg` module would still be the correct place where to put this functionality.

---

<div class="post-metadata">

**Author:** ![Beliavsky](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@Beliavsky](https://fortran-lang.discourse.group/u/Beliavsky)\
**Post date:** [March 27, 2025, 3:23pm UTC](https://fortran-lang.discourse.group/t/linear-algebra-support-in-stdlib/6917/28 "2025-03-27T15:23:16Z")

</div>

On GitHub, at [stdlib - issues](https://github.com/fortran-lang/stdlib/issues), click on the New Issue button on the right and select Feature Proposal.

[Previous page](https://fortran-lang.discourse.group/t/linear-algebra-support-in-stdlib/6917.md?page=1)
