Ifpack Package Browser (Single Doxygen Collection) Development
ifp_Precon.cc
Go to the documentation of this file.
```00001 /*@HEADER
00002 // ***********************************************************************
00003 //
00004 //       Ifpack: Object-Oriented Algebraic Preconditioner Package
00005 //                 Copyright (2002) Sandia Corporation
00006 //
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 //
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00014 //
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00025 //
00026 // ***********************************************************************
00028 */
00029
00030 #include "ifp_Matrix.h"
00031 #include "ifp_Precon.h"
00032 #include "ifp_ifpack.h"
00033
00034 double ifp_Precon::condest()
00035 {
00036   // This routine computes a  bound of the infinity-norm condition number
00037   // of the preconditioner.
00038   // It is equal to infinity-norm of M^-1 e, where e is the vector of all
00039   // ones.
00040
00041   int i;
00042
00043   int m = dimrow(); // Object is a matrix, so it has row/col dimensions.
00044   int n = dimcol();
00045   double *u = new double[n];
00046   double *v = new double[m];
00047
00048     for (i=0; i<n; i++) u[i] = 1.0;
00049
00050     apply(n, 1, u, n, v, n);
00051
00052     double cond_number = 0.0;
00053     for (i=0; i<m; i++)
00054         if (ABS(v[i]) > cond_number)
00055            cond_number = ABS(v[i]);
00056
00057     delete [] u;
00058     delete [] v;
00059
00060     return(cond_number);
00061 }
```