NcmFftlog

NcmFftlog — Abstract class for implementing logarithm fast fourier transform.

Properties

gdouble Lk Read / Write / Construct Only
guint N Read / Write
gdouble lnk0 Read / Write / Construct Only
gdouble lnr0 Read / Write / Construct Only
gchar * name Read
guint nderivs Read / Write / Construct
gboolean no-ringing Read / Write / Construct
gdouble padding Read / Write / Construct

Object Hierarchy

    GObject
    ╰── NcmFftlog
        ├── NcmFftlogGausswin2
        ├── NcmFftlogSBesselJ
        ╰── NcmFftlogTophatwin2

Description

This class provides the tools to compute the Fast Fourier Transform of any function, which is assumed to be a periodic sequence of logarithmically spaced points. It is inspired on the approach FFTLog, which we extended as described below.

A function $G(r)$ is written as \begin{equation}\label{eq:Gr} G(r) = \int_0^\infty F(k) \ K(kr) dk, \end{equation} where $F(k)$ is defined in the fundamental interval $[\ln k_0 - L/2, \ln k_0 + L/2]$, $L$ is the period, $\ln k_0$ is the center value and $K(kr)$ is a kernel function. Assuming that $F(k)$ can be written in terms of the $N$ lowest Fourier modes, we have

$$F(k) = \sum_{n} c_n e^{\frac{2\pi i n}{L} \ln\left(\frac{k}{k_0}\right)}.$$ Substituting $F(k)$ in Eq. \eqref{eq:Gr} and changing the variable $k \rightarrow t = kr$, thus \begin{align}\label{eq:Gr_decomp} r G(r) &= \sum_n c_n \int_0^\infty \frac{k}{k_0}^{\frac{2\pi i n}{L}} K(kr)^2 d(kr) \ &= \sum_n c_n \int_0^\infty \frac{t}{k_0 r}^{\frac{2\pi i n}{L}} K(t) dt \ &= \sum_n c_n e^{-\frac{2\pi i n}{L} \ln\left(\frac{r}{r_0}\right)} e^{-\frac{2\pi i n}{L} \ln(k_0 r_0)} Y_n, \end{align} where $$Y_n = \int_0^\infty t^{\frac{2\pi i n}{L}} K(t) dt,$$ and the Fourier coefficients are $$c_n = \frac{1}{N} \sum_m F(k_m) e^{- \frac{2\pi i nm}{N}}.$$ The total number of points $N$ corresponds to the number of knots in the fundamental interval, which is equally spaced.

The variables discretization is different depending whether $N$ is even or odd, in general $$ k_n = k_0 \mathrm{e}^{n L / N}, \qquad r_m = r_0 \mathrm{e}^{m L / N}. $$ If $N$ is odd, $n$ and $m$ runs from $[-\lfloor N/2\rfloor, \lfloor N/2\rfloor]$, where $\lfloor N/2\rfloor$ is the round-down (largest integer smaller than $N/2$) of $N/2$. In this case \begin{align} \ln\left(k_{-\lfloor N/2\rfloor}\right) = \ln(k_0) - \frac{(N-1)}{N} \frac{L}{2}, \ \ln\left(k_{+\lfloor N/2\rfloor}\right) = \ln(k_0) + \frac{(N-1)}{N} \frac{L}{2}. \end{align} This means that for odd $N$ the values of $k_n$ (and $r_n$) never touches the borders $\ln(k_0) \pm L/2$ and $\ln(r_0) \pm L/2$. On the other hand if $N$ is even ($\lfloor N/2\rfloor = N/2$) \begin{align} \ln\left(k_{-\lfloor N/2\rfloor}\right) = \ln(k_0) - \frac{L}{2}, \ \ln\left(k_{+\lfloor N/2\rfloor}\right) = \ln(k_0) + \frac{L}{2}. \end{align} However, since we are assuming that these functions are periodic with period $L$ these two points refer to the same value of the functions. Thus, we do not need to include both points and in the case of even $N$ we include the point $\ln(k_0) - \frac{L}{2}$ only. In the original FFTLog paper they include both points but give them a $1/2$ weight, here we avoid this complication by using the lower end point only.

