Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cross product operator #818

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

mfzmullen
Copy link
Contributor

Takes in two operators of size A0 x ... x An x 3 (or 2) and size B0 x ... x Bn x (3 or 2) with matching batch sizes and computes the cross product. If both input operators have size = 2 on the last dimension, the size of the output's last dimension is still 3. This is contrary to the NumPy implementation which drops the rank of the output by 1 if both inputs are in-plane vectors. Doing so in MatX does not seem straightforward since Rank is a static method and we may not know the sizes of A and B (e.g. 2 or 3 on the last dimension) at the time the rank is determined, but those sizes affect the rank of cross if we followed NumPy's approach. The alternative would be to have the output size equal 1 on the last dimension for two size=2 inputs and only contain the z-component of the cross product, since the other two components of cross are 0.

Copy link
Collaborator

@cliffburdick cliffburdick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks for doing this

@cliffburdick
Copy link
Collaborator

/build

@cliffburdick
Copy link
Collaborator

Hi @mfzmullen, I apologize I didn't see this earlier, but the documentation needs to be updated:

/home/jenkins/workspace/unit-tests/include/matx/operators/cross.h:188: error: argument 'OpA' of command @param is not found in the argument list of matx::cross(const OpA &A, const OpB &B) (warning treated as error, aborting now)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants