Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/**
* @file core_zlascal.c
*
* MORSE computational routines
* MORSE is a software package provided by Univ. of Tennessee,
* Univ. of California Berkeley and Univ. of Colorado Denver
*
* @version 2.8.0
* @author Dalal Sukkari
* @date 2015-11-05
* @precisions normal z -> c d s
*
**/
#include "coreblas/include/coreblas.h"
#include "coreblas/include/cblas.h"
#include <math.h>
/**
*******************************************************************************
*
* @ingroup CORE_MORSE_Complex64_t
*
* CORE_zlascal scales a two-dimensional matrix A. As opposite to
* CORE_zlascl(), no checks is performed to prevent under/overflow. This should
* have been done at higher level.
*
*******************************************************************************
*
* @param[in] uplo
* Specifies the shape of A:
* = MorseUpperLower: A is a general matrix.
* = MorseUpper: A is an upper trapezoidal matrix.
* = MorseLower: A is a lower trapezoidal matrix.
*
* @param[in] m is the number of rows of the matrix A. m >= 0
*
* @param[in] n is the number of columns of the matrix A. n >= 0
*
* @param[in] alpha
* The scalar factor.
*
* @param[in,out] A is the matrix to be multiplied by alpha
*
* @param[in] lda is the leading dimension of the array A. lda >= max(1,m).
*
*******************************************************************************
*
* @return
* \retval MORSE_SUCCESS successful exit
* \retval <0 if -i, the i-th argument had an illegal value
*
******************************************************************************/
int
CORE_zlascal( MORSE_enum uplo, int m, int n,
MORSE_Complex64_t alpha, MORSE_Complex64_t *A, int lda )
{
int i;
if ( (uplo != MorseUpperLower) &&
(uplo != MorseUpper) &&
(uplo != MorseLower))
{
coreblas_error(1, "illegal value of uplo");
return -1;
}
if (m < 0) {
coreblas_error(2, "Illegal value of m");
return -2;
}
if (n < 0) {
coreblas_error(3, "Illegal value of n");
return -3;
}
if ( (lda < max(1,m)) && (m > 0) ) {
coreblas_error(6, "Illegal value of lda");
return -6;
}
switch ( uplo ) {
case MorseUpper:
for(i=0; i<n; i++) {
cblas_zscal( min( i+1, m ), CBLAS_SADDR(alpha), A+i*lda, 1 );
}
break;
case MorseLower:
for(i=0; i<n; i++) {
cblas_zscal( max( m, m-i ), CBLAS_SADDR(alpha), A+i*lda, 1 );
}
break;
default:
if (m == lda) {
cblas_zscal( m*n, CBLAS_SADDR(alpha), A, 1 );
}
else {
for(i=0; i<n; i++) {
cblas_zscal( m, CBLAS_SADDR(alpha), A+i*lda, 1 );
}
}
}
return MORSE_SUCCESS;
}