The user must provide the following input values: $\ln k_0$ - ncm_fftlog_set_lnk0(), $\ln r_0$ - ncm_fftlog_set_lnr0(), $L$ - ncm_fftlog_set_length(), padding percentage - ncm_fftlog_set_padding(), $N$ - ncm_fftlog_set_size(), $F(k)$ (or $F(k_m)$ -- see description below).

  • Since the algorithm assumes that the function to be decomposed is periodic, it is worth extending the interval in $\ln k$ such that $F(k) \equiv 0$ in the intervals $\left[\ln k_0 -\frac{L_T}{2}, \ln k_0 - \frac{L}{2} \right)$ and $ \left(\ln k_0 + \frac{L}{2}, \ln k_0 + \frac{L_T}{2}\right]$, where the total period $L_T$ is defined by the final number of knots, i.e., $N_f = N (1 + \mathrm{padding})$.

  • $N$ knots are equally distributed in the fundamental interval and $N \times \mathrm{padding}$ knots are distributed in in the two simetric intervals as mentioned above.

  • For the sake of optimization, the final number of points $N_f$ is substituted by the smallest number $N_f^\prime$ (bigger than $N_f$) which can be decomposed as $N_f \leq N_f^\prime = N^\prime (1 + \mathrm{padding}) = 2^a 3^b 5^c 7^d$, where $a$, $b$, $c$ and $d$ are positive integers.

  • The function $F(k)$ can be provided as:

    1. a gsl_function - ncm_fftlog_eval_by_gsl_function() - whose values are computed at the knots within the fundamental interval, and set to zero within the padding intervals.

    2. as a vector - ncm_fftlog_eval_by_vector() - first one must get the vector of $\ln k$ knots, ncm_fftlog_get_lnk_vector(), and then pass a vector containing the values of the function computed at each knot.

  • Regarding $Y_n$, see the different implementations of NcmFftlog, e.g., NcmFftlogTophatwin2 and NcmFftlogGausswin2.

Functions

NcmFftlogFunc ()

gdouble
(*NcmFftlogFunc) (const gdouble x,
                  gpointer user_data);

ncm_fftlog_ref ()

NcmFftlog *
ncm_fftlog_ref (NcmFftlog *fftlog);

Increases the reference count of fftlog by one.

Parameters

fftlog

a NcmFftlog

 

Returns

fftlog .

[transfer full]


ncm_fftlog_free ()

void
ncm_fftlog_free (NcmFftlog *fftlog);

Decreases the reference count of fftlog by one.

Parameters

fftlog

a NcmFftlog

 

ncm_fftlog_clear ()

void
ncm_fftlog_clear (NcmFftlog **fftlog);

If fftlog is different from NULL, decreases the reference count of fftlog by one and sets fftlog to NULL.

Parameters

fftlog

a NcmFftlog

 

ncm_fftlog_set_name ()

void
ncm_fftlog_set_name (NcmFftlog *fftlog,
                     const gchar *name);

ncm_fftlog_peek_name ()

const gchar *
ncm_fftlog_peek_name (NcmFftlog *fftlog);

Parameters

fftlog

a NcmFftlog

 

Returns

The internal string describing NcmFftlog.

[transfer none]


ncm_fftlog_set_nderivs ()

void
ncm_fftlog_set_nderivs (NcmFftlog *fftlog,
                        guint nderivs);

Sets nderivs as the number of derivatives to calculate.

Parameters

fftlog

a NcmFftlog

 

nderivs

the number of derivatives

 

ncm_fftlog_get_nderivs ()

guint
ncm_fftlog_get_nderivs (NcmFftlog *fftlog);

Gets the number of derivatives the object is currently calculating.

Parameters

fftlog

a NcmFftlog

 

Returns

the number of derivatives calculated.


ncm_fftlog_set_lnr0 ()

void
ncm_fftlog_set_lnr0 (NcmFftlog *fftlog,
                     const gdouble lnr0);

Sets the center of the transform output $\ln(r_0)$.

Parameters

fftlog

a NcmFftlog

 

lnr0

output center $\ln(r_0)$

 

ncm_fftlog_get_lnr0 ()

gdouble
ncm_fftlog_get_lnr0 (NcmFftlog *fftlog);

Gets the center of the transform output.

Parameters

fftlog

a NcmFftlog

 

Returns

the output center $\ln(r_0)$.


ncm_fftlog_set_lnk0 ()

void
ncm_fftlog_set_lnk0 (NcmFftlog *fftlog,
                     const gdouble lnk0);

Sets the center of the transform input $\ln(k_0)$.

Parameters

fftlog

a NcmFftlog

 

lnk0

input center $\ln(k_0)$

 

ncm_fftlog_get_lnk0 ()

gdouble
ncm_fftlog_get_lnk0 (NcmFftlog *fftlog);

Gets the center of the transform input $\ln(k_0)$.

Parameters

fftlog

a NcmFftlog

 

Returns

the input center $\ln(k_0)$.


ncm_fftlog_set_size ()

void
ncm_fftlog_set_size (NcmFftlog *fftlog,
                     guint n);

Sets the number of knots $N_f^\prime$ where the integrated function is evaluated, given the input number of knots n , plus padding.

Parameters

fftlog

a NcmFftlog

 

n

number of knots

 

ncm_fftlog_set_padding ()

void
ncm_fftlog_set_padding (NcmFftlog *fftlog,
                        gdouble pad_p);

