5

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.

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. Commented Feb 1 at 14:51
  • 7
    According to en.cppreference.com/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 Commented Feb 1 at 14:52
  • 1
    @UnholySheep: And 7 dimensions! Commented Feb 1 at 22:26
  • There are articles defining/discussing cross products in higher dimensions - for example, researchgate.net/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. Commented Feb 2 at 12:58

1 Answer 1

6

std::linalg is based on the dense BLAS as specified in Chapter 2 of the BLAS Technical Forum Standard ( https://www.netlib.org/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.org/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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.