Closed bob-carpenter closed 10 years ago
Why not transpose the exponent so that it is the same structure as the base?
vec ^ row_vec --> vec ^ transpose{row_vec} = vec ^ vec
row_vec ^ vec --> row_vec ^ transpose{vec} = row_vec ^ row_vec
If we want to define mixed operations, taking the base type as the result makes the most sense to me.
My main concern is that the exponent doesn't then have consistent behavior, with:
real ^ row_vec : row_vec
vec ^ row_vec : vec
I think putting the transpose{...} there explicitly highlights that it gets applied only if there's a type mismatch with the base.
On May 16, 2014, at 1:39 AM, Avraham Adler notifications@github.com wrote:
Why not transpose the exponent so that it is the same structure as the base?
vec ^ row_vec --> vec ^ transpose{row_vec} = vec ^ vec row_vec ^ vec --> row_vec ^ transpose{vec} = row_vec ^ row_vec
— Reply to this email directly or view it on GitHub.
If it's not obvious what vec ^ row_vec or row_vec ^ vec should return, should it even be allowed? It seems that no matter what is chosen, the results are going to surprise a lot of users.
-- Kevin
On May 15, 2014, at 6:59 PM, Bob Carpenter wrote:
If we want to define mixed operations, taking the base type as the result makes the most sense to me.
My main concern is that the exponent doesn't then have consistent behavior, with:
real ^ row_vec : row_vec
vec ^ row_vec : vec
I think putting the transpose{...} there explicitly highlights that it gets applied only if there's a type mismatch with the base.
- Bob
On May 16, 2014, at 1:39 AM, Avraham Adler notifications@github.com wrote:
Why not transpose the exponent so that it is the same structure as the base?
vec ^ row_vec --> vec ^ transpose{row_vec} = vec ^ vec row_vec ^ vec --> row_vec ^ transpose{vec} = row_vec ^ row_vec
— Reply to this email directly or view it on GitHub.
— Reply to this email directly or view it on GitHub.
I agree - if the vectorization is ambiguous it's probably both worth the UX hassle.
On May 16, 2014, at 4:31 AM, "Kevin S. Van Horn" notifications@github.com wrote:
If it's not obvious what vec ^ row_vec or row_vec ^ vec should return, should it even be allowed? It seems that no matter what is chosen, the results are going to surprise a lot of users.
-- Kevin
On May 15, 2014, at 6:59 PM, Bob Carpenter wrote:
If we want to define mixed operations, taking the base type as the result makes the most sense to me.
My main concern is that the exponent doesn't then have consistent behavior, with:
real ^ row_vec : row_vec
vec ^ row_vec : vec
I think putting the transpose{...} there explicitly highlights that it gets applied only if there's a type mismatch with the base.
- Bob
On May 16, 2014, at 1:39 AM, Avraham Adler notifications@github.com wrote:
Why not transpose the exponent so that it is the same structure as the base?
vec ^ row_vec --> vec ^ transpose{row_vec} = vec ^ vec row_vec ^ vec --> row_vec ^ transpose{vec} = row_vec ^ row_vec
— Reply to this email directly or view it on GitHub.
— Reply to this email directly or view it on GitHub.
— Reply to this email directly or view it on GitHub.
Associativity and precedence to follow Fortran:
It'd be nice to support the syntax
a^b
as shorthand forpow(a,b)
.Even nicer to vectorize. If the types are coherent, the return seems obvious:
But what if they're mixed?