Sets the size of the padding in percetange of the interval.

Parameters

fftlog

a NcmFftlog

 

pad_p

padding percentage

 

ncm_fftlog_get_padding ()

gdouble
ncm_fftlog_get_padding (NcmFftlog *fftlog);

Gets the padding percentage.

Parameters

fftlog

a NcmFftlog

 

Returns

the padding percentage.


ncm_fftlog_set_noring ()

void
ncm_fftlog_set_noring (NcmFftlog *fftlog,
                       gboolean active);

Sets whether to use the no-ringing adjustment of $\ln(r_0)$.

Parameters

fftlog

a NcmFftlog

 

active

whether to use the no-ringing adjustment of $\ln(r_0)$

 

ncm_fftlog_get_noring ()

gboolean
ncm_fftlog_get_noring (NcmFftlog *fftlog);

Parameters

fftlog

a NcmFftlog

 

Returns

whether no-ringing condition is activated.


ncm_fftlog_set_length ()

void
ncm_fftlog_set_length (NcmFftlog *fftlog,
                       gdouble Lk);

Sets the length of the period Lk , where the function is periodic in logarithmic space $\ln k$.

Parameters

fftlog

a NcmFftlog

 

Lk

period in the logarithmic space

 

ncm_fftlog_get_lnk_vector ()

void
ncm_fftlog_get_lnk_vector (NcmFftlog *fftlog,
                           NcmVector *lnk);

Computes the $\ln k$ vector.

Parameters

fftlog

a NcmFftlog

 

lnk

a NcmVector

 

ncm_fftlog_eval_by_vector ()

void
ncm_fftlog_eval_by_vector (NcmFftlog *fftlog,
                           NcmVector *Fk);

Fk is a vector which contains the values of the function at each knot $\ln k_m$.

Parameters

fftlog

a NcmFftlog

 

Fk

a NcmVector

 

ncm_fftlog_eval_by_function ()

void
ncm_fftlog_eval_by_function (NcmFftlog *fftlog,
                             NcmFftlogFunc Fk,
                             gpointer user_data);

Evaluates the function Fk at each knot $\ln k_m$.

Parameters

fftlog

a NcmFftlog

 

Fk

a NcmFftlogFunc.

[scope call]

user_data

Fk user data

 

ncm_fftlog_eval_by_gsl_function ()

void
ncm_fftlog_eval_by_gsl_function (NcmFftlog *fftlog,
                                 gsl_function *Fk);

Evaluates the function Fk at each knot $\ln k_m$.

[skip]

Parameters

fftlog

a NcmFftlog

 

Fk

Fk function pointer

 

ncm_fftlog_prepare_splines ()

void
ncm_fftlog_prepare_splines (NcmFftlog *fftlog);

Prepares the set of splines respective to the function $G(r)$ and, if required, its n-order derivatives.

Parameters

fftlog

a NcmFftlog

 

ncm_fftlog_get_vector_lnr ()

NcmVector *
ncm_fftlog_get_vector_lnr (NcmFftlog *fftlog);

Gets the vector of the $\ln r$ knots.

Parameters

fftlog

a NcmFftlog

 

Returns

.

[transfer full]


ncm_fftlog_get_vector_Gr ()

NcmVector *
ncm_fftlog_get_vector_Gr (NcmFftlog *fftlog,
                          guint nderiv);

Gets the vector of the transformed function $G(r)$, nderiv = 0, or its nderiv -th derivative with respect to $\ln r$.

Parameters

fftlog

a NcmFftlog

 

nderiv

derivative number

 

Returns

a vector of $G(r)$ values or its nderiv -th derivative.

[transfer full]


ncm_fftlog_peek_spline_Gr ()

NcmSpline *
ncm_fftlog_peek_spline_Gr (NcmFftlog *fftlog,
                           guint nderiv);

Peeks the spline of $G(r)$, nderiv = 0, or the spline of the nderiv -th derivative of $G(r)$ with respect to $\ln r$.

Parameters

fftlog

a NcmFftlog

 

nderiv

derivative number

 

Returns

the nderiv component of the spline.

[transfer none]


ncm_fftlog_eval_output ()

gdouble
ncm_fftlog_eval_output (NcmFftlog *fftlog,
                        guint nderiv,
                        const gdouble lnr);

Evaluates the function $G(r)$, or the nderiv -th derivative, at the point lnr .

Parameters

fftlog

a NcmFftlog

 

nderiv

derivative number

 

lnr

logarithm base e of $r$

 

Returns

$\frac{\mathrm{d}^nG(r)}{\mathrm{d}\ln r}$ value computed at lnr .


ncm_fftlog_calibrate_size ()

void
ncm_fftlog_calibrate_size (NcmFftlog *fftlog,
                           NcmFftlogFunc Fk,
                           gpointer user_data,
                           const gdouble reltol);

