pub trait NumKernel: RawKernel + Sized {
type RealPolicy: ValidationPolicyReal<Value = Self::RawReal, Error = <Self::RawReal as RawScalarTrait>::ValidationErrors>;
type ComplexPolicy: ValidationPolicyComplex<Value = Self::RawComplex, Error = <Self::RawComplex as RawScalarTrait>::ValidationErrors>;
type Real: RealScalar<RawReal = Self::RawReal>;
type Complex: ComplexScalar<RealType = Self::Real>;
const PRECISION: u32;
}
Expand description
Defines a complete numerical kernel, acting as the central configuration point.
This trait is the primary bound for generic functions that need to operate across different numerical backends. It bundles together:
- The raw underlying types (e.g.,
f64
) via theRawKernel
supertrait. - The specific validation logic for those types.
- The precision of the kernel in bits.
- The final, high-level
Real
andComplex
validated types.
Required Associated Constants§
Required Associated Types§
Sourcetype RealPolicy: ValidationPolicyReal<Value = Self::RawReal, Error = <Self::RawReal as RawScalarTrait>::ValidationErrors>
type RealPolicy: ValidationPolicyReal<Value = Self::RawReal, Error = <Self::RawReal as RawScalarTrait>::ValidationErrors>
The validation policy for real numbers.
§Note
The bound on ValidationPolicyReal::Error
is a critical architectural choice. It enforces that the
error type defined by a policy (RealPolicy::Error
) MUST be the same as the
canonical validation error type associated with its value (RealPolicy::Value::ValidationErrors
).
This prevents mismatches and simplifies error handling throughout the library.
Sourcetype ComplexPolicy: ValidationPolicyComplex<Value = Self::RawComplex, Error = <Self::RawComplex as RawScalarTrait>::ValidationErrors>
type ComplexPolicy: ValidationPolicyComplex<Value = Self::RawComplex, Error = <Self::RawComplex as RawScalarTrait>::ValidationErrors>
The validation policy for complex numbers.
§Note
The bound on ValidationPolicyComplex::Error
is a critical architectural choice. It enforces that the
error type defined by a policy (ComplexPolicy::Error
) MUST be the same as the
canonical validation error type associated with its value (ComplexPolicy::Value::ValidationErrors
).
This prevents mismatches and simplifies error handling throughout the library.
Sourcetype Real: RealScalar<RawReal = Self::RawReal>
type Real: RealScalar<RawReal = Self::RawReal>
The final, high-level, validated real scalar type for this kernel.
This is typically an alias for RealValidated<Self>
.
Sourcetype Complex: ComplexScalar<RealType = Self::Real>
type Complex: ComplexScalar<RealType = Self::Real>
The final, high-level, validated complex scalar type for this kernel.
This is typically an alias for ComplexValidated<Self>
.
The RealType = Self::Real
bound ensures the complex type is composed of the
corresponding validated real type from the same kernel.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.