pub struct Kernel {
pub base: ArrayD<f64>,
pub normalized: ArrayD<f64>,
pub shifted: ArrayD<f64>,
pub transformed: ArrayD<Complex<f64>>,
}Expand description
N-dimensional kernel.
The Kernel struct holds the data of a specific kernel to be used for convolution in
the Lenia simulation. It also implements the necessary conversions to normalize a
kernel and prepare it for convolution using fast-fourier-transform.
Fields§
§base: ArrayD<f64>The original ndarray::ArrayD<f64> fom which the Kernel got made from
normalized: ArrayD<f64>The scaled down version of the base Kernel such that the sum of all the values of the kernel is 1.0
shifted: ArrayD<f64>Normalized kernel with its center shifted to the “top-right” corner and
then re-sized to match the size of the Lenia instance channels
transformed: ArrayD<Complex<f64>>Fourier-transformed kernel
Implementations§
Source§impl Kernel
impl Kernel
Sourcepub fn from(kernel: ArrayD<f64>, channel_shape: &[usize]) -> Self
pub fn from(kernel: ArrayD<f64>, channel_shape: &[usize]) -> Self
Creates a new Kernel struct from an n-dimensional array (ndarray::ArrayD<f64>).
Creates the normalized version of the kernel.
Creates a version of the kernel that has been transformed using discrete-fourier-transform, and shifted, for future use in fast-fourier-transform based convolution.
§Parameters
-
kernel- Base data for the kernel. -
channel_shape- Shape of the channel the kernel is supposed to act on.
§Panics
-
If the number of axes of the
kernelandchannel_shapeare not equal. -
If any of the corresponding axis lengths in
kernelare greater than inchannel_shape.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Kernel
impl RefUnwindSafe for Kernel
impl Send for Kernel
impl Sync for Kernel
impl Unpin for Kernel
impl UnwindSafe for Kernel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more