C-XSC - A C++ Class Library for Extended Scientific Computing  2.5.4
intvector.cpp
1 /*
2 ** CXSC is a C++ library for eXtended Scientific Computing (V 2.5.4)
3 **
4 ** Copyright (C) 1990-2000 Institut fuer Angewandte Mathematik,
5 ** Universitaet Karlsruhe, Germany
6 ** (C) 2000-2014 Wiss. Rechnen/Softwaretechnologie
7 ** Universitaet Wuppertal, Germany
8 **
9 ** This library is free software; you can redistribute it and/or
10 ** modify it under the terms of the GNU Library General Public
11 ** License as published by the Free Software Foundation; either
12 ** version 2 of the License, or (at your option) any later version.
13 **
14 ** This library is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 ** Library General Public License for more details.
18 **
19 ** You should have received a copy of the GNU Library General Public
20 ** License along with this library; if not, write to the Free
21 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23 
24 /* CVS $Id: intvector.cpp,v 1.15 2014/01/30 17:23:45 cxsc Exp $ */
25 
26 #define _CXSC_CPP
27 
28 #include "intvector.hpp"
29 #include "vector.inl"
30 #include "intvector.inl"
31 
32 namespace cxsc {
33 
34 int abs(int a)
35 { return a<0?-a:a; }
36 
37 // The 'DoubleSize' functions double the number of rows of a matrix
38 // or double the length of a vector preserving existing components.
39 //------------------------------------------------------------------
40 void DoubleSize ( intvector& x )
41 {
42  int n = Lb(x);
43  Resize(x,n,2*Ub(x)-n+1);
44 }
45 
46 std::ostream& operator<< ( std::ostream& os, intvector& v ) // Output of integer
47 { // vectors
48  int i, newline = (Ub(v)-Lb(v) > 15); //------------------
49 
50  for (i = Lb(v); i <= Ub(v); i++) {
51  os << v[i] << ' ';
52  if (newline) os << std::endl;
53  }
54  if (!newline) os << std::endl;
55  return os;
56 }
57 
58 } // namespace cxsc
59 
The Data Type intvector.
Definition: intvector.hpp:52
The namespace cxsc, providing all functionality of the class library C-XSC.
Definition: cdot.cpp:29
int Ub(const cimatrix &rm, const int &i) noexcept
Returns the upper bound index.
Definition: cimatrix.inl:1163
void DoubleSize(cimatrix &A)
Doubles the size of the matrix.
Definition: cimatrix.cpp:83
ivector abs(const cimatrix_subv &mv) noexcept
Returns the absolute value of the matrix.
Definition: cimatrix.inl:737
void Resize(cimatrix &A) noexcept
Resizes the matrix.
Definition: cimatrix.inl:1211
int Lb(const cimatrix &rm, const int &i) noexcept
Returns the lower bound index.
Definition: cimatrix.inl:1156