-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Description
Right now, RowVectors are implicitly embedded within Matrices, but not so for Vectors. This leads to funky behaviors such as:
julia> a = Vector(1:2)
2-element Array{Int64,1}:
1
2
julia> am = Matrix(2, 1); am[:] = 1:2; am
2×1 Array{Any,2}:
1
2
julia> a == am
false
julia> a' == am'
trueThere are many ways we could try to fix this. Two take two extremal approaches, we could:
-
On the conservative side, we could just define
==(Matrix, Vector)and be done with it -
Personally I'd rather push for automatic "do what makes sense" equality checking for types that have natural isomorphisms. E.g. if I have an
Array{T,N}, I think it makes sense to define equality with anArray{T,N+1}that has a trailing singleton dimension, as the former is naturally embedded within the space of the second.
I'd be happy to submit a PR implementing whatever we reach consensus on. Hopefully this is a small change to just equality and doesn't get sidetracked into anything more fundamental.
Pinging a random subset of the LinAlg posse @stevengj @jiahao @mbauman