1 /*********************************************************************/
2 /* Copyright 2009, 2010 The University of Texas at Austin. */
3 /* All rights reserved. */
4 /* */
5 /* Redistribution and use in source and binary forms, with or */
6 /* without modification, are permitted provided that the following */
7 /* conditions are met: */
8 /* */
9 /* 1. Redistributions of source code must retain the above */
10 /* copyright notice, this list of conditions and the following */
11 /* disclaimer. */
12 /* */
13 /* 2. Redistributions in binary form must reproduce the above */
14 /* copyright notice, this list of conditions and the following */
15 /* disclaimer in the documentation and/or other materials */
16 /* provided with the distribution. */
17 /* */
18 /* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
19 /* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
20 /* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
21 /* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
23 /* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
24 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
25 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
26 /* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
27 /* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
28 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
29 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
30 /* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
31 /* POSSIBILITY OF SUCH DAMAGE. */
32 /* */
33 /* The views and conclusions contained in the software and */
34 /* documentation are those of the authors and should not be */
35 /* interpreted as representing official policies, either expressed */
36 /* or implied, of The University of Texas at Austin. */
37 /*********************************************************************/
38
39 #include <stdio.h>
40 #include "common.h"
41 #ifdef FUNCTION_PROFILE
42 #include "functable.h"
43 #endif
44
45 #ifdef RETURN_BY_STRUCT
46 #ifdef XDOUBLE
47 #define MYTYPE myxcomplex_t
48 #elif defined DOUBLE
49 #define MYTYPE myzcomplex_t
50 #else
51 #define MYTYPE myccomplex_t
52 #endif
53 #endif
54
55 #ifndef CBLAS
56
57 #ifdef RETURN_BY_STRUCT
NAME(blasint * N,FLOAT * x,blasint * INCX,FLOAT * y,blasint * INCY)58 MYTYPE NAME( blasint *N, FLOAT *x, blasint *INCX, FLOAT *y, blasint *INCY) {
59 #elif defined RETURN_BY_STACK
60 void NAME(FLOAT _Complex *result, blasint *N, FLOAT *x, blasint *INCX, FLOAT *y, blasint *INCY) {
61 #else
62 FLOAT _Complex NAME( blasint *N, FLOAT *x, blasint *INCX, FLOAT *y, blasint *INCY) {
63 #endif
64
65 BLASLONG n = *N;
66 BLASLONG incx = *INCX;
67 BLASLONG incy = *INCY;
68 #ifndef RETURN_BY_STACK
69 FLOAT _Complex ret;
70 #endif
71 #ifdef RETURN_BY_STRUCT
72 MYTYPE myret;
73 #endif
74
75 PRINT_DEBUG_NAME;
76
77 if (n <= 0) {
78 #ifdef RETURN_BY_STRUCT
79 myret.r = 0.;
80 myret.i = 0.;
81 return myret;
82 #elif defined RETURN_BY_STACK
83 *result = ZERO;
84 return;
85 #else
86 return ZERO;
87 #endif
88 }
89
90 IDEBUG_START;
91
92 FUNCTION_PROFILE_START();
93
94 if (incx < 0) x -= (n - 1) * incx * 2;
95 if (incy < 0) y -= (n - 1) * incy * 2;
96
97 #ifdef RETURN_BY_STRUCT
98
99 #ifndef CONJ
100 ret = DOTU_K(n, x, incx, y, incy);
101 #else
102 ret = DOTC_K(n, x, incx, y, incy);
103 #endif
104
105 myret.r = CREAL ret;
106 myret.i = CIMAG ret;
107
108 FUNCTION_PROFILE_END(4, 2 * n, 2 * n);
109
110 IDEBUG_END;
111
112 return myret;
113
114 #elif defined RETURN_BY_STACK
115
116 #ifndef CONJ
117 *result = DOTU_K(n, x, incx, y, incy);
118 #else
119 *result = DOTC_K(n, x, incx, y, incy);
120 #endif
121
122 FUNCTION_PROFILE_END(4, 2 * n, 2 * n);
123
124 IDEBUG_END;
125
126 #else
127
128 #ifndef CONJ
129 ret = DOTU_K(n, x, incx, y, incy);
130 #else
131 ret = DOTC_K(n, x, incx, y, incy);
132 #endif
133
134 FUNCTION_PROFILE_END(4, 2 * n, 2 * n);
135
136 IDEBUG_END;
137
138 return ret;
139
140 #endif
141
142 }
143
144 #else
145
146 #ifdef FORCE_USE_STACK
147 void CNAME(blasint n, FLOAT *x, blasint incx, FLOAT *y, blasint incy, FLOAT _Complex *result){
148 #else
149 FLOAT _Complex CNAME(blasint n, FLOAT *x, blasint incx, FLOAT *y, blasint incy){
150
151 FLOAT _Complex ret;
152 #endif
153
154 PRINT_DEBUG_CNAME;
155
156 if (n <= 0) {
157 #ifdef FORCE_USE_STACK
158 *result = ZERO;
159 return;
160 #else
161 return ZERO;
162 #endif
163 }
164
165 if (incx < 0) x -= (n - 1) * incx * 2;
166 if (incy < 0) y -= (n - 1) * incy * 2;
167
168 IDEBUG_START;
169
170 FUNCTION_PROFILE_START();
171
172 #ifdef FORCE_USE_STACK
173
174 #ifndef CONJ
175 *result = DOTU_K(n, x, incx, y, incy);
176 #else
177 *result = DOTC_K(n, x, incx, y, incy);
178 #endif
179
180 FUNCTION_PROFILE_END(4, 2 * n, 2 * n);
181
182 IDEBUG_END;
183
184 #else
185
186 #ifndef CONJ
187 ret = DOTU_K(n, x, incx, y, incy);
188 #else
189 ret = DOTC_K(n, x, incx, y, incy);
190 #endif
191
192 FUNCTION_PROFILE_END(4, 2 * n, 2 * n);
193
194 IDEBUG_END;
195
196 return ret;
197
198 #endif
199
200 }
201
202 #endif
203