1
votes

How to calculate vector (cross) product with la4j?

Vector product is

enter image description here

and takes two vectors and return vector.

But they have scalar product, product of all elements, even Hadamard product, but no cross prduct!

They have outer product, but it produces a matrix.

How to calculate 3D cross product?

1

1 Answers

1
votes

Disclaimer: I'm la4j contributor, so I think my opinion will be valuable here.

Our library provides API and implementation for a bunch of operations with multidimensional matrices and vectors. By 'multidimensional' we mean that you can work with vectors of any length safely.

Cross product is an operation defined for only 3-dimensional vectors. It means that you can't use this operation with random-sized vectors. Therefore, the introduction of org.la4j.Vector#crossProduct operation will be strong violation of design and contracts our library provides. It is unsafe, highly specialized and so on.

So, for now there is no 'shortcut' for this operation in our library, but it's quite easy to write helper function in your application which works only with 3-dimensional vectors and computes cross product by well-known formulas.

And, of course, you are free to create feature requests and PRs in our GitHub repository, and, who knows, one day cross product would be the part of la4j.