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

« back to all changes in this revision

Viewing changes to src/blas/reference/level1/ATL_zrefaxpy.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
 *
 
3
 * -- Automatically Tuned Linear Algebra Software (ATLAS)
 
4
 *    (C) Copyright 2000 All Rights Reserved
 
5
 *
 
6
 * -- ATLAS routine -- Version 3.2 -- December 15, 2000
 
7
 *
 
8
 * -- Suggestions,  comments,  bugs reports should be sent to the follo-
 
9
 *    wing e-mail address: atlas@cs.utk.edu
 
10
 *
 
11
 * Author         : Antoine P. Petitet
 
12
 * University of Tennessee - Innovative Computing Laboratory
 
13
 * Knoxville TN, 37996-1301, USA.
 
14
 *
 
15
 * ---------------------------------------------------------------------
 
16
 *
 
17
 * -- Copyright notice and Licensing terms:
 
18
 *
 
19
 *  Redistribution  and  use in  source and binary forms, with or without
 
20
 *  modification, are  permitted provided  that the following  conditions
 
21
 *  are met:
 
22
 *
 
23
 * 1. Redistributions  of  source  code  must retain the above copyright
 
24
 *    notice, this list of conditions and the following disclaimer.
 
25
 * 2. Redistributions in binary form must reproduce  the above copyright
 
26
 *    notice,  this list of conditions, and the  following disclaimer in
 
27
 *    the documentation and/or other materials provided with the distri-
 
28
 *    bution.
 
29
 * 3. The name of the University,  the ATLAS group,  or the names of its
 
30
 *    contributors  may not be used to endorse or promote products deri-
 
31
 *    ved from this software without specific written permission.
 
32
 *
 
33
 * -- Disclaimer:
 
34
 *
 
35
 * THIS  SOFTWARE  IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 
36
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,  INCLUDING,  BUT NOT
 
37
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 
38
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY
 
39
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,  INDIRECT, INCIDENTAL, SPE-
 
40
 * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
 
41
 * TO,  PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
 
42
 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEO-
 
43
 * RY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT  (IN-
 
44
 * CLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 
45
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
46
 *
 
47
 * ---------------------------------------------------------------------
 
48
 */
 
49
/*
 
50
 * Include files
 
51
 */
 
52
#include "atlas_refmisc.h"
 
53
#include "atlas_reflevel1.h"
 
54
 
 
55
void ATL_zrefaxpy
 
56
(
 
57
   const int                  N,
 
58
   const double               * ALPHA,
 
59
   const double               * X,
 
60
   const int                  INCX,
 
61
   double                     * Y,
 
62
   const int                  INCY
 
63
)
 
64
{
 
65
/*
 
66
 * Purpose
 
67
 * =======
 
68
 *
 
69
 * ATL_zrefaxpy performs the following operation:
 
70
 *
 
71
 *    y := y + alpha * x,
 
72
 *
 
73
 * where alpha is a scalar and x and y are two n-vectors.
 
74
 *
 
75
 * Arguments
 
76
 * =========
 
77
 *
 
78
 * N       (input)                       const int
 
79
 *         On entry, N specifies the length of the vector x. N  must  be
 
80
 *         at least zero. Unchanged on exit.
 
81
 *
 
82
 * ALPHA   (input)                       const double *
 
83
 *         On entry, ALPHA specifies the scalar alpha.   When  ALPHA  is
 
84
 *         supplied as zero, then the entries of the incremented array X
 
85
 *         need not be set on input. Unchanged on exit.
 
86
 *
 
87
 * X       (input)                       const double *
 
88
 *         On entry,  X  points to the  first entry to be accessed of an
 
89
 *         incremented array of size equal to or greater than
 
90
 *            ( 1 + ( n - 1 ) * abs( INCX ) ) * sizeof( double[2] ),
 
91
 *         that contains the vector x. Unchanged on exit.
 
92
 *
 
93
 * INCX    (input)                       const int
 
94
 *         On entry, INCX specifies the increment for the elements of X.
 
95
 *         INCX must not be zero. Unchanged on exit.
 
96
 *
 
97
 * Y       (input/output)                double *
 
98
 *         On entry,  Y  points to the  first entry to be accessed of an
 
99
 *         incremented array of size equal to or greater than
 
100
 *            ( 1 + ( n - 1 ) * abs( INCY ) ) * sizeof( double[2] ),
 
101
 *         that contains the vector y.  On exit,  the entries of the in-
 
102
 *         cremented array  Y are updated with the scaled entries of the
 
103
 *         incremented array  X.
 
104
 *
 
105
 * INCY    (input)                       const int
 
106
 *         On entry, INCY specifies the increment for the elements of Y.
 
107
 *         INCY must not be zero. Unchanged on exit.
 
108
 *
 
109
 * ---------------------------------------------------------------------
 
110
 */
 
111
/*
 
112
 * .. Local Variables ..
 
113
 */
 
114
   register const double      alpha_r = *ALPHA, alpha_i = ALPHA[1];
 
115
   register double            x0_r, x0_i, x1_r, x1_i, y0_r, y0_i, y1_r, y1_i;
 
116
   double                     * StX;
 
117
   register int               i;
 
118
   int                        incx2 = 2 * INCX,  incy2 = 2 * INCY,  nu;
 
119
   const int                  incX2 = 2 * incx2, incY2 = 2 * incy2;
 
120
/* ..
 
121
 * .. Executable Statements ..
 
122
 *
 
123
 */
 
124
   if( ( N > 0 ) && !Mdzero( alpha_r, alpha_i ) )
 
125
   {
 
126
      if( ( nu = ( N >> 1 ) << 1 ) != 0 )
 
127
      {
 
128
         StX = (double *)X + nu * incx2;
 
129
 
 
130
         do
 
131
         {
 
132
            x0_r = (*X);       y0_r = (*Y);
 
133
            x0_i = X[1];       y0_i = Y[1];
 
134
            x1_r = X[incx2  ]; y1_r = Y[incy2  ];
 
135
            x1_i = X[incx2+1]; y1_i = Y[incy2+1];
 
136
 
 
137
            *Y         = y0_r + alpha_r * x0_r - alpha_i * x0_i;
 
138
            Y[1]       = y0_i + alpha_i * x0_r + alpha_r * x0_i;
 
139
            Y[incy2  ] = y1_r + alpha_r * x1_r - alpha_i * x1_i;
 
140
            Y[incy2+1] = y1_i + alpha_i * x1_r + alpha_r * x1_i;
 
141
 
 
142
            X += incX2;
 
143
            Y += incY2;
 
144
 
 
145
         } while( X != StX );
 
146
      }
 
147
 
 
148
      for( i = N - nu; i != 0; i-- )
 
149
      {
 
150
         x0_r = (*X); y0_r = (*Y);
 
151
         x0_i = X[1]; y0_i = Y[1];
 
152
 
 
153
         *Y   = y0_r + alpha_r * x0_r - alpha_i * x0_i;
 
154
         Y[1] = y0_i + alpha_i * x0_r + alpha_r * x0_i;
 
155
 
 
156
         X += incx2;
 
157
         Y += incy2;
 
158
      }
 
159
   }
 
160
/*
 
161
 * End of ATL_zrefaxpy
 
162
 */
 
163
}