Complex type of martices and vectors

Issue #99 resolved
Reza created an issue

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)

  1. Lisandro Dalcin

    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.

  2. Reza 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?

  3. Lisandro Dalcin

    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
    
  4. Reza 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?

  5. Lisandro Dalcin

    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 finally pip install petsc4py.

  6. Log in to comment