<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=""><div class=""><br class=""></div>  Least squares has two supported types: brgn and pounders. They will not compile with complex. I suspect the problem, at least with brgn, is its handling of bound constraints. Perhaps for complex numbers the handling of constraints can simply be #ifdef out? If one does not need constraints.<div class=""><br class=""></div><div class="">  Barry</div><div class=""><br class=""></div><div class="">You can start by removing the <span class="" style="font-family: Menlo; font-size: 14px; font-variant-ligatures: no-common-ligatures;">leastsquares/makefile</span><span class="" style="font-family: Menlo; font-size: 14px; font-variant-ligatures: no-common-ligatures; color: rgb(46, 174, 187);">:</span><span class="" style="font-family: Menlo; font-size: 14px; font-variant-ligatures: no-common-ligatures;">#</span><span class="" style="font-family: Menlo; font-size: 14px; font-variant-ligatures: no-common-ligatures; color: rgb(180, 36, 25);"><b class="">requiresscalar </b></span><span class="" style="font-family: Menlo; font-size: 14px; font-variant-ligatures: no-common-ligatures;">real </span>adding it into the pounders directory and then compiling and "fixing" the code in brng.c to work with complex.  </div><div class=""><br class=""></div><div class="">But BRNG is a wrapper around TAOBNTL so you need to get that to also build correctly with complex.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jun 24, 2021, at 10:11 PM, Barry Smith <<a href="mailto:bsmith@petsc.dev" class="">bsmith@petsc.dev</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class=""><br class=""></div><span style="font-family: Menlo; font-size: 14px;" class="">$ git grep requiresscalar</span><span style="font-family: Menlo; font-size: 14px;" class=""> </span><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">bound/makefile</span><span style="font-variant-ligatures: no-common-ligatures; color: #2eaebb" class="">:</span><span style="font-variant-ligatures: no-common-ligatures" class="">#</span><span style="font-variant-ligatures: no-common-ligatures; color: #b42419" class=""><b class="">requiresscalar</b></span><span style="font-variant-ligatures: no-common-ligatures" class="">    real</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">complementarity/makefile</span><span style="font-variant-ligatures: no-common-ligatures; color: #2eaebb" class="">:</span><span style="font-variant-ligatures: no-common-ligatures" class="">#</span><span style="font-variant-ligatures: no-common-ligatures; color: #b42419" class=""><b class="">requiresscalar</b></span><span style="font-variant-ligatures: no-common-ligatures" class="">    real</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">constrained/makefile</span><span style="font-variant-ligatures: no-common-ligatures; color: #2eaebb" class="">:</span><span style="font-variant-ligatures: no-common-ligatures" class="">#</span><span style="font-variant-ligatures: no-common-ligatures; color: #b42419" class=""><b class="">requiresscalar</b></span><span style="font-variant-ligatures: no-common-ligatures" class="">    real</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">leastsquares/makefile</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(46, 174, 187);" class="">:</span><span style="font-variant-ligatures: no-common-ligatures;" class="">#</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(180, 36, 25);" class=""><b class="">requiresscalar</b></span><span style="font-variant-ligatures: no-common-ligatures;" class="">    real</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">linesearch/impls/makefile</span><span style="font-variant-ligatures: no-common-ligatures; color: #2eaebb" class="">:</span><span style="font-variant-ligatures: no-common-ligatures" class="">#</span><span style="font-variant-ligatures: no-common-ligatures; color: #b42419" class=""><b class="">requiresscalar</b></span><span style="font-variant-ligatures: no-common-ligatures" class="">    real</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">pde_constrained/makefile</span><span style="font-variant-ligatures: no-common-ligatures; color: #2eaebb" class="">:</span><span style="font-variant-ligatures: no-common-ligatures" class="">#</span><span style="font-variant-ligatures: no-common-ligatures; color: #b42419" class=""><b class="">requiresscalar</b></span><span style="font-variant-ligatures: no-common-ligatures" class="">    real</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">quadratic/makefile</span><span style="font-variant-ligatures: no-common-ligatures; color: #2eaebb" class="">:</span><span style="font-variant-ligatures: no-common-ligatures" class="">#</span><span style="font-variant-ligatures: no-common-ligatures; color: #b42419" class=""><b class="">requiresscalar</b></span><span style="font-variant-ligatures: no-common-ligatures" class="">    real</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">unconstrained/makefile</span><span style="font-variant-ligatures: no-common-ligatures; color: #2eaebb" class="">:</span><span style="font-variant-ligatures: no-common-ligatures" class="">#</span><span style="font-variant-ligatures: no-common-ligatures; color: #b42419" class=""><b class="">requiresscalar</b></span><span style="font-variant-ligatures: no-common-ligatures" class="">    real</span></div><div style="margin: 0px; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class="">We added these requirements when Tao was brought back into the PETSc fold as Alp mentioned. It would be good to start eliminating the requirements when possible. </div><div class=""><br class=""></div><div class="">I have removed the <span style="font-family: Menlo; font-size: 14px; font-variant-ligatures: no-common-ligatures;" class="">leastsquares/makefile</span><span style="font-family: Menlo; font-size: 14px; font-variant-ligatures: no-common-ligatures; color: rgb(46, 174, 187);" class="">:</span><span style="font-family: Menlo; font-size: 14px; font-variant-ligatures: no-common-ligatures;" class="">#</span><span style="font-family: Menlo; font-size: 14px; font-variant-ligatures: no-common-ligatures; color: rgb(180, 36, 25);" class=""><b class="">requiresscalar</b></span><span style="font-family: Menlo; font-size: 14px; font-variant-ligatures: no-common-ligatures;" class="">    real a</span>nd have started a build to see how it goes. If everything goes well maybe we can get it working for complex without too much difficulty.</div><div class=""><br class=""></div><div class="">  Barry</div><div class=""><br class=""></div><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Jun 24, 2021, at 4:02 PM, Junchao Zhang <<a href="mailto:junchao.zhang@gmail.com" class="">junchao.zhang@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><br class=""><br class=""></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jun 24, 2021 at 3:25 PM Dener, Alp via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" class="">petsc-users@mcs.anl.gov</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">



