APyFixedArray¶
-
class APyFixedArray : public APyArray<apy_limb_t, APyFixedArray>¶
Public Functions
-
inline APyFixedArray create_array(const std::vector<std::size_t> &shape) const¶
-
inline bool is_same_spec(const APyFixedArray &other) const noexcept¶
Test if two fixed-point vectors have the same bit specifiers.
-
inline bool is_same_spec(const APyFixed &other) const noexcept¶
Test if
*thishas the same bit specifiers as anotherAPyFixed
-
inline APyFixedSpec spec() const noexcept¶
Retrieve the bit specification.
-
inline bool is_mac_with_threadpool_justified(std::size_t n_mac) const noexcept¶
Test if using threadpool is justified based on number of multiply-accumulate.
-
APyFixedArray() = delete¶
No default (empty) constructed
APyFixedArrayobjects. At least the bit-specifiers and shape has to be set during construction.
-
explicit APyFixedArray(const nb::typed<nb::iterable, nb::any> &bit_pattern_sequence, std::optional<int> int_bits = std::nullopt, std::optional<int> frac_bits = std::nullopt, std::optional<int> bits = std::nullopt)¶
-
explicit APyFixedArray(const std::vector<std::size_t> &shape, int bits, int int_bits)¶
Constructor: specify only shape and word-length. Zero data on construction.
-
explicit APyFixedArray(const std::vector<std::size_t> &shape, int bits, int int_bits, vector_type &&v)¶
Constructor: specify shape and word-length and steal the data from vector.
-
explicit APyFixedArray(const std::vector<std::size_t> &shape, std::optional<int> int_bits = std::nullopt, std::optional<int> frac_bits = std::nullopt, std::optional<int> bits = std::nullopt)¶
Constructor: specify only shape and word-length. Zero data on construction.
-
APyFixedArray operator+(const APyFixedArray &rhs) const¶
-
APyFixedArray operator+(const APyFixed &rhs) const¶
-
APyFixedArray operator-(const APyFixedArray &rhs) const¶
-
APyFixedArray operator-(const APyFixed &rhs) const¶
-
APyFixedArray operator*(const APyFixedArray &rhs) const¶
-
APyFixedArray operator*(const APyFixed &rhs) const¶
-
APyFixedArray operator/(const APyFixedArray &rhs) const¶
-
APyFixedArray operator/(const APyFixed &rhs) const¶
-
APyFixedArray operator<<(const int shift_val) const¶
-
APyFixedArray operator>>(const int shift_val) const¶
-
APyFixedArray &operator<<=(const int shift_val)¶
-
APyFixedArray &operator>>=(const int shift_val)¶
-
APyFixedArray rsub(const APyFixed &rhs) const¶
-
APyFixedArray rdiv(const APyFixed &rhs) const¶
-
template<typename T>
ThirdPartyArray<bool> operator==(const T &rhs) const¶
-
template<typename T>
ThirdPartyArray<bool> operator!=(const T &rhs) const¶
-
template<typename T>
ThirdPartyArray<bool> operator<(const T &rhs) const¶
-
template<typename T>
ThirdPartyArray<bool> operator<=(const T &rhs) const¶
-
template<typename T>
ThirdPartyArray<bool> operator>(const T &rhs) const¶
-
template<typename T>
ThirdPartyArray<bool> operator>=(const T &rhs) const¶
-
APyFixedArray operator-() const¶
Elementwise unary negation.
-
inline APyFixedArray operator+() const¶
Elementwise unary positive.
-
APyFixedArray operator~() const¶
Elementwise logic not.
-
ThirdPartyArray<std::size_t> trailing_zeros() const¶
-
ThirdPartyArray<std::size_t> leading_zeros() const¶
-
ThirdPartyArray<std::size_t> leading_ones() const¶
-
ThirdPartyArray<std::size_t> leading_signs() const¶
-
ThirdPartyArray<bool> is_zero() const¶
-
std::variant<APyFixedArray, APyFixed> matmul(const APyFixedArray &rhs) const¶
Matrix multiplication. If both arguments ar 2-D tensors, this method performs the ordinary matrix multiplication. If input dimensions are greater than 2, this method performs stacked matrix multiplications, where the dimensions of last two dimensions are treated as matrices.
-
APyFixedArray outer_product(const APyFixedArray &rhs) const¶
Matrix outer product. Throws
nb::value_errorunless both*thisandrhsare 1-D.
-
APyFixedArray convolve(const APyFixedArray &other, const std::string &mode) const¶
Perform a linear convolution with
otherusingmode
-
std::variant<APyFixedArray, APyFixed> sum(const std::optional<PyShapeParam_t> &axis = std::nullopt) const¶
Sum over one or more axes.
-
APyFixedArray cumsum(std::optional<nb::int_> axis = std::nullopt) const¶
Cumulative sum over one or more axes.
-
std::variant<APyFixedArray, APyFixed> prod(const std::optional<PyShapeParam_t> &axis = std::nullopt) const¶
Multiplication over one or more axes.
-
APyFixedArray cumprod(std::optional<nb::int_> axis = std::nullopt) const¶
Cumulative multiplication over one or more axes.
-
std::variant<APyFixedArray, APyFixed> max(const std::optional<PyShapeParam_t> &axis = std::nullopt) const¶
Return the maximum of an array or the maximum along an axis.
-
std::variant<APyFixedArray, APyFixed> min(const std::optional<PyShapeParam_t> &axis = std::nullopt) const¶
Return the minimum of an array or the minimum along an axis.
-
std::string repr() const¶
Python
__repr__()function.
-
inline int bits() const noexcept¶
Number of bits.
-
inline int int_bits() const noexcept¶
Number of integer bits.
-
inline int frac_bits() const noexcept¶
Number of fractional bits.
-
std::variant<nb::list, nb::ndarray<nb::numpy, uint64_t>, nb::ndarray<nb::numpy, uint32_t>, nb::ndarray<nb::numpy, uint16_t>, nb::ndarray<nb::numpy, uint8_t>> to_bits(bool numpy = false) const¶
Extract bit-pattern.
-
template<typename NB_ARRAY_TYPE, typename INT_TYPE>
nb::ndarray<NB_ARRAY_TYPE, INT_TYPE> to_bits_ndarray() const¶ Create an N-dimensional array containing bit-patterns.
-
nb::list to_bits_python_recursive_descent(std::size_t dim, APyBuffer<apy_limb_t>::vector_type::const_iterator &it, bool vec_is_signed = false) const¶
Create a nested Python list containing bit-patterns as Python integers.
-
nb::list to_signed_bits() const¶
Extract bit-pattern as signed Python integers.
-
nanobind::ndarray<nanobind::numpy, double> to_numpy(std::optional<nb::object> dtype = std::nullopt, std::optional<bool> copy = std::nullopt) const¶
Convert to a NumPy array.
-
APyFixedArray abs() const¶
Elementwise absolute value.
-
APyFixedArray same_zeros() const¶
Create a new array with the same shape as
*this, but with all elements set to zero.
-
APyFixedArray 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¶
Construct a new
APyFixedArraytensor object with the sameshapeand fixed-point values as*this, but with a new word-length. The underlying bit-pattern of each tensor element are copied into place, meaning that lowering the number of fractional bits may result in quantization, and lowering the number of integer bits may result in overflowing. Supports quantization and overflow options on narrowing casts.
-
std::tuple<int, int, std::vector<std::size_t>, std::vector<std::uint64_t>> python_pickle() const¶
Python pickling.
-
std::string to_string(int base = 10) const¶
Retrieve a string of the stored values in this array.
-
std::string to_string_dec() const¶
Public Static Functions
-
static inline APyFixedArray create_array_static(const std::vector<std::size_t> &shape, const APyFixed &fix)¶
-
static void python_unpickle(APyFixedArray *apyfixedarray, const std::tuple<int, int, std::vector<std::size_t>, std::vector<std::uint64_t>> &state)¶
Python un-pickling.
-
static APyFixedArray from_numbers(const nb::typed<nb::iterable, nb::any> &number_seq, std::optional<int> int_bits = std::nullopt, std::optional<int> frac_bits = std::nullopt, std::optional<int> bits = std::nullopt)¶
Create an
APyFixedArraytensor object initialized with values from a sequence of Python objects
-
static APyFixedArray from_array(const nb::ndarray<nb::c_contig> &double_seq, std::optional<int> int_bits = std::nullopt, std::optional<int> frac_bits = std::nullopt, std::optional<int> bits = std::nullopt)¶
Create an
APyFixedArraytensor object initialized with values from an ndarray.
-
static APyFixedArray zeros(const PyShapeParam_t &shape, std::optional<int> int_bits = std::nullopt, std::optional<int> frac_bits = std::nullopt, std::optional<int> bits = std::nullopt)¶
Create an
APyFixedArrayinitialized with zeros.
-
static APyFixedArray ones(const PyShapeParam_t &shape, std::optional<int> int_bits = std::nullopt, std::optional<int> frac_bits = std::nullopt, std::optional<int> bits = std::nullopt)¶
Create an
APyFixedArrayinitialized with ones.
-
static APyFixedArray eye(const nb::int_ &N, std::optional<nb::int_> M = std::nullopt, std::optional<int> int_bits = std::nullopt, std::optional<int> frac_bits = std::nullopt, std::optional<int> bits = std::nullopt)¶
Create an
APyFixedArraywith ones on the diagonal and zeros elsewhere.
-
static APyFixedArray identity(const nb::int_ &N, std::optional<int> int_bits = std::nullopt, std::optional<int> frac_bits = std::nullopt, std::optional<int> bits = std::nullopt)¶
Create a square
APyFixedArraywith ones on the diagonal and zeros elsewhere.
-
static APyFixedArray arange(const nb::object &start, const nb::object &stop, const nb::object &step, std::optional<int> int_bits = std::nullopt, std::optional<int> frac_bits = std::nullopt, std::optional<int> bits = std::nullopt)¶
Create an
APyFixedArraywith evenly spaced values within a given interval.
-
static APyFixedArray fullrange(const nb::object &start, const nb::object &stop, std::optional<int> int_bits = std::nullopt, std::optional<int> frac_bits = std::nullopt, std::optional<int> bits = std::nullopt)¶
Create an
APyFixedArraywith all values within a given interval.
Public Static Attributes
-
static constexpr auto ARRAY_NAME = std::string_view("APyFixedArray")¶
Name of this array type (used when throwing errors)
-
inline APyFixedArray create_array(const std::vector<std::size_t> &shape) const¶