<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi Jose,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
While I am running </div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:monospace"><span style="color: rgb(51, 51, 51); background-color: rgb(255, 255, 255); font-size: 10pt;">from petsc4py import PETSc
</span><br>
</span><span style="font-family: monospace; font-size: 10pt; color: rgb(51, 51, 51);">>>> print(PETSc.ScalarType) </span><span style="font-family:monospace"><br>
</span><span style="font-family: monospace; font-size: 10pt; color: rgb(51, 51, 51);"><class 'numpy.float64'></span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: monospace; font-size: 10pt; color: rgb(51, 51, 51);">only float64 I am getting not complex128.</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:monospace"><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family: monospace; font-size: 10pt; color: rgb(51, 51, 51);">Do I have to uninstall and then install it? Otherwise doing</span><span style="font-family:monospace"> <span style="color:rgb(32, 31, 30);font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:14.6667px;background-color:rgb(255, 255, 255);display:inline !important">F.setScale(-1j*t)
I am getting an error</span></span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:monospace"><span style="color:rgb(32, 31, 30);font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:14.6667px;background-color:rgb(255, 255, 255);display:inline !important">File
"SLEPc/FN.pyx", line 204, in slepc4py.SLEPc.FN.setScale
<div> File "SLEPc/SLEPc.pyx", line 115, in slepc4py.SLEPc.asScalar</div>
<span>TypeError: can't convert complex to float</span><br>
</span></span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:monospace"><span style="color:rgb(32, 31, 30);font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:14.6667px;background-color:rgb(255, 255, 255);display:inline !important"><span><br>
</span></span></span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:monospace"><span style="color:rgb(32, 31, 30);font-family:"Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;font-size:14.6667px;background-color:rgb(255, 255, 255);display:inline !important"><span>Sanku</span></span></span></div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Jose E. Roman <jroman@dsic.upv.es><br>
<b>Sent:</b> Saturday, September 4, 2021 5:33 AM<br>
<b>To:</b> Paul, Sanku <paulsank@msu.edu><br>
<b>Cc:</b> PETSc <petsc-users@mcs.anl.gov><br>
<b>Subject:</b> Re: [petsc-users] Matrix exponential</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">No problem, do<br>
F.setScale(-1j*t)<br>
<br>
What do you mean "still facing problem with complex matrices"? Did you get an error during installation? Did it install for real scalars? Try setting PETSC_CONFIGURE_OPTIONS only, and unset PETSC_DIR PETSC_ARCH. Otherwise pip may not take into account --with-scalar-type=complex<br>
<br>
Jose<br>
<br>
<br>
> El 4 sept 2021, a las 2:11, Paul, Sanku <paulsank@msu.edu> escribió:<br>
> <br>
> Hi Jose,<br>
> <br>
> I tried to install<br>
> ml -* foss/2019b Python SciPy-bundle/2019.10-Python-3.7.4<br>
> virtualenv slepc4py<br>
> cd slepc4py<br>
> source bin/activate<br>
> pip install numpy mpi4py cython<br>
> export PETSC_CONFIGURE_OPTIONS="--with-scalar-type=complex"<br>
> export PETSC_DIR=/path/to/petsc PETSC_ARCH=your-arch-name<br>
> pip install petsc petsc4py<br>
> pip install slepc slepc4py<br>
> <br>
> But still facing problem with complex matrices. Please help me to fix this.<br>
> <br>
> Thanks,<br>
> Sanku<br>
> <br>
> <br>
> From: Paul, Sanku <paulsank@msu.edu><br>
> Sent: Friday, September 3, 2021 7:39 PM<br>
> To: Jose E. Roman <jroman@dsic.upv.es><br>
> Cc: PETSc <petsc-users@mcs.anl.gov><br>
> Subject: Re: [petsc-users] Matrix exponential<br>
> <br>
> Hi Jose,<br>
> <br>
> I could now do matrix exponential but facing a problem with a complex matrix. In particular, I want to do \exp(-itH), where H is a Hamiltonian. How to implement this?<br>
> <br>
> Thanks,<br>
> Sanku<br>
> From: Jose E. Roman <jroman@dsic.upv.es><br>
> Sent: Friday, September 3, 2021 2:53 PM<br>
> To: Paul, Sanku <paulsank@msu.edu><br>
> Cc: PETSc <petsc-users@mcs.anl.gov><br>
> Subject: Re: [petsc-users] Matrix exponential<br>
> <br>
> Please always reply to the list (Reply-All), not to myself.<br>
> <br>
> You should be able to convert from a scipy sparse matrix to a PETSc matrix via PETSc.Mat().createAIJWithArrays(). Don't know how if there is any example in the petsc4py documentation.<br>
> <br>
> Jose<br>
> <br>
> <br>
> > El 3 sept 2021, a las 20:26, Paul, Sanku <paulsank@msu.edu> escribió:<br>
> > <br>
> > Dear Jose,<br>
> > <br>
> > Thank you very much for your help. I have another question can we just simply pass a sparse.csr.matrix to A. For instance, if B is the sparse.csr.matrix can we do A=B.copy(). Or do I have to do it in a different way?<br>
> > <br>
> > Best,<br>
> > Sanku<br>
> > From: Jose E. Roman <jroman@dsic.upv.es><br>
> > Sent: Friday, September 3, 2021 2:13 PM<br>
> > To: Paul, Sanku <paulsank@msu.edu><br>
> > Cc: petsc-users@mcs.anl.gov <petsc-users@mcs.anl.gov><br>
> > Subject: Re: [petsc-users] Matrix exponential<br>
> > <br>
> > You should either create the FN object and then<br>
> > <br>
> > E.setFN(F)<br>
> > <br>
> > or extract the FN object and assign to a variable<br>
> > <br>
> > F = E.getFN()<br>
> > <br>
> > You can see an example in $SLEPC_DIR/src/binding/slepc4py/demo/ex6.py<br>
> > <br>
> > <br>
> > Jose<br>
> > <br>
> > <br>
> > > El 3 sept 2021, a las 19:53, Paul, Sanku <paulsank@msu.edu> escribió:<br>
> > > <br>
> > > Dear Sir/Ma'am,<br>
> > > <br>
> > > I am trying to use SLEPc to calculate matrix exponential in my python code but I am not getting the correct result. I have attached the code. Could you let me know what I am doing wrong. This is my first time using SLEPc. So, I would like to ask you
if you could send me a tutorial on matrix exponential using SLEPc in python code.<br>
> > > <br>
> > > Best,<br>
> > > Sanku<br>
> > > <ex2.py><br>
<br>
</div>
</span></font></div>
</body>
</html>