-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
collect on a Adjoint{T,Array{T,1}} should return a Adjoint{T,Array{T,1}} #762
Comments
The size return value is correct. A zero or nothing as the first dimension does not make any sense. And for exactly this reason, the returned type from collect is also correct. There’s no guarantee that operates on the returned value is exactly he same as the input, that is simply impossible. |
Can you elaborate a bit more? How can the return value of size be correct when the adjoint of a vector is not a map from vectors to vectors but from vectors to scalars. Having size return For your second point. The proposal would exactly provide that guarantee as the return value of collect would be identical to it's input value. |
This was the compromise that was achieved through #42: adjoint vectors participate in the linear algebra of matrices largely behaving as though they were
|
Because scalar does not have dimension 0 or nothing. julia> size(1, 1)
1
No, it just mean the returned value should have a dimension of
No it doesn't. What I'm talking about is that this is a property that's impossible to achieve for all input type and it is not at all the goal of this function. If you want a function that maintains all properties of a type, the correct function to use is
While I think there are probably things that are less than well defined but I think the matching of the shape is pretty well define here. |
The size of a scalar is current an empty tuple
|
Correct, but it does have a size 1. What I was saying is that returning |
That's correct — it behaves like a 0-dimensional array. Just like zero-dimensional arrays, though, you can ask for the length of the "missing" dimensions and it'll return 1. |
Sorry for asking so many questions but I don't understand why it would it be a problem to return 0? Does it have to do with numbers being iterable in Julia? e.g. in this issue JuliaLang/julia#11769 Jeff mentions numbers to be zero-dimensional so why couldn't size just return 0? And I guess for the missing dimensions returning 0 instead of 1 could make sense but that is a bit out of scope of the current issue. |
These are better questions for the discourse mailing list. |
I removed the last sentence from the original issue to keep the discussion focused on the behavior of |
This should be closed, An analogy can be drawn from a lazy vector that is |
Fine to close this but I think what @mbauman mentions above
Is the real problem. |
how come? It's pretty common for textbooks to write something like:
or wikipedia:
Maybe you're saying |
Isn't this conversation just #42 redux? |
No my point is that
into a |
Yeah let's stop now before it's too late. |
The documentation of
collect
states that it will return an object with the same shape and number of dimensions. However currently calling collect on objects of typeAdjoint{T,Array{T,1}}
returns a1xn
matrix and these have different behaviour. AnAdjoint
of a vector in julia is a linear operator that maps vectors to scalars (as it should be) but this is not equivalent to a1xn
matrix which maps vectors to 1-element vectors. e.g.One solution would be to let
collect
on aAdjoint{T,Array{T,1}}
return aAdjoint{T,Array{T,1}}
.Also callingsize
on objects of typeAdjoint{T,Array{T,1}}
returns(1,n)
indicating that it is an1xn
matrix instead this should return e.g.(0,n)
or(nothing,n)
The text was updated successfully, but these errors were encountered: