LAPACK
3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
cblas_chpr2.c
Go to the documentation of this file.
1
/*
2
* cblas_chpr2.c
3
* The program is a C interface to chpr2.
4
*
5
* Keita Teranishi 5/20/98
6
*
7
*/
8
#include <stdio.h>
9
#include <stdlib.h>
10
#include "
cblas.h
"
11
#include "
cblas_f77.h
"
12
void
API_SUFFIX
(
cblas_chpr2
)(
const
CBLAS_LAYOUT
layout,
const
CBLAS_UPLO
Uplo,
13
const
CBLAS_INT
N,
const
void
*alpha,
const
void
*X,
14
const
CBLAS_INT
incX,
const
void
*Y,
const
CBLAS_INT
incY,
void
*Ap)
15
16
{
17
char
UL;
18
#ifdef F77_CHAR
19
F77_CHAR
F77_UL
;
20
#else
21
#define F77_UL &UL
22
#endif
23
24
#ifdef F77_INT
25
F77_INT
F77_N
=N,
F77_incX
=incX,
F77_incY
=incY;
26
#else
27
#define F77_N N
28
#define F77_incX incx
29
#define F77_incY incy
30
#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;
34
35
extern
int
CBLAS_CallFromC
;
36
extern
int
RowMajorStrg
;
37
RowMajorStrg
= 0;
38
39
CBLAS_CallFromC
= 1;
40
if
(layout ==
CblasColMajor
)
41
{
42
if
(Uplo ==
CblasLower
) UL =
'L'
;
43
else
if
(Uplo ==
CblasUpper
) UL =
'U'
;
44
else
45
{
46
API_SUFFIX
(
cblas_xerbla
)(2,
"cblas_chpr2"
,
"Illegal Uplo setting, %d\n"
,Uplo );
47
CBLAS_CallFromC
= 0;
48
RowMajorStrg
= 0;
49
return
;
50
}
51
#ifdef F77_CHAR
52
F77_UL
= C2F_CHAR(&UL);
53
#endif
54
55
F77_chpr2
(
F77_UL
, &
F77_N
, alpha, X, &
F77_incX
, Y, &
F77_incY
, Ap);
56
57
}
else
if
(layout ==
CblasRowMajor
)
58
{
59
RowMajorStrg
= 1;
60
if
(Uplo ==
CblasUpper
) UL =
'L'
;
61
else
if
(Uplo ==
CblasLower
) UL =
'U'
;
62
else
63
{
64
API_SUFFIX
(
cblas_xerbla
)(2,
"cblas_chpr2"
,
"Illegal Uplo setting, %d\n"
, Uplo);
65
CBLAS_CallFromC
= 0;
66
RowMajorStrg
= 0;
67
return
;
68
}
69
#ifdef F77_CHAR
70
F77_UL
= C2F_CHAR(&UL);
71
#endif
72
if
(N > 0)
73
{
74
n = N << 1;
75
x = malloc(n*
sizeof
(
float
));
76
y = malloc(n*
sizeof
(
float
));
77
tx = x;
78
ty = y;
79
if
( incX > 0 ) {
80
i = incX << 1 ;
81
tincx = 2;
82
stx= x+n;
83
}
else
{
84
i = incX *(-2);
85
tincx = -2;
86
stx = x-2;
87
x +=(n-2);
88
}
89
90
if
( incY > 0 ) {
91
j = incY << 1;
92
tincy = 2;
93
sty= y+n;
94
}
else
{
95
j = incY *(-2);
96
tincy = -2;
97
sty = y-2;
98
y +=(n-2);
99
}
100
101
do
102
{
103
*x = *xx;
104
x[1] = -xx[1];
105
x += tincx ;
106
xx += i;
107
}
108
while
(x != stx);
109
do
110
{
111
*y = *yy;
112
y[1] = -yy[1];
113
y += tincy ;
114
yy += j;
115
}
116
while
(y != sty);
117
118
x=tx;
119
y=ty;
120
121
#ifdef F77_INT
122
F77_incX
= 1;
123
F77_incY
= 1;
124
#else
125
incx = 1;
126
incy = 1;
127
#endif
128
129
}
else
130
{
131
x = (
float
*) X;
132
y = (
void
*) Y;
133
}
134
F77_chpr2
(
F77_UL
, &
F77_N
, alpha, y, &
F77_incY
, x, &
F77_incX
, Ap);
135
}
else
136
{
137
API_SUFFIX
(
cblas_xerbla
)(1,
"cblas_chpr2"
,
"Illegal layout setting, %d\n"
, layout);
138
CBLAS_CallFromC
= 0;
139
RowMajorStrg
= 0;
140
return
;
141
}
142
if
(X!=x)
143
free(x);
144
if
(Y!=y)
145
free(y);
146
CBLAS_CallFromC
= 0;
147
RowMajorStrg
= 0;
148
return
;
149
}
CBLAS_UPLO
CBLAS_UPLO
Definition
cblas.h:41
CblasLower
@ CblasLower
Definition
cblas.h:41
CblasUpper
@ CblasUpper
Definition
cblas.h:41
cblas_xerbla
void cblas_xerbla(CBLAS_INT p, const char *rout, const char *form,...)
Definition
cblas_xerbla.c:12
CBLAS_LAYOUT
CBLAS_LAYOUT
Definition
cblas.h:39
CblasColMajor
@ CblasColMajor
Definition
cblas.h:39
CblasRowMajor
@ CblasRowMajor
Definition
cblas.h:39
API_SUFFIX
#define API_SUFFIX(a)
Definition
cblas.h:57
CBLAS_INT
#define CBLAS_INT
Definition
cblas.h:24
cblas.h
F77_incX
#define F77_incX
F77_incY
#define F77_incY
F77_N
#define F77_N
F77_UL
#define F77_UL
cblas_chpr2
void API_SUFFIX cblas_chpr2(const CBLAS_LAYOUT layout, const CBLAS_UPLO Uplo, const CBLAS_INT N, const void *alpha, const void *X, const CBLAS_INT incX, const void *Y, const CBLAS_INT incY, void *Ap)
Definition
cblas_chpr2.c:12
F77_INT
#define F77_INT
Definition
cblas_example2_64.c:4
F77_chpr2
#define F77_chpr2(...)
Definition
cblas_f77.h:369
cblas_f77.h
CBLAS_CallFromC
int CBLAS_CallFromC
Definition
cblas_globals.c:1
RowMajorStrg
int RowMajorStrg
Definition
cblas_globals.c:2
CBLAS
src
cblas_chpr2.c
Generated on Mon Jan 20 2025 17:18:06 for LAPACK by
1.11.0