polylane 0.3.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/>.

#![cfg(feature = "std")]

mod seal {
	pub trait StdFloat { }
}

pub(crate) use seal::StdFloat as SealedStdFloat;

/// `std` maths.
pub trait StdFloat: Sized + SealedStdFloat {
	/// Performs fused multiply-add on the vector elements.
	#[must_use]
	fn mul_add(self, a: Self, b: Self) -> Self;

	/// Computes the square roots for the elements of `self`.
	#[must_use]
	fn sqrt(self) -> Self;

	/// Computes the cube roots for the elements of `self`.
	#[must_use]
	fn cbrt(self) -> Self;

	/// Computes the sines for the elements of `self`.
	#[must_use]
	fn sin(self) -> Self;

	/// Computes the cosines for the elements of `self`.
	#[must_use]
	fn cos(self) -> Self;

	/// Computes the tangents for the elements of `self`.
	#[must_use]
	fn tan(self) -> Self;

	/// Computes the arc sines for the elements of `self`.
	#[must_use]
	fn asin(self) -> Self;

	/// Computes the arc cosines for the elements of `self`.
	#[must_use]
	fn acos(self) -> Self;

	/// Computes the arc tangents for the elements of `self` via the unary function.
	#[must_use]
	fn atan(self) -> Self;

	/// Computes the arc tangents for the elements of `self` via the binary function.
	#[must_use]
	fn atan2(self, a: Self, b: Self) -> Self;

	/// Computes the hyperbolic sines for the elements of `self`.
	#[must_use]
	fn sinh(self) -> Self;

	/// Computes the hyperbolic cosines for the elements of `self`.
	#[must_use]
	fn cosh(self) -> Self;

	/// Computes the hyperbolic tangents for the elements of `self`.
	#[must_use]
	fn tanh(self) -> Self;

	/// Computes the arc hyperbolic sines for the elements of `self`.
	#[must_use]
	fn asinh(self) -> Self;

	/// Computes the arc hyperbolic cosines for the elements of `self`.
	#[must_use]
	fn acosh(self) -> Self;

	/// Computes the arc hyperbolic tangents for the elements of `self`.
	#[must_use]
	fn atanh(self) -> Self;

	/// Computes the exponential function for the elements of `self`.
	#[must_use]
	fn exp(self) -> Self;

	/// Computes the power with the base (2) for the elements of `self`.
	#[must_use]
	fn exp2(self) -> Self;

	/// Computes the logarithm with base `base` for the elements of `self`.
	#[must_use]
	fn log(self, base: Self) -> Self;

	/// Computes the natural logarithm (with base (*e*)) for the elements of `self`.
	#[must_use]
	fn ln(self) -> Self;

	/// Computes the binary logarithm (with base (2)) for the elements of `self`.
	#[must_use]
	fn log2(self) -> Self;

	/// Computes the common logarithm (with base (10)) for the elements of `self`.
	#[must_use]
	fn log10(self) -> Self;

	/// Rounds the elements of `self` to the nearest integer
	#[must_use]
	fn round(self) -> Self;

	/// Removes the integral parts of the elements of `self`.
	#[must_use]
	fn fract(self) -> Self;

	/// Rounds the elements of `self` up to the nearest integer.
	#[must_use]
	fn ceil(self) -> Self;

	/// Rounds the elements of `self` down to the nearest integer towards.
	#[must_use]
	fn floor(self) -> Self;

	/// Rounds the elements of `self` to the nearest integer closest to (0).
	#[must_use]
	fn trunc(self) -> Self;
}