Skip to content

Commit dbc45f7

Browse files
Fix const qualifier for float complex routines
1 parent 72df25b commit dbc45f7

12 files changed

+106
-41
lines changed

CBLAS/src/cblas_cgbmv.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_cgbmv)(const CBLAS_LAYOUT layout,
@@ -26,6 +28,7 @@ void API_SUFFIX(cblas_cgbmv)(const CBLAS_LAYOUT layout,
2628
F77_INT F77_M=M, F77_N=N, F77_lda=lda, F77_incX=incX, F77_incY=incY;
2729
F77_INT F77_KL=KL,F77_KU=KU;
2830
#else
31+
CBLAS_INT incx=incX;
2932
#define F77_M M
3033
#define F77_N N
3134
#define F77_lda lda
@@ -34,15 +37,19 @@ void API_SUFFIX(cblas_cgbmv)(const CBLAS_LAYOUT layout,
3437
#define F77_incX incx
3538
#define F77_incY incY
3639
#endif
37-
CBLAS_INT n=0, i=0, incx=incX;
38-
const float *xx= (float *)X, *alp= (float *)alpha, *bet = (float *)beta;
40+
CBLAS_INT n=0, i=0;
41+
const float *xx= (const float *)X, *alp= (const float *)alpha, *bet = (const float *)beta;
3942
float ALPHA[2],BETA[2];
4043
CBLAS_INT tincY, tincx;
41-
float *x=(float *)X, *y=(float *)Y, *st=0, *tx=0;
44+
float *x, *y, *st=0, *tx=0;
4245
extern int CBLAS_CallFromC;
4346
extern int RowMajorStrg;
4447
RowMajorStrg = 0;
4548

49+
memcpy(&x, &X, sizeof(float*));
50+
memcpy(&y, &Y, sizeof(float*));
51+
52+
4653
CBLAS_CallFromC = 1;
4754
if (layout == CblasColMajor)
4855
{
@@ -125,7 +132,7 @@ void API_SUFFIX(cblas_cgbmv)(const CBLAS_LAYOUT layout,
125132
y -= n;
126133
}
127134
}
128-
else x = (float *) X;
135+
else memcpy(&x, &X, sizeof(float*));
129136

130137

131138
}

CBLAS/src/cblas_cgemv.c

Lines changed: 8 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_cgemv)(const CBLAS_LAYOUT layout,
@@ -31,18 +32,22 @@ void API_SUFFIX(cblas_cgemv)(const CBLAS_LAYOUT layout,
3132
#define F77_incY incY
3233
#endif
3334

34-
CBLAS_INT n=0, i=0, incx=incX;
35+
CBLAS_INT n=0, i=0;
3536
const float *xx= (const float *)X;
3637
float ALPHA[2],BETA[2];
3738
CBLAS_INT tincY, tincx;
38-
float *x=(float *)X, *y=(float *)Y, *st=0, *tx=0;
39-
const float *stx = x;
39+
float *x, *y, *st=0, *tx=0;
4040
extern int CBLAS_CallFromC;
4141
extern int RowMajorStrg;
4242
RowMajorStrg = 0;
4343

4444
CBLAS_CallFromC = 1;
4545

46+
memcpy(&x, &X, sizeof(float *));
47+
memcpy(&y, &Y, sizeof(float *));
48+
49+
const float *stx = x;
50+
4651
if (layout == CblasColMajor)
4752
{
4853
if (TransA == CblasNoTrans) TA = 'N';

CBLAS/src/cblas_cgerc.c

Lines changed: 9 additions & 3 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_cgerc)(const CBLAS_LAYOUT layout, const CBLAS_INT M, const CBLAS_INT N,
@@ -16,15 +18,18 @@ void API_SUFFIX(cblas_cgerc)(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-
float *y=(float *)Y, *yy=(float *)Y, *ty, *st;
29+
CBLAS_INT n, i, tincy;
30+
float *y, *yy, *ty, *st;
31+
memcpy(&y,&Y,sizeof(float*));
32+
memcpy(&yy,&Y,sizeof(float*));
2833

2934
extern int CBLAS_CallFromC;
3035
extern int RowMajorStrg;
@@ -70,7 +75,8 @@ void API_SUFFIX(cblas_cgerc)(const CBLAS_LAYOUT layout, const CBLAS_INT M, const
7075
incy = 1;
7176
#endif
7277
}
73-
else y = (float *) Y;
78+
else
79+
memcpy(&y,&Y,sizeof(float*));
7480

7581
F77_cgeru( &F77_N, &F77_M, alpha, y, &F77_incY, X, &F77_incX, A,
7682
&F77_lda);

CBLAS/src/cblas_chbmv.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "cblas_f77.h"
1010
#include <stdio.h>
1111
#include <stdlib.h>
12+
#include <string.h>
1213
void API_SUFFIX(cblas_chbmv)(const CBLAS_LAYOUT layout,
1314
const CBLAS_UPLO Uplo,const CBLAS_INT N,const CBLAS_INT K,
1415
const void *alpha, const void *A, const CBLAS_INT lda,
@@ -24,21 +25,25 @@ void API_SUFFIX(cblas_chbmv)(const CBLAS_LAYOUT layout,
2425
#ifdef F77_INT
2526
F77_INT F77_N=N, F77_K=K, F77_lda=lda, F77_incX=incX, F77_incY=incY;
2627
#else
28+
CBLAS_INT incx = incX;
2729
#define F77_N N
2830
#define F77_K K
2931
#define F77_lda lda
3032
#define F77_incX incx
3133
#define F77_incY incY
3234
#endif
33-
CBLAS_INT n, i=0, incx=incX;
34-
const float *xx= (float *)X, *alp= (float *)alpha, *bet = (float *)beta;
35+
CBLAS_INT n, i=0;
36+
const float *xx= (const float *)X, *alp= (const float *)alpha, *bet = (const float *)beta;
3537
float ALPHA[2],BETA[2];
3638
CBLAS_INT tincY, tincx;
37-
float *x=(float *)X, *y=(float *)Y, *st=0, *tx;
39+
float *x, *y, *st=0, *tx;
3840
extern int CBLAS_CallFromC;
3941
extern int RowMajorStrg;
4042
RowMajorStrg = 0;
4143

44+
memcpy(&x, &X, sizeof(float*));
45+
memcpy(&y, &Y, sizeof(float*));
46+
4247
CBLAS_CallFromC = 1;
4348
if (layout == CblasColMajor)
4449
{
@@ -114,7 +119,7 @@ void API_SUFFIX(cblas_chbmv)(const CBLAS_LAYOUT layout,
114119
} while(y != st);
115120
y -= n;
116121
} else
117-
x = (float *) X;
122+
memcpy(&x, &X, sizeof(float*));
118123

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

CBLAS/src/cblas_chemv.c

Lines changed: 10 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_chemv)(const CBLAS_LAYOUT layout,
@@ -24,20 +26,24 @@ void API_SUFFIX(cblas_chemv)(const CBLAS_LAYOUT layout,
2426
#ifdef F77_INT
2527
F77_INT F77_N=N, F77_lda=lda, F77_incX=incX, F77_incY=incY;
2628
#else
29+
CBLAS_INT incx = incX;
2730
#define F77_N N
2831
#define F77_lda lda
2932
#define F77_incX incx
3033
#define F77_incY incY
3134
#endif
32-
CBLAS_INT n=0, i=0, incx=incX;
33-
const float *xx= (float *)X, *alp= (float *)alpha, *bet = (float *)beta;
35+
CBLAS_INT n=0, i=0;
36+
const float *xx= (const float *)X, *alp= (const float *)alpha, *bet = (const float *)beta;
3437
float ALPHA[2],BETA[2];
3538
CBLAS_INT tincY, tincx;
36-
float *x=(float *)X, *y=(float *)Y, *st=0, *tx;
39+
float *x, *y, *st=0, *tx;
3740
extern int CBLAS_CallFromC;
3841
extern int RowMajorStrg;
3942
RowMajorStrg = 0;
4043

44+
memcpy(&x, &X, sizeof(float*));
45+
memcpy(&y, &Y, sizeof(float*));
46+
4147

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

119125

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

CBLAS/src/cblas_cher.c

Lines changed: 11 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_cher)(const CBLAS_LAYOUT layout, const CBLAS_UPLO Uplo,
@@ -23,17 +24,22 @@ void API_SUFFIX(cblas_cher)(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;
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-
float *x=(float *)X, *xx=(float *)X, *tx, *st;
32+
CBLAS_INT n, i, tincx;
33+
float *x, *xx, *tx, *st;
3234

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

39+
memcpy(&x,&X,sizeof(float*));
40+
memcpy(&xx,&X,sizeof(float*));
41+
42+
3743
CBLAS_CallFromC = 1;
3844
if (layout == CblasColMajor)
3945
{
@@ -98,7 +104,9 @@ void API_SUFFIX(cblas_cher)(const CBLAS_LAYOUT layout, const CBLAS_UPLO Uplo,
98104
incx = 1;
99105
#endif
100106
}
101-
else x = (float *) X;
107+
else
108+
memcpy(&x,&X,sizeof(float*));
109+
102110
F77_cher(F77_UL, &F77_N, &alpha, x, &F77_incX, A, &F77_lda);
103111
} else
104112
{

CBLAS/src/cblas_cher2.c

Lines changed: 12 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_cher2)(const CBLAS_LAYOUT layout, const CBLAS_UPLO Uplo,
@@ -23,19 +24,25 @@ void API_SUFFIX(cblas_cher2)(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-
float *x=(float *)X, *xx=(float *)X, *y=(float *)Y,
33-
*yy=(float *)Y, *tx, *ty, *stx, *sty;
33+
CBLAS_INT n, i, j, tincx, tincy;
34+
float *x, *xx, *y,
35+
*yy, *tx, *ty, *stx, *sty;
3436

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

41+
memcpy(&x,&X,sizeof(float*));
42+
memcpy(&xx,&X,sizeof(float*));
43+
memcpy(&y,&Y,sizeof(float*));
44+
memcpy(&yy,&Y,sizeof(float*));
45+
3946
CBLAS_CallFromC = 1;
4047
if (layout == CblasColMajor)
4148
{
@@ -129,8 +136,8 @@ void API_SUFFIX(cblas_cher2)(const CBLAS_LAYOUT layout, const CBLAS_UPLO Uplo,
129136
#endif
130137
} else
131138
{
132-
x = (float *) X;
133-
y = (float *) Y;
139+
memcpy(&x,&X,sizeof(float*));
140+
memcpy(&y,&Y,sizeof(float*));
134141
}
135142
F77_cher2(F77_UL, &F77_N, alpha, y, &F77_incY, x,
136143
&F77_incX, A, &F77_lda);

CBLAS/src/cblas_cher2k.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void API_SUFFIX(cblas_cher2k)(const CBLAS_LAYOUT layout, const CBLAS_UPLO Uplo,
3737
extern int CBLAS_CallFromC;
3838
extern int RowMajorStrg;
3939
float ALPHA[2];
40-
const float *alp=(float *)alpha;
40+
const float *alp=(const float *)alpha;
4141

4242
CBLAS_CallFromC = 1;
4343
RowMajorStrg = 0;

CBLAS/src/cblas_chpmv.c

Lines changed: 11 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_chpmv)(const CBLAS_LAYOUT layout,
@@ -24,19 +26,24 @@ void API_SUFFIX(cblas_chpmv)(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 float *xx= (float *)X, *alp= (float *)alpha, *bet = (float *)beta;
34+
CBLAS_INT n, i=0;
35+
const float *xx= (const float *)X, *alp= (const float *)alpha, *bet = (const float *)beta;
3336
float ALPHA[2],BETA[2];
3437
CBLAS_INT tincY, tincx;
35-
float *x=(float *)X, *y=(float *)Y, *st=0, *tx;
38+
float *x, *y, *st=0, *tx;
3639
extern int CBLAS_CallFromC;
3740
extern int RowMajorStrg;
3841
RowMajorStrg = 0;
3942

43+
memcpy(&x,&X,sizeof(float*));
44+
memcpy(&y,&Y,sizeof(float*));
45+
46+
4047
CBLAS_CallFromC = 1;
4148
if (layout == CblasColMajor)
4249
{
@@ -112,8 +119,7 @@ void API_SUFFIX(cblas_chpmv)(const CBLAS_LAYOUT layout,
112119
} while(y != st);
113120
y -= n;
114121
} else
115-
x = (float *) X;
116-
122+
memcpy(&x,&X,sizeof(float*));
117123

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

0 commit comments

Comments
 (0)