APyFixed
¶
-
class APyFixed¶
Public Functions
-
template<typename RANDOM_ACCESS_ITERATOR>
inline void copy_n_from(RANDOM_ACCESS_ITERATOR src_it, std::size_t n) noexcept¶ Copy
n
items fromit
into*this
-
template<typename RANDOM_ACCESS_ITERATOR>
inline void copy_n_to(RANDOM_ACCESS_ITERATOR dst_it, std::size_t n) const noexcept¶ Copy
n
items from*this
intoit
-
inline bool same_type_as(const APyFixed &other) const¶
Test if two fixed-point numbers have the same bit specifiers.
-
APyFixed() = delete¶
No default (empty) constructed
APyFixed
objects. At lesast the bit-specifiers has to be set during construction.
-
explicit APyFixed(const nb::int_ &python_long_int_bit_pattern, std::optional<int> int_bits = std::nullopt, std::optional<int> frac_bits = std::nullopt, std::optional<int> bits = std::nullopt)¶
Main Python-exposed
APyFixed
constructor.
-
explicit APyFixed(int bits, int int_bits)¶
Construct a zero-initialized number with
bits
andint_bits
. Undefined behaviour ifbits < 1
.
-
explicit APyFixed(std::optional<int> int_bits = std::nullopt, std::optional<int> frac_bits = std::nullopt, std::optional<int> bits = std::nullopt)¶
Construct a zero-initialized number from bit specification. Throws
nanobind::value_error
if not exactly two of three bit specifiers (bits
,int_bits
,frac_bits
) are set, or if the resulting number ofbits
is less than one.
-
template<typename _IT>
explicit APyFixed(int bits, int int_bits, _IT begin, _IT end)¶ Construct a number with
bits
andint_bits
, and initialize underlying bit-pattern from iterator pair [begin
,end
).
-
explicit APyFixed(int bits, int int_bits, const std::vector<apy_limb_t> &vec)¶
Construct a number with
bits
andint_bits
, and initialize underlying bit-pattern from limb-vectorvec
.
-
explicit APyFixed(int bits, int int_bits, std::initializer_list<apy_limb_t> list)¶
Construct a number with
bits
andint_bits
, and initialize underlying bit-pattern from initializer list.
-
explicit APyFixed(int bits, int int_bits, const ScratchVector<apy_limb_t> &data)¶
Construct a number with
bits
andint_bits
, and initialize underlying bit-pattern bit stealing it from aScratchVector
.
-
bool operator==(const nb::int_ &rhs) const¶
-
bool operator!=(const nb::int_ &rhs) const¶
-
bool operator<(const nb::int_ &rhs) const¶
-
bool operator<=(const nb::int_ &rhs) const¶
-
bool operator>(const nb::int_ &rhs) const¶
-
bool operator>=(const nb::int_ &rhs) const¶
-
bool operator==(const double rhs) const¶
-
bool operator!=(const double rhs) const¶
-
bool operator<=(const double rhs) const¶
-
bool operator<(const double rhs) const¶
-
bool operator>=(const double rhs) const¶
-
bool operator>(const double rhs) const¶
-
inline int bits() const noexcept¶
Return the
bits
specifier.
-
inline int int_bits() const noexcept¶
Return the
int_bits
specifier.
-
inline int frac_bits() const noexcept¶
Return the
frac_bits
specifier.
-
inline std::size_t vector_size() const noexcept¶
Return the number of elements in the underlying limb data vector.
-
bool is_negative() const noexcept¶
Test if fixed-point number is negative.
-
bool is_positive() const noexcept¶
Test if fixed-point number is positive.
-
bool is_zero() const noexcept¶
Test if fixed-point number is zero.
-
apy_limb_t increment_lsb() noexcept¶
Increment the LSB without making the fixed-point number wider. Return carry out.
-
nb::int_ to_bits() const¶
Convert the underlying bit pattern to a Python long integer.
-
std::string bit_pattern_to_string_dec() const¶
Convert the underlying bit pattern to decimal and return in a string.
-
std::string repr() const¶
Python verbose string representation.
-
std::string latex() const¶
LaTeX representation.
-
bool is_identical(const APyFixed &other) const¶
Test if two Fixed-point numbers are identical, i.e., has the same values, the same number of integer bits, and the same number of fractional bits
-
std::size_t leading_zeros() const¶
Return leading zeros.
-
std::size_t leading_ones() const¶
Return leading ones.
-
std::size_t leading_fractional_zeros() const¶
Return leading fractional zeros.
-
std::size_t leading_signs() const¶
Return leading signs.
-
bool positive_greater_than_equal_pow2(int n) const¶
Test if positive value is greater than equal to a integer power-of-two (>= 2 ^
n
)
-
inline uint64_t get_lsbs() const¶
Return the least significant 64-bits from the underlying limb-vector (convenience function used in
APyFloat
)
-
double to_double() const¶
Convert number to double.
-
std::string to_string(int base = 10) const¶
-
std::string to_string_hex() const¶
-
std::string to_string_oct() const¶
-
std::string to_string_dec() const¶
-
operator double() const¶
-
void set_from_string(const std::string &str, int base = 10)¶
-
void set_from_string_hex(const std::string &str)¶
-
void set_from_string_oct(const std::string &str)¶
-
void set_from_string_dec(const std::string &str)¶
-
APyFixed cast(std::optional<int> int_bits = std::nullopt, std::optional<int> frac_bits = std::nullopt, std::optional<QuantizationMode> quantization = std::nullopt, std::optional<OverflowMode> overflow = std::nullopt, std::optional<int> bits = std::nullopt) const¶
Publicly exposed cast method.
-
APyFixed cast_no_overflow(int bits, int int_bits, QuantizationMode quantization = QuantizationMode::TRN) const¶
Simplified cast methods for internal use when it is known that the result will not overflow
Public Static Functions
-
static APyFixed from_number(const nb::object &py_obj, std::optional<int> int_bits = std::nullopt, std::optional<int> frac_bits = std::nullopt, std::optional<int> bits = std::nullopt)¶
Create APyFixed from Python object.
-
static APyFixed from_double(double value, std::optional<int> int_bits = std::nullopt, std::optional<int> frac_bits = std::nullopt, std::optional<int> bits = std::nullopt)¶
Create APyFixed from double.
-
static APyFixed from_unspecified_double(double value)¶
Create APyFixed from double without specifying the format. The format will be big enough to accommodate the double.
-
static APyFixed from_integer(const nb::int_ &value, std::optional<int> int_bits = std::nullopt, std::optional<int> frac_bits = std::nullopt, std::optional<int> bits = std::nullopt)¶
Create APyFixed from Python integer.
-
static APyFixed from_unspecified_integer(const nb::int_ &value)¶
Create APyFixed from Python integer without specifying the format. The format will be big enough to accommodate the Python integer.
-
static APyFixed from_string(std::string string_value, std::optional<int> int_bits = std::nullopt, std::optional<int> frac_bits = std::nullopt, int base = 10, std::optional<int> bits = std::nullopt)¶
Create APyFixed from string.
-
static inline APyFixed get_max(int bits, int int_bits)¶
Retrieve an
APyFixed
ofbits
andint_bits
with the maximum value.
Friends
- friend class APyCFixed
- friend class APyFixedArray
- friend class APyCFixedArray
- friend class APyArray
-
template<typename RANDOM_ACCESS_ITERATOR>