Janus 2.0.0
High-performance C++20 dual-mode numerical framework
Loading...
Searching...
No Matches
Arithmetic.hpp File Reference

Scalar and element-wise arithmetic functions (abs, sqrt, pow, exp, log, etc.). More...

#include "janus/core/JanusConcepts.hpp"
#include <Eigen/Dense>
#include <cmath>
Include dependency graph for Arithmetic.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  janus

Functions

template<JanusScalar T>
janus::abs (const T &x)
 Computes the absolute value of a scalar.
template<typename Derived>
auto janus::abs (const Eigen::MatrixBase< Derived > &x)
 Computes absolute value element-wise for a matrix.
template<JanusScalar T>
janus::sqrt (const T &x)
 Computes the square root of a scalar.
template<typename Derived>
auto janus::sqrt (const Eigen::MatrixBase< Derived > &x)
 Computes square root element-wise for a matrix.
template<JanusScalar T>
janus::pow (const T &base, const T &exponent)
 Computes the power function: base^exponent.
template<JanusScalar T>
requires (!std::is_same_v<T, double>)
janus::pow (const T &base, double exponent)
 Computes power function base^exponent for scalars (mixed types).
template<JanusScalar T>
requires (!std::is_same_v<T, double>)
janus::pow (double base, const T &exponent)
 Computes power function base^exponent for scalars (mixed types: double base).
template<typename Derived, typename Scalar>
auto janus::pow (const Eigen::MatrixBase< Derived > &base, const Scalar &exponent)
 Computes power function element-wise for a matrix.
template<JanusScalar T>
janus::exp (const T &x)
 Computes the exponential function e^x.
template<typename Derived>
auto janus::exp (const Eigen::MatrixBase< Derived > &x)
 Computes exponential function element-wise for a matrix.
template<JanusScalar T>
janus::log (const T &x)
 Computes the natural logarithm of x.
template<typename Derived>
auto janus::log (const Eigen::MatrixBase< Derived > &x)
 Computes natural logarithm element-wise for a matrix.
template<JanusScalar T>
janus::log10 (const T &x)
 Computes the base-10 logarithm of x.
template<typename Derived>
auto janus::log10 (const Eigen::MatrixBase< Derived > &x)
 Computes base-10 logarithm element-wise for a matrix.
template<JanusScalar T>
janus::sinh (const T &x)
 Computes hyperbolic sine.
template<typename Derived>
auto janus::sinh (const Eigen::MatrixBase< Derived > &x)
 Computes hyperbolic sine element-wise for a matrix.
template<JanusScalar T>
janus::cosh (const T &x)
 Computes hyperbolic cosine of x.
template<typename Derived>
auto janus::cosh (const Eigen::MatrixBase< Derived > &x)
 Computes hyperbolic cosine element-wise for a matrix.
template<JanusScalar T>
janus::tanh (const T &x)
 Computes hyperbolic tangent of x.
template<typename Derived>
auto janus::tanh (const Eigen::MatrixBase< Derived > &x)
 Computes hyperbolic tangent element-wise for a matrix.
template<JanusScalar T>
janus::floor (const T &x)
 Computes floor of x.
template<typename Derived>
auto janus::floor (const Eigen::MatrixBase< Derived > &x)
 Computes floor element-wise for a matrix.
template<JanusScalar T>
janus::ceil (const T &x)
 Computes ceiling of x.
template<typename Derived>
auto janus::ceil (const Eigen::MatrixBase< Derived > &x)
 Computes ceiling element-wise for a matrix.
template<JanusScalar T>
janus::sign (const T &x)
 Computes sign of x.
template<typename Derived>
auto janus::sign (const Eigen::MatrixBase< Derived > &x)
 Computes sign element-wise for a matrix.
template<JanusScalar T>
janus::fmod (const T &x, const T &y)
 Computes floating-point remainder of x/y.
template<typename Derived, typename Scalar>
auto janus::fmod (const Eigen::MatrixBase< Derived > &x, const Scalar &y)
 Computes floating-point remainder element-wise for a matrix.
template<JanusScalar T>
janus::log2 (const T &x)
 Computes base-2 logarithm of x.
template<typename Derived>
auto janus::log2 (const Eigen::MatrixBase< Derived > &x)
 Computes base-2 logarithm element-wise for a matrix.
template<JanusScalar T>
janus::exp2 (const T &x)
 Computes 2^x.
template<typename Derived>
auto janus::exp2 (const Eigen::MatrixBase< Derived > &x)
 Computes 2^x element-wise for a matrix.
template<JanusScalar T>
janus::cbrt (const T &x)
 Computes cube root of x.
template<typename Derived>
auto janus::cbrt (const Eigen::MatrixBase< Derived > &x)
 Computes cube root element-wise for a matrix.
template<JanusScalar T>
janus::round (const T &x)
 Rounds x to the nearest integer.
template<typename Derived>
auto janus::round (const Eigen::MatrixBase< Derived > &x)
 Rounds element-wise for a matrix.
template<JanusScalar T>
janus::trunc (const T &x)
 Truncates x toward zero.
template<typename Derived>
auto janus::trunc (const Eigen::MatrixBase< Derived > &x)
 Truncates element-wise for a matrix.
template<JanusScalar T>
janus::hypot (const T &x, const T &y)
 Computes sqrt(x^2 + y^2) without undue overflow/underflow.
template<JanusScalar T>
requires (!std::is_same_v<T, double>)
janus::hypot (const T &x, double y)
 Computes hypot(x, y) with mixed types.
template<JanusScalar T>
requires (!std::is_same_v<T, double>)
janus::hypot (double x, const T &y)
 Computes hypot(x, y) with mixed types (double first).
template<typename Derived>
auto janus::hypot (const Eigen::MatrixBase< Derived > &x, const Eigen::MatrixBase< Derived > &y)
 Computes hypot element-wise for matrices.
template<JanusScalar T>
janus::expm1 (const T &x)
 Computes exp(x) - 1, accurate for small x.
template<typename Derived>
auto janus::expm1 (const Eigen::MatrixBase< Derived > &x)
 Computes expm1 element-wise for a matrix.
template<JanusScalar T>
janus::log1p (const T &x)
 Computes log(1 + x), accurate for small x.
template<typename Derived>
auto janus::log1p (const Eigen::MatrixBase< Derived > &x)
 Computes log1p element-wise for a matrix.
template<JanusScalar T>
janus::copysign (const T &x, const T &y)
 Returns magnitude of x with sign of y.
template<JanusScalar T>
requires (!std::is_same_v<T, double>)
janus::copysign (const T &x, double y)
 Copysign with mixed types.
template<JanusScalar T>
requires (!std::is_same_v<T, double>)
janus::copysign (double x, const T &y)
 Copysign with mixed types (double magnitude).
template<typename Derived>
auto janus::copysign (const Eigen::MatrixBase< Derived > &x, const Eigen::MatrixBase< Derived > &y)
 Copysign element-wise for matrices.
template<JanusScalar T>
janus::square (const T &x)
 Computes x^2 (more efficient than pow(x, 2)).
template<typename Derived>
auto janus::square (const Eigen::MatrixBase< Derived > &x)
 Computes square element-wise for a matrix.

Detailed Description

Scalar and element-wise arithmetic functions (abs, sqrt, pow, exp, log, etc.).

See also
Trig.hpp, Logic.hpp