Skip to content
Snippets Groups Projects
Commit b06c7716 authored by Oliver Sander's avatar Oliver Sander Committed by sander@PCPOOL.MI.FU-BERLIN.DE
Browse files

stable implementation of sinc

[[Imported from SVN: r5588]]
parent 337257c2
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,11 @@
template <int dim>
class UnitVector
{
/** \brief Computes sin(x/2) / x without getting unstable for small x */
static double sinc(const double& x) {
return (x < 1e-4) ? 1 + (x*x/6) : std::sin(x)/x;
}
public:
/** \brief The type used for coordinates */
......@@ -29,7 +34,7 @@ public:
const double norm = v.two_norm();
UnitVector result = p;
result.data_ *= std::cos(norm);
result.data_.axpy(std::sin(norm)/norm, v);
result.data_.axpy(sinc(norm), v);
return result;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment