38 T step = (end - start) /
static_cast<double>(n - 1);
40 for (
int i = 0; i < n; ++i) {
41 ret(i) = start +
static_cast<double>(i) * step;
68 T center = 0.5 * (start + end);
69 T radius = 0.5 * (end - start);
70 double pi = std::numbers::pi_v<double>;
72 for (
int i = 0; i < n; ++i) {
73 double angle = pi *
static_cast<double>(i) /
static_cast<double>(n - 1);
74 ret(i) = center - radius * std::cos(angle);
100 if (reverse_spacing) {
101 auto ret =
sinspace(end, start, n,
false);
102 return ret.reverse();
106 double pi_half = std::numbers::pi_v<double> / 2.0;
108 for (
int i = 0; i < n; ++i) {
110 double angle = pi_half *
static_cast<double>(i) /
static_cast<double>(n - 1);
111 double factor = 1.0 - std::cos(angle);
112 ret(i) = start + (end - start) * factor;
141 for (
int i = 0; i < n; ++i) {
142 double fraction =
static_cast<double>(i) /
static_cast<double>(n - 1);
143 T exponents = start + (end - start) * fraction;
165 return logspace(log_start, log_end, n);
Scalar and element-wise arithmetic functions (abs, sqrt, pow, exp, log, etc.).
C++20 concepts constraining valid Janus scalar types.
Custom exception hierarchy for Janus framework.
Core type aliases for numeric and symbolic Eigen/CasADi interop.
Trigonometric and inverse trigonometric functions.
Input validation failed (e.g., mismatched sizes, invalid parameters).
Definition JanusError.hpp:31
Definition Diagnostics.hpp:19
JanusVector< T > logspace(const T &start, const T &end, int n)
Generates logarithmically spaced vector (base 10).
Definition Spacing.hpp:129
T pow(const T &base, const T &exponent)
Computes the power function: base^exponent.
Definition Arithmetic.hpp:72
JanusVector< T > sinspace(const T &start, const T &end, int n, bool reverse_spacing=false)
Generates sine spaced vector (denser at start by default).
Definition Spacing.hpp:90
T log10(const T &x)
Computes the base-10 logarithm of x.
Definition Arithmetic.hpp:180
JanusVector< T > cosine_spacing(const T &start, const T &end, int n)
Generates cosine spaced vector (denser at ends).
Definition Spacing.hpp:57
JanusVector< T > linspace(const T &start, const T &end, int n)
Generates linearly spaced vector.
Definition Spacing.hpp:26
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > JanusVector
Dynamic-size column vector for both numeric and symbolic backends.
Definition JanusTypes.hpp:49
JanusVector< T > geomspace(const T &start, const T &end, int n)
Generates geometrically spaced vector.
Definition Spacing.hpp:159