C-XSC - A C++ Class Library for Extended Scientific Computing  2.5.4
l_imatrix.cpp
00001 /*
00002 **  CXSC is a C++ library for eXtended Scientific Computing (V 2.5.4)
00003 **
00004 **  Copyright (C) 1990-2000 Institut fuer Angewandte Mathematik,
00005 **                          Universitaet Karlsruhe, Germany
00006 **            (C) 2000-2014 Wiss. Rechnen/Softwaretechnologie
00007 **                          Universitaet Wuppertal, Germany   
00008 **
00009 **  This library is free software; you can redistribute it and/or
00010 **  modify it under the terms of the GNU Library General Public
00011 **  License as published by the Free Software Foundation; either
00012 **  version 2 of the License, or (at your option) any later version.
00013 **
00014 **  This library is distributed in the hope that it will be useful,
00015 **  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 **  Library General Public License for more details.
00018 **
00019 **  You should have received a copy of the GNU Library General Public
00020 **  License along with this library; if not, write to the Free
00021 **  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 */
00023 
00024 /* CVS $Id: l_imatrix.cpp,v 1.18 2014/01/30 17:23:46 cxsc Exp $ */
00025 
00026 #define _CXSC_CPP
00027 
00028 #include "l_imatrix.hpp"
00029 #include "matrix.inl"
00030 #include "l_imatrix.inl"
00031 #include "livecrmat.inl"
00032 #include "liveclrmat.inl"
00033 #include "livecimat.inl"
00034 
00035 // they should also be included here
00036 #include "lrvecimat.inl"
00037 #include "iveclrmat.inl"
00038 #include "lrmatimat.inl"
00039 
00040 namespace cxsc {
00041 l_imatrix Id ( const l_imatrix& A )                // l_interval identity matrix
00042 {                                                  //---------------------------
00043   int i,j;
00044   int lbi = Lb(A,1), ubi = Ub(A,1);
00045   int lbj = Lb(A,2), ubj = Ub(A,2);
00046   l_imatrix B(lbi,ubi,lbj,ubj);
00047 
00048   for (i = lbi; i <= ubi; i++)
00049     for (j = lbj; j <= ubj; j++)
00050       B[i][j] = l_interval( (i==j) ? 1.0 : 0.0 );
00051   return B;
00052 }
00053 
00054 l_imatrix transp ( const l_imatrix& A )              // Transposed matrix
00055 {                                                    //------------------
00056   int      n;
00057   l_imatrix  res(Lb(A,2),Ub(A,2),Lb(A,1),Ub(A,1));
00058       
00059   for (n = Lb(A,1); n <= Ub(A,1); n++) Col(res,n) = Row(A,n);
00060   return res;
00061 }
00062 
00063 l_real MaxRelDiam ( const l_imatrix_subv& v )    // Maximum relative diameter
00064 {                                                //--------------------------
00065   l_real r;
00066   int  i, l=Lb(v), u=Ub(v);
00067 
00068   r = 0.0;
00069   for (i = l; i <= u; i++)
00070     if (RelDiam(v[i]) > r) r = RelDiam(v[i]);
00071   return r;
00072 }
00073 
00074 // The 'DoubleSize' functions double the number of rows of a matrix
00075 // or double the length of a vector preserving existing components.
00076 //------------------------------------------------------------------
00077 
00078 void DoubleSize ( l_imatrix& A )
00079 {
00080   int n = Lb(A,1);
00081   Resize(A,n,2*Ub(A,1)-n+1,Lb(A,2),Ub(A,2));
00082 }
00083 
00084 } // namespace cxsc
00085