Skip to content
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

.== not defined for tuples #4827

Closed
jiahao opened this issue Nov 16, 2013 · 7 comments
Closed

.== not defined for tuples #4827

jiahao opened this issue Nov 16, 2013 · 7 comments
Labels
help wanted Indicates that a maintainer wants help on an issue or pull request

Comments

@jiahao
Copy link
Member

jiahao commented Nov 16, 2013

Having .== work on tuples would simplify a lot of dimensions checking in the linear algebra routines.

julia> A=randn(10,10);

julia> any(size(A).==10)
ERROR: no method .==((Int64,Int64),Int64)

julia> all([size(A)...].==10)
true
@StefanKarpinski
Copy link
Member

That seems like a reasonable feature to me.

@mlubin
Copy link
Member

mlubin commented Nov 16, 2013

Wouldn't checking the dimension like that have a hidden memory allocation for the temporary boolean array?

@jiahao
Copy link
Member Author

jiahao commented Nov 16, 2013

for the [size(A)…] code, yes. However,
(a) .== on tuples doesn’t have to be implemented via a temporary array, and
(b) when used to check array dimensions, this is hardly a time- or memory-critical application.

@JeffBezanson
Copy link
Member

We are pretty close to being able to do any(size(A).==size(B)) without any intermediate tuples.

The painful case here is tuple .== array. Do we iterate over both, or compare the array to each element of the tuple, or the other way?

@IainNZ
Copy link
Member

IainNZ commented Aug 11, 2015

@jiahao is this still a desired feature?

@jiahao
Copy link
Member Author

jiahao commented Aug 11, 2015

yes

@IainNZ IainNZ added the help wanted Indicates that a maintainer wants help on an issue or pull request label Aug 11, 2015
@mbauman
Copy link
Member

mbauman commented Jan 10, 2017

Implemented by #17623, which has also answered how to handle tuple .== array. It's also super-efficient when using same-length tuples, but comparisons against scalars could probably be optimized further if you want to use this for linear algebra dimension checks.

@mbauman mbauman closed this as completed Jan 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Indicates that a maintainer wants help on an issue or pull request
Projects
None yet
Development

No branches or pull requests

6 participants