In cases where both input vectors have dimension 2, the z-component of the cross product is returned. Have a question about this project? Note that handles multidimensional arrays differently than : it does not perform a matrix product, but flattens input arguments to 1-D vectors first. If a and b are arrays of vectors, the vectors are defined by the last axis of a and b by default, and these axes can have dimensions 2 or 3. This must have the exact kind that would be returned if it was not used. Where the dimension of either a or b is 2, the third component of the input vector is assumed to be zero and the cross product calculated accordingly. In particular, it must have the right type, must be C-contiguous, and its dtype must be the dtype that would be returned for dot a,b. The cross product of a and b in is a vector perpendicular to both a and b.
It gives a lot of flexibility. Anyway, I am open to suggestions. Hmm, maybe a flag would be useful just because folks are likely to have files sitting around full of quaternions using both conventions. Given that, I can't see many situations when I'd need a super speedy C version of quaternion multiply. As far as I know, there is no scipy convention on this.
In cases where both input vectors have dimension 2, the z-component of the cross product is returned. You can extract just the row-wise dot products using diag: In: np. I was confused by your previous reply in this thread which I blindly followed without thinking about it. Hello, I have two groups of 3x1 arrays that are arranged into two larger 3xn arrays. Sign up for a free GitHub account to open an issue and contact its maintainers and the community. Maybe one more scalar type to add to the NumPy mix? Therefore, if these conditions are not met, an exception is raised, instead of attempting to be flexible. For a dimension of 2, the z-component of the equivalent three-dimensional cross product is returned.
Each of the 3x1 sub-arrays represents a vector in 3D space. Ignored if both input vectors have dimension 2, as the return is scalar. Especially in an implementation that could be crippled by running as unoptimised byte-code. Where the dimension of either a or b is 2, the third component of the input vector is assumed to be zero and the cross product calculated accordingly. Each of the 3x1 sub-arrays represents a vector in 3D space.
Applying suggestions on deleted lines is not supported. By default, the last axis. In Matlab, I'd use the function cross to calculate the cross product of the corresponding 'vectors' from each array. The docstring should make it very clear. Note that the current NumPy cross product is implemented in Python. Looking at the the cross product implementation, it shouldn't be to hard to duplicate this for quaternions.
If someone was given the task of cross-multiplying two three-element vectors, the formula in the text-book or Wikipedia is what they would write. The default is to assume you have Nx3 arrays and return an Nx3 array. The vdot a, b function handles complex numbers differently than dot a, b. Outdated suggestions cannot be applied. This is what I was looking for. Only one suggestion per line can be applied in a batch. By default, the last axis.
Dot product should work for any two vectors of the same length. But, it is possible that certain use cases are faster. T 100000 loops, best of 3: 4. I have a python quaternion class that I use for such things but profiling shows that it is one of the prime time bandits, so I am tempted to use c for that class anyway. Suggestions cannot be applied while the pull request is closed. You could try using: from numpy. Can be an int, float, or complex depending on the types of a and b.
Returns: c : ndarray Vector cross product s. This suggestion is invalid because no changes were made to the code. It gives a lot of flexibility. Setting up ordinary arrays was much faster, but then the cross-product calculation was slower. On the other hand, I have files containing 20,000 quaternions, each of which needs to be converted to a rotation matrix and applied to some 400 vectors, so a c version would have its place. Suggestions cannot be applied from pending reviews.
But for large arrays np. T 100000 loops, best of 3: 4. What should such a product be called? Suggestions cannot be applied while viewing a subset of changes. This is a performance feature. But you can change the axis used to find vectors. You could try using: from numpy. This is what you expect given a library function to do the job.