Hi to the developers,
It would be convenient to have built-in the max or min of an array and a real number, which means taking the max or min in each entry
real[int] aa(nn),res(nn);
real rr;
res=max(aa,rr);
would give res(i)=max(aa(i),rr)
This would simplify and fasten computations, avoiding to make explicit loops.
Then also useful would be the max (resp min) of two arrays of same length
real[int] aa(nn),bb(nn),res(nn);
res=max(aa,bb);
would do res(i)=max(aa(i),bb(i))
Thanks for your consideration.
Dear Chris,
Thanks for your suggestion. My idea was to have a “fast” operator encoded in C++,
useful when it is called many times. Indeed the “max” and “min” are the elementary bricks to build nonlinearities. But maybe it is not possible because not available as C++ built-in commands.
To compare with, the abs() operator is defined for an array probably because it is already defined in C++.
It follows that we can code for example for the max of two arrays aa,bb, writing \max(a,b)=a+\max(0,b-a), and \max(0,x)=(x+|x|)/2,
Why not use a func or a macro to get this functionality immediately and make your code more readable? That should be much faster than an implicit/explicit loop even if its not totally optimal. FWIW, the FF developers seem friendly to pull requests if you’d like to contribute such functions. Looks like it could be added here: Afunction.cpp.
Thanks for your suggestions again. I am going to use a func, I did not think of that possibility. About pull requests I don’t know how to do that, and I am not able to write a C++ piece of code.