discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Scalar product is not distributive

RP
Ronaldo Persiano
Wed, Dec 5, 2018 4:30 PM

echo([1]+[1,2] );
echo([2]([1]+[1,2]));
echo([2]
[1] + [2]*[1,2]);

// ECHO: [2] ???

// ECHO: 4

// ECHO: undef

Is this intentional or a bug?

echo([1]+[1,2] ); echo([2]*([1]+[1,2])); echo([2]*[1] + [2]*[1,2]); // ECHO: [2] ??? // ECHO: 4 // ECHO: undef Is this intentional or a bug?
P
Parkinbot
Wed, Dec 5, 2018 5:06 PM

Would you expect a 1D or a 2D value as sum of a 1D vector and a 2D vector?
OpenSCAD silently returns a value procrusted to the lowest dimension. Matlab
returns a 2D value and doesn't differentiate between [1] and 1. Is it, what
you are opting for?

echo([1]+[1,2] ); // [2]
echo([1, 2, 3]+[1, 2]); //[1, 4]
echo(1+[1,2] ); // undef

--
Sent from: http://forum.openscad.org/

Would you expect a 1D or a 2D value as sum of a 1D vector and a 2D vector? OpenSCAD silently returns a value procrusted to the lowest dimension. Matlab returns a 2D value and doesn't differentiate between [1] and 1. Is it, what you are opting for? echo([1]+[1,2] ); // [2] echo([1, 2, 3]+[1, 2]); //[1, 4] echo(1+[1,2] ); // undef -- Sent from: http://forum.openscad.org/
RP
Ronaldo Persiano
Wed, Dec 5, 2018 5:33 PM

I would expect undef as the sum. So, [2]([1]+[1,2]) ==  [2][1]+[2]*[1,2])
== undef

Em qua, 5 de dez de 2018 às 17:07, Parkinbot rudolf@digitaldocument.de
escreveu:

Would you expect a 1D or a 2D value as sum of a 1D vector and a 2D vector?
OpenSCAD silently returns a value procrusted to the lowest dimension.
Matlab
returns a 2D value and doesn't differentiate between [1] and 1. Is it, what
you are opting for?

echo([1]+[1,2] ); // [2]
echo([1, 2, 3]+[1, 2]); //[1, 4]
echo(1+[1,2] ); // undef

--
Sent from: http://forum.openscad.org/


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

I would expect undef as the sum. So, [2]*([1]+[1,2]) == [2]*[1]+[2]*[1,2]) == undef Em qua, 5 de dez de 2018 às 17:07, Parkinbot <rudolf@digitaldocument.de> escreveu: > Would you expect a 1D or a 2D value as sum of a 1D vector and a 2D vector? > OpenSCAD silently returns a value procrusted to the lowest dimension. > Matlab > returns a 2D value and doesn't differentiate between [1] and 1. Is it, what > you are opting for? > > echo([1]+[1,2] ); // [2] > echo([1, 2, 3]+[1, 2]); //[1, 4] > echo(1+[1,2] ); // undef > > > > > -- > Sent from: http://forum.openscad.org/ > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
NH
nop head
Wed, Dec 5, 2018 6:31 PM

I would not expect the truncation, so:

echo([1]+[1,2] ); // [2, 2]
echo([1, 2, 3]+[1, 2]); //[2, 4, 3]
echo(1+[1,2] ); // undef

On Wed, 5 Dec 2018 at 17:34, Ronaldo Persiano rcmpersiano@gmail.com wrote:

I would expect undef as the sum. So, [2]([1]+[1,2]) ==  [2][1]+[2]*[1,2])
== undef

Em qua, 5 de dez de 2018 às 17:07, Parkinbot rudolf@digitaldocument.de
escreveu:

Would you expect a 1D or a 2D value as sum of a 1D vector and a 2D
vector?
OpenSCAD silently returns a value procrusted to the lowest dimension.
Matlab
returns a 2D value and doesn't differentiate between [1] and 1. Is it,
what
you are opting for?

echo([1]+[1,2] ); // [2]
echo([1, 2, 3]+[1, 2]); //[1, 4]
echo(1+[1,2] ); // undef

--
Sent from: http://forum.openscad.org/


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

I would not expect the truncation, so: echo([1]+[1,2] ); // [2, 2] echo([1, 2, 3]+[1, 2]); //[2, 4, 3] echo(1+[1,2] ); // undef On Wed, 5 Dec 2018 at 17:34, Ronaldo Persiano <rcmpersiano@gmail.com> wrote: > I would expect undef as the sum. So, [2]*([1]+[1,2]) == [2]*[1]+[2]*[1,2]) > == undef > > Em qua, 5 de dez de 2018 às 17:07, Parkinbot <rudolf@digitaldocument.de> > escreveu: > >> Would you expect a 1D or a 2D value as sum of a 1D vector and a 2D >> vector? >> OpenSCAD silently returns a value procrusted to the lowest dimension. >> Matlab >> returns a 2D value and doesn't differentiate between [1] and 1. Is it, >> what >> you are opting for? >> >> echo([1]+[1,2] ); // [2] >> echo([1, 2, 3]+[1, 2]); //[1, 4] >> echo(1+[1,2] ); // undef >> >> >> >> >> -- >> Sent from: http://forum.openscad.org/ >> >> _______________________________________________ >> OpenSCAD mailing list >> Discuss@lists.openscad.org >> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >> > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
P
Parkinbot
Thu, Dec 6, 2018 1:38 AM

I would expect

echo([1]+[2,3])  // undef
echo(1+[2,3])    // [3,4]
echo(1+[1,2,3])    // [2,3,4]

following the pattern

echo(5*[1,2]);  // [5,10]
echo([5]*[1,2]);  // undef

--
Sent from: http://forum.openscad.org/

I would expect echo([1]+[2,3]) // undef echo(1+[2,3]) // [3,4] echo(1+[1,2,3]) // [2,3,4] following the pattern echo(5*[1,2]); // [5,10] echo([5]*[1,2]); // undef -- Sent from: http://forum.openscad.org/