46 static_cast<index_type>(std::numeric_limits<digit_type>::max());
125 const auto next_digits =
digits(
dim) + 1;
126 if (next_digits >=
data_.cols()) {
130 data_ = std::move(new_data);
147 const auto right_digits =
149 const auto min_digits = std::min(left_digits, right_digits);
151 if (
data_(i, j + 1) != right.data_(i, j + 1)) {
155 for (
index_type j = min_digits; j < left_digits; ++j) {
160 for (
index_type j = min_digits; j < right_digits; ++j) {
161 if (right.data_(i, j + 1) !=
static_cast<digit_type>(0)) {
186 template <
typename Scalar>
190 auto num =
static_cast<Scalar
>(0);
191 auto coeff =
static_cast<Scalar
>(1);
192 static const Scalar inv_base =
193 static_cast<Scalar
>(1) /
static_cast<Scalar
>(3);
195 num += coeff *
static_cast<Scalar
>(
data_(
dim, i + 1));
245 std::size_t temp = 0;
248 if (vec(i, j) != 0) {
249 non_zero_digits = j + 1;
253 constexpr std::size_t coeff = 3;
255 temp +=
static_cast<std::size_t
>(
256 static_cast<std::uint8_t
>(vec(i, j)));
258 constexpr std::size_t coeff = 79865413;
Definition of assertion macros.
#define NUM_COLLECT_ASSERT(CONDITION)
Macro to check whether a condition is satisfied.
#define NUM_COLLECT_DEBUG_ASSERT(CONDITION)
Macro to check whether a condition is satisfied in debug build only.
Class of vectors of ternary floating-point numbers.
void change_dim(index_type dim)
Change the number of dimensions.
auto digits(index_type dim) const -> index_type
Get the number of digits of a dimension.
auto elem_as(index_type dim) const -> Scalar
Get the element of this vector as a floating-point number.
static constexpr index_type init_digits_per_dimensions
Initial digits per dimensions.
auto operator()(index_type dim, index_type digit) -> digit_type &
Access a digit.
std::int8_t digit_type
Type of a digit.
data_type data_
Data matrix.
void push_back(index_type dim, digit_type digit)
Add a digit to a dimension.
auto operator!=(const ternary_vector &right) const -> bool
Compare with another object.
ternary_vector()=default
Constructor.
Eigen::Matrix< digit_type, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > data_type
Type of data matrix.
static constexpr index_type max_digits
Maximum number of digits per dimension.
auto operator==(const ternary_vector &right) const -> bool
Compare with another object.
auto dim() const -> index_type
Get the number of dimensions.
auto operator()(index_type dim, index_type digit) const -> digit_type
Access a digit.
ternary_vector(index_type dim)
Constructor.
std::size_t result_type
Type of result.
auto operator()(const argument_type &vec) const -> result_type
Calculate hash.
Definition of index_type type.
std::ptrdiff_t index_type
Type of indices in this library.
Namespace of internal implementations.
Namespace of num_collect source codes.