LASs - Linear Algebra Routines on OmpSs  1.0.0
LASs
ddss_dsyrk.c
Go to the documentation of this file.
1 #include "../include/lass.h"
2 
3 /**
4  *
5  * @file ddss_dsyrk.c
6  *
7  * @brief LASs-DDSs ddss_dsyrk 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 2018-02-13
15  * @reviewer
16  * @modified
17  *
18  **/
19 
20 /**
21  *
22  * @ingroup DDSS
23  *
24  * Performs one of the symmetric rank k operations:
25  *
26  * C = ALPHA * A * op( A ) + BETA * C or
27  * C = ALPHA * op( A ) * A + BETA * C
28  *
29  * where op( X ) is:
30  *
31  * op( X ) = X**T
32  *
33  * ALPHA and BETA are scalars, C is an N by N symmetric matrix and A is an
34  * N by K matrix in the first case and a K by N matrix in the second case.
35  *
36  **/
37 
38 /**
39  * @param[in]
40  * UPLO enum DDSS_UPLO.
41  * UPLO specifies the form in which C is stored:
42  * - Lower: Lower triangular part of C is stored. The upper traingular
43  * part is not referenced.
44  * - Upper: Upper triangular part of C is stored. The lower triangular
45  * part is not referenced.
46  *
47  * @param[in]
48  * TRANS_A enum DDSS_TRANS.
49  * TRANS_A specifies the operation to be performed as follows:
50  * - NoTrans: C = ALPHA * A * A**T + BETA * C
51  * - Trans: C = ALPHA * A**T * A + BETA * C
52  *
53  * @param[in]
54  * N int.
55  * N specifies the order of matrix C. N must be at least zero.
56  *
57  * @param[in]
58  * K int.
59  * With TRANS_A = NoTrans, K specifies the number of columns of the
60  * matrix A, and with TRANS_A = Trans, K specifies the number of rows
61  * of the matrix A. K must be at least zero.
62  *
63  * @param[in]
64  * ALPHA double.
65  * ALPHA specifies the scalar alpha.
66  *
67  * @param[in]
68  * A double *.
69  * A is a pointer to a matrix of dimension Na ( rows ) by Ka
70  * ( columns ), where Na is N and Ka is K when TRANS_A = NoTrans,
71  * and Na is K and Ka is N otherwise.
72  *
73  * @param[in]
74  * LDA int.
75  * LDA specifies the number of columns of A ( row-major order ).
76  * When TRANS_A = NoTrans then LDA must be at least max( 1, K ),
77  * otherwise LDA must be at least max( 1, N ).
78  *
79  * @param[in]
80  * BETA double.
81  * BETA specifies the scalar beta.
82  *
83  * @param[in, out]
84  * C double *.
85  * C is a pointer to a matrix of dimension N by N.
86  * When UPLO = Uppper the strictly lower triangular part of C is not
87  * referenced. On exit, the upper triangular part of C is overwritten
88  * by the upper triangular part of the updated solution matrix C.
89  * When UPLO = Lower the strictly upper triangular part of C is not
90  * referenced. On exit, the lower triangular part of C is overwritten
91  * by the lower triangular part of the updated solution matrix C.
92  *
93  * @param[in]
94  * LDC int.
95  * LDC specifies the number of columns of C ( row-major order ).
96  * LDC must be at least max( 1, N ).
97  *
98  **/
99 
100 /**
101  *
102  * @sa kdsyrk
103  *
104  **/
105 
106 int ddss_dsyrk( enum DDSS_UPLO UPLO, enum DDSS_TRANS TRANS_A,
107  int N, int K,
108  const double ALPHA, double *A, int LDA,
109  const double BETA, double *C, int LDC )
110 {
111 
112  // Local variables
113  int nA;
114 
115  // Argument checking
116  if ( ( UPLO != Upper ) && ( UPLO != Lower ) )
117  {
118  fprintf( stderr, "Illegal value of UPLO, in ddss_dsyrk code\n" );
119  return NoSuccess;
120  }
121 
122  if ( ( TRANS_A != NoTrans ) && ( TRANS_A != Trans ) )
123  {
124  fprintf( stderr, "Illegal value of TRANS_A, in ddss_dsyrk code\n" );
125  return NoSuccess;
126  }
127 
128  if ( N < 0 )
129  {
130  fprintf( stderr, "Illegal value of N, in ddss_dsyrk code\n" );
131  return NoSuccess;
132  }
133 
134  if ( K < 0 )
135  {
136  fprintf( stderr, "Illegal value of K, in ddss_dsyrk code\n" );
137  return NoSuccess;
138  }
139 
140  if ( TRANS_A == NoTrans )
141  {
142  nA = K;
143  }
144  else
145  {
146  nA = N;
147  }
148 
149  if ( LDA < MAX( 1, nA ) )
150  {
151  fprintf( stderr, "Illegal value of LDA, in ddss_dsyrk code\n" );
152  return NoSuccess;
153  }
154 
155  if ( LDC < MAX( 1, N ) )
156  {
157  fprintf( stderr, "Illegal value of LDC, in ddss_dsyrk code\n" );
158  return NoSuccess;
159  }
160 
161  // Quick return
162  if ( N == 0 || ( ( ALPHA == 0.0 || K == 0 ) && BETA == 1.0 ) )
163  {
164  return Success;
165  }
166 
167  return kdsyrk( UPLO, TRANS_A,
168  N, K,
169  ALPHA, A, LDA,
170  BETA, C, LDC );
171 
172 }
int ddss_dsyrk(enum DDSS_UPLO UPLO, enum DDSS_TRANS TRANS_A, int N, int K, const double ALPHA, double *A, int LDA, const double BETA, double *C, int LDC)
Definition: ddss_dsyrk.c:106
enum LASS_RETURN kdsyrk(enum DDSS_UPLO UPLO, enum DDSS_TRANS TRANS_A, int N, int K, const double ALPHA, double *A, int LDA, const double BETA, double *C, int LDC)
Definition: kdsyrk.c:117