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

« back to all changes in this revision

Viewing changes to src/blas/level1/ATL_rotg.c

  • Committer: Package Import Robot
  • Author(s): Sébastien Villemot
  • Date: 2013-06-11 15:58:16 UTC
  • mfrom: (1.1.3 upstream)
  • mto: (2.2.21 experimental)
  • mto: This revision was merged to the branch mainline in revision 26.
  • Revision ID: package-import@ubuntu.com-20130611155816-b72z8f621tuhbzn0
Tags: upstream-3.10.1
Import upstream version 3.10.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 *             Automatically Tuned Linear Algebra Software v3.8.4
 
2
 *             Automatically Tuned Linear Algebra Software v3.10.1
3
3
 *                    (C) Copyright 1999 R. Clint Whaley
4
4
 *
5
5
 * Redistribution and use in source and binary forms, with or without
33
33
#include <math.h>
34
34
 
35
35
#ifdef TREAL
36
 
void Mjoin(PATL,rotg)(TYPE *a, TYPE *b, TYPE *c, TYPE *s)
 
36
void Mjoin(PATL,rotg)
 
37
(
 
38
   TYPE *a,    /* INPUT : first rotational elimination parameter */
 
39
               /* OUTPUT: r (see below) */
 
40
   TYPE *b,    /* INPUT: second rotational elimination parameter */
 
41
               /* OUTPUT: z (see below) */
 
42
   TYPE *c,    /* OUTPUT: cosine */
 
43
   TYPE *s     /* OUTPUT: sine */
 
44
)
 
45
/*
 
46
 *   | c  s|*|a| = |r|
 
47
 *   |-s  c| |b|   |0|
 
48
 * This routine returns:
 
49
 *    r = sigma * sqrt(a^2 + b^2), where
 
50
 *      sigma = sign(a) if abs(a) > abs(b)
 
51
 *      sigma = sign(b) if abs(a) <= abs(b)
 
52
 *    r is returned in *a
 
53
 *
 
54
 *    z = s     if (abs(a) > abs(b))
 
55
 *    z = 1/c   if (abs(a) <= abs(b) && c != 0 && r != 0)
 
56
 *    z = 1     if (abs(a) <= abs(b) && c == 0 && r != 0)
 
57
 *    z = 0     if (r == 0)
 
58
 *    z is returned in *b
 
59
 *
 
60
 *    c : cosign of the angle of (Givens) rotation
 
61
 *    c = a/r   if (r != 0)
 
62
 *    c = 1     if (r == 0)
 
63
 *
 
64
 *    s : sine of the angle of (Givens) rotation
 
65
 *    s = b/r   if (r != 0)
 
66
 *    s = 0     if (r == 0)
 
67
 *    FURTHER DETAILS:
 
68
 *       http://publib.boulder.ibm.com/infocenter/clresctr/vxrx/index.jsp?topic=/com.ibm.cluster.essl43.guideref.doc/am501_hsrotg.html
 
69
 *
 
70
 */
37
71
{
38
72
   TYPE roe, scal, r, z, aa, ab, t0, t1;
39
73
 
42
76
   if (aa > ab) roe = *a;
43
77
   else roe = *b;
44
78
   scal = aa + ab;
45
 
   if (scal == ATL_rzero)
46
 
   {
47
 
      *c = ATL_rone;
48
 
      *s = *a = *b = ATL_rzero;
49
 
   }
50
 
   else
 
79
   if (scal != ATL_rzero)
51
80
   {
52
81
      t0 = aa / scal; t1 = ab / scal;
53
82
      r = scal * sqrt(t0*t0 + t1*t1);
60
89
      *a = r;
61
90
      *b = z;
62
91
   }
 
92
   else
 
93
   {
 
94
      *c = ATL_rone;
 
95
      *s = *a = *b = ATL_rzero;
 
96
   }
63
97
}
64
98
#else
65
99
#define Msafnrm2(x_, nrm2_) \