Commit 1d0a0e1d authored by Martin Reinecke's avatar Martin Reinecke
Browse files

header cleanup

parent a7c3d242
......@@ -9,7 +9,6 @@ libmrutil_la_SOURCES = \
libsharp2/sharp_geomhelpers.cc \
libsharp2/sharp_ylmgen.cc \
libsharp2/sharp_internal.h \
libsharp2/sharp_ylmgen.h \
mr_util/math_utils.h \
mr_util/cmplx.h \
mr_util/aligned_array.h \
......
......@@ -30,7 +30,6 @@
#include <memory>
#include "mr_util/math_utils.h"
#include "mr_util/fft.h"
#include "libsharp2/sharp_ylmgen.h"
#include "libsharp2/sharp_internal.h"
#include "libsharp2/sharp_almhelpers.h"
#include "libsharp2/sharp_geomhelpers.h"
......
......@@ -37,6 +37,7 @@
#include <complex>
#include <cmath>
#include <cstring>
#include <vector>
#include "libsharp2/sharp.h"
#include "libsharp2/sharp_internal.h"
#include "mr_util/error_handling.h"
......@@ -46,6 +47,7 @@
#pragma GCC visibility push(hidden)
using namespace mr;
using namespace std;
using Tv=native_simd<double>;
static constexpr size_t VLEN=Tv::size();
......@@ -249,7 +251,7 @@ MRUTIL_NOINLINE static void iter_to_ieee(const sharp_Ylmgen &gen,
}
MRUTIL_NOINLINE static void alm2map_kernel(s0data_v & MRUTIL_RESTRICT d,
const vector<sharp_ylmgen_dbl2> &coef, const dcmplx * MRUTIL_RESTRICT alm,
const vector<sharp_Ylmgen::dbl2> &coef, const dcmplx * MRUTIL_RESTRICT alm,
size_t l, size_t il, size_t lmax, size_t nv2)
{
for (; l+6<=lmax; il+=4, l+=8)
......@@ -381,7 +383,7 @@ MRUTIL_NOINLINE static void calc_alm2map (sharp_protojob & MRUTIL_RESTRICT job,
}
MRUTIL_NOINLINE static void map2alm_kernel(s0data_v & MRUTIL_RESTRICT d,
const vector<sharp_ylmgen_dbl2> &coef, dcmplx * MRUTIL_RESTRICT alm, size_t l,
const vector<sharp_Ylmgen::dbl2> &coef, dcmplx * MRUTIL_RESTRICT alm, size_t l,
size_t il, size_t lmax, size_t nv2)
{
for (; l+2<=lmax; il+=2, l+=4)
......@@ -548,7 +550,7 @@ MRUTIL_NOINLINE static void iter_to_ieee_spin (const sharp_Ylmgen &gen,
}
MRUTIL_NOINLINE static void alm2map_spin_kernel(sxdata_v & MRUTIL_RESTRICT d,
const vector<sharp_ylmgen_dbl2> &fx, const dcmplx * MRUTIL_RESTRICT alm,
const vector<sharp_Ylmgen::dbl2> &fx, const dcmplx * MRUTIL_RESTRICT alm,
size_t l, size_t lmax, size_t nv2)
{
size_t lsave = l;
......@@ -684,7 +686,7 @@ MRUTIL_NOINLINE static void calc_alm2map_spin (sharp_protojob & MRUTIL_RESTRICT
}
MRUTIL_NOINLINE static void map2alm_spin_kernel(sxdata_v & MRUTIL_RESTRICT d,
const vector<sharp_ylmgen_dbl2> &fx, dcmplx * MRUTIL_RESTRICT alm,
const vector<sharp_Ylmgen::dbl2> &fx, dcmplx * MRUTIL_RESTRICT alm,
size_t l, size_t lmax, size_t nv2)
{
size_t lsave=l;
......@@ -815,7 +817,7 @@ MRUTIL_NOINLINE static void calc_map2alm_spin (sharp_protojob & MRUTIL_RESTRICT
MRUTIL_NOINLINE static void alm2map_deriv1_kernel(sxdata_v & MRUTIL_RESTRICT d,
const vector<sharp_ylmgen_dbl2> &fx, const dcmplx * MRUTIL_RESTRICT alm,
const vector<sharp_Ylmgen::dbl2> &fx, const dcmplx * MRUTIL_RESTRICT alm,
size_t l, size_t lmax, size_t nv2)
{
size_t lsave=l;
......
......@@ -29,12 +29,63 @@
#define SHARP2_INTERNAL_H
#include <complex>
#include <vector>
#include "libsharp2/sharp.h"
#include "libsharp2/sharp_ylmgen.h"
#include "mr_util/error_handling.h"
static constexpr int sharp_minscale=0, sharp_limscale=1, sharp_maxscale=1;
static constexpr double sharp_fbig=0x1p+800,sharp_fsmall=0x1p-800;
static constexpr double sharp_ftol=0x1p-60;
static constexpr double sharp_fbighalf=0x1p+400;
using std::complex;
class sharp_Ylmgen
{
public:
struct dbl2 { double a, b; };
sharp_Ylmgen(size_t l_max, size_t m_max, size_t spin);
/*! Prepares the object for the calculation at \a m. */
void prepare(size_t m_);
/*! Returns a vector with \a lmax+1 entries containing
normalisation factors that must be applied to Y_lm values computed for
\a spin. */
static std::vector<double> get_norm(size_t lmax, size_t spin);
/*! Returns a vectorwith \a lmax+1 entries containing
normalisation factors that must be applied to Y_lm values computed for
first derivatives. */
static std::vector<double> get_d1norm(size_t lmax);
/* for public use; immutable during lifetime */
size_t lmax, mmax, s;
std::vector<double> cf;
std::vector<double> powlimit;
/* for public use; will typically change after call to Ylmgen_prepare() */
size_t m;
std::vector<double> alpha;
std::vector<dbl2> coef;
/* used if s==0 */
std::vector<double> mfac, eps;
/* used if s!=0 */
size_t sinPow, cosPow;
bool preMinus_p, preMinus_m;
std::vector<double> prefac;
std::vector<int> fscale;
size_t mlo, mhi;
private:
/* used if s==0 */
std::vector<double> root, iroot;
/* used if s!=0 */
std::vector<double> flm1, flm2, inv;
};
class sharp_protojob
{
public:
......@@ -43,7 +94,7 @@ class sharp_protojob
size_t flags;
ptrdiff_t s_m, s_th; // strides in m and theta direction
complex<double> *phase;
vector<double> norm_l;
std::vector<double> norm_l;
complex<double> *almtmp;
const sharp_geom_info &ginfo;
const sharp_alm_info &ainfo;
......
......@@ -28,7 +28,7 @@
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include "libsharp2/sharp_ylmgen.h"
#include "libsharp2/sharp_internal.h"
#include "mr_util/error_handling.h"
using namespace std;
......
/*
* This file is part of libsharp2.
*
* libsharp2 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* libsharp2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with libsharp2; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* libsharp2 is being developed at the Max-Planck-Institut fuer Astrophysik */
/*! \file sharp_ylmgen.h
* Code for efficient calculation of Y_lm(phi=0,theta)
*
* Copyright (C) 2005-2019 Max-Planck-Society
* \author Martin Reinecke
*/
#ifndef SHARP2_YLMGEN_H
#define SHARP2_YLMGEN_H
#include <vector>
using std::vector;
enum { sharp_minscale=0, sharp_limscale=1, sharp_maxscale=1 };
static constexpr double sharp_fbig=0x1p+800,sharp_fsmall=0x1p-800;
static constexpr double sharp_ftol=0x1p-60;
static constexpr double sharp_fbighalf=0x1p+400;
struct sharp_ylmgen_dbl2 { double a, b; };
class sharp_Ylmgen
{
public:
sharp_Ylmgen(size_t l_max, size_t m_max, size_t spin);
/*! Prepares the object for the calculation at \a m. */
void prepare(size_t m_);
/*! Returns a vector with \a lmax+1 entries containing
normalisation factors that must be applied to Y_lm values computed for
\a spin. */
static vector<double> get_norm(size_t lmax, size_t spin);
/*! Returns a vectorwith \a lmax+1 entries containing
normalisation factors that must be applied to Y_lm values computed for
first derivatives. */
static vector<double> get_d1norm(size_t lmax);
/* for public use; immutable during lifetime */
size_t lmax, mmax, s;
vector<double> cf;
vector<double> powlimit;
/* for public use; will typically change after call to Ylmgen_prepare() */
size_t m;
vector<double> alpha;
vector<sharp_ylmgen_dbl2> coef;
/* used if s==0 */
vector<double> mfac, eps;
/* used if s!=0 */
size_t sinPow, cosPow;
bool preMinus_p, preMinus_m;
vector<double> prefac;
vector<int> fscale;
size_t mlo, mhi;
private:
/* used if s==0 */
vector<double> root, iroot;
/* used if s!=0 */
vector<double> flm1, flm2, inv;
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment