Added a specific function for computing \vec{k}

This commit is contained in:
Guilhem Lavaux 2012-11-28 17:49:58 -05:00
parent 5d6ad978e8
commit bcf4ae2deb

View File

@ -113,6 +113,24 @@ namespace CosmoTool
this->delta_k); this->delta_k);
} }
template<typename Array, typename Array2>
void get_Kvec(const Array& ik, Array& kvec)
{
const DimArray& dims = this->getDims();
assert(ik.size() == dims.size());
assert(kvec.size() == dims.size());
kvec[0] = ik[0] * delta_k[0];
for (int q = 1; q < ik.size(); q++)
{
int dk = ik[q];
if (dk > dims[q]/2)
dk = dk - dims[q];
kvec[q] = dk*delta_k[q];
}
}
template<typename Array> template<typename Array>
double get_K(const Array& ik) double get_K(const Array& ik)
{ {