Dimension
- class trainsum.dimension.Dimension(size: int, /, idf: int | None = None)
- class trainsum.dimension.Dimension(bases: Sequence[int], /, idf: int | None = None)
A quantized dimension, represented as a sequence of digits. If a integer is provided during initialization, it will be factorized into its prime factors to create the digits. Otherwise, the provided sequence of integers will be used as the bases of the digits.
- Parameters:
size (int | Sequence[int])
idf (int)
- idf: int
The identifier of the dimension, shared by all digits in the dimension.
- size()
Calculate the size of the dimension, i.e., the product of the bases of all digits.
- Return type:
int
- to_idxs(digits)
Convert digit indices with shape (len(Dimension), …) to dimension indices with shape (…).
- Parameters:
digits (T)
- Return type:
T
- to_digits(idxs)
Convert dimension indices with shape (…) to digit indices with shape (len(Dimension), …).
- Parameters:
idxs (T)
- Return type:
T