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

Conditional selection, comparison, and logical operations. More...

#include "janus/core/JanusConcepts.hpp"
#include "janus/core/JanusError.hpp"
#include "janus/core/JanusTypes.hpp"
#include "janus/math/Arithmetic.hpp"
#include <Eigen/Dense>
#include <algorithm>
#include <type_traits>
#include <utility>
Include dependency graph for Logic.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  janus::BooleanType< T >
struct  janus::BooleanType< SymbolicScalar >

Namespaces

namespace  janus
namespace  janus::detail
 Smooth approximation of ReLU function: softplus(x) = (1/beta) * log(1 + exp(beta * x)).

Typedefs

template<typename T>
using janus::BooleanType_t = typename BooleanType<T>::type

Functions

template<typename Cond, JanusScalar T1, JanusScalar T2>
auto janus::where (const Cond &cond, const T1 &if_true, const T2 &if_false)
 Select values based on condition (ternary operator) Returns: cond ? if_true : if_false Supports mixed types.
template<typename Cond, typename DerivedTrue, typename DerivedFalse>
auto janus::detail::select (const Cond &cond, const Eigen::MatrixBase< DerivedTrue > &if_true, const Eigen::MatrixBase< DerivedFalse > &if_false)
bool janus::detail::is_symbolic_predicate (const SymbolicScalar &expr)
SymbolicScalar janus::detail::as_symbolic_predicate (const SymbolicScalar &expr)
template<typename Derived>
SymbolicScalar janus::detail::count_symbolic_truthy (const Eigen::MatrixBase< Derived > &a)
template<typename DerivedCond, typename DerivedTrue, typename DerivedFalse>
auto janus::where (const Eigen::ArrayBase< DerivedCond > &cond, const Eigen::MatrixBase< DerivedTrue > &if_true, const Eigen::MatrixBase< DerivedFalse > &if_false)
 Element-wise select.
template<JanusScalar T1, JanusScalar T2>
auto janus::min (const T1 &a, const T2 &b)
 Computes minimum of two values.
template<typename Derived>
auto janus::min (const Eigen::MatrixBase< Derived > &a, const Eigen::MatrixBase< Derived > &b)
 Computes minimum element-wise for a matrix/vector.
template<JanusScalar T1, JanusScalar T2>
auto janus::max (const T1 &a, const T2 &b)
 Computes maximum of two values.
template<typename Derived>
auto janus::max (const Eigen::MatrixBase< Derived > &a, const Eigen::MatrixBase< Derived > &b)
 Computes maximum element-wise for a matrix/vector.
template<JanusScalar T, JanusScalar TLow, JanusScalar THigh>
auto janus::clamp (const T &val, const TLow &low, const THigh &high)
 Clamps value between low and high.
template<typename Derived, typename Scalar>
auto janus::clamp (const Eigen::MatrixBase< Derived > &val, const Scalar &low, const Scalar &high)
 Clamps values element-wise for a matrix/vector.
template<typename DerivedA, typename DerivedB>
auto janus::lt (const Eigen::MatrixBase< DerivedA > &a, const Eigen::MatrixBase< DerivedB > &b)
 Element-wise less than comparison.
template<typename DerivedA, typename DerivedB>
auto janus::gt (const Eigen::MatrixBase< DerivedA > &a, const Eigen::MatrixBase< DerivedB > &b)
 Element-wise greater than comparison.
template<typename DerivedA, typename DerivedB>
auto janus::le (const Eigen::MatrixBase< DerivedA > &a, const Eigen::MatrixBase< DerivedB > &b)
 Element-wise less than or equal comparison.
template<typename DerivedA, typename DerivedB>
auto janus::ge (const Eigen::MatrixBase< DerivedA > &a, const Eigen::MatrixBase< DerivedB > &b)
 Element-wise greater than or equal comparison.
template<typename DerivedA, typename DerivedB>
auto janus::eq (const Eigen::MatrixBase< DerivedA > &a, const Eigen::MatrixBase< DerivedB > &b)
 Element-wise equality comparison.
template<typename DerivedA, typename DerivedB>
auto janus::neq (const Eigen::MatrixBase< DerivedA > &a, const Eigen::MatrixBase< DerivedB > &b)
 Element-wise inequality comparison.
template<JanusScalar T, JanusScalar TLow, JanusScalar THigh, JanusScalar Sharpness = double>
auto janus::sigmoid_blend (const T &x, const TLow &val_low, const THigh &val_high, const Sharpness &sharpness=1.0)
 Smoothly blends between val_low and val_high using a sigmoid function blend = val_low + (val_high - val_low) * (1 / (1 + exp(-sharpness * x))).
template<typename Derived, typename Scalar>
auto janus::sigmoid_blend (const Eigen::MatrixBase< Derived > &x, const Scalar &val_low, const Scalar &val_high, const Scalar &sharpness=1.0)
 Smoothly blends element-wise for a matrix using a sigmoid function.
template<JanusScalar T1, JanusScalar T2>
auto janus::logical_and (const T1 &x1, const T2 &x2)
 Logical AND (x && y).
template<typename DerivedA, typename DerivedB>
auto janus::logical_and (const Eigen::MatrixBase< DerivedA > &a, const Eigen::MatrixBase< DerivedB > &b)
 Element-wise logical AND for matrices.
template<JanusScalar T1, JanusScalar T2>
auto janus::logical_or (const T1 &x1, const T2 &x2)
 Logical OR (x || y).
template<typename DerivedA, typename DerivedB>
auto janus::logical_or (const Eigen::MatrixBase< DerivedA > &a, const Eigen::MatrixBase< DerivedB > &b)
 Element-wise logical OR for matrices.
template<JanusScalar T>
auto janus::logical_not (const T &x)
 Logical NOT (!x).
template<typename Derived>
auto janus::logical_not (const Eigen::MatrixBase< Derived > &a)
 Element-wise logical NOT for a matrix.
template<typename Derived>
auto janus::all (const Eigen::MatrixBase< Derived > &a)
 Returns true if all elements are true (non-zero).
template<typename Derived>
auto janus::any (const Eigen::MatrixBase< Derived > &a)
 Returns true if any element is true (non-zero).
template<typename CondType, typename Scalar>
Scalar janus::select (const std::vector< CondType > &conditions, const std::vector< Scalar > &values, const Scalar &default_value)
 Multi-way conditional selection (cleaner alternative to nested where).
template<typename CondType, typename Scalar>
Scalar janus::select (std::initializer_list< CondType > conditions, std::initializer_list< Scalar > values, const Scalar &default_value)

Detailed Description

Conditional selection, comparison, and logical operations.

See also
Arithmetic.hpp