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

« back to all changes in this revision

Viewing changes to scipy/sparse/linalg/dsolve/SuperLU/SRC/sgsequ.c

  • Committer: Bazaar Package Importer
  • Author(s): Sameer Morar
  • Date: 2011-02-03 04:28:09 UTC
  • mfrom: (9.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20110203042809-qs95kuod7723re62
Tags: 0.8.0+dfsg1-1ubuntu1
* Merge from debian experimental (LP: #696403). Remaining changes:
  - debian/patches/stdc_format_macros.patch: Fix FTBFS issue with python 2.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
 
 
3
 
/*
 
2
/*! @file sgsequ.c
 
3
 * \brief Computes row and column scalings
 
4
 *
 
5
 * <pre>
4
6
 * -- SuperLU routine (version 2.0) --
5
7
 * Univ. of California Berkeley, Xerox Palo Alto Research Center,
6
8
 * and Lawrence Berkeley National Lab.
7
9
 * November 15, 1997
8
10
 *
 
11
 * Modified from LAPACK routine SGEEQU
 
12
 * </pre>
9
13
 */
10
14
/*
11
15
 * File name:   sgsequ.c
12
16
 * History:     Modified from LAPACK routine SGEEQU
13
17
 */
14
18
#include <math.h>
15
 
#include "ssp_defs.h"
16
 
#include "util.h"
17
 
 
 
19
#include "slu_sdefs.h"
 
20
 
 
21
 
 
22
 
 
23
/*! \brief
 
24
 *
 
25
 * <pre>
 
26
 * Purpose   
 
27
 *   =======   
 
28
 *
 
29
 *   SGSEQU computes row and column scalings intended to equilibrate an   
 
30
 *   M-by-N sparse matrix A and reduce its condition number. R returns the row
 
31
 *   scale factors and C the column scale factors, chosen to try to make   
 
32
 *   the largest element in each row and column of the matrix B with   
 
33
 *   elements B(i,j)=R(i)*A(i,j)*C(j) have absolute value 1.   
 
34
 *
 
35
 *   R(i) and C(j) are restricted to be between SMLNUM = smallest safe   
 
36
 *   number and BIGNUM = largest safe number.  Use of these scaling   
 
37
 *   factors is not guaranteed to reduce the condition number of A but   
 
38
 *   works well in practice.   
 
39
 *
 
40
 *   See supermatrix.h for the definition of 'SuperMatrix' structure.
 
41
 *
 
42
 *   Arguments   
 
43
 *   =========   
 
44
 *
 
45
 *   A       (input) SuperMatrix*
 
46
 *           The matrix of dimension (A->nrow, A->ncol) whose equilibration
 
47
 *           factors are to be computed. The type of A can be:
 
48
 *           Stype = SLU_NC; Dtype = SLU_S; Mtype = SLU_GE.
 
49
 *          
 
50
 *   R       (output) float*, size A->nrow
 
51
 *           If INFO = 0 or INFO > M, R contains the row scale factors   
 
52
 *           for A.
 
53
 *          
 
54
 *   C       (output) float*, size A->ncol
 
55
 *           If INFO = 0,  C contains the column scale factors for A.
 
56
 *          
 
57
 *   ROWCND  (output) float*
 
58
 *           If INFO = 0 or INFO > M, ROWCND contains the ratio of the   
 
59
 *           smallest R(i) to the largest R(i).  If ROWCND >= 0.1 and   
 
60
 *           AMAX is neither too large nor too small, it is not worth   
 
61
 *           scaling by R.
 
62
 *          
 
63
 *   COLCND  (output) float*
 
64
 *           If INFO = 0, COLCND contains the ratio of the smallest   
 
65
 *           C(i) to the largest C(i).  If COLCND >= 0.1, it is not   
 
66
 *           worth scaling by C.
 
67
 *          
 
68
 *   AMAX    (output) float*
 
69
 *           Absolute value of largest matrix element.  If AMAX is very   
 
70
 *           close to overflow or very close to underflow, the matrix   
 
71
 *           should be scaled.
 
72
 *          
 
73
 *   INFO    (output) int*
 
74
 *           = 0:  successful exit   
 
75
 *           < 0:  if INFO = -i, the i-th argument had an illegal value   
 
76
 *           > 0:  if INFO = i,  and i is   
 
77
 *                 <= A->nrow:  the i-th row of A is exactly zero   
 
78
 *                 >  A->ncol:  the (i-M)-th column of A is exactly zero   
 
79
 *
 
80
 *   ===================================================================== 
 
81
 * </pre>
 
82
 */
18
83
void
19
84
sgsequ(SuperMatrix *A, float *r, float *c, float *rowcnd,
20
85
        float *colcnd, float *amax, int *info)
21
86
{
22
 
/*    
23
 
    Purpose   
24
 
    =======   
25
 
 
26
 
    SGSEQU computes row and column scalings intended to equilibrate an   
27
 
    M-by-N sparse matrix A and reduce its condition number. R returns the row
28
 
    scale factors and C the column scale factors, chosen to try to make   
29
 
    the largest element in each row and column of the matrix B with   
30
 
    elements B(i,j)=R(i)*A(i,j)*C(j) have absolute value 1.   
31
 
 
32
 
    R(i) and C(j) are restricted to be between SMLNUM = smallest safe   
33
 
    number and BIGNUM = largest safe number.  Use of these scaling   
34
 
    factors is not guaranteed to reduce the condition number of A but   
35
 
    works well in practice.   
36
 
 
37
 
    See supermatrix.h for the definition of 'SuperMatrix' structure.
38
 
 
39
 
    Arguments   
40
 
    =========   
41
 
 
42
 
    A       (input) SuperMatrix*
43
 
            The matrix of dimension (A->nrow, A->ncol) whose equilibration
44
 
            factors are to be computed. The type of A can be:
45
 
            Stype = SLU_NC; Dtype = SLU_S; Mtype = SLU_GE.
46
 
            
47
 
    R       (output) float*, size A->nrow
48
 
            If INFO = 0 or INFO > M, R contains the row scale factors   
49
 
            for A.
50
 
            
51
 
    C       (output) float*, size A->ncol
52
 
            If INFO = 0,  C contains the column scale factors for A.
53
 
            
54
 
    ROWCND  (output) float*
55
 
            If INFO = 0 or INFO > M, ROWCND contains the ratio of the   
56
 
            smallest R(i) to the largest R(i).  If ROWCND >= 0.1 and   
57
 
            AMAX is neither too large nor too small, it is not worth   
58
 
            scaling by R.
59
 
            
60
 
    COLCND  (output) float*
61
 
            If INFO = 0, COLCND contains the ratio of the smallest   
62
 
            C(i) to the largest C(i).  If COLCND >= 0.1, it is not   
63
 
            worth scaling by C.
64
 
            
65
 
    AMAX    (output) float*
66
 
            Absolute value of largest matrix element.  If AMAX is very   
67
 
            close to overflow or very close to underflow, the matrix   
68
 
            should be scaled.
69
 
            
70
 
    INFO    (output) int*
71
 
            = 0:  successful exit   
72
 
            < 0:  if INFO = -i, the i-th argument had an illegal value   
73
 
            > 0:  if INFO = i,  and i is   
74
 
                  <= A->nrow:  the i-th row of A is exactly zero   
75
 
                  >  A->ncol:  the (i-M)-th column of A is exactly zero   
76
 
 
77
 
    ===================================================================== 
78
 
*/
 
87
 
79
88
 
80
89
    /* Local variables */
81
90
    NCformat *Astore;