~logan/ubuntu/trusty/suitesparse/4.2.1-3ubuntu1

« back to all changes in this revision

Viewing changes to KLU/Source/klu_scale.c

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme
  • Date: 2007-05-29 09:36:29 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070529093629-zowquo0b7slkk6nc
Tags: 3.0.0-2
* suitesparse builds properly twice in a row
* Bug fix: "suitesparse - FTBFS: Broken build depens: libgfortran1-dev",
  thanks to Bastian Blank (Closes: #426349).
* Bug fix: "suitesparse_3.0.0-1: FTBFS: build-depends on
  libgfortran1-dev", thanks to Steve Langasek (Closes: #426354).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* ========================================================================== */
2
 
/* === klu_scale ============================================================ */
 
2
/* === KLU_scale ============================================================ */
3
3
/* ========================================================================== */
4
4
 
5
5
/* Scale a matrix and check to see if it is valid.  Can be called by the user.
6
 
 * This is called by klu_factor and klu_refactor.  Returns TRUE if the input
 
6
 * This is called by KLU_factor and KLU_refactor.  Returns TRUE if the input
7
7
 * matrix is valid, FALSE otherwise.  If the W input argument is non-NULL,
8
8
 * then the input matrix is checked for duplicate entries.
9
9
 *
16
16
 
17
17
#include "klu_internal.h"
18
18
 
19
 
int KLU_scale           /* return TRUE if successful, FALSE otherwise */
 
19
Int KLU_scale           /* return TRUE if successful, FALSE otherwise */
20
20
(
21
21
    /* inputs, not modified */
22
 
    int scale,          /* 0: none, 1: sum, 2: max */
23
 
    int n,
24
 
    int Ap [ ],         /* size n+1, column pointers */
25
 
    int Ai [ ],         /* size nz, row indices */
 
22
    Int scale,          /* 0: none, 1: sum, 2: max */
 
23
    Int n,
 
24
    Int Ap [ ],         /* size n+1, column pointers */
 
25
    Int Ai [ ],         /* size nz, row indices */
26
26
    double Ax [ ],
27
27
    /* outputs, not defined on input */
28
28
    double Rs [ ],      /* size n, can be NULL if scale <= 0 */
29
29
    /* workspace, not defined on input or output */
30
 
    int W [ ],          /* size n, can be NULL */
 
30
    Int W [ ],          /* size n, can be NULL */
31
31
    /* --------------- */
32
 
    klu_common *Common
 
32
    KLU_common *Common
33
33
)
34
34
{
35
35
    double a ;
36
36
    Entry *Az ;
37
 
    int row, col, p, pend, check_duplicates ;
 
37
    Int row, col, p, pend, check_duplicates ;
 
38
 
 
39
    /* ---------------------------------------------------------------------- */
 
40
    /* check inputs */
 
41
    /* ---------------------------------------------------------------------- */
38
42
 
39
43
    if (Common == NULL)
40
44
    {
51
55
 
52
56
    Az = (Entry *) Ax ;
53
57
 
54
 
    if (n <= 0 || (Ap == NULL) || (Ai == NULL) || (Az == NULL))
 
58
    if (n <= 0 || Ap == NULL || Ai == NULL || Az == NULL ||
 
59
        (scale > 0 && Rs == NULL))
55
60
    {
56
 
        /* Ap, Ai, and Ax must be present, and n must be > 0 */
 
61
        /* Ap, Ai, Ax and Rs must be present, and n must be > 0 */
57
62
        Common->status = KLU_INVALID ;
58
63
        return (FALSE) ;
59
64
    }
73
78
        }
74
79
    }
75
80
 
 
81
    /* ---------------------------------------------------------------------- */
 
82
    /* scale */
 
83
    /* ---------------------------------------------------------------------- */
 
84
 
76
85
    if (scale > 0)
77
86
    {
78
87
        /* initialize row sum or row max */
83
92
    }
84
93
 
85
94
    /* check for duplicates only if W is present */
86
 
    check_duplicates = (W != (int *) NULL) ;
 
95
    check_duplicates = (W != (Int *) NULL) ;
87
96
    if (check_duplicates)
88
97
    {
89
98
        for (row = 0 ; row < n ; row++)