ComplexCoeffs¶
- class zixy.container.coeffs.ComplexCoeffs(data=None, indexer=slice(None, None, None))[source]¶
Bases:
NumericalCoeffs[complex]A collection of
complex.A resizable vector-like container of coefficients that may be an owning instance referencing a contiguous Rust-bound data object, or a view on a slice of the elements in another collection.
- __getitem__(indexer: int | slice) CoeffT | Self¶
- Overloads:
self, indexer (int) → CoeffT
self, indexer (builtins.slice) → Self
Get the element or elements selected by
indexer.- Parameters:
indexer – Index or slice selecting the coefficient(s) to return.
- Returns:
Coefficient or slice selected by
indexer.
- __imul__(rhs: int | float | complex | Sign | ComplexSign | Expr | Iterable[int | float | complex | Sign | ComplexSign | Expr]) Self¶
Multiply
selfbyrhsin-place.- Raises:
ValueError – If the result of the multiplication cannot be represented by the type of
self.
- __init__(data=None, indexer=slice(None, None, None))¶
Initialize the coefficient vector.
- Parameters:
data – Rust-bound object storing a vector of coefficients. If
None, an empty vector of the appropriate type is initialized.indexer – Slice over which the data is to be viewed.
- __setitem__(indexer: int | slice, source: CoeffT | Coeffs[CoeffT] | None = None) None¶
Set the indexed element(s) to the given value(s).
- Parameters:
indexer – Index or slice of coefficient(s) within
selfto assign.source – Value(s) specifying the coefficient(s) to assign.
- allclose(other: Coeffs[Any], rtol: float = 1e-05, atol: float = 1e-08) bool¶
Check whether
selfandotherare within a certain tolerance.- Parameters:
other – Other instance to compare to.
rtol – Relative tolerance.
atol – Absolute tolerance.
- Returns:
Whether
selfandotherare within the given tolerances of each other.
Note
This method operates by comparing the NumPy arrays returned by
np_array.
- any_significant(atol: float = 1e-08) bool¶
Check whether any element of
selfis significantly different from zero.- Parameters:
atol – The absolute tolerance to use.
- Returns:
Whether any element of
selfis significantly different from zero.
- append(value: CoeffT) None¶
Append
valueto the end ofself.- Parameters:
value – Value to append.
Note
This method operates in-place.
- append_n(n: int, value: CoeffT) None¶
Append
valueto the end ofselfntimes.- Parameters:
n – Number of times to repeatedly append
value.value – Value to append.
Note
This method operates in-place.
- as_view() Self¶
Return a view of
self.- Returns:
If
selfis owning, a new view on the same underlying data, otherwiseself.
- coeffs_type¶
alias of
ComplexVec
- count(value) integer -- return number of occurrences of value¶
- extend(other: Self) None¶
Append the elements of
otherto the end ofself.- Parameters:
other – Other instance whose elements are appended to
self.
Note
This method operates in-place.
- fill(coeff: CoeffT) None¶
Set all the coefficients in the vector to the given value.
- Parameters:
coeff – Coefficient value to which to set all coefficients in the vector.
- classmethod from_scalar(coeff: CoeffT, n: int = 1) Self¶
Get a new instance of
clswith the given scalar repeatedntimes.- Parameters:
coeff – Coefficient value.
n – Number of times to repeat
coeff.
- Returns:
New instance with
coeffrepeatedntimes.
- classmethod from_sequence(source: Sequence[NumberT] | NDArray[inexact]) Self¶
Get a new instance from a sequence of coefficients.
- Parameters:
source – Sequence of coefficients.
- Returns:
New instance with elements set according to
source.
- classmethod from_size(n: int) Self¶
Create a new instance of
clswith the given size.- Parameters:
n – The size of the new instance.
- Returns:
An instance of
clswith the given size.
- classmethod from_view(source: Self) Self¶
Create a new instance of
clsfrom a view.- Parameters:
source – View to clone into the new instance.
- Returns:
An owning clone of
source.
- property imag_part: RealCoeffs¶
Get the imaginary part of
selfas a new instance ofRealCoeffs.
- into(t: type[OutT]) OutT¶
Clone
selfinto a new related container of typet.- Parameters:
t – Type of the new container to create.
- Returns:
A new instance of
tcontaining the same data asself.
- map_index(index: int) int¶
Map an index in
selfto an index in the underlying data.- Parameters:
index – Index in
self.- Returns:
Corresponding index in the underlying data.
- property np_array: NDArray[complex128]¶
Get the contents of
selfcopied as a flat NumPy array.- Returns:
NumPy array containing all elements of
self.
- classmethod parse(source: str) Self¶
Construct an instance of
clsfrom a string representation.- Parameters:
source – The string to read from.
- Returns:
An instance of
clsrepresented bysource.
- property real_part: RealCoeffs¶
Get the real part of
selfas a new instance ofRealCoeffs.
- reordered(inds: Sequence[int]) Self¶
Get a new instance with the elements of
selfin a new order.- Parameters:
inds – Sequence of indices defining the new order. Should be a permutation of
range(len(self)).- Returns:
A new instance with the reordered elements.
- resize(n: int) Self¶
Resize the underlying container.
- Parameters:
n – The new size of the container.
Note
This method operates in-place.
- Raises:
ValueError – If the container is a view.
- scale(scalar: int | float | complex | Sign | ComplexSign | Expr) None¶
Scale all elements by a given factor.
- Parameters:
scalar – Scalar factor by which to scale all elements.
Note
This method operates in-place.
- set(source: Iterable[CoeffT]) None¶
Assign the viewed coefficients according to the values yielded by the given iterable.
- Parameters:
source – Iterable containing the values to be assigned to the viewed coefficients of
self.