Jump to page: 1 29  
Page
Thread overview
Should we add `a * b` for vectors?
Sep 22, 2017
Ilya Yaroshenko
Sep 23, 2017
jmh530
Sep 24, 2017
Manu
Sep 24, 2017
Z
Sep 24, 2017
Mark
Sep 24, 2017
H. S. Teoh
Sep 24, 2017
jmh530
Sep 25, 2017
Nicholas Wilson
Sep 25, 2017
user1234
Sep 25, 2017
Nicholas Wilson
Sep 25, 2017
jmh530
Sep 24, 2017
jmh530
Sep 26, 2017
Atila Neves
Sep 27, 2017
Manu
Sep 27, 2017
Ilya Yaroshenko
Sep 27, 2017
jmh530
Sep 27, 2017
Manu
Sep 28, 2017
jmh530
Sep 27, 2017
Manu
Sep 28, 2017
Walter Bright
Sep 28, 2017
Wyatt
Sep 30, 2017
Walter Bright
Oct 02, 2017
Timon Gehr
Oct 03, 2017
Walter Bright
Oct 03, 2017
jmh530
Oct 04, 2017
Walter Bright
Oct 05, 2017
Walter Bright
Oct 05, 2017
Timon Gehr
Oct 07, 2017
Walter Bright
Oct 08, 2017
Timon Gehr
Oct 09, 2017
Jacob Carlborg
Oct 05, 2017
Joakim
Oct 07, 2017
Walter Bright
Oct 04, 2017
Dukc
Oct 04, 2017
Walter Bright
Oct 04, 2017
Walter Bright
Oct 05, 2017
Jacob Carlborg
Oct 05, 2017
Walter Bright
Oct 05, 2017
Dukc
Oct 05, 2017
Dukc
Oct 05, 2017
Walter Bright
Oct 05, 2017
Timon Gehr
Oct 05, 2017
Dukc
Oct 05, 2017
Dukc
Oct 05, 2017
Walter Bright
Oct 05, 2017
Walter Bright
Oct 05, 2017
nkm1
Oct 05, 2017
Dukc
Oct 05, 2017
nkm1
Oct 05, 2017
nkm1
Oct 05, 2017
Dukc
Oct 05, 2017
Walter Bright
Oct 05, 2017
Timon Gehr
Oct 05, 2017
Dukc
Oct 05, 2017
Timon Gehr
Oct 05, 2017
Walter Bright
Oct 05, 2017
Timon Gehr
Oct 05, 2017
Walter Bright
Oct 06, 2017
Walter Bright
Oct 09, 2017
Timon Gehr
Oct 09, 2017
Timon Gehr
Oct 05, 2017
Timon Gehr
Oct 05, 2017
Walter Bright
Oct 05, 2017
Jonathan M Davis
Oct 06, 2017
Guillaume Boucher
Oct 06, 2017
jmh530
Oct 06, 2017
Timon Gehr
Oct 06, 2017
Jonathan M Davis
Oct 06, 2017
jmh530
Oct 06, 2017
Jonathan M Davis
Oct 06, 2017
jmh530
Sep 30, 2017
Manu
Sep 30, 2017
Walter Bright
Oct 03, 2017
Enamex
Oct 03, 2017
Walter Bright
Sep 27, 2017
jmh530
Sep 27, 2017
tn
Sep 27, 2017
John Colvin
September 22, 2017
Should we add `a * b` to ndslice for 1d vectors?
Discussion at https://github.com/libmir/mir-algorithm/issues/91
September 23, 2017
On Friday, 22 September 2017 at 17:11:56 UTC, Ilya Yaroshenko wrote:
> Should we add `a * b` to ndslice for 1d vectors?
> Discussion at https://github.com/libmir/mir-algorithm/issues/91

My position is still that it can't hurt to add a dot product function and other arithmetic or linear algebra functions that might be used in the future with operator overloading. Ideally they could switch to other mir implementations at compile time if those have been imported.
September 24, 2017
On 23 September 2017 at 03:11, Ilya Yaroshenko via Digitalmars-d < digitalmars-d@puremagic.com> wrote:

> Should we add `a * b` to ndslice for 1d vectors?
> Discussion at https://github.com/libmir/mir-algorithm/issues/91
>

I often ponder this sort of question... and while the nerdy bit of my would
love to see this, I can never get past the fact that `is(typeof(a) !=
typeof(a * b))`... I feel that's a big enough reason to put a bullet in the
idea. D has array operations, which look just like 1d ndslices, also SIMD
vectors usually implement operators, but they do element-wise operation, so
now there's a confusion.
Consider, a generic function receives some T; if T is a slice or simd, it
does element-wise stuff, if T is an ndslice, it behaves differently. That
doesn't seem right.


