# KSPSolveTranspose?

**URL:** <https://community.freefem.org/t/kspsolvetranspose/2291>\
**Category:** Feature Request\
**Created:** [February 24, 2023, 4:59pm UTC](https://community.freefem.org/t/kspsolvetranspose/2291 "2023-02-24T16:59:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmd](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/cmd/32/67_2.png) [@cmd](https://community.freefem.org/u/cmd)\
**Post date:** [February 24, 2023, 4:59pm UTC](https://community.freefem.org/t/kspsolvetranspose/2291/1 "2023-02-24T16:59:38Z")

</div>

Hello,  
I was unable to find any documentation about the implementation of `KSPSolveTranspose` in the FF/PETSc interface, though I can see it is mentioned in `PETSc-code.hpp`. I was wondering if this:

```auto
load "PETSc"
Mat A;
real[int] bP, solP;
KSPSolve(A, bP, solP);
real[int] b;
ChangeNumbering(J, b, bP, inverse = true, exchange = true);
real[int] solT = A'^-1*b;
real[int] solTP;
ChangeNumbering(J, solT, solTP);

```

could be replaced with something like this?

```auto
load "PETSc"
Mat A;
real[int] bP, solP, solTP;
KSPSolve(A, bP, solP);
KSPSolveTranspose(A, bP, solTP);

```

Thanks!

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [February 25, 2023, 6:43am UTC](https://community.freefem.org/t/kspsolvetranspose/2291/2 "2023-02-25T06:43:34Z")

</div>

It is most definitely possible, mostly a matter of copy/pasting the code path of `KSPSolveHermitianTranspose()`. Would you feel like making a PR for this addition?

---

<div class="post-metadata">

**Author:** ![cmd](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/cmd/32/67_2.png) [@cmd](https://community.freefem.org/u/cmd)\
**Post date:** [February 25, 2023, 8:45am UTC](https://community.freefem.org/t/kspsolvetranspose/2291/3 "2023-02-25T08:45:54Z")

</div>

Thanks! [done](https://github.com/FreeFem/FreeFem-sources/commit/5ed239b4dc29fe29e638bc7a66b030f1e7ebd1dc).

---

<div class="post-metadata">

**Author:** ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)\
**Post date:** [February 25, 2023, 8:53am UTC](https://community.freefem.org/t/kspsolvetranspose/2291/4 "2023-02-25T08:53:58Z")

</div>

Not quite though. This needs to be in a branch and then you need to create a PR. Furthermore, you must adapt the code to avoid conjugating in the complex case.

---

<div class="post-metadata">

**Author:** ![cmd](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/cmd/32/67_2.png) [@cmd](https://community.freefem.org/u/cmd)\
**Post date:** [February 25, 2023, 9:16am UTC](https://community.freefem.org/t/kspsolvetranspose/2291/5 "2023-02-25T09:16:13Z")

</div>

Got it. Sorry about the amateurism. New territory for me 🙂

> <https://github.com/FreeFem/FreeFem-sources/pull/256>
