fork download
  1. #include <vector>
  2. #include <complex>
  3.  
  4. template <class T>
  5. void apply(const std::vector<std::complex<T> >& in, std::vector<T>& out,
  6. T (*f)(std::complex<T> const&))
  7. {
  8. out.resize(in.size());
  9. for(size_t i = 0; i < in.size(); ++i)
  10. out[i] = f(in[i]);
  11. }
  12.  
  13. int main(){
  14. std::vector<std::complex<float> > vcomp;
  15. std::vector<float> vf;
  16. apply(vcomp, vf, &std::abs<float>);
  17. }
  18.  
Success #stdin #stdout 0.02s 2720KB
stdin
Standard input is empty
stdout

Standard output is empty