-
-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
decide if [1 2 3]
should be a matrix or row vector
#450
Comments
[1 2 3]
should be a matrix or row vector[1 2 3]
should be a matrix or row vector
Would this refer to the space-delimited array literal only or also to |
+1 for RowVector |
1 similar comment
+1 for RowVector |
+1 for |
Won't |
Good question. I don't know. That might be part of the decision here. |
Yes, the parser distinguishes |
It would be an interesting experiment to implement this and see how much code it breaks in published packages. My guess is that most code would keep running, and it will turn out to be very rare that people actually wanted a 1-by-n matrix rather than a row vector when they wrote (Personally, I don't think I'll ever want to create a m-by-1 or 1-by-n matrix from scalars, but If I ever do, I'll be happy to use a more verbose syntax, such as |
There's also this:
|
If that behaviour is maintained, then it makes no sense that |
Triage decision is not to promote to matrix for scalar hcat (what @dlfivefifty said :). |
The thing I was trying to say during the call was that we might get some feedback when ["A" "B" "C"] starts returning julia> RowVector(["A", "B", "C"])
1×3 RowVector{Any,Array{String,1}}:
Error showing value of type RowVector{Any,Array{String,1}}:
ERROR: MethodError: no method matching transpose(::String)
Closest candidates are:
transpose(::BitArray{2}) at linalg/bitarray.jl:265
transpose(::Number) at number.jl:100
transpose(::RowVector{T,CV} where CV<:(ConjArray{T,1,V} where V<:(AbstractArray{T,1} where T) where T) where T) at linalg/rowvector.jl:82
...
Stacktrace:
[1] _getindex at ./abstractarray.jl:906 [inlined]
[2] getindex(::RowVector{Any,Array{String,1}}, ::Int64, ::Int64) at ./abstractarray.jl:882
[3] isassigned(::RowVector{Any,Array{String,1}}, ::Int64, ::Int64, ::Vararg{Int64,N} where N) at ./abstractarray.jl:222
[4] alignment(::IOContext{Base.Terminals.TTYTerminal}, ::RowVector{Any,Array{String,1}}, ::Array{Int64,1}, ::Array{Int64,1}, ::Int64, ::Int64, ::Int64) at ./show.jl:1357
[5] print_matrix(::IOContext{Base.Terminals.TTYTerminal}, ::RowVector{Any,Array{String,1}}, ::String, ::String, ::String, ::String, ::String, ::String, ::Int64, ::Int64) at ./show.jl:1487
[6] print_matrix(::IOContext{Base.Terminals.TTYTerminal}, ::RowVector{Any,Array{String,1}}, ::String, ::String, ::String) at ./show.jl:1459
[7] #showarray#263(::Bool, ::Function, ::IOContext{Base.Terminals.TTYTerminal}, ::RowVector{Any,Array{String,1}}, ::Bool) at ./show.jl:1709
[8] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("text/plain")}, ::RowVector{Any,Array{String,1}}) at ./REPL.jl:122
[9] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::RowVector{Any,Array{String,1}}) at ./REPL.jl:125
[10] display(::RowVector{Any,Array{String,1}}) at ./multimedia.jl:194
[11] eval(::Module, ::Any) at ./boot.jl:235
[12] print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool, ::Void) at ./REPL.jl:144
[13] print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at ./REPL.jl:129
[14] (::Base.REPL.#do_respond#16{Bool,Base.REPL.##26#36{Base.REPL.LineEditREPL,Base.REPL.REPLHistoryProvider},Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at ./REPL.jl:646 i.e. a something you cannot index into. Possible solutions seem to be
|
There's talk of making transpose non-recursive, which resolves this: #408
Edit: that was a silly example since it should be a |
I'm very much aware of #408 and I'm not too confident that it easily fixed. Instead 3. above, we could change the behavior of |
We can record here that modulo type issues due to #408, there seems to be preference for |
OK, so between recursive adjoints, non-recursive transposes, the need to support all the fast BLAS stuff and lazy conjugation, the need to be able to extract a row of a While I was really hoping to avoid recursive adjoints altogether, I guess we just need to do this. Similarly for the upcoming lazy matrix adjoint/transpose. |
Two design questions:
|
Would you then apply different functions depending on the element type? |
Would it make sense to have |
Stefan - yes exactly, we can either do that or extend the Andreas - I'm guessing that these will all just get inlined away for e.g. |
Wouldn't it mean that we'd have to define |
I thought the idea is |
I was referring to #450 where it was suggested that |
For Though I'm thinking that extending |
This is a linear-algebra operation so could be decoupled from Base, but then the question is if we require doing |
Triage feels that this should be a row vector. |
The plan in JuliaLang/julia#23424: The only thing I'd really like to consider is that |
I'd be happy with that – anything with both spaces and semicolons as a matrix. |
I'm ok with that too, but it's a pity there's no corresponding way to get an Nx1 object from |
Close enough perhaps? julia> [1; 2]
2-element Array{Int64,1}:
1
2 |
|
Ah, sorry! My expectation that |
To be honest I've always been confused why |
I would think |
I guess I've always found this syntax meaning to be a little unnecessary when we have I also find that my brain assumes |
I must confess that this just feels slightly less obvious to me now that we no longer have a specific
is any better than the status quo. I know it's semantically the same as the old |
Also worth considering that the those wrappers likely will move out with |
As much as I like moving things out of Base, I don't think it should drive everything. If we want |
I share Andreas's view on this question. Additionally, the matrix literal / array concatenation syntax leaves something to be desired as it stands, and adding another special case sounds less than fantastic. Best! |
But what about...THIS: #450 |
So with the implementation of recursive transposed row vector, I would still love to see I mean, we could reserve this syntax for linear algebra usage and require It could potentially get a bit yuck with the storage of the elements of this literal being recursively transposed compared to how they are written - especially for element types that don’t |
That sort of oddity would be lovely to do away with in sorting out JuliaLang/julia#7128. Best! |
I was under the impression that the proposal was for |
I don't think that resolves this. Solving JuliaLang/julia#7128 in general appears to be harder; indeed there is no solution in the pipeline. Currently, |
Triage feels that having |
There was some discussion of this now that we have row vectors.
The text was updated successfully, but these errors were encountered: