~ubuntu-branches/ubuntu/raring/python-scipy/raring-proposed

« back to all changes in this revision

Viewing changes to Lib/sandbox/pysparse/umfpack/umf_scale.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-01-07 14:12:12 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070107141212-mm0ebkh5b37hcpzn
* Remove build dependency on python-numpy-dev.
* python-scipy: Depend on python-numpy instead of python-numpy-dev.
* Package builds on other archs than i386. Closes: #402783.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ========================================================================== */
 
2
/* === UMF_scale ============================================================ */
 
3
/* ========================================================================== */
 
4
 
 
5
/* -------------------------------------------------------------------------- */
 
6
/* UMFPACK Version 4.1 (Apr. 30, 2003), Copyright (c) 2003 by Timothy A.      */
 
7
/* Davis.  All Rights Reserved.  See ../README for License.                   */
 
8
/* email: davis@cise.ufl.edu    CISE Department, Univ. of Florida.            */
 
9
/* web: http://www.cise.ufl.edu/research/sparse/umfpack                       */
 
10
/* -------------------------------------------------------------------------- */
 
11
 
 
12
/* Divide a vector of stride 1 by the pivot value. */
 
13
 
 
14
#include "umf_internal.h"
 
15
 
 
16
GLOBAL void UMF_scale
 
17
(
 
18
    Int n,
 
19
    Entry pivot,
 
20
    Entry X [ ]
 
21
)
 
22
{
 
23
    Int i ;
 
24
    Entry x ;
 
25
    double s ;
 
26
 
 
27
    /* ---------------------------------------------------------------------- */
 
28
    /* compute the approximate absolute value of the pivot, and select method */
 
29
    /* ---------------------------------------------------------------------- */
 
30
 
 
31
    APPROX_ABS (s, pivot) ;
 
32
 
 
33
    if (s < RECIPROCAL_TOLERANCE || IS_NAN (pivot))
 
34
    {
 
35
        /* ------------------------------------------------------------------ */
 
36
        /* tiny, or zero, pivot case */
 
37
        /* ------------------------------------------------------------------ */
 
38
 
 
39
        /* The pivot is tiny, or NaN.  Do not divide zero by the pivot value,
 
40
         * and do not multiply by 1/pivot, either. */
 
41
 
 
42
        for (i = 0 ; i < n ; i++)
 
43
        {
 
44
            /* X [i] /= pivot ; */
 
45
            x = X [i] ;
 
46
            if (IS_NONZERO (x))
 
47
            {
 
48
                DIV (X [i], x, pivot) ;
 
49
            }
 
50
        }
 
51
 
 
52
    }
 
53
    else
 
54
    {
 
55
 
 
56
        /* ------------------------------------------------------------------ */
 
57
        /* normal case.  select the x/pivot or x * (1/pivot) method */
 
58
        /* ------------------------------------------------------------------ */
 
59
 
 
60
        /* The pivot is not tiny, and is not NaN.   Don't bother to check for
 
61
         * zeros in the pivot column, X. */
 
62
 
 
63
#if !defined (NRECIPROCAL) && !(defined (__GNUC__) && defined (COMPLEX))
 
64
 
 
65
            /* -------------------------------------------------------------- */
 
66
            /* multiply x by (1/pivot) */
 
67
            /* -------------------------------------------------------------- */
 
68
 
 
69
            /* Slightly less accurate, but faster.  It allows the use of
 
70
             * the level-1 BLAS dscal or zscal routine.  This not used when
 
71
             * UMFPACK is used in MATLAB (either as a built-in routine, or as
 
72
             * a mexFunction).
 
73
             *
 
74
             * Using gcc version 3.2 can cause the following code to fail for
 
75
             * some complex matrices (not all), with or without the BLAS.  This
 
76
             * was found in Red Hat Linux 7.3 on a Dell Latitude C840 with a
 
77
             * Pentium 4M.  Thus, this code is not used when gcc is used, for
 
78
             * the complex case.
 
79
             *
 
80
             * It works just fine with Intel's icc compiler, version 7.0.
 
81
             */
 
82
 
 
83
            /* pivot = 1 / pivot */
 
84
            RECIPROCAL (pivot) ;
 
85
 
 
86
#if defined (USE_NO_BLAS)
 
87
            for (i = 0 ; i < n ; i++)
 
88
            {
 
89
                /* X [i] *= pivot ; */
 
90
                x = X [i] ;
 
91
                MULT (X [i], x, pivot) ;
 
92
            }
 
93
#else
 
94
            BLAS_SCAL (n, pivot, X) ;
 
95
#endif
 
96
 
 
97
#else
 
98
 
 
99
            /* -------------------------------------------------------------- */
 
100
            /* divide x by the pivot */
 
101
            /* -------------------------------------------------------------- */
 
102
 
 
103
            /* This is slightly more accurate, particularly if the pivot column
 
104
             * consists of only IEEE subnormals.  Always do this if UMFPACK is
 
105
             * being compiled as a built-in routine or mexFunction in MATLAB,
 
106
             * or if gcc is being used with complex matrices. */
 
107
 
 
108
            for (i = 0 ; i < n ; i++)
 
109
            {
 
110
                /* X [i] /= pivot ; */
 
111
                x = X [i] ;
 
112
                DIV (X [i], x, pivot) ;
 
113
            }
 
114
 
 
115
#endif
 
116
 
 
117
    }
 
118
}