Struct funspace::fourier::FourierC2c
source · [−]pub struct FourierC2c<A> { /* private fields */ }
Expand description
Implementations
Trait Implementations
sourceimpl<A: FloatNum> BaseElements for FourierC2c<A>
impl<A: FloatNum> BaseElements for FourierC2c<A>
type RealNum = A
type RealNum = A
Real valued scalar type
sourcefn transform_kind(&self) -> TransformKind
fn transform_kind(&self) -> TransformKind
Return kind of transform
sourceimpl<A, T> BaseFromOrtho<T> for FourierC2c<A> where
A: FloatNum,
T: ScalarNum,
impl<A, T> BaseFromOrtho<T> for FourierC2c<A> where
A: FloatNum,
T: ScalarNum,
sourcefn to_ortho_slice(&self, indata: &[T], outdata: &mut [T])
fn to_ortho_slice(&self, indata: &[T], outdata: &mut [T])
Composite space coefficients -> Orthogonal space coefficients
sourcefn from_ortho_slice(&self, indata: &[T], outdata: &mut [T])
fn from_ortho_slice(&self, indata: &[T], outdata: &mut [T])
Orthogonal space coefficients -> Composite space coefficients
sourcefn to_ortho<S, D>(&self, indata: &ArrayBase<S, D>, axis: usize) -> Array<T, D> where
S: Data<Elem = T>,
D: Dimension,
fn to_ortho<S, D>(&self, indata: &ArrayBase<S, D>, axis: usize) -> Array<T, D> where
S: Data<Elem = T>,
D: Dimension,
Composite coefficients -> Orthogonal coefficients
sourcefn to_ortho_inplace<S1, S2, D>(
&self,
indata: &ArrayBase<S1, D>,
outdata: &mut ArrayBase<S2, D>,
axis: usize
) where
S1: Data<Elem = T>,
S2: Data<Elem = T> + DataMut,
D: Dimension,
T: Clone,
T: Clone + Zero + Copy,
fn to_ortho_inplace<S1, S2, D>(
&self,
indata: &ArrayBase<S1, D>,
outdata: &mut ArrayBase<S2, D>,
axis: usize
) where
S1: Data<Elem = T>,
S2: Data<Elem = T> + DataMut,
D: Dimension,
T: Clone,
T: Clone + Zero + Copy,
Composite coefficients -> Orthogonal coefficients
sourcefn from_ortho<S, D>(&self, indata: &ArrayBase<S, D>, axis: usize) -> Array<T, D> where
S: Data<Elem = T>,
D: Dimension,
fn from_ortho<S, D>(&self, indata: &ArrayBase<S, D>, axis: usize) -> Array<T, D> where
S: Data<Elem = T>,
D: Dimension,
Composite coefficients -> Orthogonal coefficients
sourcefn from_ortho_inplace<S1, S2, D>(
&self,
indata: &ArrayBase<S1, D>,
outdata: &mut ArrayBase<S2, D>,
axis: usize
) where
S1: Data<Elem = T>,
S2: Data<Elem = T> + DataMut,
D: Dimension,
T: Clone,
T: Clone + Zero + Copy,
fn from_ortho_inplace<S1, S2, D>(
&self,
indata: &ArrayBase<S1, D>,
outdata: &mut ArrayBase<S2, D>,
axis: usize
) where
S1: Data<Elem = T>,
S2: Data<Elem = T> + DataMut,
D: Dimension,
T: Clone,
T: Clone + Zero + Copy,
Composite coefficients -> Orthogonal coefficients
sourcefn to_ortho_par<S, D>(
&self,
indata: &ArrayBase<S, D>,
axis: usize
) -> Array<T, D> where
S: Data<Elem = T>,
D: Dimension,
Self: Sync,
T: Send + Sync,
fn to_ortho_par<S, D>(
&self,
indata: &ArrayBase<S, D>,
axis: usize
) -> Array<T, D> where
S: Data<Elem = T>,
D: Dimension,
Self: Sync,
T: Send + Sync,
Composite coefficients -> Orthogonal coefficients (Parallel)
sourcefn to_ortho_inplace_par<S1, S2, D>(
&self,
indata: &ArrayBase<S1, D>,
outdata: &mut ArrayBase<S2, D>,
axis: usize
) where
S1: Data<Elem = T>,
S2: Data<Elem = T> + DataMut,
D: Dimension,
T: Clone + Send + Sync,
T: Clone + Zero + Copy + Send + Sync,
Self: Sync,
fn to_ortho_inplace_par<S1, S2, D>(
&self,
indata: &ArrayBase<S1, D>,
outdata: &mut ArrayBase<S2, D>,
axis: usize
) where
S1: Data<Elem = T>,
S2: Data<Elem = T> + DataMut,
D: Dimension,
T: Clone + Send + Sync,
T: Clone + Zero + Copy + Send + Sync,
Self: Sync,
Composite coefficients -> Orthogonal coefficients (Parallel)
sourcefn from_ortho_par<S, D>(
&self,
indata: &ArrayBase<S, D>,
axis: usize
) -> Array<T, D> where
S: Data<Elem = T>,
D: Dimension,
Self: Sync,
T: Send + Sync,
fn from_ortho_par<S, D>(
&self,
indata: &ArrayBase<S, D>,
axis: usize
) -> Array<T, D> where
S: Data<Elem = T>,
D: Dimension,
Self: Sync,
T: Send + Sync,
Composite coefficients -> Orthogonal coefficients (Parallel)
sourcefn from_ortho_inplace_par<S1, S2, D>(
&self,
indata: &ArrayBase<S1, D>,
outdata: &mut ArrayBase<S2, D>,
axis: usize
) where
S1: Data<Elem = T>,
S2: Data<Elem = T> + DataMut,
D: Dimension,
T: Clone + Send + Sync,
T: Clone + Zero + Copy + Send + Sync,
Self: Sync,
fn from_ortho_inplace_par<S1, S2, D>(
&self,
indata: &ArrayBase<S1, D>,
outdata: &mut ArrayBase<S2, D>,
axis: usize
) where
S1: Data<Elem = T>,
S2: Data<Elem = T> + DataMut,
D: Dimension,
T: Clone + Send + Sync,
T: Clone + Zero + Copy + Send + Sync,
Self: Sync,
Composite coefficients -> Orthogonal coefficients (Parallel)
sourceimpl<A, T> BaseGradient<T> for FourierC2c<A> where
A: FloatNum,
T: ScalarNum + Add<Complex<A>, Output = T> + Mul<Complex<A>, Output = T> + Div<Complex<A>, Output = T> + Sub<Complex<A>, Output = T>,
impl<A, T> BaseGradient<T> for FourierC2c<A> where
A: FloatNum,
T: ScalarNum + Add<Complex<A>, Output = T> + Mul<Complex<A>, Output = T> + Div<Complex<A>, Output = T> + Sub<Complex<A>, Output = T>,
sourcefn gradient_slice(&self, indata: &[T], outdata: &mut [T], n_times: usize)
fn gradient_slice(&self, indata: &[T], outdata: &mut [T], n_times: usize)
Differentiate along slice
use funspace::traits::BaseGradient;
use funspace::fourier::FourierC2c;
use funspace::utils::approx_eq_complex;
use num_complex::Complex;
use num_traits::Zero;
let fo = FourierC2c::<f64>::new(5);
let mut k = FourierC2c::<f64>::wavenumber(5);
let expected: Vec<Complex<f64>> = k.iter().map(|x| x.powi(2)).collect();
let mut outdata = vec![Complex::<f64>::zero(); 5];
fo.gradient_slice(&k, &mut outdata, 1);
approx_eq_complex(&outdata, &expected);
Panics
When type conversion fails ( safe )
sourcefn gradient<S, D>(
&self,
indata: &ArrayBase<S, D>,
n_times: usize,
axis: usize
) -> Array<T, D> where
S: Data<Elem = T>,
D: Dimension,
fn gradient<S, D>(
&self,
indata: &ArrayBase<S, D>,
n_times: usize,
axis: usize
) -> Array<T, D> where
S: Data<Elem = T>,
D: Dimension,
Differentiate in spectral space
sourcefn gradient_inplace<S1, S2, D>(
&self,
indata: &ArrayBase<S1, D>,
outdata: &mut ArrayBase<S2, D>,
n_times: usize,
axis: usize
) where
S1: Data<Elem = T>,
S2: Data<Elem = T> + DataMut,
D: Dimension,
fn gradient_inplace<S1, S2, D>(
&self,
indata: &ArrayBase<S1, D>,
outdata: &mut ArrayBase<S2, D>,
n_times: usize,
axis: usize
) where
S1: Data<Elem = T>,
S2: Data<Elem = T> + DataMut,
D: Dimension,
Differentiate in spectral space
sourceimpl<A: FloatNum> BaseMatOpDiffmat for FourierC2c<A>
impl<A: FloatNum> BaseMatOpDiffmat for FourierC2c<A>
sourcefn diffmat(&self, deriv: usize) -> Array2<Self::NumType>
fn diffmat(&self, deriv: usize) -> Array2<Self::NumType>
Explicit differential operator $ D $
Matrix-based version of BaseGradient::gradient()
Panics
Type conversion fails
sourcefn diffmat_pinv(
&self,
deriv: usize
) -> (Array2<Self::NumType>, Array2<Self::NumType>)
fn diffmat_pinv(
&self,
deriv: usize
) -> (Array2<Self::NumType>, Array2<Self::NumType>)
Explicit inverse of differential operator $ D^* $
Returns (D_pinv, I_pinv)
, where D_pinv
is the pseudoinverse
and I_pinv
the corresponding pseudoidentity matrix, such
that
D_pinv @ D = I_pinv
Can be used as a preconditioner.
sourceimpl<A: FloatNum> BaseMatOpLaplacian for FourierC2c<A>
impl<A: FloatNum> BaseMatOpLaplacian for FourierC2c<A>
type NumType = A
type NumType = A
Scalar type of laplacian matrix
sourceimpl<A: FloatNum> BaseMatOpStencil for FourierC2c<A>
impl<A: FloatNum> BaseMatOpStencil for FourierC2c<A>
sourceimpl<A: FloatNum> BaseSize for FourierC2c<A>
impl<A: FloatNum> BaseSize for FourierC2c<A>
sourceimpl<A: FloatNum> BaseTransform for FourierC2c<A>
impl<A: FloatNum> BaseTransform for FourierC2c<A>
sourcefn forward_slice(
&self,
indata: &[Self::Physical],
outdata: &mut [Self::Spectral]
)
fn forward_slice(
&self,
indata: &[Self::Physical],
outdata: &mut [Self::Spectral]
)
Example
Forward transform
use funspace::traits::BaseTransform;
use funspace::fourier::FourierC2c;
use funspace::utils::approx_eq_complex;
use num_complex::Complex;
use num_traits::Zero;
let mut fo = FourierC2c::<f64>::new(4);
let indata = vec![
Complex::new(1., 1.),
Complex::new(2., 2.),
Complex::new(3., 3.),
Complex::new(4., 4.)
];
let expected = vec![
Complex::new(10., 10.),
Complex::new(-4., 0.),
Complex::new(-2., -2.),
Complex::new(0., -4.)
];
let mut outdata = vec![Complex::<f64>::zero(); 4];
fo.forward_slice(&indata, &mut outdata);
approx_eq_complex(&outdata, &expected);
sourcefn backward_slice(
&self,
indata: &[Self::Spectral],
outdata: &mut [Self::Physical]
)
fn backward_slice(
&self,
indata: &[Self::Spectral],
outdata: &mut [Self::Physical]
)
Example
Backward transform
use funspace::traits::BaseTransform;
use funspace::fourier::FourierC2c;
use funspace::utils::approx_eq_complex;
use num_complex::Complex;
use num_traits::Zero;
let mut fo = FourierC2c::<f64>::new(4);
let indata = vec![
Complex::new(10., 10.),
Complex::new(-4., 0.),
Complex::new(-2., -2.),
Complex::new(0., -4.)
];
let expected = vec![
Complex::new(1., 1.),
Complex::new(2., 2.),
Complex::new(3., 3.),
Complex::new(4., 4.)
];
let mut outdata = vec![Complex::<f64>::zero(); 4];
fo.backward_slice(&indata, &mut outdata);
approx_eq_complex(&outdata, &expected);
sourcefn forward<S, D>(
&self,
indata: &ArrayBase<S, D>,
axis: usize
) -> Array<Self::Spectral, D> where
S: Data<Elem = Self::Physical>,
D: Dimension,
Self::Physical: Clone,
Self::Spectral: Zero + Clone + Copy,
fn forward<S, D>(
&self,
indata: &ArrayBase<S, D>,
axis: usize
) -> Array<Self::Spectral, D> where
S: Data<Elem = Self::Physical>,
D: Dimension,
Self::Physical: Clone,
Self::Spectral: Zero + Clone + Copy,
Physical values -> Spectral coefficients
sourcefn forward_inplace<S1, S2, D>(
&self,
indata: &ArrayBase<S1, D>,
outdata: &mut ArrayBase<S2, D>,
axis: usize
) where
S1: Data<Elem = Self::Physical>,
S2: Data<Elem = Self::Spectral> + DataMut,
D: Dimension,
Self::Physical: Clone,
Self::Spectral: Clone + Zero + Copy,
fn forward_inplace<S1, S2, D>(
&self,
indata: &ArrayBase<S1, D>,
outdata: &mut ArrayBase<S2, D>,
axis: usize
) where
S1: Data<Elem = Self::Physical>,
S2: Data<Elem = Self::Spectral> + DataMut,
D: Dimension,
Self::Physical: Clone,
Self::Spectral: Clone + Zero + Copy,
Physical values -> Spectral coefficients
sourcefn backward<S, D>(
&self,
indata: &ArrayBase<S, D>,
axis: usize
) -> Array<Self::Physical, D> where
S: Data<Elem = Self::Spectral>,
D: Dimension,
Self::Spectral: Clone,
Self::Physical: Zero + Clone + Copy,
fn backward<S, D>(
&self,
indata: &ArrayBase<S, D>,
axis: usize
) -> Array<Self::Physical, D> where
S: Data<Elem = Self::Spectral>,
D: Dimension,
Self::Spectral: Clone,
Self::Physical: Zero + Clone + Copy,
Spectral coefficients -> Physical values
sourcefn backward_inplace<S1, S2, D>(
&self,
indata: &ArrayBase<S1, D>,
outdata: &mut ArrayBase<S2, D>,
axis: usize
) where
S1: Data<Elem = Self::Spectral>,
S2: Data<Elem = Self::Physical> + DataMut,
D: Dimension,
Self::Spectral: Clone,
Self::Physical: Clone + Zero + Copy,
fn backward_inplace<S1, S2, D>(
&self,
indata: &ArrayBase<S1, D>,
outdata: &mut ArrayBase<S2, D>,
axis: usize
) where
S1: Data<Elem = Self::Spectral>,
S2: Data<Elem = Self::Physical> + DataMut,
D: Dimension,
Self::Spectral: Clone,
Self::Physical: Clone + Zero + Copy,
Spectral coefficients -> Physical values
sourcefn forward_par<S, D>(
&self,
indata: &ArrayBase<S, D>,
axis: usize
) -> Array<Self::Spectral, D> where
S: Data<Elem = Self::Physical>,
D: Dimension,
Self::Physical: Clone + Send + Sync,
Self::Spectral: Zero + Clone + Copy + Send + Sync,
Self: Sync,
fn forward_par<S, D>(
&self,
indata: &ArrayBase<S, D>,
axis: usize
) -> Array<Self::Spectral, D> where
S: Data<Elem = Self::Physical>,
D: Dimension,
Self::Physical: Clone + Send + Sync,
Self::Spectral: Zero + Clone + Copy + Send + Sync,
Self: Sync,
Physical values -> Spectral coefficients (Parallel)
sourcefn forward_inplace_par<S1, S2, D>(
&self,
indata: &ArrayBase<S1, D>,
outdata: &mut ArrayBase<S2, D>,
axis: usize
) where
S1: Data<Elem = Self::Physical>,
S2: Data<Elem = Self::Spectral> + DataMut,
D: Dimension,
Self::Physical: Clone + Send + Sync,
Self::Spectral: Clone + Zero + Copy + Send + Sync,
Self: Sync,
fn forward_inplace_par<S1, S2, D>(
&self,
indata: &ArrayBase<S1, D>,
outdata: &mut ArrayBase<S2, D>,
axis: usize
) where
S1: Data<Elem = Self::Physical>,
S2: Data<Elem = Self::Spectral> + DataMut,
D: Dimension,
Self::Physical: Clone + Send + Sync,
Self::Spectral: Clone + Zero + Copy + Send + Sync,
Self: Sync,
Physical values -> Spectral coefficients (Parallel)
sourcefn backward_par<S, D>(
&self,
indata: &ArrayBase<S, D>,
axis: usize
) -> Array<Self::Physical, D> where
S: Data<Elem = Self::Spectral>,
D: Dimension,
Self::Spectral: Clone + Send + Sync,
Self::Physical: Zero + Clone + Copy + Send + Sync,
Self: Sync,
fn backward_par<S, D>(
&self,
indata: &ArrayBase<S, D>,
axis: usize
) -> Array<Self::Physical, D> where
S: Data<Elem = Self::Spectral>,
D: Dimension,
Self::Spectral: Clone + Send + Sync,
Self::Physical: Zero + Clone + Copy + Send + Sync,
Self: Sync,
Spectral coefficients -> Physical values (Parallel)
sourcefn backward_inplace_par<S1, S2, D>(
&self,
indata: &ArrayBase<S1, D>,
outdata: &mut ArrayBase<S2, D>,
axis: usize
) where
S1: Data<Elem = Self::Spectral>,
S2: Data<Elem = Self::Physical> + DataMut,
D: Dimension,
Self::Spectral: Clone + Send + Sync,
Self::Physical: Clone + Zero + Copy + Send + Sync,
Self: Sync,
fn backward_inplace_par<S1, S2, D>(
&self,
indata: &ArrayBase<S1, D>,
outdata: &mut ArrayBase<S2, D>,
axis: usize
) where
S1: Data<Elem = Self::Spectral>,
S2: Data<Elem = Self::Physical> + DataMut,
D: Dimension,
Self::Spectral: Clone + Send + Sync,
Self::Physical: Clone + Zero + Copy + Send + Sync,
Self: Sync,
Spectral coefficients -> Physical values (Parallel)
sourceimpl<A: Clone> Clone for FourierC2c<A>
impl<A: Clone> Clone for FourierC2c<A>
sourcefn clone(&self) -> FourierC2c<A>
fn clone(&self) -> FourierC2c<A>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl<A> !RefUnwindSafe for FourierC2c<A>
impl<A> Send for FourierC2c<A>
impl<A> Sync for FourierC2c<A>
impl<A> Unpin for FourierC2c<A>
impl<A> !UnwindSafe for FourierC2c<A>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more