#!/usr/local/bin/perl -w

use Math::MatrixReal; # qw(new_from_string);

$A = Math::MatrixReal->new_from_string(<<"MATRIX");
[  1   2   3  ]
[  5   7  11  ]
[ 23  19  13  ]
MATRIX
  
$b = Math::MatrixReal->new_from_string(<<"MATRIX");
[   0   ]
[   1   ]
[  29   ]
MATRIX

$LR = $A->decompose_LR();
if (($dim,$x,$B) = $LR->solve_LR($b))
{
    print "x = \n";
    print $x;
    $test = $A * $x;
    print "A * x = \n";
    print $test;
}

($A_,$b_) = $A->normalize($b);

$LR = $A_->decompose_LR();
if (($dim,$x,$B) = $LR->solve_LR($b_))
{
    print "x = \n";
    print $x;
    $test = $A * $x;
    print "A * x = \n";
    print $test;
}

__END__
  This will print:
  
             x =
               [  1.000000000000E+00 ]
               [  1.000000000000E+00 ]
               [ -1.000000000000E+00 ]
               A * x =
               [  4.440892098501E-16 ]
               [  1.000000000000E+00 ]
               [  2.900000000000E+01 ]
               x =
               [  1.000000000000E+00 ]
               [  1.000000000000E+00 ]
               [ -1.000000000000E+00 ]
               A * x =
               [  0.000000000000E+00 ]
               [  1.000000000000E+00 ]
               [  2.900000000000E+01 ]
  
You can see that in the second example (where
    "normalize()" has been used), the result is "better",
  i.e., more accurate!
  
