Struct funspace::chebyshev::Chebyshev [−][src]
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
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
Return transform kind
Return differentiated array
Return differentiated array
Return differentiated array
Return differentiated array
Return itself
Return itself
Return itself
Return itself
Return itself
Return itself
Return itself
Return itself
Return itself
Return itself
Return itself
Return itself
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.]);
type Physical = A
type Spectral = A
Forward transform along first axis. See Chebyshev::forward
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)
Auto Trait Implementations
impl<A> !RefUnwindSafe for Chebyshev<A>
impl<A> !UnwindSafe for Chebyshev<A>
Blanket Implementations
Mutably borrows from an owned value. Read more