Module cosmic::cosmic_theme::palette::num

source ·
Expand description

Traits for abstracting over numeric types.

These traits describe various numeric properties and operations. They are similar in purpose to the immensely helpful traits in num-traits, but the structure is different. The philosophy behind this module is to focus on capabilities, rather than categories, and to assume as little as possible. Within reason.

Instead of having large traits with a lot of methods and dependencies, each operation (or group of operations), are separated into their own traits. This allows number types to have partial compatibility by only implementing some of the traits, and new methods can be added as new traits without affecting old functionality.

Traits§

  • Method for getting the absolute value of a number.
  • A helper trait that collects arithmetic traits under one name.
  • Method for getting the cube root of a number.
  • Trait for clamping a value.
  • Assigning trait for clamping a value.
  • Methods for calculating e ^ x,
  • Trait for creating a vectorized value from a scalar value.
  • Conversion from an array of scalars to a vectorized value.
  • Methods for calculating the lengths of a hypotenuse.
  • Conversion from a vectorized value to an array of scalars.
  • Methods for checking if a number can be used as a divisor.
  • Trait for getting the natural logarithm of self.
  • Methods for getting the largest or smallest of two values.
  • Combined multiplication and addition operation.
  • Combined multiplication and subtraction operation.
  • Methods for the value 1.
  • Trait for lanewise comparison of two values.
  • Method for raising a number by a real number exponent.
  • Method for raising a number by a signed integer exponent.
  • Method for raising a number by a n unsigned integer exponent.
  • Numbers that belong to the real number set. It’s both a semantic marker and provides a constructor for number constants.
  • Method for calculating 1 / x.
  • Methods for rounding numbers to integers.
  • Saturating addition operation.
  • Saturating subtraction operation.
  • Trait for getting a number that represents the sign of self.
  • Method for getting the square root of a number.
  • Trigonometry methods and their inverses.
  • Methods for the value 0.