<div style="overflow-wrap: break-word;" class="">
Hi Lucas,
<div class=""><br class="">
</div>
<div class="">In theory, you can attempt to solve complex-valued problems by concatenating the real and imaginary parts into a single real-valued solution vector and solving it as if it’s a real-valued problem.</div>
<div class=""><br class="">
</div>
<div class="">There’s a more practical issue of the PETSc build excluding the TAO source code entirely for complex builds. I think this is done because we cannot guarantee that TAO code has been completely rigorous in its distinction of PetscReal from PetscScalar.
 There may be places where we used Scalar and assumed it’s Real. The methods developed in the last few years have paid more attention to this but there’s a lot of older code floating around that might break even if you hacked the build into compiling TAO for
 complex configurations.</div></div></blockquote><div class="">If an expression does not support PetscComplex, shouldn't it report a compilation error?</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;" class="">
<div class=""><br class="">
</div>
<div class="">I’m not entirely sure what’s necessary to enable TAO builds for complex PETSc. Perhaps Todd, Satish or Barry will have a better idea. If you want to give it a try though I’d be happy to help you resolve the errors as they come up so that it can
 be compiled for complex builds. Can’t provide convergence guarantees but it would at least let you attempt a solution.</div>
<div class=""><br class="">
</div>
<div class="">Alp</div>
<div class="">
<div class="">
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On Jun 24, 2021, at 2:44 PM, Lucas Banting <<a href="mailto:bantingl@myumanitoba.ca" target="_blank" class="">bantingl@myumanitoba.ca</a>> wrote:</div>
<br class="">
<div class="">
<div style="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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt" class="">
Hi,</div>
<div style="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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt" class="">
<br class="">
</div>
<div style="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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt" class="">
I have a complex valued optimization code that requires non-linear least squares curve fitting at each iteration. I wanted to use Tao to do the non-linear least squares problem, but just discovered that Tao can only be used with real scalar types. Is there
 any workarounds?</div>
<div style="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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt" class="">
<br class="">
</div>
<div style="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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt" class="">
I was wondering if maybe I could somehow use two different Petsc installations at once, or is there any other ways to hack tao into working?</div>
<div style="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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt" class="">
<br class="">
</div>
<div style="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;text-decoration:none;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt" class="">
Thanks,
<div class="">Lucas</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>

</blockquote></div></div>
</div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></div></div></body></html>