C-XSC - A C++ Class Library for Extended Scientific Computing  2.5.4
intvector.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: intvector.cpp,v 1.15 2014/01/30 17:23:45 cxsc Exp $ */
00025 
00026 #define _CXSC_CPP
00027 
00028 #include "intvector.hpp"
00029 #include "vector.inl"
00030 #include "intvector.inl"
00031 
00032 namespace cxsc {
00033 
00034 int abs(int a)
00035 { return a<0?-a:a; }
00036 
00037 // The 'DoubleSize' functions double the number of rows of a matrix
00038 // or double the length of a vector preserving existing components.
00039 //------------------------------------------------------------------
00040 void DoubleSize ( intvector& x )
00041 {
00042   int n = Lb(x);
00043   Resize(x,n,2*Ub(x)-n+1);
00044 }
00045 
00046 std::ostream& operator<< ( std::ostream& os, intvector& v ) // Output of integer
00047 {                                                          // vectors
00048   int i, newline = (Ub(v)-Lb(v) > 15);                     //------------------
00049 
00050   for (i = Lb(v); i <= Ub(v); i++) {
00051     os << v[i] << ' ';
00052     if (newline) os << std::endl;
00053   }
00054   if (!newline) os << std::endl;
00055   return os;
00056 }
00057 
00058 } // namespace cxsc
00059