[petsc-users] Question about linking LAPACK library

Satish Balay balay at mcs.anl.gov
Tue Apr 25 08:10:57 CDT 2023


On Tue, 25 Apr 2023, Matthew Knepley wrote:

> On Tue, Apr 25, 2023 at 6:03 AM ­권승리 / 학생 / 항공우주공학과 <ksl7912 at snu.ac.kr>
> wrote:
> 
> > Thank you for your reply.
> >
> > I think I gave an example of an unrealistic problem.
> >
> > I just wanted to know how to compute the inverse matrix, so I was
> > wondering if there is an example of computing the inverse matrix in PETSc.
> >
> 
> You just use
> 
>   KSPCreate(PETSC_COMM_WORLD, &ksp);
>   KSPSetOperator(ksp, A, A);
>   KSPSetFromOptions(ksp);
>   KSPSolve(ksp, b, x);
> 
> This solves the system. If you want an exact solution use
> 
>   -pc_type lu
> 
> There is a manual chapter on linear solves such as there.
> 
>   Thanks,
> 
>      Matt
> 
> 
> > Alternatively, I want to know how to link the LAPACK library.

You might want to check:

src/mat/impls/dense/seq/dense.c:  PetscCallBLAS("LAPACKgetrf", LAPACKgetrf_(&m, &n, mat->v, &mat->lda, mat->pivots, &info));

Satish


> >
> > best,
> >
> > Seung Lee Kwon
> >
> > 2023년 4월 25일 (화) 오후 6:44, Matthew Knepley <knepley at gmail.com>님이 작성:
> >
> >> On Mon, Apr 24, 2023 at 11:47 PM ­권승리 / 학생 / 항공우주공학과 <ksl7912 at snu.ac.kr>
> >> wrote:
> >>
> >>> Dear all
> >>>
> >>> It depends on the problem. It can have hundreds of thousands of degrees
> >>> of freedom.
> >>>
> >>
> >> Suppose your matrix was dense and had 1e6 dofs. The work to invert a
> >> matrix is O(N^3) with a small
> >> constant, so it would take 1e18 = 1 exaflop to invert this matrix and
> >> about 10 Terabytes of RAM to store
> >> it. Is this available to you? PETSc's supports Elemental and SCALAPACK
> >> for this kind of calculation.
> >>
> >> If the system is sparse, you could invert it using MUMPS, SuperLU_dist,
> >> or Pardiso. Then the work and
> >> storage depend on the density. There are good estimates for connectivity
> >> based on regular grids of given
> >> dimension. The limiting resource here is usually memory, which motivates
> >> people to try iterative methods.
> >> The convergence of iterative methods depend on detailed properties of
> >> your system, like the operator spectrum.
> >>
> >>   Thanks,
> >>
> >>      Matt
> >>
> >>
> >>> best,
> >>>
> >>> Seung Lee Kwon
> >>>
> >>> 2023년 4월 25일 (화) 오후 12:32, Barry Smith <bsmith at petsc.dev>님이 작성:
> >>>
> >>>>
> >>>>   How large are the dense matrices you would like to invert?
> >>>>
> >>>> On Apr 24, 2023, at 11:27 PM, ­권승리 / 학생 / 항공우주공학과 <ksl7912 at snu.ac.kr>
> >>>> wrote:
> >>>>
> >>>> Dear all
> >>>>
> >>>> Hello.
> >>>> I want to make an inverse matrix like inv(A) in MATLAB.
> >>>>
> >>>> Are there some methods to inverse matrix in petsc?
> >>>>
> >>>> If not, I want to use the inverse function in the LAPACK library.
> >>>>
> >>>> Then, how to use the LAPACK library in petsc? I use the C language.
> >>>>
> >>>> Best,
> >>>>
> >>>> Seung Lee Kwon
> >>>>
> >>>> --
> >>>> Seung Lee Kwon, Ph.D.Candidate
> >>>> Aerospace Structures and Materials Laboratory
> >>>> Department of Mechanical and Aerospace Engineering
> >>>> Seoul National University
> >>>> Building 300 Rm 503, Gwanak-ro 1, Gwanak-gu, Seoul, South Korea, 08826
> >>>> E-mail : ksl7912 at snu.ac.kr
> >>>> Office : +82-2-880-7389
> >>>> C. P : +82-10-4695-1062
> >>>>
> >>>>
> >>>>
> >>>
> >>> --
> >>> Seung Lee Kwon, Ph.D.Candidate
> >>> Aerospace Structures and Materials Laboratory
> >>> Department of Mechanical and Aerospace Engineering
> >>> Seoul National University
> >>> Building 300 Rm 503, Gwanak-ro 1, Gwanak-gu, Seoul, South Korea, 08826
> >>> E-mail : ksl7912 at snu.ac.kr
> >>> Office : +82-2-880-7389
> >>> C. P : +82-10-4695-1062
> >>>
> >>
> >>
> >> --
> >> What most experimenters take for granted before they begin their
> >> experiments is infinitely more interesting than any results to which their
> >> experiments lead.
> >> -- Norbert Wiener
> >>
> >> https://www.cse.buffalo.edu/~knepley/
> >> <http://www.cse.buffalo.edu/~knepley/>
> >>
> >
> >
> > --
> > Seung Lee Kwon, Ph.D.Candidate
> > Aerospace Structures and Materials Laboratory
> > Department of Mechanical and Aerospace Engineering
> > Seoul National University
> > Building 300 Rm 503, Gwanak-ro 1, Gwanak-gu, Seoul, South Korea, 08826
> > E-mail : ksl7912 at snu.ac.kr
> > Office : +82-2-880-7389
> > C. P : +82-10-4695-1062
> >
> 
> 
> 


More information about the petsc-users mailing list