Increases the original (input) number of knots until the $G(r)$ splines reach the required precision reltol .

Parameters

fftlog

a NcmFftlog

 

Fk

a NcmFftlogFunc.

[scope call]

user_data

Fk user data

 

reltol

relative tolerance

 

ncm_fftlog_calibrate_size_gsl ()

void
ncm_fftlog_calibrate_size_gsl (NcmFftlog *fftlog,
                               gsl_function *Fk,
                               const gdouble reltol);

Increases the original (input) number of knots until the $G(r)$ splines reach the required precision reltol .

[skip]

Parameters

fftlog

a NcmFftlog

 

Fk

Fk function pointer

 

reltol

relative tolerance

 

ncm_fftlog_get_size ()

guint
ncm_fftlog_get_size (NcmFftlog *fftlog);

Gets the number of knots $N^\prime$ where the integrated function is evaluated.

Parameters

fftlog

a NcmFftlog

 

Returns

the number of knots $N^\prime$.


ncm_fftlog_get_full_size ()

gint
ncm_fftlog_get_full_size (NcmFftlog *fftlog);

Gets the number of knots $N_f^\prime$ where the integrated function is evaluated plus padding.

Parameters

fftlog

a NcmFftlog

 

Returns

the total number of knots $N_f^\prime$.


ncm_fftlog_get_norma ()

gdouble
ncm_fftlog_get_norma (NcmFftlog *fftlog);

Gets the number of knots $N_f^\prime$ where the integrated function is evaluated plus padding.

Parameters

fftlog

a NcmFftlog

 

Returns

the total number of knots $N_f^\prime$ (double).


ncm_fftlog_get_length ()

gdouble
ncm_fftlog_get_length (NcmFftlog *fftlog);

Gets the value of the ``physical'' period, i.e., period of the fundamental interval.

Parameters

fftlog

a NcmFftlog

 

Returns

the period $L$.


ncm_fftlog_get_full_length ()

gdouble
ncm_fftlog_get_full_length (NcmFftlog *fftlog);

Gets the value of the total period, i.e., period defined by the fundamental interval plus the padding size.

Parameters

fftlog

a NcmFftlog

 

Returns

the total period $L_T$.


ncm_fftlog_get_mode_index ()

gint
ncm_fftlog_get_mode_index (NcmFftlog *fftlog,
                           gint i);

Gets the index of the mode i of the Fourier decomposition. This index corresponds to the label $n$ in Eq. \eqref{eq:Gr_decomp}.

Parameters

fftlog

a NcmFftlog

 

i

index

 

Returns

the index of the mode


ncm_fftlog_get_array_index ()

gint
ncm_fftlog_get_array_index (NcmFftlog *fftlog,
                            gint phys_i);

Gets the array index i of the Fourier decomposition. This index corresponds the position in the fft array of the element $n$ in Eq. \eqref{eq:Gr_decomp}.

Parameters

fftlog

a NcmFftlog

 

phys_i

index

 

Returns

the array index corresponding to phys_i


ncm_fftlog_peek_output_vector ()

NcmVector *
ncm_fftlog_peek_output_vector (NcmFftlog *fftlog,
                               guint nderiv);

Peeks the output vector respective to $G(r)$, nderiv = 0, or its comp -th derivative with respect to $\ln r$.

Parameters

fftlog

a NcmFftlog

 

nderiv

derivative number

 

Returns

the output vector $G(r)$ or its comp -th derivative.

[transfer none]

Property Details

The “Lk” property

  “Lk”                       gdouble

Function log-period.

Owner: NcmFftlog

Flags: Read / Write / Construct Only

Default value: 1


The “N” property

  “N”                        guint

Number of knots.

Owner: NcmFftlog

Flags: Read / Write

Default value: 10


The “lnk0” property

  “lnk0”                     gdouble

Center value for ln(k).

Owner: NcmFftlog

Flags: Read / Write / Construct Only

Default value: 0


The “lnr0” property

  “lnr0”                     gdouble

Center value for ln(r).

Owner: NcmFftlog

Flags: Read / Write / Construct Only

Default value: 0


The “name” property

  “name”                     gchar *

FFTW Plan wisdown name.

Owner: NcmFftlog

Flags: Read

Default value: "fftlog_default_wisdown"


The “nderivs” property

  “nderivs”                  guint

Number of derivatives.

Owner: NcmFftlog

Flags: Read / Write / Construct

Default value: 0


The “no-ringing” property

  “no-ringing”               gboolean

No ringing.

Owner: NcmFftlog

Flags: Read / Write / Construct

Default value: TRUE


The “padding” property

  “padding”                  gdouble

Padding percentage.

Owner: NcmFftlog

Flags: Read / Write / Construct

Allowed values: >= 0

Default value: 1