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