# Solve A.T x = f

Hi,

I am trying to implement the adjoint state method. To do this I have to solve
A^T \lambda = f
where \lambda, and f are vectors and A^T is the transpose of the matrix A, which comes from

dolfin.assemble(a).


Originally I did this by using

import dolfin


but for the specific bilinear form I have, the assembly takes nearly 20X longer than assembling its adjoint!

I have tried assembling a simple bilinear form a, and its adjoint and the assembly times are basically the same, so I’m super confused why it takes longer for my case.

Does anyone know of a way to do this without assembling the adjoint of the form, or how to speed up assembly of the adjoint of a form? I’m trying to extract a MWE on my case but I’m not sure the exact part of it that’s making assembly of the adjoint slow.

I am using the version of FEniCS installed through Anaconda.

Thanks alot!
Jonathan

Thanks, that helps a lot! I was able to get it working using the transpose through petsc4py, but I still think there an issue with assembling the dolfin.adjoint() applied to a form that somehow makes it slower when the form is complicated enough.

I’ll try to figure out what makes it slow in my case when I get a chance.

Update

I figured out why assembling the adjoint was so slow.

I was using making the adjoint form in a loop. If you premake the adjoint form outside of the loop, then there’s basically no difference in speed.

# This is slow in a loop