Blame view
fvn_sparse/UMFPACK/Source/umf_scale.c
2.3 KB
422234dc3 git-svn-id: https... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
/* ========================================================================== */ /* === UMF_scale ============================================================ */ /* ========================================================================== */ /* -------------------------------------------------------------------------- */ /* UMFPACK Copyright (c) Timothy A. Davis, CISE, */ /* Univ. of Florida. All Rights Reserved. See ../Doc/License for License. */ /* web: http://www.cise.ufl.edu/research/sparse/umfpack */ /* -------------------------------------------------------------------------- */ /* Divide a vector of stride 1 by the pivot value. */ #include "umf_internal.h" GLOBAL void UMF_scale ( Int n, Entry pivot, Entry X [ ] ) { Entry x ; double s ; Int i ; /* ---------------------------------------------------------------------- */ /* compute the approximate absolute value of the pivot, and select method */ /* ---------------------------------------------------------------------- */ APPROX_ABS (s, pivot) ; if (s < RECIPROCAL_TOLERANCE || IS_NAN (pivot)) { /* ------------------------------------------------------------------ */ /* tiny, or zero, pivot case */ /* ------------------------------------------------------------------ */ /* The pivot is tiny, or NaN. Do not divide zero by the pivot value, * and do not multiply by 1/pivot, either. */ for (i = 0 ; i < n ; i++) { /* X [i] /= pivot ; */ x = X [i] ; #ifndef NO_DIVIDE_BY_ZERO if (IS_NONZERO (x)) { DIV (X [i], x, pivot) ; } #else /* Do not divide by zero */ if (IS_NONZERO (x) && IS_NONZERO (pivot)) { DIV (X [i], x, pivot) ; } #endif } } else { /* ------------------------------------------------------------------ */ /* normal case */ /* ------------------------------------------------------------------ */ /* The pivot is not tiny, and is not NaN. Don't bother to check for * zeros in the pivot column, X. This is slightly more accurate than * multiplying by 1/pivot (but slightly slower), particularly if the * pivot column consists of only IEEE subnormals. */ for (i = 0 ; i < n ; i++) { /* X [i] /= pivot ; */ x = X [i] ; DIV (X [i], x, pivot) ; } } } |