01: /* ///////////////////////////// P /// L /// A /// S /// M /// A /////////////////////////////// */
02: /* ///                    PLASMA computational routine (version 2.0.0)                       ///
03:  * ///                    Release Date: July, 4th 2009                                       ///
04:  * ///                    PLASMA is a software package provided by Univ. of Tennessee,       ///
05:  * ///                    Univ. of California Berkeley and Univ. of Colorado Denver          /// */
06: 
07: /* /////////////////////////// P /// U /// R /// P /// O /// S /// E /////////////////////////// */
08: // PLASMA_zgesv_Tile - Computes the solution to a system of linear equations A * X = B,
09: // where A is an N-by-N matrix and X and B are N-by-NRHS matrices.
10: // The tile LU decomposition with partial tile pivoting and row interchanges is used to factor A.
11: // The factored form of A is then used to solve the system of equations A * X = B.
12: // All matrices are passed through descriptors. All dimensions are taken from the descriptors.
13: 
14: /* ///////////////////// A /// R /// G /// U /// M /// E /// N /// T /// S ///////////////////// */
15: // A        PLASMA_Complex64_t* (INOUT)
16: //          On entry, the N-by-N coefficient matrix A.
17: //          On exit, the tile L and U factors from the factorization (not equivalent to LAPACK).
18: //
19: // L        PLASMA_Complex64_t* (OUT)
20: //          On exit, auxiliary factorization data, related to the tile L factor,
21: //          necessary to solve the system of equations.
22: //
23: // IPIV     int* (OUT)
24: //          On exit, the pivot indices that define the permutations (not equivalent to LAPACK).
25: //
26: // B        PLASMA_Complex64_t* (INOUT)
27: //          On entry, the N-by-NRHS matrix of right hand side matrix B.
28: //          On exit, if return value = 0, the N-by-NRHS solution matrix X.
29: 
30: /* ///////////// R /// E /// T /// U /// R /// N /////// V /// A /// L /// U /// E ///////////// */
31: //          = 0: successful exit
32: //          > 0: if i, U(i,i) is exactly zero. The factorization has been completed,
33: //               but the factor U is exactly singular, so the solution could not be computed.
34: 
35: /* //////////////////////////////////// C /// O /// D /// E //////////////////////////////////// */
36: #include "common.h"
37: 
38: int PLASMA_zgesv_Tile(PLASMA_desc *A, PLASMA_desc *L, int *IPIV, PLASMA_desc *B)
39: {
40:     PLASMA_desc descA = *A;
41:     PLASMA_desc descL = *L;
42:     PLASMA_desc descB = *B;
43:     plasma_context_t *plasma;
44: 
45:     plasma = plasma_context_self();
46:     if (plasma == NULL) {
47:         plasma_fatal_error("PLASMA_zgesv_Tile", "PLASMA not initialized");
48:         return PLASMA_ERR_NOT_INITIALIZED;
49:     }
50:     /* Check descriptors for correctness */
51:     if (plasma_desc_check(&descA) != PLASMA_SUCCESS) {
52:         plasma_error("PLASMA_zgesv_Tile", "invalid first descriptor");
53:         return PLASMA_ERR_ILLEGAL_VALUE;
54:     }
55:     if (plasma_desc_check(&descL) != PLASMA_SUCCESS) {
56:         plasma_error("PLASMA_zgesv_Tile", "invalid second descriptor");
57:         return PLASMA_ERR_ILLEGAL_VALUE;
58:     }
59:     if (plasma_desc_check(&descB) != PLASMA_SUCCESS) {
60:         plasma_error("PLASMA_zgesv_Tile", "invalid third descriptor");
61:         return PLASMA_ERR_ILLEGAL_VALUE;
62:     }
63:     /* Check input arguments */
64:     /* Quick return */
65: /*
66:     if (min(N, NRHS) == 0)
67:         return PLASMA_SUCCESS;
68: */
69:     /* Clear IPIV and Lbdl */
70:     plasma_memzero(IPIV, descA.mt*descA.nt*PLASMA_NB, PlasmaInteger);
71:     plasma_memzero(descL.mat, descL.mt*descL.nt*PLASMA_IBNBSIZE, PlasmaComplexDouble);
72: 
73:     /* Set INFO to ZERO */
74:     PLASMA_INFO = PLASMA_SUCCESS;
75: 
76:     plasma_parallel_call_3(plasma_pzgetrf,
77:         PLASMA_desc, descA,
78:         PLASMA_desc, descL,
79:         int*, IPIV);
80: 
81:     if (PLASMA_INFO == PLASMA_SUCCESS)
82:     {
83:         plasma_parallel_call_4(plasma_pztrsmpl,
84:             PLASMA_desc, descA,
85:             PLASMA_desc, descB,
86:             PLASMA_desc, descL,
87:             int*, IPIV);
88: 
89:         plasma_parallel_call_7(plasma_pztrsm,
90:             PLASMA_enum, PlasmaLeft,
91:             PLASMA_enum, PlasmaUpper,
92:             PLASMA_enum, PlasmaNoTrans,
93:             PLASMA_enum, PlasmaNonUnit,
94:             PLASMA_Complex64_t, 1.0,
95:             PLASMA_desc, descA,
96:             PLASMA_desc, descB);
97:     }
98:     return PLASMA_INFO;
99: }