APyFixedArray

class APyFixedArray : public APyArray<apy_limb_t, APyFixedArray>

Public Functions

inline APyFixed create_scalar() const
inline APyFixedArray create_array(const std::vector<std::size_t> &shape) const
inline bool same_type_as(const APyFixedArray &other) const noexcept

Test if two fixed-point vectors have the same bit specifiers.

inline bool same_type_as(const APyFixed &other) const noexcept

Test if *this has the same bit specifiers as another APyFixed

APyFixedArray() = delete

No default (empty) constructed APyFixedArray objects. At lesast the bit-specifiers and shape has to be set during construction.

explicit APyFixedArray(const nb::sequence &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
APyFixedArray operator-() const

Elementwise unary negation.

APyFixedArray 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 convolve(const APyFixedArray &other, const std::string &mode) const

Perform a linear convolution with other using mode

std::variant<APyFixedArray, APyFixed> sum(std::optional<std::variant<nb::tuple, nb::int_>> 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(std::optional<std::variant<nb::tuple, nb::int_>> 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(std::optional<std::variant<nb::tuple, nb::int_>> axis = std::nullopt) const

Return the maximum of an array or the maximum along an axis.

std::variant<APyFixedArray, APyFixed> min(std::optional<std::variant<nb::tuple, nb::int_>> 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) const

Create a nested Python list containing bit-patterns as Python integers.

nb::ndarray<nb::numpy, double> to_numpy() const

Convert to a NumPy array.

APyFixedArray abs() const

Elementwise absolute value.

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 APyFixedArray tensor object with the same shape and 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.

Public Static Functions

static inline APyFixedArray create_array_static(const std::vector<std::size_t> &shape, const APyFixed &fix)
static APyFixedArray from_numbers(const nb::sequence &number_seq, std::optional<int> int_bits = std::nullopt, std::optional<int> frac_bits = std::nullopt, std::optional<int> bits = std::nullopt)

Create an APyFixedArray tensor 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 APyFixedArray tensor object initialized with values from an ndarray.

static APyFixedArray zeros(const nb::tuple &shape, std::optional<int> int_bits = std::nullopt, std::optional<int> frac_bits = std::nullopt, std::optional<int> bits = std::nullopt)

Create an APyFixedArray initialized with zeros.

static APyFixedArray ones(const nb::tuple &shape, std::optional<int> int_bits = std::nullopt, std::optional<int> frac_bits = std::nullopt, std::optional<int> bits = std::nullopt)

Create an APyFixedArray initialized 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 APyFixedArray with 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 APyFixedArray with 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 APyFixedArray with evenly spaced 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)