I would like to replicate the following python function in lua/torch.
def add_and_multiply(a,b):
c=a+b;
d=a*b;
return c,d
How can I return two values simultaneously in lua/torch as above? Also, suppose a and b were matrices(with appropriate dimensions), how would the code change for torch?
The same thing happens in lua too. You can even skip using two extra local
variables:
function add_and_multiply(a,b)
return a + b, a * b
end