EleFits  5.3.0
A modern C++ API on top of CFITSIO
Loading...
Searching...
No Matches

◆ generate()

TDerived & generate ( TFunc &&  func,
const TContainers &...  args 
)

Generate values from a function with optional input containers.

Parameters
funcThe generator function, which takes as many inputs as there are arguments
argsThe arguments in the form of containers of compatible sizes

For example, here is how to imlement element-wise square root and multiplication:

Container a = ...;
Container b = ...;
Container res(a.size());
res.generate([](auto v) { return std::sqrt(v) }, a); // res = sqrt(a)
res.generate([](auto v, auto w) { return v * w; }, a, b); // res = a * b
T sqrt(T... args)