Complex type of martices and vectors
I get the following error when I am trying to make a vector or matrix using complex arrays.
TypeError: Cannot cast array data from dtype('complex128') to dtype('float64') according to the rule 'safe'
Can the data types be set to complex?
Comments (6)
-
-
- changed status to resolved
-
reporter Thank you Lisandro. I installed petsc4py using conda ( conda install -c conda-forge petsc4py ) so that I can use it with Anaconda. Can I pass this configuration option in this method of installation?
-
No, no way, the conda package is a precompiled binary with real scalars, we do not have yet a variant supporting complex scalars. Maybe you can try this? Create a fresh conda environment with the python version you want then do this:
conda install -c conda-forge mpich mpi4py numpy export PETSC_CONFIGURE_OPTIONS="--with-scalar-type=complex" pip install petsc pip install petsc4py
-
reporter I followed the mentioned steps and received the following error after running pip install petsc:
Failed building wheel for petsc Running setup.py clean for petsc Failed to build petsc .... UNABLE to CONFIGURE with GIVEN OPTIONS .......
any idea if it can be fixed easily?
-
Well, at this point, I guess you should download latest PETSc tarball and build it by hand, next
export PETSC_DIR=/path/to/petsc PETSC_ARCH=your-arch-name
, and finallypip install petsc4py
. - Log in to comment
You need a PESTc build with complex scalars enabled (configure option
--with-scalar-type=complex
). Unfortunately, PETSc does not allow using real and complex vector and matrices in the same build.