Struct funspace::chebyshev::Chebyshev[][src]

pub struct Chebyshev<A> {
    pub n: usize,
    pub m: usize,
    pub x: Array1<A>,
    // some fields omitted
}
Expand description

Fields

n: usize

Number of coefficients in physical space

m: usize

Number of coefficients in spectral space ( equal to n in this case )

x: Array1<A>

Grid coordinates of chebyshev nodes (2nd kind).

Implementations

Creates a new Basis.

Arguments
  • n - Length of array’s dimension which shall live in chebyshev space.
Panics

Panics when input type cannot be cast from f64.

Examples
use funspace::chebyshev::Chebyshev;
let cheby = Chebyshev::<f64>::new(10);

Differentiat 1d Array n_times using the recurrence relation of chebyshev polynomials.

Differentiation is performed on input array directly.

Panics

Panics when input type cannot be cast from f64.

Example

Differentiate along lane

use funspace::chebyshev::Chebyshev;
use funspace::utils::approx_eq;
use ndarray::prelude::*;
let mut cheby = Chebyshev::<f64>::new(4);
// Differentiate twice
let mut input = array![1., 2., 3., 4.];
cheby.differentiate_lane(&mut input, 2);
approx_eq(&input, &array![12., 96.,  0.,  0.]);
// Differentiate zero times, return itself
let mut input = array![1., 2., 3., 4.];
cheby.differentiate_lane(&mut input, 0);
approx_eq(&input, &array![1., 2., 3., 4.]);

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

Return differentiated array

Differentiate on input array

Return differentiated array

Differentiate on input array

Return differentiated array

Differentiate on input array

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

Return itself

Return itself

Return itself

Return itself

Return itself

Return itself

Return itself

Return itself

Laplacian

Pseudoinverse Laplacian of chebyshev spectral differentiation matrices

Second order equations become banded when preconditioned with this matrix

Example
use funspace::chebyshev::Chebyshev;
use funspace::LaplacianInverse;
use funspace::utils::approx_eq;
use ndarray::s;
let ch = Chebyshev::<f64>::new(5);
let lap = ch.laplace();
let pinv = ch.laplace_inv();
let peye = pinv.dot(&lap);
approx_eq(&peye.slice(s![2..,..]).to_owned(), &ch.laplace_inv_eye());

Pseudoidentity matrix of laplacian

Example

Forward transform along first axis

use funspace::Transform;
use funspace::chebyshev::Chebyshev;
use funspace::utils::approx_eq;
use ndarray::prelude::*;
let mut cheby = Chebyshev::new(4);
let input = array![1., 2., 3., 4.];
let output = cheby.forward(&input, 0);
approx_eq(&output, &array![2.5, 1.33333333, 0. , 0.16666667]);
Example

Backward transform along first axis

use funspace::Transform;
use funspace::chebyshev::Chebyshev;
use funspace::utils::approx_eq;
use ndarray::prelude::*;
let mut cheby = Chebyshev::new(4);
let input = array![1., 2., 3., 4.];
let output = cheby.backward(&input, 0);
approx_eq(&output, &array![-2. ,  2.5, -3.5, 10.]);

See Chebyshev::backward

Panics

Panics when input type cannot be cast from f64.

Forward transform along first axis. See Chebyshev::forward

See Chebyshev::backward_par

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.