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

« back to all changes in this revision

Viewing changes to src/blas/level3/kernel/ATL_syr2k_putU.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
void Mjoin(Mjoin(PATL,syr2k_putU),BNM)
 
40
   (const int N, const TYPE *D, const SCALAR beta0, TYPE *A, const int lda)
 
41
 
 
42
/*
 
43
 * Takes D with property (D + D') = (D + D')', and writes it to
 
44
 * upper part of symetric matrix A
 
45
 */
 
46
{
 
47
   register int i, j;
 
48
   const int ldap1 = lda+1;
 
49
   const TYPE *Dc=D, *Dr;
 
50
   TYPE *Ad=A, *Ar;
 
51
   const register SCALAR beta=beta0;
 
52
 
 
53
   for (j=0; j != N; j++)
 
54
   {
 
55
      for (Dr=Dc+j, Ar=Ad, i=j; i != N; i++, Dr += N, Ar += lda)
 
56
         #if defined(BETA1)
 
57
            *Ar += Dc[i] + *Dr;
 
58
         #elif defined (BETA0)
 
59
            *Ar =  Dc[i] + *Dr;
 
60
         #else
 
61
            *Ar = *Ar*beta + Dc[i] + *Dr;
 
62
         #endif
 
63
      Ad += ldap1;
 
64
      Dc += N;
 
65
   }
 
66
}
 
67
 
 
68
#else
 
69
 
 
70
#ifdef Herm_
 
71
   void Mjoin(Mjoin(PATL,her2k_putU),BNM)
 
72
#else
 
73
   void Mjoin(Mjoin(PATL,syr2k_putU),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
 * upper part of symetric 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 = D + j2;
 
99
      #ifdef BETA1
 
100
         for (i=0; i != j2; i += 2, Dr += ldD2)
 
101
         {
 
102
            A[i] += Dc[i] + *Dr;
 
103
            A[i+1] += Dc[i+1] MPi Dr[1];
 
104
         }
 
105
         A[j2] += Dc[j2] + Dc[j2];
 
106
         #ifdef Herm_
 
107
            A[j2+1] = zero;
 
108
         #else
 
109
            A[j2+1] += Dc[j2+1] + Dc[j2+1];
 
110
         #endif
 
111
      #elif defined(BETA0)
 
112
         for (i=0; i != j2; i += 2, Dr += ldD2)
 
113
         {
 
114
            A[i] = Dc[i] + *Dr;
 
115
            A[i+1] = Dc[i+1] MPi Dr[1];
 
116
         }
 
117
         A[j2] = Dc[j2] + Dc[j2];
 
118
         #ifdef Herm_
 
119
            A[j2+1] = zero;
 
120
         #else
 
121
            A[j2+1] = Dc[j2+1] + Dc[j2+1];
 
122
         #endif
 
123
      #elif defined(BETAN1) || defined(BETAXI0)
 
124
         for (i=0; i != j2; i += 2, Dr += ldD2) 
 
125
         {
 
126
            A[i] = ATL_MulByBETA(A[i]) + Dc[i] + *Dr;
 
127
            A[i+1] = ATL_MulByBETA(A[i+1]) + Dc[i+1] MPi Dr[1];
 
128
         }
 
129
         A[j2] = ATL_MulByBETA(A[j2]) + Dc[j2] + Dc[j2];
 
130
         #ifdef Herm_
 
131
            A[j2+1] = zero;
 
132
         #else
 
133
            A[j2+1] = ATL_MulByBETA(A[j2+1]) + Dc[j2+1] + Dc[j2+1];
 
134
         #endif
 
135
      #else
 
136
         for (i=0; i <= j2; i += 2, Dr += ldD2) 
 
137
         {
 
138
            ra = A[i];
 
139
            ia = A[i+1];
 
140
            A[i] = ra*rbeta - ia*ibeta + Dc[i] + *Dr;
 
141
            A[i+1] = rbeta*ia + ibeta*ra + Dc[i+1] + Dr[1];
 
142
         }
 
143
      #endif
 
144
      A += lda2;
 
145
      Dc += ldD2;
 
146
   }
 
147
}
 
148
 
 
149
#endif
 
150
#undef MPi