You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed some inconsistent behavior in the vector3d constructor. I was considering trying to fix it myself, but I wanted to make sure that I didn't introduce any new bugs in the process ... pondering fixes, I think the case of a 3x3 input matrix might be an issue, since you can't unambiguously define whether the output should be a row or column vector solely from the shape of the input, unlike other N x 3 or 3 x N matrices.
Example of inconsistent behavior:
% Create some row vectors
x = rand(1, 10);
y = rand(1, 10);
z = rand(1, 10);
% Create a vector3d from row vectors - result is a row vector (reasonable)
vector3d(x, y, z)
ans =vector3dsize:1x10
[...]% Create a vector3d from column vectors - result is a column vector (reasonable)
vector3d(x', y', z')
ans =vector3dsize:10x1
[...]% Create a 3 x N matrix
xyz = [x; y; z;];
% Create a vector3d from 3 x N matrix - result is a 1 x N vector3d (reasonable)
vector3d(xyz)
ans =vector3dsize:1x10
[...]% Create a vector3d from N x 3 matrix - unexpected result!
vector3d(xyz')
ans =vector3dsize:1x3
[...]
Expected result:
If a 3 x N matrix produces a 1 x N vector3d, a N x 3 matrix should produce a N x 1 vector3d.
However, a 3 x 3 matrix is ambiguous. Possibly best to have that case throw a warning or error.
What MTEX version do you use?
MTEX 5.11.2
The text was updated successfully, but these errors were encountered:
I agree that the behavior is not desirable. Unfortunately, I also do not oversee whether changing this behavior creates unintended bugs. As a workaround I would recommend to use vector3d.byXYZ(d)' whenever you have a Nx3 data matrix and vector3d(d)` whenever you have a 3xN data matrix.
I noticed some inconsistent behavior in the vector3d constructor. I was considering trying to fix it myself, but I wanted to make sure that I didn't introduce any new bugs in the process ... pondering fixes, I think the case of a 3x3 input matrix might be an issue, since you can't unambiguously define whether the output should be a row or column vector solely from the shape of the input, unlike other N x 3 or 3 x N matrices.
Example of inconsistent behavior:
Expected result:
If a 3 x N matrix produces a 1 x N vector3d, a N x 3 matrix should produce a N x 1 vector3d.
However, a 3 x 3 matrix is ambiguous. Possibly best to have that case throw a warning or error.
What MTEX version do you use?
MTEX 5.11.2
The text was updated successfully, but these errors were encountered: