Home >Computer Tutorials >Computer Knowledge >What functions can be called in Fortran to solve the inverse matrix?

What functions can be called in Fortran to solve the inverse matrix?

王林
王林forward
2024-01-23 23:42:121549browse

1. What is the calling function of the inverse matrix in Fortran?

In Fortran, you can use the LAPACK library function to calculate the inverse of a matrix. The following are the general steps for calling LAPACK to calculate the inverse matrix:

  1. Import the LAPACK library:
    • In a Fortran program, by using EXTERNAL Statement to import subroutines in LAPACK.
EXTERNAL DGETRF, DGETRI
  1. Call the inverse matrix function:
    • Use the function provided by LAPACK, such as DGETRF Perform LU decomposition and then use DGETRI to calculate the inverse matrix.
CALL DGETRF(N, N, A, LDA, IPIV, INFO)
CALL DGETRI(N, A, LDA, IPIV, WORK, LWORK, INFO)
  1. Parameter description:
    • N: The order of the matrix.
    • A: Input matrix.
    • LDA: The size of the first dimension of matrix A.
    • IPIV: Stores the intermediate results of LU decomposition.
    • WORK: work array.
    • LWORK: The size of the working array.
    • INFO: Returns the operation status.

#2. Fortran programming questions to solve linear equations?

To solve a system of linear equations, you can use the functions in LAPACK. The following are the general steps:

  1. Import the LAPACK library:
    • Import the LAPACK library in the Fortran program and declare the use of related subroutines.
EXTERNAL DGESV
  1. Call the linear equations solving function:
    • Use the function provided by LAPACKDGESV Solve systems of linear equations.
CALL DGESV(N, NRHS, A, LDA, IPIV, B, LDB, INFO)
  1. Parameter description:
    • N: The order of the matrix.
    • NRHS: The number of columns of the right matrix.
    • A: coefficient matrix.
    • LDA: The size of the first dimension of matrix A.
    • IPIV: Stores the intermediate results of LU decomposition.
    • B: Right matrix.
    • LDB: The size of the first dimension of matrix B.
    • INFO: Returns the operation status.

3. Fortran95 subroutine naming expert helps to correct mistakes and get high scores?

In Fortran95, the naming rules for subroutines are relatively free, but some common rules include:

  1. Clear naming:
    • The name of the subroutine should be able to clearly express its function and avoid using names that are too simple or meaningless.
SUBROUTINE SolveLinearSystem
  1. Use underscores to connect words:
    • To improve readability, use underscores_ Connect words.
SUBROUTINE Matrix_Multiplication
  1. Avoid conflicts with built-in functions:
    • Avoid using the same name as a Fortran built-in function to avoid confusion .
SUBROUTINE MySum

Summary

  1. (1) In Fortran, the inversion of a matrix can be achieved using the functions in the LAPACK library Solve systems of linear equations.
  2. (2) The naming of subroutines should clearly express their functions. Underscores can be used to connect words to avoid conflicts with built-in functions.

What functions can be called in Fortran to solve the inverse matrix?

The above is the detailed content of What functions can be called in Fortran to solve the inverse matrix?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:docexcel.net. If there is any infringement, please contact admin@php.cn delete