[FEA] Add cross product operator
Should support 3D points with an arbitrary rank (Nx3)
I use cross products quite a bit and would be interested in implementing this. Anything I should be aware of regarding intended implementation or anything?
Great! I think I would do the following:
- Copy the operator source from something like
polyval.hinto a new file calledcross.hwith the namings inside changed - Take two operators as input. Have a runtime check that the last dimension has length 3 (Or 2 for bonus points if you want z=0). The other dimensions are batching. The dimensions are a bit awkward because of the 3D nature not fitting in a warp size, but it doesn't need to be optimal right now.
- Add unit tests for batching and non-batching cases
- Update docs pointing to the tests and any extra notes
Great thanks! I'll start on this sometime this week.
As a matter of convention in MatX, are assertions best defined in the constructor for a class template specialization (e.g. like in polyval.h) or in the Exec method, like in corr.h?
In general if they're template parameters of the class they should go at the top of the class (doesn't even have to be in the ctor). In the corr.h case those are template parameters to the function so they must be in the function itself.
This hasn't dropped off my radar, just haven't had a chance to look at it since implementing the runtime checks.
Finally got around to this! Have some unit tests put together locally but unsure where to put the documentation. Would it make sense to place it in docs_input/api/linalg/other? Logic being that Numpy has a cross function in np.linalg (which just seems to reference the core version of np.cross).
Hi @mfzmullen , thanks! Yes, that location sounds good.
Cross was added: https://nvidia.github.io/MatX/api/linalg/other/cross.html