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

".-" is not a unary operator #14161

Closed
eschnett opened this issue Nov 26, 2015 · 7 comments
Closed

".-" is not a unary operator #14161

eschnett opened this issue Nov 26, 2015 · 7 comments
Labels
broadcast Applying a function over a collection

Comments

@eschnett
Copy link
Contributor

I notice that .- is not a unary operator:

julia> .-[1]
ERROR: syntax: ".-" is not a unary operator

For consistency, I'd expect .+ and .- to be available as unary operators as well.

@stevengj
Copy link
Member

It's hard to imagine a circumstance in which .-x != -x, so on that grounds I'm inclined not to add the former synonym.

@eschnett eschnett changed the title j".-" is not a unary operator ".-" is not a unary operator Nov 26, 2015
@eschnett
Copy link
Contributor Author

It's the same case as as for x - y and x .- y. If there's an element-wise subtraction operator, I expect an element-wise negation operator as well.

@stevengj
Copy link
Member

@eschnett, that's not true. x - y is not defined if x and y do not have the same shape, where x .- y is (often) defined. As a binary operator, therefore, .- is a strict generalization.

@oxinabox
Copy link
Contributor

oxinabox commented Dec 3, 2015

Are there any element wise unary operators?
I can't recall if there is an element-wise "not" operator

@KristofferC
Copy link
Member

Nothing really actionable here.

@stevengj
Copy link
Member

stevengj commented Jan 26, 2017

Now that dot operators are fusing, we should probably reconsider this. e.g. imagine you want to compute log.(.-a) rather than log.(-a), in order to avoid the temporary array for a::Array.

@stevengj stevengj reopened this Jan 26, 2017
@yuyichao
Copy link
Contributor

I think we might still want to parse unary .- as broadcast.

@stevengj stevengj added the broadcast Applying a function over a collection label Jan 26, 2017
stevengj added a commit to stevengj/julia that referenced this issue Jan 26, 2017
stevengj added a commit to stevengj/julia that referenced this issue Jan 27, 2017
StefanKarpinski pushed a commit that referenced this issue Feb 2, 2017
* support dots for unary operators (closes #14161)
* docs for unary dot operators
* work around #20249
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
broadcast Applying a function over a collection
Projects
None yet
Development

No branches or pull requests

5 participants