/* ========================================================================== */1/* === UMF_scale ============================================================ */2/* ========================================================================== */34/* -------------------------------------------------------------------------- */5/* UMFPACK Version 4.4, Copyright (c) 2005 by Timothy A. Davis. CISE Dept, */6/* Univ. of Florida. All Rights Reserved. See ../Doc/License for License. */7/* web: http://www.cise.ufl.edu/research/sparse/umfpack */8/* -------------------------------------------------------------------------- */910/* Divide a vector of stride 1 by the pivot value. */1112#include "umf_internal.h"1314GLOBAL void UMF_scale15(16Int n,17Entry pivot,18Entry X [ ]19)20{21Entry x ;22double s ;23Int i ;2425/* ---------------------------------------------------------------------- */26/* compute the approximate absolute value of the pivot, and select method */27/* ---------------------------------------------------------------------- */2829APPROX_ABS (s, pivot) ;3031if (s < RECIPROCAL_TOLERANCE || IS_NAN (pivot))32{33/* ------------------------------------------------------------------ */34/* tiny, or zero, pivot case */35/* ------------------------------------------------------------------ */3637/* The pivot is tiny, or NaN. Do not divide zero by the pivot value,38* and do not multiply by 1/pivot, either. */3940for (i = 0 ; i < n ; i++)41{42/* X [i] /= pivot ; */43x = X [i] ;4445#ifndef NO_DIVIDE_BY_ZERO46if (IS_NONZERO (x))47{48DIV (X [i], x, pivot) ;49}50#else51/* Do not divide by zero */52if (IS_NONZERO (x) && IS_NONZERO (pivot))53{54DIV (X [i], x, pivot) ;55}56#endif5758}5960}61else62{6364/* ------------------------------------------------------------------ */65/* normal case. select the x/pivot or x * (1/pivot) method */66/* ------------------------------------------------------------------ */6768/* The pivot is not tiny, and is not NaN. Don't bother to check for69* zeros in the pivot column, X. */7071#if !defined (NRECIPROCAL) && !(defined (__GNUC__) && defined (COMPLEX))7273/* -------------------------------------------------------------- */74/* multiply x by (1/pivot) */75/* -------------------------------------------------------------- */7677/* Slightly less accurate, but faster. It allows the use of78* the level-1 BLAS dscal or zscal routine. This not used when79* UMFPACK is used in MATLAB (either as a built-in routine, or as80* a mexFunction).81*82* Using gcc version 3.2 can cause the following code to fail for83* some complex matrices (not all), with or without the BLAS. This84* was found in Red Hat Linux 7.3 on a Dell Latitude C840 with a85* Pentium 4M. Thus, this code is not used when gcc is used, for86* the complex case.87*88* It works just fine with Intel's icc compiler, version 7.0.89*/9091/* pivot = 1 / pivot */92RECIPROCAL (pivot) ;9394#if defined (USE_NO_BLAS)95for (i = 0 ; i < n ; i++)96{97/* X [i] *= pivot ; */98x = X [i] ;99MULT (X [i], x, pivot) ;100}101#else102BLAS_SCAL (n, pivot, X) ;103#endif104105#else106107/* -------------------------------------------------------------- */108/* divide x by the pivot */109/* -------------------------------------------------------------- */110111/* This is slightly more accurate, particularly if the pivot column112* consists of only IEEE subnormals. Always do this if UMFPACK is113* being compiled as a built-in routine or mexFunction in MATLAB,114* or if gcc is being used with complex matrices. */115116for (i = 0 ; i < n ; i++)117{118/* X [i] /= pivot ; */119x = X [i] ;120DIV (X [i], x, pivot) ;121}122123#endif124125}126}127128129