Struct funspace::fourier::FourierR2c[][src]

pub struct FourierR2c<A> {
    pub n: usize,
    pub m: usize,
    pub x: Array1<A>,
    pub k: Array1<Complex<A>>,
    pub fft_handler: R2cFftHandler<A>,
    // some fields omitted
}
Expand description

Fields

n: usize

Number of coefficients in physical space

m: usize

Number of coefficients in spectral space

x: Array1<A>

Grid coordinates of fourier nodes

k: Array1<Complex<A>>

Complex wavenumber vector

fft_handler: R2cFftHandler<A>

Handles discrete cosine transform

Implementations

Returns a new Fourier Basis for real-to-complex transforms

Differentiate 1d Array n_times

Example

Differentiate along lane

use funspace::fourier::FourierR2c;
use funspace::utils::approx_eq_complex;
use ndarray::prelude::*;
let fo = FourierR2c::<f64>::new(5);
let mut k = fo.k.clone();
let expected = k.mapv(|x| x.powf(2.));
fo.differentiate_lane(&mut k, 1);
approx_eq_complex(&k, &expected);
Panics

When type conversion fails ( safe )

Trait Implementations

Size in physical space

Size in spectral space

Size of orthogonal space

Coordinates in physical space

Return mass matrix (= eye)

Return transform kind

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Perform differentiation in spectral space

Return differentiated array

Differentiate on input array

Perform differentiation in spectral space

Return differentiated array

Differentiate on input array

Performs the conversion.

Return itself

Return itself

Return itself

Return itself

Return itself

Return itself

Return itself

Return itself

Laplacian ( = |k^2| ) diagonal matrix

Pseudoinverse Laplacian for FourierR2c basis

Pseudoidentity matrix (= eye matrix with removed first row for FourierR2c)

Copied from c2c

Example

Forward transform along first axis

use funspace::fourier::FourierR2c;
use funspace::Transform;
use funspace::utils::approx_eq_complex;
use num_complex::Complex;
use ndarray::prelude::*;
let mut fo = FourierR2c::new(4);
let input = array![1., 2., 3., 4.];
let expected = array![
    Complex::new(10., 0.),
    Complex::new(-2., 2.),
    Complex::new(-2., 0.)
];
let output = fo.forward(&input, 0);
approx_eq_complex(&output, &expected);
Example

Backward transform along first axis

use funspace::fourier::FourierR2c;
use funspace::Transform;
use funspace::utils::approx_eq;
use num_complex::Complex;
use ndarray::prelude::*;
let mut fo = FourierR2c::new(4);
let input = array![
    Complex::new(10., 0.),
    Complex::new(-2., 2.),
    Complex::new(-2., 0.)
];
let expected = array![1., 2., 3., 4.];
let output = fo.backward(&input, 0);
approx_eq(&output, &expected);

See FourierR2c::backward

Panics

Panics when input type cannot be cast from f64.

Parallel version. See FourierR2c::forward

Parallel version. See FourierR2c::forward_inplace

Parallel version. See FourierR2c::backward

Parallel version. See FourierR2c::backward_inplace

Panics

Panics when input type cannot be cast from f64.

Scalar type in physical space (before transform)

Scalar type in spectral space (after transfrom)

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.