44template <base::concepts::real_scalar_dense_vector VariableType,
48 static_assert(MaxDigits > 0,
"MaxDigits must be a positive integer.");
55 VariableType::RowsAtCompileTime;
59 VariableType::MaxRowsAtCompileTime;
167 "Tried to add a digit to a full adc_ternary_vector.");
191 return data_ == right.data_;
212 template <
typename Scalar>
215 auto num =
static_cast<Scalar
>(0);
216 auto coeff =
static_cast<Scalar
>(1);
217 static const Scalar inv_base =
218 static_cast<Scalar
>(1) /
static_cast<Scalar
>(3);
220 num += coeff *
static_cast<Scalar
>(
data_.coeff(
dim, i));
234 const VariableType& width)
const -> VariableType {
235 VariableType res(
dim());
237 res(i) = lower_bound(i) +
248 [[nodiscard]]
auto hash() const ->
std::
size_t {
252 res +=
static_cast<std::size_t
>(
data_.coeff(i, j)) +
253 (res << 1U) + (res >> 2U);
288 num_collect::opt::impl::adc_ternary_vector<VariableType, MaxDigits>> {
Definition of assertion macros.
#define NUM_COLLECT_DEBUG_ASSERT(CONDITION)
Macro to check whether a condition is satisfied in debug build only.
Class of exception on not satisfying a precondition.
Class of vectors of ternary floating-point numbers in num_collect::opt::adaptive_diagonal_curves.
auto is_full() const -> bool
Check whether this vector is full.
auto elem_as(index_type dim) const -> Scalar
Get the element of this vector as a floating-point number.
auto operator()(index_type dim, index_type digit) const -> digit_type
Access a digit.
static constexpr index_type max_dimensions_at_compile_time
Eigen::Matrix< digit_type, dimensions_at_compile_time, MaxDigits, Eigen::RowMajor, max_dimensions_at_compile_time, MaxDigits > data_type
index_type current_max_digits_
auto digits(index_type dim) const -> index_type
Get the number of digits in a dimension.
adc_ternary_vector(index_type dim)
Constructor.
auto next_divided_dimension_index() const -> index_type
Get the next dimension index to add a digit.
auto dim() const -> index_type
static constexpr index_type dimensions_at_compile_time
auto as_variable(const VariableType &lower_bound, const VariableType &width) const -> VariableType
Convert this vector to a variable.
static constexpr index_type max_digits_at_compile_time
auto operator!=(const adc_ternary_vector &right) const -> bool
Compare with another object.
auto operator==(const adc_ternary_vector &right) const -> bool
Compare with another object.
auto hash() const -> std::size_t
Calculate the hash of this vector.
index_type next_divided_dimension_index_
auto current_max_digits() const -> index_type
Get the current maximum number of digits.
auto push_back(digit_type digit) -> std::pair< index_type, index_type >
Add a digit to a dimension specified by next_divided_dimension_index().
adc_ternary_vector()=default
Constructor.
auto operator()(index_type dim, index_type digit) -> digit_type &
Access a digit.
std::size_t result_type
Type of result.
num_collect::opt::impl::adc_ternary_vector< VariableType, MaxDigits > argument_type
Type of argument.
auto operator()(const argument_type &vec) const -> result_type
Calculate hash.
Concept of Eigen's dense vectors with real scalars.
Definition of exceptions.
Definition of index_type type.
Definition of macros for logging.
#define NUM_COLLECT_LOG_AND_THROW(EXCEPTION_TYPE,...)
Write an error log and throw an exception for an error.
std::ptrdiff_t index_type
Type of indices in this library.
Namespace of internal implementations.
Namespace of num_collect source codes.
Definition of real_scalar_dense_vector concept.