S2kit  1.1
Toolkit for working with functions defined on the sphere
test_s2_semi_memo_inv.c File Reference

Example of source code to computie inverse spherical harmonic transform using the seminaive and naive algorithms. More...

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <fftw3.h>
#include "s2kit/FST_semi_memo.h"
#include "s2kit/cospml.h"
#include "s2kit/weights.h"
#include "util/csecond.h"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example of source code to computie inverse spherical harmonic transform using the seminaive and naive algorithms.

Computed function samples using spherical coefficients of the function, which are given in the named input file, and writes those samples in the named output file.

The code will pre-compute associated Legendre functions before doing inverse transform. This won't a be part of what's being timed.

In its current state, assuming that will seminaive at all orders. If you wish to change this, modify the cutoff variable in this file, i.e. cutoff = ... at what order to switch from seminaive to naive algorithm.

Sample call:

test_s2_semi_memo_inv coeffs_file output_file bw
test_s2_semi_memo_inv coeff_bw8.dat samples_bw8.dat 8

The format of the input coefficient file is an interleaved real/imaginary parts of the coefficients, where the coefficients are given in "code" order, as defined in test_s2_semi_memo.c:

f(0,0) f(0,1) f(0,2) ... f(0,bw-1)
f(1,1) f(1,2) ... f(1,bw-1)
etc.
f(bw-2,bw-2) f(bw-2,bw-1)
f(bw-1,bw-1)
f(-(bw-1),bw-1)
f(-(bw-2),bw-2) f(-(bw-2),bw-1)
etc.
f(-2,2) ... f(-2,bw-1)
f(-1,1) f(-1,2) ... f(-1,bw-1)

To help you out, there is a function IndexOfHarmonicCoeff() which returns the array index of the coefficient f_{l,m}.

The format of the output sample file is an interleaved real/imaginary parts of the function samples arranged in "latitude-major" format, i.e. the function is sampled in this order:

(theta_0, phi_0)
(theta_0, phi_1)
(theta_0, phi_2)
...
(theta_0, phi_{bw-1})
(theta_1, phi_0)
(theta_1, phi_1)
...
(theta_{bw-1}, phi_{bw-1})
where theta_k = pi*(2*j+1)/(4*bw)
phi_j = 2*pi*k/(2*bw)

Definition in file test_s2_semi_memo_inv.c.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 72 of file test_s2_semi_memo_inv.c.