Vector covector incorrect multiplication with another vector.
v1 = Vector[2,3,4]
v2 = Vector[4,5,6]
Vector does not have distinction between row and column, there's no column vector notion in the language.
v1 * v2.covector #Matrix8,10,12],[12,15,18],[16,20,24
Should be illegal. But works like if v2.covector is transposed / column vector which it's clearly not.¶
v1.covector * v2.covector #ExceptionForMatrix::ErrDimensionMismatch: Matrix dimension mismatch
v1 * v2 #ExceptionForMatrix::ErrOperationNotDefined: Operation(*) can't be defined: Vector op Vector
No comments, see my observation below.¶
v1.covector * v2 #Vector
#Again covector treated like transposed / column vector.
Personal observation: Terrible choice to represent Vector like an Array, Vector should be a shortcut to Matrix.
Updated by jeremyevans0 (Jeremy Evans) about 1 year ago
- Assignee set to marcandre (Marc-Andre Lafortune)
- Status changed from Open to Assigned
I don't think this is a bug, but I'll let marcandre make the determination.
Vector can't be multipled with
Vector, you get an error. You can multiple a
Vector by a
Matrix and vice-versa by design, and
Vector#covector returns a
Matrix. You can multiple a
Matrix by a
Matrix only if the column_count of the receiver is the row count of the argument.
Vector is good design or bad design I'm not going to speculate on. However, you could consider using NMatrix (https://rubygems.org/gems/nmatrix), as that represents vectors as matrices.
Updated by marcandre (Marc-Andre Lafortune) about 1 year ago
- Status changed from Assigned to Rejected
Thanks Jeremy for updating this issue. I double checked and never received the original email notification...
Vectordoes not have distinction between row and column, there's no column vector notion in the language.
Actually, in the library
Vector is a column vector. You can see this for example with:
Vector[1, 2].to_matrix # => Matrix[, ]
So I believe that it is correct that
v.covector * v or
v * v.covector returns some result while other combinations should raise.
I'll close this but will reopen if there's more discussion to be had.