Skip to content

Commit fc06714

Browse files
Fix const qualifier for double complex routines
1 parent dbc45f7 commit fc06714

10 files changed

+108
-42
lines changed

CBLAS/src/cblas_zgbmv.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88
#include <stdio.h>
99
#include <stdlib.h>
10+
#include <string.h>
1011
#include "cblas.h"
1112
#include "cblas_f77.h"
1213
void API_SUFFIX(cblas_zgbmv)(const CBLAS_LAYOUT layout,
@@ -26,6 +27,7 @@ void API_SUFFIX(cblas_zgbmv)(const CBLAS_LAYOUT layout,
2627
F77_INT F77_M=M, F77_N=N, F77_lda=lda, F77_incX=incX, F77_incY=incY;
2728
F77_INT F77_KL=KL,F77_KU=KU;
2829
#else
30+
CBLAS_INT incx = incX;
2931
#define F77_M M
3032
#define F77_N N
3133
#define F77_lda lda
@@ -34,15 +36,18 @@ void API_SUFFIX(cblas_zgbmv)(const CBLAS_LAYOUT layout,
3436
#define F77_incX incx
3537
#define F77_incY incY
3638
#endif
37-
CBLAS_INT n, i=0, incx=incX;
38-
const double *xx= (double *)X, *alp= (double *)alpha, *bet = (double *)beta;
39+
CBLAS_INT n, i=0;
40+
const double *xx= (const double *)X, *alp= (const double *)alpha, *bet = (const double *)beta;
3941
double ALPHA[2],BETA[2];
4042
CBLAS_INT tincY, tincx;
41-
double *x=(double *)X, *y=(double *)Y, *st=0, *tx;
43+
double *x, *y, *st=0, *tx;
4244
extern int CBLAS_CallFromC;
4345
extern int RowMajorStrg;
4446
RowMajorStrg = 0;
4547

48+
memcpy(&x,&X,sizeof(double*));
49+
memcpy(&y,&Y,sizeof(double*));
50+
4651
CBLAS_CallFromC = 1;
4752
if (layout == CblasColMajor)
4853
{
@@ -125,7 +130,8 @@ void API_SUFFIX(cblas_zgbmv)(const CBLAS_LAYOUT layout,
125130
y -= n;
126131
}
127132
}
128-
else x = (double *) X;
133+
else
134+
memcpy(&x,&X,sizeof(double*));
129135

130136

131137
}

CBLAS/src/cblas_zgemv.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88
#include <stdio.h>
99
#include <stdlib.h>
10+
#include <string.h>
1011
#include "cblas.h"
1112
#include "cblas_f77.h"
1213
void API_SUFFIX(cblas_zgemv)(const CBLAS_LAYOUT layout,
@@ -24,22 +25,26 @@ void API_SUFFIX(cblas_zgemv)(const CBLAS_LAYOUT layout,
2425
#ifdef F77_INT
2526
F77_INT F77_M=M, F77_N=N, F77_lda=lda, F77_incX=incX, F77_incY=incY;
2627
#else
28+
CBLAS_INT incx = incX;
2729
#define F77_M M
2830
#define F77_N N
2931
#define F77_lda lda
3032
#define F77_incX incx
3133
#define F77_incY incY
3234
#endif
3335

34-
CBLAS_INT n, i=0, incx=incX;
35-
const double *xx= (double *)X, *alp= (double *)alpha, *bet = (double *)beta;
36+
CBLAS_INT n, i=0;
37+
const double *xx= (const double *)X, *alp= (const double *)alpha, *bet = (const double *)beta;
3638
double ALPHA[2],BETA[2];
3739
CBLAS_INT tincY, tincx;
38-
double *x=(double *)X, *y=(double *)Y, *st=0, *tx;
40+
double *x, *y, *st=0, *tx;
3941
extern int CBLAS_CallFromC;
4042
extern int RowMajorStrg;
4143
RowMajorStrg = 0;
4244

45+
memcpy(&x,&X,sizeof(double*));
46+
memcpy(&y,&Y,sizeof(double*));
47+
4348
CBLAS_CallFromC = 1;
4449

4550
if (layout == CblasColMajor)
@@ -124,7 +129,8 @@ void API_SUFFIX(cblas_zgemv)(const CBLAS_LAYOUT layout,
124129
y -= n;
125130
}
126131
}
127-
else x = (double *) X;
132+
else
133+
memcpy(&x,&X,sizeof(double*));
128134
}
129135
else
130136
{
@@ -145,7 +151,7 @@ void API_SUFFIX(cblas_zgemv)(const CBLAS_LAYOUT layout,
145151

146152
if (TransA == CblasConjTrans)
147153
{
148-
if (x != (double *)X) free(x);
154+
if (x != X) free(x);
149155
if (N > 0)
150156
{
151157
do

CBLAS/src/cblas_zgerc.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
*/
88
#include <stdio.h>
99
#include <stdlib.h>
10+
#include <string.h>
11+
1012
#include "cblas.h"
1113
#include "cblas_f77.h"
1214
void API_SUFFIX(cblas_zgerc)(const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBLAS_INT N,
@@ -16,20 +18,24 @@ void API_SUFFIX(cblas_zgerc)(const CBLAS_LAYOUT layout, const CBLAS_INT M, const
1618
#ifdef F77_INT
1719
F77_INT F77_M=M, F77_N=N, F77_lda=lda, F77_incX=incX, F77_incY=incY;
1820
#else
21+
CBLAS_INT incy = incY;
1922
#define F77_M M
2023
#define F77_N N
2124
#define F77_incX incX
2225
#define F77_incY incy
2326
#define F77_lda lda
2427
#endif
2528

26-
CBLAS_INT n, i, tincy, incy=incY;
27-
double *y=(double *)Y, *yy=(double *)Y, *ty, *st;
29+
CBLAS_INT n, i, tincy;
30+
double *y, *yy, *ty, *st;
2831

2932
extern int CBLAS_CallFromC;
3033
extern int RowMajorStrg;
3134
RowMajorStrg = 0;
3235

36+
memcpy(&y,&Y,sizeof(double*));
37+
memcpy(&yy,&Y,sizeof(double*));
38+
3339
CBLAS_CallFromC = 1;
3440
if (layout == CblasColMajor)
3541
{
@@ -56,7 +62,7 @@ void API_SUFFIX(cblas_zgerc)(const CBLAS_LAYOUT layout, const CBLAS_INT M, const
5662
}
5763
do
5864
{
59-
*y = *yy;
65+
*y = (double) *yy;
6066
y[1] = -yy[1];
6167
y += tincy ;
6268
yy += i;
@@ -70,7 +76,8 @@ void API_SUFFIX(cblas_zgerc)(const CBLAS_LAYOUT layout, const CBLAS_INT M, const
7076
incy = 1;
7177
#endif
7278
}
73-
else y = (double *) Y;
79+
else
80+
memcpy(&y,&Y,sizeof(double*));
7481

7582
F77_zgeru( &F77_N, &F77_M, alpha, y, &F77_incY, X, &F77_incX, A,
7683
&F77_lda);

CBLAS/src/cblas_zhbmv.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include "cblas_f77.h"
1010
#include <stdio.h>
1111
#include <stdlib.h>
12+
#include <string.h>
13+
1214
void API_SUFFIX(cblas_zhbmv)(const CBLAS_LAYOUT layout,
1315
const CBLAS_UPLO Uplo,const CBLAS_INT N,const CBLAS_INT K,
1416
const void *alpha, const void *A, const CBLAS_INT lda,
@@ -24,21 +26,25 @@ void API_SUFFIX(cblas_zhbmv)(const CBLAS_LAYOUT layout,
2426
#ifdef F77_INT
2527
F77_INT F77_N=N, F77_K=K, F77_lda=lda, F77_incX=incX, F77_incY=incY;
2628
#else
29+
CBLAS_INT incx = incX;
2730
#define F77_N N
2831
#define F77_K K
2932
#define F77_lda lda
3033
#define F77_incX incx
3134
#define F77_incY incY
3235
#endif
33-
CBLAS_INT n, i=0, incx=incX;
34-
const double *xx= (double *)X, *alp= (double *)alpha, *bet = (double *)beta;
36+
CBLAS_INT n, i=0;
37+
const double *xx= (const double *)X, *alp= (const double *)alpha, *bet = (const double *)beta;
3538
double ALPHA[2],BETA[2];
3639
CBLAS_INT tincY, tincx;
37-
double *x=(double *)X, *y=(double *)Y, *st=0, *tx;
40+
double *x, *y, *st=0, *tx;
3841
extern int CBLAS_CallFromC;
3942
extern int RowMajorStrg;
4043
RowMajorStrg = 0;
4144

45+
memcpy(&x,&X,sizeof(double*));
46+
memcpy(&y,&Y,sizeof(double*));
47+
4248
CBLAS_CallFromC = 1;
4349
if (layout == CblasColMajor)
4450
{
@@ -114,7 +120,7 @@ void API_SUFFIX(cblas_zhbmv)(const CBLAS_LAYOUT layout,
114120
} while(y != st);
115121
y -= n;
116122
} else
117-
x = (double *) X;
123+
memcpy(&x,&X,sizeof(double*));
118124

119125
if (Uplo == CblasUpper) UL = 'L';
120126
else if (Uplo == CblasLower) UL = 'U';

CBLAS/src/cblas_zhemv.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88
#include <stdio.h>
99
#include <stdlib.h>
10+
#include <string.h>
1011
#include "cblas.h"
1112
#include "cblas_f77.h"
1213
void API_SUFFIX(cblas_zhemv)(const CBLAS_LAYOUT layout,
@@ -24,20 +25,23 @@ void API_SUFFIX(cblas_zhemv)(const CBLAS_LAYOUT layout,
2425
#ifdef F77_INT
2526
F77_INT F77_N=N, F77_lda=lda, F77_incX=incX, F77_incY=incY;
2627
#else
28+
CBLAS_INT incx = incX;
2729
#define F77_N N
2830
#define F77_lda lda
2931
#define F77_incX incx
3032
#define F77_incY incY
3133
#endif
32-
CBLAS_INT n, i=0, incx=incX;
33-
const double *xx= (double *)X, *alp= (double *)alpha, *bet = (double *)beta;
34+
CBLAS_INT n, i=0;
35+
const double *xx= (const double *)X, *alp= (const double *)alpha, *bet = (const double *)beta;
3436
double ALPHA[2],BETA[2];
3537
CBLAS_INT tincY, tincx;
36-
double *x=(double *)X, *y=(double *)Y, *st=0, *tx;
38+
double *x, *y, *st=0, *tx;
3739
extern int CBLAS_CallFromC;
3840
extern int RowMajorStrg;
3941
RowMajorStrg = 0;
4042

43+
memcpy(&x,&X,sizeof(double*));
44+
memcpy(&y,&Y,sizeof(double*));
4145

4246
CBLAS_CallFromC = 1;
4347
if (layout == CblasColMajor)
@@ -114,7 +118,8 @@ void API_SUFFIX(cblas_zhemv)(const CBLAS_LAYOUT layout,
114118
} while(y != st);
115119
y -= n;
116120
} else
117-
x = (double *) X;
121+
memcpy(&x,&X,sizeof(double*));
122+
118123

119124

120125
if (Uplo == CblasUpper) UL = 'L';

CBLAS/src/cblas_zher.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88
#include <stdio.h>
99
#include <stdlib.h>
10+
#include <string.h>
1011
#include "cblas.h"
1112
#include "cblas_f77.h"
1213
void API_SUFFIX(cblas_zher)(const CBLAS_LAYOUT layout, const CBLAS_UPLO Uplo,
@@ -23,17 +24,22 @@ void API_SUFFIX(cblas_zher)(const CBLAS_LAYOUT layout, const CBLAS_UPLO Uplo,
2324
#ifdef F77_INT
2425
F77_INT F77_N=N, F77_lda=lda, F77_incX=incX;
2526
#else
27+
CBLAS_INT incx = incX;
2628
#define F77_N N
2729
#define F77_lda lda
2830
#define F77_incX incx
2931
#endif
30-
CBLAS_INT n, i, tincx, incx=incX;
31-
double *x=(double *)X, *xx=(double *)X, *tx, *st;
32+
CBLAS_INT n, i, tincx;
33+
double *x, *xx, *tx, *st;
3234

3335
extern int CBLAS_CallFromC;
3436
extern int RowMajorStrg;
3537
RowMajorStrg = 0;
3638

39+
40+
memcpy(&x,&X,sizeof(double*));
41+
memcpy(&xx,&X,sizeof(double*));
42+
3743
CBLAS_CallFromC = 1;
3844
if (layout == CblasColMajor)
3945
{
@@ -98,7 +104,8 @@ void API_SUFFIX(cblas_zher)(const CBLAS_LAYOUT layout, const CBLAS_UPLO Uplo,
98104
incx = 1;
99105
#endif
100106
}
101-
else x = (double *) X;
107+
else
108+
memcpy(&x,&X,sizeof(double*));
102109
F77_zher(F77_UL, &F77_N, &alpha, x, &F77_incX, A, &F77_lda);
103110
} else API_SUFFIX(cblas_xerbla)(1, "cblas_zher", "Illegal layout setting, %d\n", layout);
104111
if(X!=x)

CBLAS/src/cblas_zher2.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88
#include <stdio.h>
99
#include <stdlib.h>
10+
#include <string.h>
1011
#include "cblas.h"
1112
#include "cblas_f77.h"
1213
void API_SUFFIX(cblas_zher2)(const CBLAS_LAYOUT layout, const CBLAS_UPLO Uplo,
@@ -23,19 +24,27 @@ void API_SUFFIX(cblas_zher2)(const CBLAS_LAYOUT layout, const CBLAS_UPLO Uplo,
2324
#ifdef F77_INT
2425
F77_INT F77_N=N, F77_lda=lda, F77_incX=incX, F77_incY=incY;
2526
#else
27+
CBLAS_INT incx = incX, incy = incY;
2628
#define F77_N N
2729
#define F77_lda lda
2830
#define F77_incX incx
2931
#define F77_incY incy
3032
#endif
31-
CBLAS_INT n, i, j, tincx, tincy, incx=incX, incy=incY;
32-
double *x=(double *)X, *xx=(double *)X, *y=(double *)Y,
33-
*yy=(double *)Y, *tx, *ty, *stx, *sty;
33+
CBLAS_INT n, i, j, tincx, tincy;
34+
double *x, *xx, *y,
35+
*yy, *tx, *ty, *stx, *sty;
3436

3537
extern int CBLAS_CallFromC;
3638
extern int RowMajorStrg;
3739
RowMajorStrg = 0;
3840

41+
42+
memcpy(&x,&X,sizeof(double*));
43+
memcpy(&xx,&X,sizeof(double*));
44+
memcpy(&y,&Y,sizeof(double*));
45+
memcpy(&yy,&Y,sizeof(double*));
46+
47+
3948
CBLAS_CallFromC = 1;
4049
if (layout == CblasColMajor)
4150
{
@@ -129,8 +138,9 @@ void API_SUFFIX(cblas_zher2)(const CBLAS_LAYOUT layout, const CBLAS_UPLO Uplo,
129138
#endif
130139
} else
131140
{
132-
x = (double *) X;
133-
y = (double *) Y;
141+
142+
memcpy(&x,&X,sizeof(double*));
143+
memcpy(&y,&Y,sizeof(double*));
134144
}
135145
F77_zher2(F77_UL, &F77_N, alpha, y, &F77_incY, x,
136146
&F77_incX, A, &F77_lda);

CBLAS/src/cblas_zhpmv.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
*/
88
#include <stdio.h>
99
#include <stdlib.h>
10+
#include <string.h>
11+
1012
#include "cblas.h"
1113
#include "cblas_f77.h"
1214
void API_SUFFIX(cblas_zhpmv)(const CBLAS_LAYOUT layout,
@@ -24,19 +26,23 @@ void API_SUFFIX(cblas_zhpmv)(const CBLAS_LAYOUT layout,
2426
#ifdef F77_INT
2527
F77_INT F77_N=N, F77_incX=incX, F77_incY=incY;
2628
#else
29+
CBLAS_INT incx = incX;
2730
#define F77_N N
2831
#define F77_incX incx
2932
#define F77_incY incY
3033
#endif
31-
CBLAS_INT n, i=0, incx=incX;
32-
const double *xx= (double *)X, *alp= (double *)alpha, *bet = (double *)beta;
34+
CBLAS_INT n, i=0;
35+
const double *xx= (const double *)X, *alp= (const double *)alpha, *bet = (const double *)beta;
3336
double ALPHA[2],BETA[2];
3437
CBLAS_INT tincY, tincx;
35-
double *x=(double *)X, *y=(double *)Y, *st=0, *tx;
38+
double *x, *y, *st=0, *tx;
3639
extern int CBLAS_CallFromC;
3740
extern int RowMajorStrg;
3841
RowMajorStrg = 0;
3942

43+
memcpy(&x,&X,sizeof(double*));
44+
memcpy(&y,&Y,sizeof(double*));
45+
4046
CBLAS_CallFromC = 1;
4147
if (layout == CblasColMajor)
4248
{
@@ -112,8 +118,7 @@ void API_SUFFIX(cblas_zhpmv)(const CBLAS_LAYOUT layout,
112118
} while(y != st);
113119
y -= n;
114120
} else
115-
x = (double *) X;
116-
121+
memcpy(&x,&X,sizeof(double*));
117122

118123
if (Uplo == CblasUpper) UL = 'L';
119124
else if (Uplo == CblasLower) UL = 'U';

0 commit comments

Comments
 (0)