admin管理员组

文章数量:1312721

I know for sure how to calculate a cross product myself, but usually I tree to use the standard library where possible.

I am aware that std::linalg is still in development so this might already be the reason, but even blas seems not to have that.

Is there really no cross product defined in std::linalg and, if yes, is there a reason for that?

In Python there is numpy.linalg.cross and I assumed that something similar exists basically in every linear algebra library.

I know for sure how to calculate a cross product myself, but usually I tree to use the standard library where possible.

I am aware that std::linalg is still in development so this might already be the reason, but even blas seems not to have that.

Is there really no cross product defined in std::linalg and, if yes, is there a reason for that?

In Python there is numpy.linalg.cross and I assumed that something similar exists basically in every linear algebra library.

Share Improve this question edited Feb 1 at 17:36 Jan Schultke 40.2k8 gold badges95 silver badges175 bronze badges asked Feb 1 at 14:38 Torsten KnodtTorsten Knodt 7661 gold badge6 silver badges23 bronze badges 4
  • 1 p1673r12 says "We prefer to let a higher-level library decide this, and make everything explicit at our lower level." -- which I presume includes why it does not provide vector-vector cross product. They're deferring to a higher-level (not std...?) library to implement that. – Eljay Commented Feb 1 at 14:51
  • 7 According to en.cppreference/w/cpp/numeric/linalg the library implements the algorithms according to the BLAS standard which indeed does not specify a cross-product operation. My personal guess would be because cross-product is only really defined for 3-dimensional vectors and therefore not general enough – UnholySheep Commented Feb 1 at 14:52
  • 1 @UnholySheep: And 7 dimensions! – Davis Herring Commented Feb 1 at 22:26
  • There are articles defining/discussing cross products in higher dimensions - for example, researchgate/publication/… I'm not aware (although, admittedly, I've never had reason to investigate) of practical applications of higher order cross products. There is also a uniqueness problem (although 3D cross products are unique [apart from sign], higher order cross products are not) which would offer a wrinkle for providing a library facility for them. – Peter Commented Feb 2 at 12:58
Add a comment  | 

1 Answer 1

Reset to default 6

std::linalg is based on the dense BLAS as specified in Chapter 2 of the BLAS Technical Forum Standard ( https://wwwlib./blas/blast-forum/chapter2.pdf ), and focuses on the subset of routines that appear in the "Reference BLAS" with its core of BLAS 1, 2, and 3 routines (source: Section 9.1 of the std::linalg main proposal P1673: https://www.open-std./jtc1/sc22/wg21/docs/papers/2023/p1673r13.html ). Vector cross products are not in the BLAS Standard.

Sections 6 - 10 of P1673 clarify std::linalg's design. Section 9 in particular explains "What we exclude from the design" and why.

FYI, the version of P1673 that was voted into the C++ Working Draft was R13.

本文标签: cIs there really not cross product in stdlinalg and if yes whyStack Overflow