sharp_almhelpers.cc 1.61 KB
Newer Older
Martin Reinecke's avatar
Martin Reinecke committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
 *  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_almhelpers.c
 *  Spherical transform library
 *
 *  Copyright (C) 2008-2019 Max-Planck-Society
 *  \author Martin Reinecke
 */

#include "libsharp2/sharp_almhelpers.h"

Martin Reinecke's avatar
Martin Reinecke committed
30
31
32
using namespace std;

unique_ptr<sharp_alm_info> sharp_make_triangular_alm_info (int lmax, int mmax, int stride)
Martin Reinecke's avatar
Martin Reinecke committed
33
  {
Martin Reinecke's avatar
Martin Reinecke committed
34
  vector<ptrdiff_t> mvstart(mmax+1);
Martin Reinecke's avatar
Martin Reinecke committed
35
36
  ptrdiff_t tval = 2*lmax+1;
  for (ptrdiff_t m=0; m<=mmax; ++m)
Martin Reinecke's avatar
Martin Reinecke committed
37
38
    mvstart[m] = stride*((m*(tval-m))>>1);
  return make_unique<sharp_alm_info>(lmax, mmax, stride, mvstart.data());
Martin Reinecke's avatar
Martin Reinecke committed
39
40
  }

Martin Reinecke's avatar
Martin Reinecke committed
41
unique_ptr<sharp_alm_info> sharp_make_rectangular_alm_info (int lmax, int mmax, int stride)
Martin Reinecke's avatar
Martin Reinecke committed
42
  {
Martin Reinecke's avatar
Martin Reinecke committed
43
  vector<ptrdiff_t> mvstart(mmax+1);
Martin Reinecke's avatar
Martin Reinecke committed
44
  for (ptrdiff_t m=0; m<=mmax; ++m)
Martin Reinecke's avatar
Martin Reinecke committed
45
46
    mvstart[m] = stride*m*(lmax+1);
  return make_unique<sharp_alm_info>(lmax, mmax, stride, mvstart.data());
Martin Reinecke's avatar
Martin Reinecke committed
47
  }