On Wednesday, 31 August 2016 00:14:30 UTC+1, Sheehan Olver wrote:
>
> I agree with Chris, though I prefer Matrix(eye(5)) to collect(eye(5)).
>
>>
Matrix(eye(5)) looks reasonably pleasing to the eyes :). (but still 8
keystrokes more than needed)
I agree with Chris, though I prefer Matrix(eye(5)) to collect(eye(5)).
I've found teaching-wise that saying "Matlab has Dense and Sparse. Julia
has a lot more special types." worked pretty well to explain the
situation.
The issue though is with rand: it seems like overkill for rand(5,5)
I agree with
On Wednesday, August 31, 2016 at 3:26:22 AM UTC+10, Chris Rackauckas wrote:
>
> Even then, creating the 5x5 dense matrix to then copy it into A[1:5,1:5]
> is not what you'd want to do. Ideally would just have eye(5) return
> something like I which has a size, and just sets
> I agree that there can be a teaching problem with Julia. A lot of things
happen like fast magic to "mathematicians not trained in CS".
yes, this is the issue. FWIW in other respects it is nice to use Julia for
teaching, e.g., the fact that there are no classes is great!
> I don't think the
Even then, creating the 5x5 dense matrix to then copy it into A[1:5,1:5] is
not what you'd want to do. Ideally would just have eye(5) return something
like I which has a size, and just sets A[i,j]=1 if i=j 0 otherwise, with
checks that it's the right size. Actually, the current I would do it if
If this is your only use-case of I, then you don't need it anyways. Just
write 1.0 * A instead; same effect, independent of what type of array A is.
But what if I use I in a different way? Suppose I want to A[1:5,1:5] =
eye(5); I can't do that with I. Of course we could give it another type
I don't think there is anything like pushing the language to computer
scientists, it's the exact opposite, making it seamlessly fast without
forcing the user to manipulate types. Again, you write B = I*A and get B =
copy(A) performance. That is the original proposal.
Most of us follow the same
I agree with Sheehan that this affect a number of functions in Base, not
just eye - that was the point I was trying to make, sorry I wasn't clear.
I raised this in a discussion in a formal issue somewhere, which I can't
find now. Somebody (Steven Johnson?) argued that `zeros` and `ones` are
But the core issue isn't 'eye' specific, it's "what should the default type
for functions that create matrices be?"Christoph's comments do not
deviate from this question.
The answer to this question affects 'rand', 'zeros', 'ones', 'linspace',
etc. just as much as eye. ArrayFire means
Sorry for the combative tone Christoph. I thought it was necessary in order
to not deviate too much from the core issue. Thank you for your
participation and for raising your personal opinions about the topic.
-Júlio
Personal opinion again: I think it is not good to underestimate the
importance of teaching. Mathematics students in particular tend to stick
with the language they learn first. It is part of why Matlab is so
successful in the applied mathematics community.
P.S.: Not sure why such a combative
But eye and linspace are not the only culprits: there's rand, zeros, etc. so
unless everything is a special type, ArrayFire will still need constructors like
rand(AFArray{Float64},5,5)
Sent from my iPhone
> On 30 Aug 2016, at 13:02, Júlio Hoffimann wrote:
>
> So
So maybe add a dimension or create a type that makes more sense for the
application?
-Júlio
I doesn't have a dimension so you can't do collect(I)
Sent from my iPhone
> On 30 Aug 2016, at 12:53, Júlio Hoffimann wrote:
>
> Why is it so important to have all this machinery around linspace and eye?
> collect is more than enough in my opinion and all the
Why is it so important to have all this machinery around linspace and eye?
collect is more than enough in my opinion and all the proposals for keeping
both versions and pass a type as a parameter are diluting the main issue
here: the need for a smart mechanism that handles things efficiently and
I’d also propose adding
linspace(Vector{Float64},0,100)
linspace(Range,0,100)
linspace(LinSpace{Float64},0,100)
as constructors that return the corresponding type. That way Christoph can use
the linspace(Vector{Float64},0,100) version in his teaching.
> On 30 Aug
I just think the moment you start mixing default behaviors, you teaching
becomes exponentially harder. I found range objects not that hard to teach,
just "it uses an abstract version of an array to not really build the
array, but know what the value would be every time you want one. If you
I confess I'm not quite sure what the right answer is here. It would seem
overkill to have both `I` and something that's the same thing, except sized.
OTOH, I see the attraction.
Maybe if it were part of a general mechanism, e.g., SizedArrayOperator{O,N}
(for performing an operation `O` on
Christoph,
Can you elaborate on why you want to have both? Also, why you wanted the
non-lazy linspace? If I understood correctly, you're talking about
returning a array with allocated memory versus a range object, isn't the
latter always preferred? I don't understand.
-Júlio
I think the ArrayFire.jl (https://github.com/JuliaComputing/ArrayFire.jl)
syntax for matrices (e.g. rand(AFArray{Float64},100,100)) should be adopted
in Base to allow multiple eye commands that return different types:
eye(Diagonal{Float64},10)
eye(SparseMatrix,10) # default to Float?
Two give my two cents:
I think this is an inconsistency in the design of the standard library.
* while we have both I and eye available for the Identity matrix,
* linspace was replaced with a lazy data-structure.
Personally I would like to keep both I and eye; but I also would have liked
to
Tim,
Would it make sense to have "I" as an object that acts like UniformScaling
and doesn't require any memory allocation, but is only transformed into
sparse matrix via the [] operator? Maybe something similar to arrays ->
subarrays?
-Júlio
The reason is because `I` doesn't have a size, so you can't `full(I)`. I
think the most reasonable thing would be for `I` to have an optional size
(and then act like an identity operator of that size, so error on the wrong
size multiplications, etc.), and then have sparse(I), Diagonal(I), and
But if it does not makes sense from your point to give a full matrix, why
does it make more sense to return a diagonal matrix? It is still lots of
heap allocated memory. So you replace a large performance trap with a
smaller one. What has been gained? We would still have to teach people the
On Monday, August 29, 2016 10:40:10 AM CDT Júlio Hoffimann wrote:
> Why would one want dense identity matrix?
Because you might want it to serve as an initialization for an iterative
optimization routine (e.g., ICA) that updates the solution in place, and which
assumes a dense matrix?
We could
The confusion is pretty clear. Someone suggested code like
m = m + lambda*eye(m)
when eye(m) shouldn't be used there. And if lambda is a vector of
eigenvalues, eye(m) still shouldn't be used there and instead the Diagonal
should be used. So if you shouldn't be using this command, why should it
As Julio asks, why should the default be a dense identity matrix? Who
actually wants to use that? I agree `I` should be in more visible in the
docs and in most cases it's the better option. But if you actually want a
matrix as an array instead of just an operator (this is reasonable, because
Why would one want dense identity matrix?
What is the confusion? Use eye(n) if you want a dense identity matrix. Use
I if you want something that acts like an identity element. Use
Diagonal(ones(n)) if you want a diagonal identity matrix. I see no reason
at all why eye should be changed.
On Monday, August 29, 2016 at 4:32:34 PM UTC+2,
But you don't want a sparse matrix. It would not be an efficient way to
actually use it since sparse matrices have a bit of overhead due to their
table structure. Even better would be a Diagonal since it's just an array
with dispatches to act like a diagonal matrix. But best would be to use the
It is more than sparse, it acts as scalar at first, maybe the operator []
modifies the type to sparse?
-Júlio
You mean a sparse matrix?
Andreas, is there a way to get the best of both worlds? Let's say eye() is
deprecated, can we somehow set off-diagonal terms in a type that is smart
like UniformScaling and supports indexing with operator []?
-Júlio
Isn't `I` better here?
On Monday, August 29, 2016 at 6:49:41 AM UTC-7, Evan Fields wrote:
>
>
>
> On Monday, August 29, 2016 at 9:39:19 AM UTC-4, Júlio Hoffimann wrote:
>>
>> I'd like to understand the existence of eye() in Julia, it is still not
>> clear to me. Is it because one wants type
Evan, this is exactly where you should use I, i.e.
m = m + λ*I
The reason is that eye(m) will first allocate a dense matrix of size(m,1)^2
elements. Then * will do size(m,1)^2 multiplications of lambda and allocate
a new size(m,1)^2 matrix for the result. Finally, size(m,1)^2 additions
will be
On Monday, August 29, 2016 at 9:39:19 AM UTC-4, Júlio Hoffimann wrote:
>
> I'd like to understand the existence of eye() in Julia, it is still not
> clear to me. Is it because one wants type stability when updating a matrix
> iteratively? Is this possibly a limitation from the design of the
Julia is developing over time. Originally, eye was probably implemented to
mimic Matlab. Later we realized that the type system allowed us to define
the much nicer UniformScaling which has the special case
const I = UniformScaling(1)
which is almost alway better to use unless you plan to modify
We could deprecate eye. Then the users would get a warning directing them
to use `I` instead.
On Mon, Aug 29, 2016 at 6:29 AM, Júlio Hoffimann
wrote:
> I still think that having a "global variable" named "I" is not robust.
> I've read so many scripts in matlab that do
I'd like to understand the existence of eye() in Julia, it is still not
clear to me. Is it because one wants type stability when updating a matrix
iteratively? Is this possibly a limitation from the design of the language?
-Júlio
I still think that having a "global variable" named "I" is not robust. I've
read so many scripts in matlab that do I = eye(n). This approach is not
gonna work.
-Júlio
If we could somehow make `I` more visible, wouldn't you think that
B = I*A
is better than
B = eye(1)*A
?
Small side note: the best we can hope for is probably performance similarly
to B = copy(A) because it wouldn't be okay to alias A and B when B has been
constructed from *.
On Mon, Aug
Hi Andreas,
As a user I would like to write
B = eye(1) * A
and have the performance of
B = A
90% of the users won't be aware of this 1-character variable "I" defined in
Base nor use it. Also, I can guarantee that "I" is much easier to overwrite
than a well known function name.
-Júlio
You can also overwrite eye
Could you elaborate on the "90% of the users won't be aware of these
internal details in their day-to-day coding" part? If we ignore the name
for a while, why is `I` not what you want here? It is as efficient as it
can possibly be.
On Sunday, August 28, 2016 at
43 matches
Mail list logo