J
Juanjo
Hi,
I have a piece of code that looks like below. The code simply does not
compile because the compiler chooses to believe that std::cos<double>
has type signature std::complex<double> cos(std::complex<double>)
The reason I think is that there are two contradictory definitions,
one in cmath, ::using cos, and another one in complex which reads
template<typename _Tp> complex<_Tp> cos(const complex<_Tp>&);
This is with g++ 4.3. Does anybody have a solution? Am I trying the
impossible?
Juanjo
#include <cmath>
#include <complex>
#include <tensor/tensor.h>
namespace tensor {
Tensor<double> cos(const Tensor<double> &t) {
Tensor<double> output(t.dimensions());
// The iterators here have type double * and const double *
std::transform(t.begin(), t.end(), output.begin(),
std::cos<double>);
return output;
}
} // namespace tensor
I have a piece of code that looks like below. The code simply does not
compile because the compiler chooses to believe that std::cos<double>
has type signature std::complex<double> cos(std::complex<double>)
The reason I think is that there are two contradictory definitions,
one in cmath, ::using cos, and another one in complex which reads
template<typename _Tp> complex<_Tp> cos(const complex<_Tp>&);
This is with g++ 4.3. Does anybody have a solution? Am I trying the
impossible?
Juanjo
#include <cmath>
#include <complex>
#include <tensor/tensor.h>
namespace tensor {
Tensor<double> cos(const Tensor<double> &t) {
Tensor<double> output(t.dimensions());
// The iterators here have type double * and const double *
std::transform(t.begin(), t.end(), output.begin(),
std::cos<double>);
return output;
}
} // namespace tensor