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 <ctype.h>
41 #include "common.h"
42 
CNAME(BLASLONG m,FLOAT * a,FLOAT * b,BLASLONG incb,void * buffer)43 int CNAME(BLASLONG m, FLOAT *a, FLOAT *b, BLASLONG incb, void *buffer){
44 
45   BLASLONG i;
46 #if (TRANSA == 2) || (TRANSA == 4)
47   FLOAT _Complex temp;
48 #endif
49 #ifndef UNIT
50   FLOAT atemp1, atemp2, btemp1, btemp2;
51 #endif
52   FLOAT *gemvbuffer = (FLOAT *)buffer;
53   FLOAT *B = b;
54 
55   if (incb != 1) {
56     B = buffer;
57     gemvbuffer = (FLOAT *)(((BLASLONG)buffer + m * sizeof(FLOAT) * 2 + 4095) & ~4095);
58     COPY_K(m, b, incb, buffer, 1);
59   }
60 
61     for (i = 0; i < m; i++) {
62 
63 #if (TRANSA == 1) || (TRANSA == 3)
64 #if   TRANSA == 1
65       if (i > 0) AXPYU_K (i, 0, 0, B[i * 2 + 0],  B[i * 2 + 1],
66       			  a, 1, B, 1, NULL, 0);
67 #else
68       if (i > 0) AXPYC_K(i, 0, 0, B[i * 2 + 0],  B[i * 2 + 1],
69 			  a, 1, B, 1, NULL, 0);
70 #endif
71 #endif
72 
73 #ifndef UNIT
74 #if (TRANSA == 1) || (TRANSA == 3)
75       atemp1 = a[i * 2 + 0];
76       atemp2 = a[i * 2 + 1];
77 #else
78       atemp1 = a[0];
79       atemp2 = a[1];
80 #endif
81 
82       btemp1 = B[i * 2 + 0];
83       btemp2 = B[i * 2 + 1];
84 
85 #if (TRANSA == 1) || (TRANSA == 2)
86       B[i * 2 + 0] = atemp1 * btemp1 - atemp2 * btemp2;
87       B[i * 2 + 1] = atemp1 * btemp2 + atemp2 * btemp1;
88 #else
89       B[i * 2 + 0] = atemp1 * btemp1 + atemp2 * btemp2;
90       B[i * 2 + 1] = atemp1 * btemp2 - atemp2 * btemp1;
91 #endif
92 #endif
93 
94 #if (TRANSA == 2) || (TRANSA == 4)
95       if (i < m - 1) {
96 #if TRANSA == 2
97 	temp = DOTU_K(m - i - 1,
98 			  a + 2, 1,
99 			  B + (i + 1) * 2, 1);
100 #else
101 	temp = DOTC_K(m - i - 1,
102 			  a + 2, 1,
103 			  B + (i + 1) * 2, 1);
104 #endif
105 
106       B[i * 2 + 0] += CREAL(temp);
107       B[i * 2 + 1] += CIMAG(temp);
108       }
109 #endif
110 
111 #if (TRANSA == 1) || (TRANSA == 3)
112     a += (i + 1) * 2;
113 #else
114     a += (m - i) * 2;
115 #endif
116     }
117 
118   if (incb != 1) {
119     COPY_K(m, buffer, 1, b, incb);
120   }
121 
122   return 0;
123 }
124 
125