~ubuntu-branches/ubuntu/vivid/atlas/vivid

« back to all changes in this revision

Viewing changes to src/blas/level3/kernel/ATL_syr2k_putL.c

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2002-04-13 10:07:52 UTC
  • Revision ID: james.westby@ubuntu.com-20020413100752-va9zm0rd4gpurdkq
Tags: upstream-3.2.1ln
ImportĀ upstreamĀ versionĀ 3.2.1ln

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *             Automatically Tuned Linear Algebra Software v3.2
 
3
 *                    (C) Copyright 1997 R. Clint Whaley                     
 
4
 *
 
5
 * Redistribution and use in source and binary forms, with or without
 
6
 * modification, are permitted provided that the following conditions
 
7
 * are met:
 
8
 *   1. Redistributions of source code must retain the above copyright
 
9
 *      notice, this list of conditions and the following disclaimer.
 
10
 *   2. Redistributions in binary form must reproduce the above copyright
 
11
 *      notice, this list of conditions, and the following disclaimer in the
 
12
 *      documentation and/or other materials provided with the distribution.
 
13
 *   3. The name of the University of Tennessee, the ATLAS group,
 
14
 *      or the names of its contributers may not be used to endorse
 
15
 *      or promote products derived from this software without specific
 
16
 *      written permission.
 
17
 *
 
18
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
 
19
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 
20
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
21
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE
 
22
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
23
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
24
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
25
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
26
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
27
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 
28
 * POSSIBILITY OF SUCH DAMAGE. 
 
29
 *
 
30
 */
 
31
#include "atlas_kern3.h"
 
32
 
 
33
#ifdef Herm_
 
34
   #define MPi -
 
35
#else
 
36
   #define MPi +
 
37
#endif
 
38
#ifdef TREAL
 
39
 
 
40
void Mjoin(Mjoin(PATL,syr2k_putL),BNM)
 
41
   (const int N, const TYPE *D, const SCALAR beta0, TYPE *A, const int lda)
 
42
 
 
43
/*
 
44
 * Takes D with property (D + D') = (D + D')', and writes it to
 
45
 * lower part of symmetric matrix A
 
46
 */
 
47
{
 
48
   register int i, j;
 
49
   const TYPE *Dc=D, *Dr;
 
50
   TYPE *Ac=A;
 
51
   const register SCALAR beta=beta0;
 
52
 
 
53
   for (j=0; j != N; j++)
 
54
   {
 
55
      for (Dr=Dc+j, i=j; i != N; i++, Dr += N)
 
56
         #if defined(BETA1)
 
57
            Ac[i] += Dc[i] + *Dr;
 
58
         #elif defined (BETA0)
 
59
            Ac[i] =  Dc[i] + *Dr;
 
60
         #else
 
61
            Ac[i] = Ac[i]*beta + Dc[i] + *Dr;
 
62
         #endif
 
63
      Ac += lda;
 
64
      Dc += N;
 
65
   }
 
66
}
 
67
 
 
68
#else
 
69
 
 
70
#ifdef Herm_
 
71
   void Mjoin(Mjoin(PATL,her2k_putL),BNM)
 
72
#else
 
73
   void Mjoin(Mjoin(PATL,syr2k_putL),BNM)
 
74
#endif
 
75
   (const int N, const TYPE *D, const SCALAR beta0, TYPE *A, const int lda)
 
76
 
 
77
/*
 
78
 * Takes D with property (D + D') = (D + D')', and writes it to
 
79
 * lower part of symmetric matrix A
 
80
 */
 
81
{
 
82
   register int i, j2;
 
83
   const int N2=N<<1, lda2=lda<<1;
 
84
   #define ldD2 N2
 
85
   #ifdef Herm_
 
86
      const TYPE zero=0.0;
 
87
   #endif
 
88
   const TYPE *Dc=D, *Dr;
 
89
   #ifdef BETAXI0
 
90
      const register TYPE rbeta=*beta0;
 
91
   #elif defined(BETAX)
 
92
      register TYPE ra, ia;
 
93
      const register TYPE rbeta=*beta0, ibeta=beta0[1];
 
94
   #endif
 
95
 
 
96
   for (j2=0; j2 != N2; j2 += 2)
 
97
   {
 
98
      Dr = Dc + j2 + ldD2;
 
99
      #ifdef BETA1
 
100
         A[j2] += Dc[j2] + Dc[j2];
 
101
         #ifdef Herm_
 
102
            A[j2+1] = zero;
 
103
         #else
 
104
            A[j2+1] += Dc[j2+1] + Dc[j2+1];
 
105
         #endif
 
106
         if (N2 != j2)
 
107
         {
 
108
            for (i=j2+2; i != N2; i += 2, Dr += ldD2)
 
109
            {
 
110
               A[i] += Dc[i] + *Dr;
 
111
               A[i+1] += Dc[i+1] MPi Dr[1];
 
112
            }
 
113
         }
 
114
      #elif defined(BETA0)
 
115
         A[j2] = Dc[j2] + Dc[j2];
 
116
         #ifdef Herm_
 
117
            A[j2+1] = zero;
 
118
         #else
 
119
            A[j2+1] = Dc[j2+1] + Dc[j2+1];
 
120
         #endif
 
121
         if (N2 != j2)
 
122
         {
 
123
            for (i=j2+2; i != N2; i += 2, Dr += ldD2)
 
124
            {
 
125
               A[i] = Dc[i] + *Dr;
 
126
               A[i+1] = Dc[i+1] MPi Dr[1];
 
127
            }
 
128
         }
 
129
      #elif defined(BETAN1) || defined(BETAXI0)
 
130
         A[j2] = ATL_MulByBETA(A[j2]) + Dc[j2] + Dc[j2];
 
131
         #ifdef Herm_
 
132
            A[j2+1] = zero;
 
133
         #else
 
134
            A[j2+1] = ATL_MulByBETA(A[j2+1]) + Dc[j2+1] + Dc[j2+1];
 
135
         #endif
 
136
         if (N2 != j2)
 
137
         {
 
138
            for (i=j2+2; i != N2; i += 2, Dr += ldD2) 
 
139
            {
 
140
               A[i] = ATL_MulByBETA(A[i]) + Dc[i] + *Dr;
 
141
               A[i+1] = ATL_MulByBETA(A[i+1]) + Dc[i+1] MPi Dr[1];
 
142
            }
 
143
         }
 
144
      #else
 
145
         ra = A[j2];
 
146
         ia = A[j2+1];
 
147
         A[j2] = ra*rbeta - ia*ibeta + Dc[j2] + Dc[j2];
 
148
         A[j2+1] = rbeta*ia + ibeta*ra + Dc[j2+1] + Dc[j2+1];
 
149
         if (j2 != N2)
 
150
         {
 
151
            for (i=j2+2; i != N2; i += 2, Dr += ldD2) 
 
152
            {
 
153
               ra = A[i];
 
154
               ia = A[i+1];
 
155
               A[i] = ra*rbeta - ia*ibeta + Dc[i] + *Dr;
 
156
               A[i+1] = rbeta*ia + ibeta*ra + Dc[i+1] + Dr[1];
 
157
            }
 
158
         }
 
159
      #endif
 
160
      A += lda2;
 
161
      Dc += ldD2;
 
162
   }
 
163
}
 
164
 
 
165
#endif
 
166
#undef MPi