-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathCMRVecBlass.cpp
152 lines (124 loc) · 4.2 KB
/
CMRVecBlass.cpp
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#include "CMRVecBlass.h"
namespace Daetk
{
extern "C"
{
#ifndef CRAYCC
void F77NAME(srot)(const int * N, float* X, const int* INCX, float* Y,const int* INCY, float* C,
float* S);
void F77NAME(sswap)(const int* N, float* X, const int* INCX, float* Y, const int* INCY);
void F77NAME(sscal)(const int* N, const float* ALPHA, float* X, const int* INCX);
void F77NAME(scopy)(const int* N,const float* X, const int* INCX, float* Y, const int* INCY);
void F77NAME(saxpy)(const int* N, const float* ALPHA, const float* X, const int* INCX, float* Y,
const int* INCY);
float F77NAME(sdot)(const int* N, const float* X, const int* INCX, const float* Y, const int* INCY);
float F77NAME(snrm2)(const int* N, const float* X, const int* INCX);
float F77NAME(sasum)(const int* N, const float* X, const int* INCX);
int F77NAME(isamax)(const int* N, const float* X, const int* INCX);
#else
void F77NAME(SROT)(const int * N, float* X, const int* INCX, float* Y,const int* INCY, float* C,
float* S);
void F77NAME(SSWAP)(const int* N, float* X, const int* INCX, float* Y, const int* INCY);
void F77NAME(SSCAL)(const int* N, const float* ALPHA, float* X, const int* INCX);
void F77NAME(SCOPY)(const int* N,const float* X, const int* INCX, float* Y, const int* INCY);
void F77NAME(SAXPY)(const int* N, const float* ALPHA, const float* X, const int* INCX, float* Y,
const int* INCY);
float F77NAME(SDOT)(const int* N, const float* X, const int* INCX, const float* Y, const int* INCY);
float F77NAME(SNRM2)(const int* N, const float* X, const int* INCX);
float F77NAME(SASUM)(const int* N, const float* X, const int* INCX);
int F77NAME(ISAMAX)(const int* N, const float* X, const int* INCX);
#endif
}
void rot(CMRVecs& X, CMRVecs& Y, float& C, float& S)
{
int dim(X.dim()),xstride(X.stride()),ystride(Y.stride());
float *x(X.castToArray()),*y(Y.castToArray());
#ifndef CRAYCC
F77NAME(srot)(&dim,x,&xstride,y,&ystride,&C,&S);
#else
F77NAME(SROT)(&dim,x,&xstride,y,&ystride,&C,&S);
#endif
}
void swap(CMRVecs& X, CMRVecs& Y)
{
int dim(X.dim()),xstride(X.stride()),ystride(Y.stride());
float *x(X.castToArray()),*y(Y.castToArray());
#ifndef CRAYCC
F77NAME(sswap)(&dim,x, &xstride,y,&ystride);
#else
F77NAME(SSWAP)(&dim,x, &xstride,y,&ystride);
#endif
}
void scal(const float& ALPHA, CMRVecs& X)
{
int dim(X.dim()),xstride(X.stride());
float *x(X.castToArray()),alpha(ALPHA);
#ifndef CRAYCC
F77NAME(sscal)(&dim, &alpha, x, &xstride);
#else
F77NAME(SSCAL)(&dim, &alpha, x, &xstride);
#endif
}
void copy(const CMRVecs& X, CMRVecs& Y)
{
int dim(X.dim()),xstride(X.stride()),ystride(Y.stride());
const float *x(X.castToConstArray());
float *y(Y.castToArray());
#ifndef CRAYCC
F77NAME(scopy)(&dim,x, &xstride,y, &ystride);
#else
F77NAME(SCOPY)(&dim,x, &xstride,y, &ystride);
#endif
}
void axpy(const float& ALPHA, const CMRVecs& X, CMRVecs& Y)
{
int dim(X.dim()),xstride(X.stride()),ystride(Y.stride());
const float *x(X.castToConstArray()),alpha(ALPHA);
float *y(Y.castToArray());
#ifndef CRAYCC
F77NAME(saxpy)(&dim, &alpha, x, &xstride, y, &ystride);
#else
F77NAME(SAXPY)(&dim, &alpha, x, &xstride, y, &ystride);
#endif
}
float dot(const CMRVecs& X,const CMRVecs& Y)
{
int dim(X.dim()),xstride(X.stride()),ystride(Y.stride());
const float *x(X.castToConstArray()),*y(Y.castToConstArray());
#ifndef CRAYCC
return F77NAME(sdot)(&dim, x, &xstride, y, &ystride);
#else
return F77NAME(SDOT)(&dim, x, &xstride, y, &ystride);
#endif
}
float nrm2(const CMRVecs& X)
{
int dim(X.dim()),xstride(X.stride());
const float *x(X.castToConstArray());
#ifndef CRAYCC
return F77NAME(snrm2)(&dim,x,&xstride);
#else
return F77NAME(SNRM2)(&dim,x,&xstride);
#endif
}
float sum(const CMRVecs& X)
{
int dim(X.dim()),xstride(X.stride());
const float *x(X.castToConstArray());
#ifndef CRAYCC
return F77NAME(sasum)(&dim, x, &xstride);
#else
return F77NAME(SASUM)(&dim, x, &xstride);
#endif
}
int imax(const CMRVecs& X)
{
int dim(X.dim()),xstride(X.stride());
const float *x(X.castToConstArray());
#ifndef CRAYCC
return F77NAME(isamax)(&dim, x, &xstride) - 1 - X.base();
#else
return F77NAME(ISAMAX)(&dim, x, &xstride) - 1 - X.base();
#endif
}
}//Daetk