我要评分
获取效率
正确性
完整性
易理解

P?GETRF

Calculate the LU factorization of matrix A. This function uses partial pivoting, allowing row interchanges. The operation is defined as A = PLU, where P is a permutation matrix, L is a lower triangular matrix or a lower echelon matrix and the diagonal is 1, and U is an upper triangular matrix or an upper echelon matrix.

Interface Definition

C interface:

void psgetrf_(const int *m, const int *n, float *a, const int *ia, const int *ja, const int *desca, int *ipiv, int *info)

void pdgetrf_(const int *m, const int *n, double*a, const int *ia, const int *ja, const int *desca, int *ipiv, int *info)

void pcgetrf_(const int *m, const int *n, float _Complex *a, const int *ia, const int *ja, const int *desca, int *ipiv, int *info)

void pzgetrf_(const int *m, const int *n, double _Complex*a, const int *ia, const int *ja, const int *desca, int *ipiv, int *info)

Fortran interface:

PSGETRF(m, n, a, ia, ja, desca, ipiv, info)

PDGETRF(m, n, a, ia, ja, desca, ipiv, info)

PCGETRF(m, n, a, ia, ja, desca, ipiv, info)

PZGETRF(m, n, a, ia, ja, desca, ipiv, info)

Parameters

Parameter

Type

Scope

Description

Input/Output

m

Integer

Global

Number of rows to be operated, for example, the number of rows in a submatrix

Input

n

Integer

Global

Number of columns to be operated, for example, the number of columns in a submatrix

Input

a

  • A single-precision floating-point array for psgetrf
  • A double-precision floating-point array for pdgetrf
  • A single-precision complex number array for pcgetrf
  • A double-precision complex array for pzgetrf

Local

  • Stores the local M*N part of distributed matrix A before this function is called.
  • Stores the local factorization results L and U after this function is called. The diagonal elements of L (all are 1) are not stored.

Input/Output

ia

Integer

Global

Row indices of the submatrix in the global matrix

Input

ja

Integer

Global

Column indices of the submatrix in the global matrix

Input

desca

Integer array

Local and global

Descriptor of distributed matrix A

Input

ipiv

Integer

Local

Contains the pivoting information.

Output

info

Integer

Global

Execution result:

  • 0: The execution is successful.
  • Smaller than 0: The value of the -info-th parameter is invalid.
  • Greater than 0: The info-th element on the diagonal of matrix U is 0. The matrix factorization is complete, but U is singular. As a result, an error of dividing by zero occurs when a system of linear equations is solved.

Output

Dependencies

#include <kscalapack.h>

#include <kscalapack_utils.h>

Examples

C interface:
    int m = 8;
    int n = 8;       
    int nprow = 2;   
    int npcol = 2;
    int mb = 4;:q   
    int nb = 4;          
    np = 4;
    int descA[9];
    int info;
    int ipiv[10] = {0};
    int lddA = mpA > 1 ? mpA : 1;
    descinit_( descA,  &n, &n, &nb, &nb, &izero, &izero, &ictxt, &lddA, &info);     
    /* 
     * Origin A: 
     *  

    4.00000 19.0000 25.0000 16.0000 19.0000 19.0000 25.0000 16.0000
    22.0000 8.00000 17.0000 25.0000 22.0000 21.0000 17.0000 25.0000
    23.0000 22.0000 7.00000 19.0000 23.0000 22.0000 18.0000 19.0000
    21.0000 18.0000 23.0000 13.0000 21.0000 18.0000 23.0000 22.0000
    19.0000 19.0000 25.0000 16.0000 4.00000 19.0000 25.0000 16.0000
    22.0000 21.0000 17.0000 25.0000 22.0000 8.00000 17.0000 25.0000
    23.0000 22.0000 18.0000 19.0000 23.0000 22.0000 7.00000 19.0000
    21.0000 18.0000 23.0000 22.0000 21.0000 18.0000 23.0000 13.0000
    */
    /* Query optimal work size */ 
    pdgetrf_(&n, &n, A, &ione, &ione, descA, ipiv, &info);
    // run with 4 processes
    * After PDGETRF: 
    /*
    23.0000 22.0000 7.00000 19.0000 23.0000 22.0000 18.0000 19.0000
    0.173913 15.1739 23.7826 12.6957 15.0000 15.1739 21.8696 12.6957
    0.956522 -0.859599 30.7479 17.7393 12.8940 13.0000 18.5817 17.7393
    0.913043 -0.137536 0.646538 -14.0708 -6.27341 -8.40499 -2.44069 -5.07082
    0.826087 0.0544413 0.582891 0.762348 -18.5499 -1.17005 -0.0305972 -6.86113
    0.956522 -0.00286533 0.337340 -0.0624197 0.253277 -17.6137 -6.56767 2.29955
    1.00000 0.00000 0.357749 0.451018 0.0961398 0.0424351 -16.2651 -3.49711
    0.913043 -0.137536 0.646538 0.360379 0.216315 0.290848 -0.0218688 -11.5045
    */