<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Matt<div class=""><br class=""></div><div class="">Yes, petsc4py does the right thing. This is probably. Picking up the wrong PETSc arch.</div><div class=""><br class=""></div><div class="">Peng, can you please run this?</div><div class=""><div class=""><br class=""></div><div class="">import petsc4py<br class=""><div>petsc4py.init()</div><div>print(petsc4py.get_config())</div><div><br class=""><blockquote type="cite" class=""><div class="">On Oct 13, 2022, at 11:23 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com" class="">knepley@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta charset="UTF-8" class=""><div dir="ltr" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class="">Lisandro,<div class=""><br class=""></div><div class="">PETSc is compiled for single. Does petsc4py respect this, or does it always use double for getArray() and friends?</div><div class=""><br class=""></div><div class=""> Thanks,</div><div class=""><br class=""></div><div class=""> Matt</div></div><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div class="gmail_quote" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><div dir="ltr" class="gmail_attr">On Thu, Oct 13, 2022 at 11:42 AM Peng Sun <<a href="mailto:psun@outlook.com" class="">psun@outlook.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class="msg-9108617864171965949"><div dir="ltr" class=""><div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">Hi Matt,</div><div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""><br class=""></div><div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">Sure, please see the attached configure.log file. Thanks!</div><div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""><br class=""></div><div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">Best regards,</div><div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class="">Peng Sun<br class=""></div><div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""><br class=""></div><div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""><br class=""></div><div id="m_-7847157880467528269appendonsend" class=""></div><hr style="display: inline-block; width: 965.015625px;" class=""><div id="m_-7847157880467528269divRplyFwdMsg" dir="ltr" class=""><font face="Calibri, sans-serif" style="font-size: 11pt;" class=""><b class="">From:</b><span class="Apple-converted-space"> </span>Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank" class="">knepley@gmail.com</a>><br class=""><b class="">Sent:</b><span class="Apple-converted-space"> </span>Thursday, October 13, 2022 6:34 AM<br class=""><b class="">To:</b><span class="Apple-converted-space"> </span>Peng Sun <<a href="mailto:psun@outlook.com" target="_blank" class="">psun@outlook.com</a>><br class=""><b class="">Cc:</b><span class="Apple-converted-space"> </span><a href="mailto:petsc-users@mcs.anl.gov" target="_blank" class="">petsc-users@mcs.anl.gov</a><span class="Apple-converted-space"> </span><<a href="mailto:petsc-users@mcs.anl.gov" target="_blank" class="">petsc-users@mcs.anl.gov</a>><br class=""><b class="">Subject:</b><span class="Apple-converted-space"> </span>Re: [petsc-users] Issue with single precision complex numbers in petsc4py</font><div class=""> </div></div><div class=""><div dir="ltr" class="">First send configure.log so we can see the setup.<div class=""><br class=""></div><div class=""> <span class="Apple-converted-space"> </span>Thanks,</div><div class=""><br class=""></div><div class=""> <span class="Apple-converted-space"> </span>Matt</div></div><br class=""><div class=""><div dir="ltr" class="">On Thu, Oct 13, 2022 at 12:53 AM Peng Sun <<a href="mailto:psun@outlook.com" target="_blank" class="">psun@outlook.com</a>> wrote:<br class=""></div><blockquote style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;" class=""><div class=""><div dir="ltr" class=""><div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;" class=""><p style="margin-right: 0in; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">Dear PETSc community,<u class=""></u> <u class=""></u></p><p style="margin-right: 0in; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><br class=""></p><p style="margin-right: 0in; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">I have a question regarding the single precision complex numbers of petsc4py.<span class=""> <span class="Apple-converted-space"> </span></span>I configured PETSc with the “--with-scalar-type=complex --with-precision=single" option before compiling, but all the DA structures I created with petsc4py had double precision. </p><p style="margin-right: 0in; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><br class=""></p><p style="margin-right: 0in; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">Here is a minimum test code on Python 3.8/PETSc 3.12/petsc4py 3.12: both print commands show data type of complex128. Could anybody please help me? Thanks!</p><p style="margin-right: 0in; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><br class=""></p><div style="margin: 0px 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><pre style="margin-top: 0px; width: auto; max-height: 600px; overflow: auto; text-align: left;" class=""><code style="margin: 0px;" class=""><span style="margin: 0px; font-size: 13px;" class="">import</span> petsc4py
<span style="margin: 0px; font-size: 13px;" class="">import</span> sys
petsc4py.init(sys.argv)
<span style="margin: 0px; font-size: 13px;" class="">from</span> petsc4py <span style="margin: 0px; font-size: 13px;" class="">import</span> PETSc
da=PETSc.DA().create(sizes=[<span style="margin: 0px; font-size: 13px;" class="">2</span>,<span style="margin: 0px; font-size: 13px;" class="">2</span>,<span style="margin: 0px; font-size: 13px;" class="">2</span>],dof=<span style="margin: 0px; font-size: 13px;" class="">1</span>,stencil_type=<span style="margin: 0px; font-size: 13px;" class="">0</span>,stencil_width=<span style="margin: 0px; font-size: 13px;" class="">1</span>,boundary_type=<span style="margin: 0px; font-size: 13px;" class="">1</span>)
da_1 = da.createGlobalVec()
<span style="margin: 0px; font-size: 13px;" class="">print</span>(petsc4py.PETSc.ComplexType)
<span style="margin: 0px; font-size: 13px;" class="">print</span>(da_1.getArray().dtype)</code></pre><br class=""></div><p style="margin-right: 0in; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><br class=""></p><p style="margin-right: 0in; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><br class=""></p><p style="margin-right: 0in; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">Best regards,</p><p style="margin-right: 0in; margin-left: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">Peng Sun</p></div></div></div></blockquote></div><br clear="all" class=""><div class=""><br class=""></div>--<span class="Apple-converted-space"> </span><br class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class="">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br class="">-- Norbert Wiener</div><div class=""><br class=""></div><div class=""><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank" class="">https://www.cse.buffalo.edu/~knepley/</a><br class=""></div></div></div></div></div></div></div></div></div></div></blockquote></div><br clear="all" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><br class=""></div><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class="">--<span class="Apple-converted-space"> </span></span><br style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div dir="ltr" class="gmail_signature" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class="">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br class="">-- Norbert Wiener</div><div class=""><br class=""></div><div class=""><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank" class="">https://www.cse.buffalo.edu/~knepley/</a></div></div></div></div></div></div></div></div></blockquote></div><br class=""></div></div></body></html>