LASs - Linear Algebra Routines on OmpSs  1.0.0
LASs
dnpgetrf.c
Go to the documentation of this file.
1 #include "../include/lass.h"
2 
3 /**
4  *
5  * @file dnpgetrf.c
6  *
7  * @brief LASs-DDSs dnpgetrf routine.
8  *
9  * LASs-DDSs is a software package provided by:
10  * Barcelona Supercomputing Center - Centro Nacional de Supercomputacion
11  *
12  * @author Pedro Valero-Lara pedro.valero@bsc.es
13  * @author Boro Sofranac boro.sofranac@bsc.es
14  * @date 2017-21-11
15  * @reviewer
16  * @modified
17  *
18  **/
19 
20 /**
21  *
22  * @ingroup DDSS
23  *
24  * Performs the LU factorization without pivoting of a general M-by-N matrix A:
25  *
26  * A = L * U
27  *
28  * where L is a lower triangular ( lower trapezoidal if M > N ) matrix with
29  * unit diagonal elements and U is an upper triangular ( upper trapezoidal
30  * if M < N ) matrix.
31  *
32 **/
33 
34 /**
35  *
36  * @param[in]
37  * M int.
38  * M specifies the number of rows of the matrix A. M >= 0.
39  *
40  * @param[in]
41  * N int.
42  * N specifies the number of columns of the matrix A. N >= 0.
43  *
44  * @param[in,out]
45  * A double *.
46  * A is a pointer to a regular matrix of dimension M-by-N.
47  * On exit, if return value is Success, the matrix A is overwriten by
48  * the factors L and U. The unit diagonal elements of L are not stored.
49  *
50  * @param[in]
51  * LDA int.
52  * LDA specifies the number of columns of A ( row-major order ).
53  * LDA must be at least max( 1, N ).
54  *
55  **/
56 
57 /**
58  *
59  * @retval Success successful exit
60  * @retval NoSuccess unsuccessful exit
61  *
62  **/
63 
64 /**
65  *
66  * @sa kdnpgetrf
67  *
68  **/
69 
70 enum LASS_RETURN dnpgetrf( int M, int N, double *A, int LDA )
71 {
72 
73  // Local variable
74  double alpha;
75  double sfmin;
76  int i, j, k;
77  int info = 0;
78 
79  // Argument checking
80  if ( M < 0 )
81  {
82  fprintf( stderr, "Illegal value of M, in dnpgetrf code\n" );
83  return NoSuccess;
84  }
85 
86  if ( N < 0 )
87  {
88  fprintf( stderr, "Illegal value of N, in dnpgetrf code\n" );
89  return NoSuccess;
90  }
91 
92  if ( LDA < MAX( 1, N ) )
93  {
94  fprintf( stderr, "Illegal value of LDA, in dnpgetrf code\n" );
95  return NoSuccess;
96  }
97 
98  // Qick return
99  if ( MIN( M, N ) == 0 )
100  {
101  return Success;
102  }
103 
104  /****************
105  --DNPGETRF tile--
106  ****************/
107 
108  // Minimum value in double precision
109  sfmin = LAPACKE_dlamch_work( 'S' );
110  k = MIN( M, N );
111 
112  for ( i = 0; i < k; i++ )
113  {
114  alpha = A[i * LDA + i];
115  if ( alpha != ( double )0.0 )
116  {
117  // Compute elements from J+1 to M of the J-th column
118  if ( i < M )
119  {
120  if ( fabs( alpha ) > fabs( sfmin ) )
121  {
122  alpha = 1.0 / alpha;
123  cblas_dscal( M - i - 1, alpha,
124  &( A[( i + 1 ) * LDA + i] ), LDA );
125  }
126  else
127  {
128  for( j= i + 1; j < M; j++ )
129  {
130  A[j * LDA + i] = A[j * LDA + i] / alpha;
131  }
132  }
133  }
134  }
135  else if ( info == 0 )
136  {
137  info = i;
138  }
139  if ( i < k )
140  {
141  cblas_dger( CblasRowMajor,
142  M - i - 1, N - i - 1,
143  -1.0,
144  &A[( i + 1 ) * LDA + i], LDA,
145  &A[ i * LDA + ( i + 1 )], 1,
146  &A[( i + 1 ) * LDA + ( i + 1 ) ], LDA );
147  }
148  }
149 
150  return Success;
151 
152 }
enum LASS_RETURN dnpgetrf(int M, int N, double *A, int LDA)
Definition: dnpgetrf.c:70