I wish to make custom listable function (for 2D points) with the next behaviour:
myf[{x_, y_}] := {doSmth@x, doSmth@y};
pts = {{x1,y1},{x2,y2}, ...};
myf[pts] === {myf[{x1,y1}], myf[{x2,y2}], ...}
I'm going to do huge calculations, and read this in documentation:
To apply a function to a vector, take advantage of Listable functions when possible
And there is example that Listable without Map works ~10 times faster.
But when I set
Attributes[myf] = {Listable}
I get
myf[pts] === {{myf[x1], myf[y1]}, {myf[x2], myf[y2]}, ...}
which is not what is needed ((
Compile, but to useCompileproperly we need to know what's thatdoSmth, so please make the question more specific. – xzczd Oct 30 '23 at 11:58{xk, yk}as a complex numberzk := xk + yk I, then define a Listable function to be used on{z1, z2, ...}. – Silvia Oct 30 '23 at 19:42myfis already listable, it will automatically map. for example: ```myf = (#+1)*2&;myf@{{1,2},{3,4}}```
– AsukaMinato Oct 31 '23 at 18:31