polylane 0.9.0

Portable and versatile SIMD.
Documentation
// Copyright 2025 Gabriel Bjørnager Jensen.
//
// This Source Code Form is subject to the terms of
// the Mozilla Public License, v. 2.0. If a copy of
// the MPL was not distributed with this file, you
// can obtain one at:
// <https://mozilla.org/MPL/2.0/>.

use crate::cmp::{SimdPartialEq, SimdPartialOrd};
use crate::num::SimdUint;
use crate::simd::SimdScalar;

use core::cmp::{PartialEq, PartialOrd};
use core::ops::{
	Add,
	AddAssign,
	Div,
	DivAssign,
	Mul,
	MulAssign,
	Neg,
	Rem,
	RemAssign,
	Sub,
	SubAssign,
};
use multitype::Float;

/// Denotes SIMD vector of floating-point scalars.
pub trait SimdFloat
where
	Self:
		crate::num::seal::SimdFloat
		+ Copy
		+ PartialEq
		+ PartialOrd
		+ SimdPartialEq
		+ SimdPartialOrd
		// Arithmetic operators:
		+ Add<Output = Self>
		+ Div<Output = Self>
		+ Mul<Output = Self>
		+ Neg<Output = Self>
		+ Rem<Output = Self>
		+ Sub<Output = Self>
		// Assigning arithmetic operators:
		+ AddAssign
		+ DivAssign
		+ MulAssign
		+ RemAssign
		+ SubAssign,
{
	/// The underlying, scalar type.
	type Scalar: SimdScalar + Float;

	/// The length of the vector type.
	const LEN: usize;

	/// A vector type of equivalently-wide, unsigned integers.
	type Bits: SimdUint;

	/// See <code>[f64]::[EPSILON](f64::EPSILON)</code>.
	const EPSILON:         Self;

	/// See <code>[f64]::[MIN](f64::MIN)</code>.
	const MIN:             Self;

	/// See <code>[f64]::[MIN_POSITIVE](f64::MIN_POSITIVE)</code>.
	const MIN_POSITIVE:    Self;

	/// See <code>[f64]::[MAX](f64::MAX)</code>.
	const MAX:             Self;

	/// See <code>[f64]::[INFINITY](f64::INFINITY)</code>.
	const INFINITY:        Self;

	/// See <code>[f64]::[NEG_INFINITY](f64::NEG_INFINITY)</code>.
	const NEG_INFINITY:    Self;

	/// See <code>[f64]::[NAN](f64::NAN)</code>.
	const NAN:             Self;

	/// See <code>[f64](core::f64)::[consts](core::f64::consts)::[E](core::f64::consts::E)</code>.
	const E:               Self;

	/// See <code>[f64](core::f64)::[consts](core::f64::consts)::[PI](core::f64::consts::PI)</code>.
	const PI:              Self;

	/// See <code>[f64](core::f64)::[consts](core::f64::consts)::[TAU](core::f64::consts::TAU)</code>.
	const TAU:             Self;

	/// See <code>[f64](core::f64)::[consts](core::f64::consts)::[LOG2_10](core::f64::consts::LOG2_10)</code>.
	const LOG2_10:         Self;

	/// See <code>[f64](core::f64)::[consts](core::f64::consts)::[LOG2_E](core::f64::consts::LOG2_E)</code>.
	const LOG2_E:          Self;

	/// See <code>[f64](core::f64)::[consts](core::f64::consts)::[LN_2](core::f64::consts::LN_2)</code>.
	const LN_2:            Self;

	/// See <code>[f64](core::f64)::[consts](core::f64::consts)::[LN_10](core::f64::consts::LN_10)</code>.
	const LN_10:           Self;

	/// See <code>[f64](core::f64)::[consts](core::f64::consts)::[LOG10_2](core::f64::consts::LOG10_2)</code>.
	const LOG10_2:         Self;

	/// See <code>[f64](core::f64)::[consts](core::f64::consts)::[LOG10_E](core::f64::consts::LOG10_E)</code>.
	const LOG10_E:         Self;

	/// See <code>[f64](core::f64)::[consts](core::f64::consts)::[SQRT_2](core::f64::consts::SQRT_2)</code>.
	const SQRT_2:          Self;

	/// See <code>[f64](core::f64)::[consts](core::f64::consts)::[FRAC_1_PI](core::f64::consts::FRAC_1_PI)</code>.
	const FRAC_1_PI:       Self;

	/// See <code>[f64](core::f64)::[consts](core::f64::consts)::[FRAC_1_SQRT_2](core::f64::consts::FRAC_1_SQRT_2)</code>.
	const FRAC_1_SQRT_2:   Self;

	/// See <code>[f64](core::f64)::[consts](core::f64::consts)::[FRAC_2_PI](core::f64::consts::FRAC_2_PI)</code>.
	const FRAC_2_PI:       Self;

	/// See <code>[f64](core::f64)::[consts](core::f64::consts)::[FRAC_2_SQRT_PI](core::f64::consts::FRAC_2_SQRT_PI)</code>.
	const FRAC_2_SQRT_PI:  Self;

	/// See <code>[f64](core::f64)::[consts](core::f64::consts)::[FRAC_PI_2](core::f64::consts::FRAC_PI_2)</code>.
	const FRAC_PI_2:       Self;

	/// See <code>[f64](core::f64)::[consts](core::f64::consts)::[FRAC_PI_3](core::f64::consts::FRAC_PI_3)</code>.
	const FRAC_PI_3:       Self;

	/// See <code>[f64](core::f64)::[consts](core::f64::consts)::[FRAC_PI_4](core::f64::consts::FRAC_PI_4)</code>.
	const FRAC_PI_4:       Self;

	/// See <code>[f64](core::f64)::[consts](core::f64::consts)::[FRAC_PI_6](core::f64::consts::FRAC_PI_6)</code>.
	const FRAC_PI_6:       Self;

	/// See <code>[f64](core::f64)::[consts](core::f64::consts)::[FRAC_PI_8](core::f64::consts::FRAC_PI_8)</code>.
	const FRAC_PI_8:       Self;

	/// See <code>[f64]::[from_bits](f64::from_bits)</code>.
	#[must_use]
	fn from_bits(bits: Self::Bits) -> Self;

	/// See <code>[f64]::[abs](f64::abs)</code>.
	#[must_use]
	fn abs(self) -> Self;

	/// See <code>[f64]::[recip](f64::recip)</code>.
	#[must_use]
	fn recip(self) -> Self;

	/// See <code>[f64]::[midpoint](f64::midpoint)</code>.
	#[must_use]
	fn midpoint(self, rhs: Self) -> Self;

	/// See <code>[f64]::[to_radians](f64::to_radians)</code>.
	#[must_use]
	fn to_radians(self) -> Self;

	/// See <code>[f64]::[to_degrees](f64::to_degrees)</code>.
	#[must_use]
	fn to_degrees(self) -> Self;

	/// See <code>[f64]::[next_down](f64::next_down)</code>.
	#[must_use]
	fn next_down(self) -> Self;

	/// See <code>[f64]::[next_up](f64::next_up)</code>.
	#[must_use]
	fn next_up(self) -> Self;

	/// See <code>[f64]::[signum](f64::signum)</code>.
	#[must_use]
	fn signum(self) -> Self;

	/// See <code>[f64]::[copysign](f64::copysign)</code>.
	#[must_use]
	fn copysign(self, sign: Self) -> Self;

	/// See <code>[f64]::[is_nan](f64::is_nan)</code>.
	#[must_use]
	fn is_nan(self) -> Self::Mask;

	/// See <code>[f64]::[is_infinite](f64::is_infinite)</code>.
	#[must_use]
	fn is_infinite(self) -> Self::Mask;

	/// See <code>[f64]::[is_finite](f64::is_finite)</code>.
	#[must_use]
	fn is_finite(self) -> Self::Mask;

	/// See <code>[f64]::[is_normal](f64::is_normal)</code>.
	#[must_use]
	fn is_normal(self) -> Self::Mask;

	/// See <code>[f64]::[is_subnormal](f64::is_subnormal)</code>.
	#[must_use]
	fn is_subnormal(self) -> Self::Mask;

	/// See <code>[f64]::[is_sign_negative](f64::is_sign_negative)</code>.
	#[must_use]
	fn is_sign_negative(self) -> Self::Mask;

	/// See <code>[f64]::[is_sign_positive](f64::is_sign_positive)</code>.
	#[must_use]
	fn is_sign_positive(self) -> Self::Mask;

	/// See <code>[f64]::[clamp](f64::clamp)</code>.
	#[must_use]
	fn clamp(self, min: Self, max: Self) -> Self;

	/// See <code>[f64]::[min](f64::min)</code>.
	#[must_use]
	fn min(self, rhs: Self) -> Self;

	/// See <code>[f64]::[max](f64::max)</code>.
	#[must_use]
	fn max(self, rhs: Self) -> Self;

	/// See <code>[f64]::[to_bits](f64::to_bits)</code>.
	#[must_use]
	fn to_bits(self) -> Self::Bits;
}