Scalar product is not distributive

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Scalar product is not distributive

Ronaldo
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?


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Scalar product is not distributive

Parkinbot
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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Scalar product is not distributive

Ronaldo
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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Scalar product is not distributive

nophead
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 <[hidden email]> 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 <[hidden email]> 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
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: Scalar product is not distributive

Parkinbot
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/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org