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

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

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.

Idea is to record the execution time for the spectral -> grid -> spectral roundtrip after precomputations have been done.
The strategy is to generate random coefficients representing a complete spherical harmonic series of funcions Y(m,l). The ordering of the these coefficients is assumed to be the same as an output of the FSTSemiMemo() function, namely:

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)

This means that there are (bw*bw) coefficients.

Once the coefficients are generated, the corresponding function is synthesized using InvFSTSemiMemo(), then transformed (analyzed) using FSTSemiMemo(). Then timing data will be printed.

Sample call:

test_s2_semi_memo bw loops [error_file]
Note
In this program, the coefficients generated are such that the grid points (sample values) produced are real. InvFSTSemiMemo() and FSTSemiMemo() will take advantage of this. If you wish to change this, change the data_format argument of each function further down from REAL to COMPLEX. This is also documented in the file FST_semi_memo.c

Definition in file test_s2_semi_memo.c.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 62 of file test_s2_semi_memo.c.