Commit 09902695 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

add pyHealpix; still need to fix warnings

parent d7af95c1
This diff is collapsed.
This diff is collapsed.
/*
* This file is part of Healpix_cxx.
*
* Healpix_cxx 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.
*
* Healpix_cxx 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 Healpix_cxx; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* For more information about HEALPix, see http://healpix.sourceforge.net
*/
/*
* Healpix_cxx is being developed at the Max-Planck-Institut fuer Astrophysik
* and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt
* (DLR).
*/
/*
* Copyright (C) 2011-2020 Max-Planck-Society
* Author: Martin Reinecke
*/
#include "Healpix_cxx/healpix_tables.h"
#include "mr_util/string_utils.h"
#include "mr_util/error_handling.h"
using namespace std;
namespace mr {
namespace healpix {
const nside_dummy SET_NSIDE=nside_dummy();
Ordering_Scheme string2HealpixScheme (const string &inp)
{
string tmp=trim(inp);
if (equal_nocase(tmp,"RING")) return RING;
if (equal_nocase(tmp,"NESTED")) return NEST;
MR_fail ("bad Healpix ordering scheme '"+tmp+
"': expected 'RING' or 'NESTED'");
}
const int Healpix_Tables::jrll[] = { 2,2,2,2,3,3,3,3,4,4,4,4 },
Healpix_Tables::jpll[] = { 1,3,5,7,0,2,4,6,1,3,5,7 };
const uint8_t Healpix_Tables::peano_arr2[] = {
0, 35, 65, 66, 68, 5,103, 6,110,109, 15, 44, 72, 9,107, 10,
31,126, 60,125, 81, 16, 82, 51,123, 88, 26, 25,119, 84, 22, 21,
42, 75, 41,104, 12, 47, 77, 78, 38, 71, 37,100, 98, 97, 3, 32,
53, 54,116, 87, 57, 58,120, 91, 19,114, 48,113, 93, 28, 94, 63,
64, 1, 99, 2, 46, 79, 45,108, 4, 39, 69, 70, 8, 43, 73, 74,
85, 20, 86, 55,115, 80, 18, 17, 89, 24, 90, 59, 61, 62,124, 95,
106,105, 11, 40,102,101, 7, 36, 76, 13,111, 14, 34, 67, 33, 96,
127, 92, 30, 29, 27,122, 56,121, 49, 50,112, 83, 23,118, 52,117,
128,194,195,161,196,133,135,230,204,141,143,238,171,233,232,138,
149,212,214,183,221,159,158,252,217,155,154,248,178,243,241,144,
175,237,236,142,235,170,168,201,227,162,160,193,132,198,199,165,
186,251,249,152,242,176,177,211,246,180,181,215,157,220,222,191,
192,129,131,226,136,202,203,169,140,206,207,173,231,166,164,197,
213,151,150,244,145,208,210,179,153,216,218,187,254,188,189,223,
239,174,172,205,167,229,228,134,163,225,224,130,200,137,139,234,
250,184,185,219,190,255,253,156,182,247,245,148,209,147,146,240 };
const uint8_t Healpix_Tables::peano_arr[] =
{ 16, 1,27, 2,31,20, 6, 5,10,19, 9,24,13,14,28,23,
0,11,17,18,21, 4,22,15,26,25, 3, 8, 7,30,12,29,
48,33,35,58,53,39,38,60,59,42,40,49,62,44,45,55,
32,50,51,41,37,52,54,47,43,57,56,34,46,63,61,36 };
const uint8_t Healpix_Tables::peano_face2path[2][12] =
{ { 2,5,2,5,3,6,3,6,2,3,2,3 }, { 2,6,2,3,3,5,2,6,2,3,3,5 } };
const uint8_t Healpix_Tables::peano_face2face[2][12] =
{ { 0,5,6,11,10,1,4,7,2,3,8,9 }, { 0,5,8,9,6,1,2,7,10,11,4,3 } };
const int Healpix_Tables::nb_xoffset[] = { -1,-1, 0, 1, 1, 1, 0,-1 },
Healpix_Tables::nb_yoffset[] = { 0, 1, 1, 1, 0,-1,-1,-1 };
const int Healpix_Tables::nb_facearray[][12] =
{ { 8, 9,10,11,-1,-1,-1,-1,10,11, 8, 9 }, // S
{ 5, 6, 7, 4, 8, 9,10,11, 9,10,11, 8 }, // SE
{ -1,-1,-1,-1, 5, 6, 7, 4,-1,-1,-1,-1 }, // E
{ 4, 5, 6, 7,11, 8, 9,10,11, 8, 9,10 }, // SW
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11 }, // center
{ 1, 2, 3, 0, 0, 1, 2, 3, 5, 6, 7, 4 }, // NE
{ -1,-1,-1,-1, 7, 4, 5, 6,-1,-1,-1,-1 }, // W
{ 3, 0, 1, 2, 3, 0, 1, 2, 4, 5, 6, 7 }, // NW
{ 2, 3, 0, 1,-1,-1,-1,-1, 0, 1, 2, 3 } }; // N
const int Healpix_Tables::nb_swaparray[][3] =
{ { 0,0,3 }, // S
{ 0,0,6 }, // SE
{ 0,0,0 }, // E
{ 0,0,5 }, // SW
{ 0,0,0 }, // center
{ 5,0,0 }, // NE
{ 0,0,0 }, // W
{ 6,0,0 }, // NW
{ 3,0,0 } }; // N
const int Healpix_Tables::swap_clen[] =
{ 0,7,5,4,12,10,13,18,14,19,18,17,27,21 };
const int Healpix_Tables::swap_cycle[] =
{ 0,1,8,12,16,21,40,
0,1,2,40,114,
0,4,160,263,
0,4,30,49,51,87,526,1027,1105,1387,1807,2637,
0,8,10,18,39,74,146,307,452,4737,
0,1,2,7,9,17,80,410,1526,1921,32859,33566,38931,
0,5,6,10,12,24,27,95,372,494,924,1409,3492,4248,9137,66043,103369,156899,
0,1,2,3,4,45,125,351,697,24337,102940,266194,341855,419857,
0,1,2,3,9,16,1705,2082,2126,8177,12753,15410,52642,80493,83235,88387,99444,
1675361,2495125,
0,2,6,8,9,11,20,50,93,152,183,2137,13671,44794,486954,741908,4803258,
5692573,
0,1,5,6,44,53,470,2847,3433,4906,13654,14710,400447,1797382,2744492,
18775974,23541521,
0,4,9,10,16,33,83,117,318,451,5759,10015,128975,171834,211256,347608,
1278690,2154097,2590798,3427694,5581717,21012301,27023976,72522811,
95032729,139166747,171822389,
0,5,10,267,344,363,2968,3159,9083,18437,76602,147614,1246902,1593138,
2035574,6529391,9511830,11340287,29565945,281666026,677946848 };
}}
/*
* This file is part of Healpix_cxx.
*
* Healpix_cxx 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.
*
* Healpix_cxx 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 Healpix_cxx; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* For more information about HEALPix, see http://healpix.sourceforge.net
*/
/*
* Healpix_cxx is being developed at the Max-Planck-Institut fuer Astrophysik
* and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt
* (DLR).
*/
/*! \file healpix_tables.h
* Copyright (C) 2011-2020 Max-Planck-Society
* \author Martin Reinecke
*/
#ifndef HEALPIX_TABLES_H
#define HEALPIX_TABLES_H
#include <cstdint>
#include <string>
namespace mr {
namespace healpix {
/*! The two possible ordering schemes of a HEALPix map. */
enum Ordering_Scheme { RING, /*!< RING scheme */
NEST /*!< NESTED scheme */
};
Ordering_Scheme string2HealpixScheme (const std::string &inp);
class nside_dummy {};
extern const nside_dummy SET_NSIDE;
class Healpix_Tables
{
protected:
static const int jrll[], jpll[];
static const uint8_t peano_face2path[2][12], peano_face2face[2][12],
peano_arr[],peano_arr2[];
static const int nb_xoffset[], nb_yoffset[],
nb_facearray[][12], nb_swaparray[][3];
static const int swap_clen[], swap_cycle[];
};
}}
#endif
......@@ -31,7 +31,14 @@ libmrutil_la_SOURCES = \
mr_util/threading.h \
mr_util/timers.h \
mr_util/unity_roots.h \
mr_util/useful_macros.h
mr_util/useful_macros.h \
mr_util/rangeset.h \
mr_util/geom_utils.h \
mr_util/geom_utils.cc \
Healpix_cxx/healpix_tables.h \
Healpix_cxx/healpix_tables.cc \
Healpix_cxx/healpix_base.h \
Healpix_cxx/healpix_base.cc
# format is "current:revision:age"
# any change: increase revision
......
......@@ -44,9 +44,9 @@ using namespace mr;
using dcmplx = complex<double>;
using fcmplx = complex<float>;
static int chunksize_min=500, nchunks_max=10;
static size_t chunksize_min=500, nchunks_max=10;
static void get_chunk_info (int ndata, int nmult, int &nchunks, int &chunksize)
static void get_chunk_info (size_t ndata, size_t nmult, size_t &nchunks, size_t &chunksize)
{
chunksize = (ndata+nchunks_max-1)/nchunks_max;
if (chunksize>=chunksize_min) // use max number of chunks
......@@ -79,55 +79,55 @@ struct ringhelper
{
double phi0_;
vector<dcmplx> shiftarr;
int s_shift;
size_t s_shift;
unique_ptr<mr::detail_fft::rfftp<double>> plan;
int length;
int norot;
size_t length;
bool norot;
ringhelper() : length(0) {}
void update(int nph, int mmax, double phi0)
void update(size_t nph, size_t mmax, double phi0)
{
norot = (abs(phi0)<1e-14);
if (!(norot))
if (!norot)
if ((mmax!=s_shift-1) || (!approx(phi0,phi0_,1e-12)))
{
shiftarr.resize(mmax+1);
s_shift = mmax+1;
phi0_ = phi0;
// FIXME: improve this by using sincos2pibyn(nph) etc.
for (int m=0; m<=mmax; ++m)
for (size_t m=0; m<=mmax; ++m)
shiftarr[m] = dcmplx(cos(m*phi0),sin(m*phi0));
// double *tmp=(double *) self->shiftarr;
// sincos_multi (mmax+1, phi0, &tmp[1], &tmp[0], 2);
}
if (nph!=int(length))
if (nph!=length)
{
plan.reset(new mr::detail_fft::rfftp<double>(nph));
length=nph;
}
}
MRUTIL_NOINLINE void phase2ring (const sharp_geom_info &info, size_t iring,
double *data, int mmax, const dcmplx *phase, int pstride)
double *data, size_t mmax, const dcmplx *phase, size_t pstride)
{
int nph = info.nph(iring);
size_t nph = info.nph(iring);
update (nph, mmax, info.phi0(iring));
if (nph>=2*mmax+1)
{
if (norot)
for (int m=0; m<=mmax; ++m)
for (size_t m=0; m<=mmax; ++m)
{
data[2*m]=phase[m*pstride].real();
data[2*m+1]=phase[m*pstride].imag();
}
else
for (int m=0; m<=mmax; ++m)
for (size_t m=0; m<=mmax; ++m)
{
dcmplx tmp = phase[m*pstride]*shiftarr[m];
data[2*m]=tmp.real();
data[2*m+1]=tmp.imag();
}
for (int m=2*(mmax+1); m<nph+2; ++m)
for (size_t m=2*(mmax+1); m<nph+2; ++m)
data[m]=0.;
}
else
......@@ -135,8 +135,8 @@ struct ringhelper
data[0]=phase[0].real();
fill(data+1,data+nph+2,0.);
ptrdiff_t idx1=1, idx2=nph-1;
for (int m=1; m<=mmax; ++m)
size_t idx1=1, idx2=nph-1;
for (size_t m=1; m<=mmax; ++m)
{
dcmplx tmp = phase[m*pstride];
if(!norot) tmp*=shiftarr[m];
......@@ -151,16 +151,16 @@ struct ringhelper
data[2*idx2+1]-=tmp.imag();
}
if (++idx1>=nph) idx1=0;
if (--idx2<0) idx2=nph-1;
idx2 = (idx2==0) ? nph-1 : idx2-1;
}
}
data[1]=data[0];
plan->exec(&(data[1]), 1., false);
}
MRUTIL_NOINLINE void ring2phase (const sharp_geom_info &info, size_t iring,
double *data, int mmax, dcmplx *phase, int pstride)
double *data, size_t mmax, dcmplx *phase, size_t pstride)
{
int nph = info.nph(iring);
size_t nph = info.nph(iring);
update (nph, mmax, -info.phi0(iring));
......@@ -171,18 +171,18 @@ struct ringhelper
if (mmax<=nph/2)
{
if (norot)
for (int m=0; m<=mmax; ++m)
for (size_t m=0; m<=mmax; ++m)
phase[m*pstride] = dcmplx(data[2*m], data[2*m+1]);
else
for (int m=0; m<=mmax; ++m)
for (size_t m=0; m<=mmax; ++m)
phase[m*pstride] =
dcmplx(data[2*m], data[2*m+1]) * shiftarr[m];
}
else
{
for (int m=0; m<=mmax; ++m)
for (size_t m=0; m<=mmax; ++m)
{
int idx=m%nph;
auto idx=m%nph;
dcmplx val;
if (idx<(nph-idx))
val = dcmplx(data[2*idx], data[2*idx+1]);
......@@ -272,14 +272,14 @@ template<typename T> MRUTIL_NOINLINE void sharp_job<T>::almtmp2alm (size_t mi)
}
template<typename T> MRUTIL_NOINLINE void sharp_job<T>::ringtmp2ring (size_t iring,
const vector<double> &ringtmp, ptrdiff_t rstride)
const vector<double> &ringtmp, size_t rstride)
{
for (size_t i=0; i<nmaps(); ++i)
ginfo.add_ring(flags&SHARP_USE_WEIGHTS, iring, &ringtmp[i*rstride+1], map[i]);
}
template<typename T> MRUTIL_NOINLINE void sharp_job<T>::ring2ringtmp (size_t iring,
vector<double> &ringtmp, ptrdiff_t rstride)
vector<double> &ringtmp, size_t rstride)
{
for (size_t i=0; i<nmaps(); ++i)
ginfo.get_ring(flags&SHARP_USE_WEIGHTS, iring, map[i], &ringtmp[i*rstride+1]);
......@@ -289,16 +289,16 @@ template<typename T> MRUTIL_NOINLINE void sharp_job<T>::ring2ringtmp (size_t iri
template<typename T> MRUTIL_NOINLINE void sharp_job<T>::map2phase (size_t mmax, size_t llim, size_t ulim)
{
if (type != SHARP_MAP2ALM) return;
int pstride = s_m;
size_t pstride = s_m;
mr::execDynamic(ulim-llim, 0, 1, [&](mr::Scheduler &sched)
{
ringhelper helper;
int rstride=ginfo.nphmax()+2;
size_t rstride=ginfo.nphmax()+2;
vector<double> ringtmp(nmaps()*rstride);
while (auto rng=sched.getNext()) for(auto ith=rng.lo+llim; ith<rng.hi+llim; ++ith)
{
int dim2 = s_th*(ith-llim);
size_t dim2 = s_th*(ith-llim);
ring2ringtmp(ginfo.pair(ith).r1,ringtmp,rstride);
for (size_t i=0; i<nmaps(); ++i)
helper.ring2phase (ginfo, ginfo.pair(ith).r1,
......@@ -317,16 +317,16 @@ template<typename T> MRUTIL_NOINLINE void sharp_job<T>::map2phase (size_t mmax,
template<typename T> MRUTIL_NOINLINE void sharp_job<T>::phase2map (size_t mmax, size_t llim, size_t ulim)
{
if (type == SHARP_MAP2ALM) return;
int pstride = s_m;
size_t pstride = s_m;
mr::execDynamic(ulim-llim, 0, 1, [&](mr::Scheduler &sched)
{
ringhelper helper;
int rstride=ginfo.nphmax()+2;
size_t rstride=ginfo.nphmax()+2;
vector<double> ringtmp(nmaps()*rstride);
while (auto rng=sched.getNext()) for(auto ith=rng.lo+llim; ith<rng.hi+llim; ++ith)
{
int dim2 = s_th*(ith-llim);
size_t dim2 = s_th*(ith-llim);
for (size_t i=0; i<nmaps(); ++i)
helper.phase2ring (ginfo, ginfo.pair(ith).r1,
&ringtmp[i*rstride],mmax,&phase[dim2+2*i],pstride);
......@@ -356,7 +356,7 @@ template<typename T> MRUTIL_NOINLINE void sharp_job<T>::execute()
/* clear output arrays if requested */
init_output();
int nchunks, chunksize;
size_t nchunks, chunksize;
get_chunk_info(ginfo.npairs(),sharp_veclen()*sharp_max_nvec(spin),
nchunks,chunksize);
vector<dcmplx> phasebuffer;
......@@ -365,7 +365,7 @@ template<typename T> MRUTIL_NOINLINE void sharp_job<T>::execute()
std::atomic<unsigned long long> a_opcnt(0);
/* chunk loop */
for (int chunk=0; chunk<nchunks; ++chunk)
for (size_t chunk=0; chunk<nchunks; ++chunk)
{
size_t llim=chunk*chunksize, ulim=min(llim+chunksize,ginfo.npairs());
vector<bool> ispair(ulim-llim);
......@@ -421,10 +421,10 @@ template<typename T> sharp_job<T>::sharp_job (sharp_jobtype type_,
MR_assert(map.size()==nmaps(), "incorrect # of a_lm components");
}
template<typename T> void sharp_execute (sharp_jobtype type, int spin, const vector<complex<T> *> &alm,
template<typename T> void sharp_execute (sharp_jobtype type, size_t spin, const vector<complex<T> *> &alm,
const vector<T *> &map,
const sharp_geom_info &geom_info, const sharp_alm_info &alm_info,
int flags, double *time, unsigned long long *opcnt)
size_t flags, double *time, unsigned long long *opcnt)
{
sharp_job job(type, spin, alm, map, geom_info, alm_info, flags);
......@@ -433,16 +433,16 @@ template<typename T> void sharp_execute (sharp_jobtype type, int spin, const vec
if (opcnt!=nullptr) *opcnt = job.opcnt;
}
template void sharp_execute<double> (sharp_jobtype type, int spin, const vector<complex<double> *> &alm,
template void sharp_execute<double> (sharp_jobtype type, size_t spin, const vector<complex<double> *> &alm,
const vector<double *> &map,
const sharp_geom_info &geom_info, const sharp_alm_info &alm_info,
int flags, double *time, unsigned long long *opcnt);
template void sharp_execute<float> (sharp_jobtype type, int spin, const vector<complex<float> *> &alm,
size_t flags, double *time, unsigned long long *opcnt);
template void sharp_execute<float> (sharp_jobtype type, size_t spin, const vector<complex<float> *> &alm,
const vector<float *> &map,
const sharp_geom_info &geom_info, const sharp_alm_info &alm_info,
int flags, double *time, unsigned long long *opcnt);
size_t flags, double *time, unsigned long long *opcnt);
void sharp_set_chunksize_min(int new_chunksize_min)
void sharp_set_chunksize_min(size_t new_chunksize_min)
{ chunksize_min=new_chunksize_min; }
void sharp_set_nchunks_max(int new_nchunks_max)
void sharp_set_nchunks_max(size_t new_nchunks_max)
{ nchunks_max=new_nchunks_max; }
......@@ -126,13 +126,58 @@ enum sharp_jobflags {
(in seconds) will be written here.
\param opcnt If not nullptr, a conservative estimate of the total floating point
operation count for this SHT will be written here. */
template<typename T> void sharp_execute (sharp_jobtype type, int spin, const std::vector<std::complex<T> *> &alm,
template<typename T> void sharp_execute (sharp_jobtype type, size_t spin, const std::vector<std::complex<T> *> &alm,
const std::vector<T *> &map,
const sharp_geom_info &geom_info, const sharp_alm_info &alm_info,
int flags, double *time, unsigned long long *opcnt);
size_t flags, double *time, unsigned long long *opcnt);
void sharp_set_chunksize_min(int new_chunksize_min);
void sharp_set_nchunks_max(int new_nchunks_max);
template<typename T> void sharp_alm2map(const std::complex<T> *alm, T *map,
const sharp_geom_info &geom_info, const sharp_alm_info &alm_info,
size_t flags, double *time, unsigned long long *opcnt)
{
std::vector<std::complex<T> *> va;
va.push_back(const_cast<std::complex<T> *>(alm));
std::vector<T *> vm;
vm.push_back(map);
sharp_execute(SHARP_Y, 0, va, vm, geom_info, alm_info, flags, time, opcnt);
}
template<typename T> void sharp_alm2map_spin(size_t spin, const std::complex<T> *alm1, const std::complex<T> *alm2, T *map1, T *map2,
const sharp_geom_info &geom_info, const sharp_alm_info &alm_info,
size_t flags, double *time, unsigned long long *opcnt)
{
std::vector<std::complex<T> *> va;
va.push_back(const_cast<std::complex<T> *>(alm1));
va.push_back(const_cast<std::complex<T> *>(alm2));
std::vector<T *> vm;
vm.push_back(map1);
vm.push_back(map2);
sharp_execute(SHARP_Y, spin, va, vm, geom_info, alm_info, flags, time, opcnt);
}
template<typename T> void sharp_map2alm(std::complex<T> *alm, const T *map,
const sharp_geom_info &geom_info, const sharp_alm_info &alm_info,
size_t flags, double *time, unsigned long long *opcnt)
{
std::vector<std::complex<T> *> va;
va.push_back(alm);
std::vector<T *> vm;
vm.push_back(const_cast<T *>(map));
sharp_execute(SHARP_Yt, 0, va, vm, geom_info, alm_info, flags, time, opcnt);
}
template<typename T> void sharp_map2alm_spin(size_t spin, std::complex<T> *alm1, std::complex<T> *alm2, const T *map1, const T *map2,
const sharp_geom_info &geom_info, const sharp_alm_info &alm_info,
size_t flags, double *time, unsigned long long *opcnt)
{
std::vector<std::complex<T> *> va;
va.push_back(alm1);
va.push_back(alm2);
std::vector<T *> vm;
vm.push_back(const_cast<T *>(map1));
vm.push_back(const_cast<T *>(map2));
sharp_execute(SHARP_Yt, spin, va, vm, geom_info, alm_info, flags, time, opcnt);
}
void sharp_set_chunksize_min(size_t new_chunksize_min);
void sharp_set_nchunks_max(size_t new_nchunks_max);
/*! \} */
......
......@@ -58,7 +58,7 @@ template<typename T> void sharp_standard_alm_info::tclear (T *alm) const
{
for (size_t mi=0;mi<mval_.size();++mi)
for (size_t l=mval_[mi];l<=lmax_;++l)
reinterpret_cast<T *>(alm)[mvstart[mi]+l*stride]=0.;
reinterpret_cast<T *>(alm)[mvstart[mi]+ptrdiff_t(l)*stride]=0.;
}
void sharp_standard_alm_info::clear_alm(const any &alm) const
{
......@@ -69,7 +69,7 @@ void sharp_standard_alm_info::clear_alm(const any &alm) const
template<typename T> void sharp_standard_alm_info::tget(size_t mi, const T *alm, dcmplx *almtmp, size_t nalm) const
{
for (auto l=mval_[mi]; l<=lmax_; ++l)
almtmp[nalm*l] = alm[mvstart[mi]+l*stride];
almtmp[nalm*l] = alm[mvstart[mi]+ptrdiff_t(l)*stride];
}
void sharp_standard_alm_info::get_alm(size_t mi, const any &alm, dcmplx *almtmp, size_t nalm) const
{
......@@ -82,7 +82,7 @@ void sharp_standard_alm_info::get_alm(size_t mi, const any &alm, dcmplx *almtmp,
template<typename T> void sharp_standard_alm_info::tadd(size_t mi, const dcmplx *almtmp, T *alm, size_t nalm) const
{
for (auto l=mval_[mi]; l<=lmax_; ++l)
alm[mvstart[mi]+l*stride] += T(almtmp[nalm*l]);
alm[mvstart[mi]+ptrdiff_t(l)*stride] += T(almtmp[nalm*l]);
}
void sharp_standard_alm_info::add_alm(size_t mi, const dcmplx *almtmp, const any &alm, size_t nalm) const
{
......@@ -91,9 +91,9 @@ void sharp_standard_alm_info::add_alm(size_t mi, const dcmplx *almtmp, const any
else MR_fail("bad a_lm data type");
}
ptrdiff_t sharp_standard_alm_info::index (int l, int mi)
ptrdiff_t sharp_standard_alm_info::index (size_t l, size_t mi)
{
return mvstart[mi]+stride*l;
return mvstart[mi]+stride*ptrdiff_t(l);
}
/* This currently requires all m values from 0 to nm-1 to be present.
It might be worthwhile to relax this criterion such that holes in the m
......@@ -112,19 +112,19 @@ size_t sharp_standard_alm_info::mmax() const
return nm_-1;
}
unique_ptr<sharp_standard_alm_info> sharp_make_triangular_alm_info (int lmax, int mmax, int stride)
unique_ptr<sharp_standard_alm_info> sharp_make_triangular_alm_info (size_t lmax, size_t mmax, ptrdiff_t stride)
{
vector<ptrdiff_t> mvstart(mmax+1);
ptrdiff_t tval = 2*lmax+1;
for (ptrdiff_t m=0; m<=mmax; ++m)
mvstart[m] = stride*((m*(tval-m))>>1);
size_t tval = 2*lmax+1;