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 <stdlib.h>
41 #include <ctype.h>
42 #include "common.h"
43
CNAME(BLASLONG m,BLASLONG n,BLASLONG dummy1,FLOAT beta_r,FLOAT beta_i,FLOAT * dummy2,BLASLONG dummy3,FLOAT * dummy4,BLASLONG dummy5,FLOAT * c,BLASLONG ldc)44 int CNAME(BLASLONG m, BLASLONG n, BLASLONG dummy1,
45 FLOAT beta_r, FLOAT beta_i,
46 FLOAT *dummy2, BLASLONG dummy3,
47 FLOAT *dummy4, BLASLONG dummy5,
48 FLOAT *c, BLASLONG ldc){
49 BLASLONG i, j;
50
51 FLOAT *c_offset, *c_offset1;
52 FLOAT atemp1, atemp2, atemp3, atemp4;
53 FLOAT btemp1, btemp2, btemp3, btemp4;
54 FLOAT ctemp1, ctemp2, ctemp3, ctemp4;
55
56 ldc *= 2;
57
58 c_offset = c;
59
60 if (beta_r == 0. && beta_i == 0.) {
61 j = n;
62 do {
63 c_offset1 = c_offset;
64 c_offset += ldc;
65
66 i = (m >> 2);
67 if (i > 0){
68 do {
69 *(c_offset1 + 0) = ZERO;
70 *(c_offset1 + 1) = ZERO;
71 *(c_offset1 + 2) = ZERO;
72 *(c_offset1 + 3) = ZERO;
73 *(c_offset1 + 4) = ZERO;
74 *(c_offset1 + 5) = ZERO;
75 *(c_offset1 + 6) = ZERO;
76 *(c_offset1 + 7) = ZERO;
77 c_offset1 += 8;
78 i--;
79 } while (i > 0);
80 }
81
82 i = (m & 3);
83 if (i > 0){
84 do {
85 *(c_offset1 + 0) = ZERO;
86 *(c_offset1 + 1) = ZERO;
87 c_offset1 += 2;
88 i--;
89 } while (i > 0);
90 }
91 j --;
92 } while (j > 0);
93
94 } else {
95
96 j = n;
97 do {
98 c_offset1 = c_offset;
99 c_offset += ldc;
100
101 i = (m >> 1);
102 if (i > 0){
103 do {
104 atemp1 = *(c_offset1 + 0);
105 atemp2 = *(c_offset1 + 1);
106 atemp3 = *(c_offset1 + 2);
107 atemp4 = *(c_offset1 + 3);
108
109 btemp1 = beta_r * atemp1;
110 btemp2 = beta_i * atemp2;
111 btemp3 = beta_r * atemp2;
112 btemp4 = beta_i * atemp1;
113
114 ctemp1 = btemp1 - btemp2;
115 ctemp2 = btemp3 + btemp4;
116
117 btemp1 = beta_r * atemp3;
118 btemp2 = beta_i * atemp4;
119 btemp3 = beta_r * atemp4;
120 btemp4 = beta_i * atemp3;
121
122 ctemp3 = btemp1 - btemp2;
123 ctemp4 = btemp3 + btemp4;
124
125 *(c_offset1 + 0) = ctemp1;
126 *(c_offset1 + 1) = ctemp2;
127 *(c_offset1 + 2) = ctemp3;
128 *(c_offset1 + 3) = ctemp4;
129 c_offset1 += 4;
130 i --;
131 } while (i > 0);
132 }
133
134 i = (m & 1);
135 if (i > 0){
136 do {
137 atemp1 = *(c_offset1 + 0);
138 atemp2 = *(c_offset1 + 1);
139
140 btemp1 = beta_r * atemp1;
141 btemp2 = beta_i * atemp2;
142 btemp3 = beta_r * atemp2;
143 btemp4 = beta_i * atemp1;
144
145 ctemp1 = btemp1 - btemp2;
146 ctemp2 = btemp3 + btemp4;
147
148 *(c_offset1 + 0) = ctemp1;
149 *(c_offset1 + 1) = ctemp2;
150 c_offset1 += 2;
151 i --;
152 } while (i > 0);
153 }
154 j --;
155 } while (j > 0);
156 }
157 return 0;
158 }
159