September 24, 2017
On Sunday, 24 September 2017 at 05:24:57 UTC, Manu wrote:
> On 23 September 2017 at 03:11, Ilya Yaroshenko via Digitalmars-d < digitalmars-d@puremagic.com> wrote:
>
>> Should we add `a * b` to ndslice for 1d vectors?
>> Discussion at https://github.com/libmir/mir-algorithm/issues/91
>>
>
> I often ponder this sort of question... and while the nerdy bit of my would
> love to see this, I can never get past the fact that `is(typeof(a) !=
> typeof(a * b))`... I feel that's a big enough reason to put a bullet in the
> idea. D has array operations, which look just like 1d ndslices, also SIMD
> vectors usually implement operators, but they do element-wise operation, so
> now there's a confusion.
> Consider, a generic function receives some T; if T is a slice or simd, it
> does element-wise stuff, if T is an ndslice, it behaves differently. That
> doesn't seem right.

Python has a dedicated matrix multiplication operator, that is not used by the standard library, but is implemented for e.g. numpy arrays.

https://www.python.org/dev/peps/pep-0465/
September 24, 2017
On Friday, 22 September 2017 at 17:11:56 UTC, Ilya Yaroshenko wrote:
> Should we add `a * b` to ndslice for 1d vectors?
> Discussion at https://github.com/libmir/mir-algorithm/issues/91

Generally I expect that a binary operation denoted by + or * would produce an element from the original domain, e.g. multiplying two matrices yields a matrix, concatenating two strings yields a string, etc. So personally I don't like this notation.

Note that in the case of 3-dimensional vectors, people might confuse this for the cross product. I would go with dot(a,b) and cross(a,b) (if you support it).
September 24, 2017
On Sun, Sep 24, 2017 at 06:18:38PM +0000, Mark via Digitalmars-d wrote:
> On Friday, 22 September 2017 at 17:11:56 UTC, Ilya Yaroshenko wrote:
> > Should we add `a * b` to ndslice for 1d vectors?
> > Discussion at https://github.com/libmir/mir-algorithm/issues/91
> 
> Generally I expect that a binary operation denoted by + or * would produce an element from the original domain, e.g. multiplying two matrices yields a matrix, concatenating two strings yields a string, etc. So personally I don't like this notation.
> 
> Note that in the case of 3-dimensional vectors, people might confuse this
> for the cross product. I would go with dot(a,b) and cross(a,b) (if you
> support it).

With UFCS, you have the slightly nicer notation a.dot(b) and a.cross(b).


T

-- 
Claiming that your operating system is the best in the world because more people use it is like saying McDonalds makes the best food in the world. -- Carl B. Constantine
September 24, 2017
On Sunday, 24 September 2017 at 18:18:38 UTC, Mark wrote:
>
> Generally I expect that a binary operation denoted by + or * would produce an element from the original domain, e.g. multiplying two matrices yields a matrix, concatenating two strings yields a string, etc. So personally I don't like this notation.

This is true of element-wise operators. + works, - works, but * (and by implication /) only has that property for Hadamard/Schur products. It also would work for inverse. Even matrix multiplication could have A*B produce a matrix, but if A is 1XN and B is MX1, then you may as well return the scalar.

>
> Note that in the case of 3-dimensional vectors, people might confuse this for the cross product. I would go with dot(a,b) and cross(a,b) (if you support it).

I assure you, no one would confuse dot for cross. No language or linear algebra library does this. The typical option is matrix multiplication for *, but languages like Python and Matlab can't do things like have a special version that is dot for vectors and matrix multiplication for matrices.
September 24, 2017
On Sunday, 24 September 2017 at 22:33:48 UTC, H. S. Teoh wrote:
>
> With UFCS, you have the slightly nicer notation a.dot(b) and a.cross(b).
>
>
> T

Below is a link to the operators in Matlab and associated functions. mir can include all of those functions, but not all of them can be implemented as operators (because D doesn't have things like .*). I think it would be annoying to constantly have to write plus or mtimes in writing formulas for a linear algebra library.

https://www.mathworks.com/help/matlab/matlab_prog/matlab-operators-and-special-characters.html
September 25, 2017
On Sunday, 24 September 2017 at 23:59:59 UTC, jmh530 wrote:
> On Sunday, 24 September 2017 at 22:33:48 UTC, H. S. Teoh wrote:
>>
>> With UFCS, you have the slightly nicer notation a.dot(b) and a.cross(b).
>>
>>
>> T
>
> Below is a link to the operators in Matlab and associated functions. mir can include all of those functions, but not all of them can be implemented as operators (because D doesn't have things like .*). I think it would be annoying to constantly have to write plus or mtimes in writing formulas for a linear algebra library.
>
> https://www.mathworks.com/help/matlab/matlab_prog/matlab-operators-and-special-characters.html

There's nothing stopping someone writing a DIP to include `@` (and possibly `#`) as overloadable binary operators. All other characters on the standard keyboard are used I think.
September 25, 2017
On Monday, 25 September 2017 at 01:08:35 UTC, Nicholas Wilson wrote:
> There's nothing stopping someone writing a DIP to include `@` (and possibly `#`) as overloadable binary operators. All other characters on the standard keyboard are used I think.

̣̣§
« First   ‹ Prev
1 2 3 4 5 6 7 8 9