- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 34
Closed
JuliaLang/julia
#38062Labels
parserLanguage parsing and surface syntaxLanguage parsing and surface syntax
Description
Now that .op
is generally the vectorized form of op
, it's very confusing that .'
means transpose rather than the vectorized form of '
(adjoint, aka ctranspose). This issue is for discussing alternative syntaxes for transpose and/or adjoint.
ttparker, Sacha0, Gnimuc, srohrer32, mschauer and 6 more
Metadata
Metadata
Assignees
Labels
parserLanguage parsing and surface syntaxLanguage parsing and surface syntax
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
mbauman commentedon Mar 15, 2017
Andreas tried
Aᵀ
(and maybeAᴴ
) in JuliaLang/julia#19344, but it wasn't very well received. We could similarly pun on^
with special exponent typesT
(and maybeH
) such thatA^T
is transpose, but that's rather shady, too. Not sure there are many other good options that still kinda/sorta look like math notation.StefanKarpinski commentedon Mar 15, 2017
I kind of think that
t(A)
might be the best, but it's unfortunate to "steal" another one-letter name.nalimilan commentedon Mar 15, 2017
Moving my comment from the other issue (not that it solves anything, but...):
+1 for using something else than
.'
.I couldn't find languages with a special syntax for transposition, except for APL which uses the not-so-obvious
⍉
, and Python which uses*X
(which would be confusing for Julia). Several languages usetranspose(X)
; R usest(X)
. That's not pretty, but it's not worse than.'
. At least you're less tempted to use'
by confusing it with.'
: it would be clear that these are very different operations.See Rosetta code. (BTW, the Julia example actually illustrates conjugate transpose...)
mauro3 commentedon Mar 15, 2017
Could one of the other ticks be used?
`
or"
ararslan commentedon Mar 15, 2017
-100 to changing adjoint, since it's one of the awesome things that makes writing Julia code as clear as writing math, plus conjugate transpose is usually what you want anyway so it makes sense to have an abbreviated syntax for it.
As long as we have the nice syntax for conjugate transpose, a postfix operator for regular transpose seems mostly unnecessary, so just having it be a regular function call seems fine to me.
transpose
already works; couldn't we just use that? I find thet(x)
R-ism unfortunate, as it's not clear from the name what it's actually supposed to do.Using a different tick would be kind of weird, e.g.
A`
can look a lot likeA'
depending on the font, andA"
looks too much likeA''
.stevengj commentedon Mar 16, 2017
If we make the change in #408, then a postfix transpose actually becomes more useful than it is now. e.g. if you have two vectors
x
andy
and you want to applyf
pairwise on them, you can do e.g.f.(x, y.')
... with #408, this will be applicable to arrays of arbitrary types.Honestly, I think our best option is still to leave it as-is. None of the suggestions seem like a clear improvement to me.
.'
has the advantage of familiarity from Matlab. The.
actually is somewhat congruent with dot-call syntax in examples likef.(x, y.')
, and suggests (somewhat correctly) that the transpose "fuses" (it doesn't produce a temporary copy thanks toRowVector
and future generalizations thereof).In fact, we could even take it further, and make
f.(x, g.(y).')
a fusing operation. i.e. we change.'
transpose to be non-recursive ala #408 and we extend its semantics to include fusion with other nested dot calls. (If you want the non-fusing version, you would calltranspose
.)StefanKarpinski commentedon Mar 16, 2017
I like that plan a lot, @stevengj.
StefanKarpinski commentedon Mar 16, 2017
One wrinkle: presumably the
@.
macro does not turny'
intoy.'
(since that would be wrong). It could, however, turny'
into some kind of fused adjoint operation.stevengj commentedon Mar 16, 2017
The main problem is finding a clean way to make
f.(x, g.(y).')
have fusing semantics. One possibility would be to transform it tof.(x, g.(y.'))
and hence tobroadcast(x,y -> f(x, g(y)), x, y.')
?Note that, for this to work properly, we might need to restore the fallback
transpose(x) = x
method, in which case we might as well let transpose remain recursive.StefanKarpinski commentedon Mar 17, 2017
I think deciding whether transpose should be recursive or not is orthogonal to whether we make it participate in dot syntax fusion. The choice of making it non-recursive is not motivated by that.
stevengj commentedon Mar 17, 2017
@StefanKarpinski, if restore a fallback
transpose(x) = x
, then most of the motivation for changing it to be non-recursive goes away.107 remaining items