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 $$
Trait Implementations
Return transform kind
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. ]);
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. ]);
Differentiation in spectral space
Differentiation in spectral space
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. ]);
type Physical = A
type Spectral = A
Parallel version. See CompositeChebyshev::forward
Parallel version. See CompositeChebyshev::forward_inplace
Parallel version. See CompositeChebyshev::backward
Parallel version. See CompositeChebyshev::backward_inplace
type Physical = A
type Physical = A
Scalar type in physical space (before transform)
type Spectral = A
type Spectral = A
Scalar type in spectral space (after transfrom)
fn try_into(
self
) -> Result<CompositeChebyshev<T>, <Self as TryInto<CompositeChebyshev<T>>>::Error>
fn try_into(
self
) -> Result<CompositeChebyshev<T>, <Self as TryInto<CompositeChebyshev<T>>>::Error>
Performs the conversion.
Auto Trait Implementations
impl<A> !RefUnwindSafe for CompositeChebyshev<A>
impl<A> Send for CompositeChebyshev<A>
impl<A> Sync for CompositeChebyshev<A>
impl<A> Unpin for CompositeChebyshev<A>
impl<A> !UnwindSafe for CompositeChebyshev<A>
Blanket Implementations
Mutably borrows from an owned value. Read more