View Raw SPL
/*****************************************************************************
* *
* RCOND.SPL Copyright (C) 2011 DSP Development Corporation *
* All Rights Reserved *
* *
* Author: Randy Race *
* *
* Synopsis: Estimates the reciprocal condition number of a matrix *
* *
* Revisions: 26 Aug 2011 RRR Creation *
* *
*****************************************************************************/
#if @HELP_RCOND
RCOND
Purpose: Estimates the reciprocal condition number of a matrix.
Syntax: RCOND(a, p)
a - input matrix, defaults to the current series
Returns: A real, the estimated reciprocal condition number.
Example:
W1: {{1, 2, 3},
{4, 5, 6},
{7, 8, 9}}
W2: {{1, 2, 3},
{4, 5, 6},
{7, 8, 0}}
rcond(W1) == 1.54198E-018
rcond(W2) == 0.0193548
Remarks:
If the input array is well conditioned, the reciprocal
condition number is near 1. If the input is ill
conditioned, the reciprocal condition number is near 0.
See COND to compute the condition number.
See Also:
Cond
Norm
Rcond
Svd
#endif
static wl = "";
/* reciprocal condition number */
rcond(a)
{
local r;
if (argc < 1)
{
a = refseries(w0);
}
/* ensure series */
a = castseries(a);
/* suppress errors */
wl = getconf("math_warning_level");
setconf("math_warning_level", "-1");
/* condition number */
r = 1 / cond(a, 1);
/* reset */
setconf("math_warning_level", wl);
wl = "";
return(r);
}
/* error handling - reset warning level */
rcond_error(errnum, errmes)
{
if (strlen(wl) != 0)
{
setconf("math_warning_level", wl);
wl = "";
}
error(errmes)
}