Skip to main content
deleted 17 characters in body
Source Link
Felipe
  • 719
  • 10

The behavior of Listable vector functions is weird, the output of the code below for me was {{2, 6, 12}, {1, 8, 27}} and {f[1, 1, 1], f[2, 2, 2], f[3, 3, 3]}. From the second output I would expect a list with 3 sub lists for the first, but you don't get that. Is it supposed to work like that or is it a bug? (I know that taking the transpose of output 1 I get the output 2 format, but I have functions with higher rank tensors, which makes it hard to keep track of these transposes)

test = {x,y,z};
f =Function[{x,y,z}, {x*y+z, z^2*x}  ];
SetAttributes[f,Listable]
f[ {1,2,3},{1,2,3},{1,2,3}]
Clear@f;
SetAttributes[f,Listable];
f[ {1,2,3},{1,2,3},{1,2,3}]```

The behavior of Listable vector functions is weird, the output of the code below for me was {{2, 6, 12}, {1, 8, 27}} and {f[1, 1, 1], f[2, 2, 2], f[3, 3, 3]}. From the second output I would expect a list with 3 sub lists for the first, but you don't get that. Is it supposed to work like that or is it a bug? (I know that taking the transpose of output 1 I get the output 2 format, but I have functions with higher rank tensors, which makes it hard to keep track of these transposes)

test = {x,y,z};
f =Function[{x,y,z}, {x*y+z, z^2*x}  ];
SetAttributes[f,Listable]
f[ {1,2,3},{1,2,3},{1,2,3}]
Clear@f;
SetAttributes[f,Listable];
f[ {1,2,3},{1,2,3},{1,2,3}]```

The behavior of Listable vector functions is weird, the output of the code below for me was {{2, 6, 12}, {1, 8, 27}} and {f[1, 1, 1], f[2, 2, 2], f[3, 3, 3]}. From the second output I would expect a list with 3 sub lists for the first, but you don't get that. Is it supposed to work like that or is it a bug? (I know that taking the transpose of output 1 I get the output 2 format, but I have functions with higher rank tensors, which makes it hard to keep track of these transposes)

f =Function[{x,y,z}, {x*y+z, z^2*x}  ];
SetAttributes[f,Listable]
f[ {1,2,3},{1,2,3},{1,2,3}]
Clear@f;
SetAttributes[f,Listable];
f[ {1,2,3},{1,2,3},{1,2,3}]```
Source Link
Felipe
  • 719
  • 10

Behaviour of listable vector functions

The behavior of Listable vector functions is weird, the output of the code below for me was {{2, 6, 12}, {1, 8, 27}} and {f[1, 1, 1], f[2, 2, 2], f[3, 3, 3]}. From the second output I would expect a list with 3 sub lists for the first, but you don't get that. Is it supposed to work like that or is it a bug? (I know that taking the transpose of output 1 I get the output 2 format, but I have functions with higher rank tensors, which makes it hard to keep track of these transposes)

test = {x,y,z};
f =Function[{x,y,z}, {x*y+z, z^2*x}  ];
SetAttributes[f,Listable]
f[ {1,2,3},{1,2,3},{1,2,3}]
Clear@f;
SetAttributes[f,Listable];
f[ {1,2,3},{1,2,3},{1,2,3}]```