Working with other array libraries
By default FFTArray uses NumPy which is great for compatibility with other libraries and available everywhere.
However, in order to achieve higher performance or get access to specific features it can be helpful to use another array library.
FTArray is built upon the Python Array API Standard to enable this use case.
All Array creation functions try to infer the array library from their inputs if possible and also have an optional xp argument.
The xp argument accepts a namespace like numpy or jax.numpy and automatically wraps it with the array-api-compat library to make it compatible to the Python Array API standard.
Default array library
If a function cannot determine via its arguments which array library to use it falls back to NumPy.
This default fallback can be changed via the methods in Setting defaults.
Sharp bits
Array conversion between libraries
The Array API standard only defines limited rules about converting arrays from one array library to another.
The values method has an otpional xp argument which converts the values into another Array API namespace.
This is always done via NumPy and only supports explicitly supported libraries.
See values for more details.
Binary operations with an array library scalar as the first and a fftarray.Array as the second operand
As of v2024.12 the Array API standard does not mandate that implementations return NotImplemented on binary operations.
Some array libraries do not return NotImplemented but raise an error on binary operations with an array library scalar as the first and an fftarray.Array as the second operand.
In this case FFTArray never gets the chance to implement the binary operation and this does not work.
Since NumPy and JAX both return NotImplemented in these cases this works with these two libraries.