Struct funspace::chebyshev::CompositeChebyshev[][src]

pub struct CompositeChebyshev<A: FloatNum> {
    pub n: usize,
    pub m: usize,
    pub ortho: Chebyshev<A>,
    pub stencil: ChebyshevStencil<A>,
    // some fields omitted
}

Fields

n: usize

Number of coefficients in physical space

m: usize

Number of coefficients in spectral space

ortho: Chebyshev<A>

Parent base

stencil: ChebyshevStencil<A>

Transform stencil

Implementations

Return function space of chebyshev space with dirichlet boundary conditions $$ \phi_k = T_k - T_{k+2} $$

Return function space of chebyshev space with neumann boundary conditions $$ \phi_k = T_k - k^{2} / (k+2)^2 T_{k+2} $$

Dirichlet boundary condition basis $$ \phi_0 = 0.5 T_0 - 0.5 T_1 $$ $$ \phi_1 = 0.5 T_0 + 0.5 T_1 $$

Neumann boundary condition basis $$ \phi_0 = 0.5T_0 - 1/8T_1 $$ $$ \phi_1 = 0.5T_0 + 1/8T_1 $$

Return grid coordinates

Trait Implementations

Size in physical space

Size in spectral space

Size of orthogonal space

Coordinates in physical space

Returns transformation stencil

Return transform kind

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Differentiation in spectral space

use funspace::Differentiate;
use funspace::chebyshev::CompositeChebyshev;
use funspace::utils::approx_eq;
use ndarray::prelude::*;
let mut cheby = CompositeChebyshev::<f64>::dirichlet(5);
let mut input = array![1., 2., 3.];
let output = cheby.differentiate(&input, 2, 0);
approx_eq(&output, &array![-88.,  -48., -144., 0., 0. ]);

Differentiate on input array

Differentiation in spectral space

use funspace::Differentiate;
use funspace::chebyshev::CompositeChebyshev;
use funspace::utils::approx_eq;
use ndarray::prelude::*;
let mut cheby = CompositeChebyshev::<f64>::dirichlet(5);
let mut input = array![1., 2., 3.];
let output = cheby.differentiate(&input, 2, 0);
approx_eq(&output, &array![-88.,  -48., -144., 0., 0. ]);

Differentiate on input array

Differentiation in spectral space

Differentiate on input array

Differentiation in spectral space

Differentiate on input array

Performs the conversion.

Return coefficents in associated composite space

use funspace::chebyshev::CompositeChebyshev;
use ndarray::prelude::*;
use funspace::utils::approx_eq;
use funspace::FromOrtho;
let (nx, ny) = (5, 4);
let mut composite_coeff = Array2::<f64>::zeros((nx - 2, ny));
for (i, v) in composite_coeff.iter_mut().enumerate() {
    *v = i as f64;
}
let cd = CompositeChebyshev::<f64>::dirichlet(nx);

let expected = array![
    [0., 1., 2., 3.],
    [4., 5., 6., 7.],
    [8., 8., 8., 8.],
    [-4., -5., -6., -7.],
    [-8., -9., -10., -11.],
];
let parent_coeff = cd.to_ortho(&composite_coeff, 0);
approx_eq(&parent_coeff, &expected);

Return coefficents in associated composite space

use funspace::chebyshev::CompositeChebyshev;
use ndarray::prelude::*;
use funspace::utils::approx_eq;
use funspace::FromOrtho;
let (nx, ny) = (5, 4);
let mut parent_coeff = Array2::<f64>::zeros((nx, ny));
for (i, v) in parent_coeff.iter_mut().enumerate() {
    *v = i as f64;
}
let cd = CompositeChebyshev::<f64>::dirichlet(nx);

let expected = array![
    [-8., -8., -8., -8.],
    [-4., -4., -4., -4.],
    [-8., -8., -8., -8.],
];
let composite_coeff = cd.from_ortho(&parent_coeff, 0);
approx_eq(&composite_coeff, &expected);

Return coefficents in associated composite space

use funspace::chebyshev::CompositeChebyshev;
use ndarray::prelude::*;
use funspace::utils::approx_eq;
use funspace::FromOrtho;
let (nx, ny) = (5, 4);
let mut composite_coeff = Array2::<f64>::zeros((nx - 2, ny));
for (i, v) in composite_coeff.iter_mut().enumerate() {
    *v = i as f64;
}
let cd = CompositeChebyshev::<f64>::dirichlet(nx);

let expected = array![
    [0., 1., 2., 3.],
    [4., 5., 6., 7.],
    [8., 8., 8., 8.],
    [-4., -5., -6., -7.],
    [-8., -9., -10., -11.],
];
let parent_coeff = cd.to_ortho(&composite_coeff, 0);
approx_eq(&parent_coeff, &expected);

Return coefficents in associated composite space

use funspace::chebyshev::CompositeChebyshev;
use ndarray::prelude::*;
use funspace::utils::approx_eq;
use funspace::FromOrtho;
let (nx, ny) = (5, 4);
let mut parent_coeff = Array2::<f64>::zeros((nx, ny));
for (i, v) in parent_coeff.iter_mut().enumerate() {
    *v = i as f64;
}
let cd = CompositeChebyshev::<f64>::dirichlet(nx);

let expected = array![
    [-8., -8., -8., -8.],
    [-4., -4., -4., -4.],
    [-8., -8., -8., -8.],
];
let composite_coeff = cd.from_ortho(&parent_coeff, 0);
approx_eq(&composite_coeff, &expected);
Example

Forward transform along first axis

use funspace::Transform;
use funspace::chebyshev::CompositeChebyshev;
use funspace::utils::approx_eq;
use ndarray::prelude::*;
let mut cheby = CompositeChebyshev::dirichlet(5);
let input = array![1., 2., 3., 4., 5.];
let output = cheby.forward(&input, 0);
approx_eq(&output, &array![2., 0.70710678, 1.]);

See CompositeChebyshev::forward

use funspace::Transform;
use funspace::chebyshev::CompositeChebyshev;
use funspace::utils::approx_eq;
use ndarray::prelude::*;
let mut cheby = CompositeChebyshev::dirichlet(5);
let input = array![1., 2., 3., 4., 5.];
let mut output = Array1::<f64>::zeros(3);
cheby.forward_inplace(&input, &mut output, 0);
approx_eq(&output, &array![2., 0.70710678, 1.]);
Example

Backward transform along first axis

use funspace::Transform;
use funspace::chebyshev::CompositeChebyshev;
use funspace::utils::approx_eq;
use ndarray::prelude::*;
let mut cheby = CompositeChebyshev::dirichlet(5);
let input = array![1., 2., 3.];
let output = cheby.backward(&input, 0);
approx_eq(&output, &array![0.,1.1716, -4., 6.8284, 0. ]);

See CompositeChebyshev::backward

use funspace::Transform;
use funspace::chebyshev::CompositeChebyshev;
use funspace::utils::approx_eq;
use ndarray::prelude::*;
let mut cheby = CompositeChebyshev::dirichlet(5);
let input = array![1., 2., 3.];
let mut output = Array1::<f64>::zeros(5);
cheby.backward_inplace(&input, &mut output, 0);
approx_eq(&output, &array![0.,1.1716, -4., 6.8284, 0. ]);

Parallel version. See CompositeChebyshev::forward

Parallel version. See CompositeChebyshev::backward

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.