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

Example of source code to computie forward 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 "s2kit/util.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 forward spherical harmonic transform using the seminaive and naive algorithms.

Computes the spherical coefficients of the function, whose sample values are given in the named input file, and writes those coefficients in the named output file.

The code will pre-compute associated Legendre functions before doing 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_fwd sample_file output_file bw [output_format]
test_s2_semi_memo_fwd y31_bw8.dat y31_coef.dat 8

The format of the input sample file will be an interleaved real/imaginary parts of the function samples arranged in "latitude-major" format, i.e. the function will be 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)

output_format is an optional argument:
0 - coefficients in "code" order (interleaved real/imaginary), i.e. suitable for test_s2_semi_memo_inv.c;
1 - coefficients in prettier "human" order (verbose), i.e. if f_{l,m} is the coefficient of degree l, order m, then the coefficients will be arranged this way:

f_{0,0},
f_{1,-1}, f_{1,0}, f_{1,1},
f_{2,-2}, f_{2,-1}, f_{2,0}, f_{2,1}, f_{2,2},
...
E.g. l = 2 m = 1 2.3 + 6 I.

The default output format is "code" order. To help you out, there is a function IndexOfHarmonicCoeff() which returns the array index of the coefficient f_{l,m}.

Definition in file test_s2_semi_memo_fwd.c.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 71 of file test_s2_semi_memo_fwd.c.