C-XSC - A C++ Class Library for Extended Scientific Computing 2.5.4
l_imatrix.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: l_imatrix.cpp,v 1.18 2014/01/30 17:23:46 cxsc Exp $ */
25
26#define _CXSC_CPP
27
28#include "l_imatrix.hpp"
29#include "matrix.inl"
30#include "l_imatrix.inl"
31#include "livecrmat.inl"
32#include "liveclrmat.inl"
33#include "livecimat.inl"
34
35// they should also be included here
36#include "lrvecimat.inl"
37#include "iveclrmat.inl"
38#include "lrmatimat.inl"
39
40namespace cxsc {
41l_imatrix Id ( const l_imatrix& A ) // l_interval identity matrix
42{ //---------------------------
43 int i,j;
44 int lbi = Lb(A,1), ubi = Ub(A,1);
45 int lbj = Lb(A,2), ubj = Ub(A,2);
46 l_imatrix B(lbi,ubi,lbj,ubj);
47
48 for (i = lbi; i <= ubi; i++)
49 for (j = lbj; j <= ubj; j++)
50 B[i][j] = l_interval( (i==j) ? 1.0 : 0.0 );
51 return B;
52}
53
54l_imatrix transp ( const l_imatrix& A ) // Transposed matrix
55{ //------------------
56 int n;
57 l_imatrix res(Lb(A,2),Ub(A,2),Lb(A,1),Ub(A,1));
58
59 for (n = Lb(A,1); n <= Ub(A,1); n++) Col(res,n) = Row(A,n);
60 return res;
61}
62
63l_real MaxRelDiam ( const l_imatrix_subv& v ) // Maximum relative diameter
64{ //--------------------------
65 l_real r;
66 int i, l=Lb(v), u=Ub(v);
67
68 r = 0.0;
69 for (i = l; i <= u; i++)
70 if (RelDiam(v[i]) > r) r = RelDiam(v[i]);
71 return r;
72}
73
74// The 'DoubleSize' functions double the number of rows of a matrix
75// or double the length of a vector preserving existing components.
76//------------------------------------------------------------------
77
79{
80 int n = Lb(A,1);
81 Resize(A,n,2*Ub(A,1)-n+1,Lb(A,2),Ub(A,2));
82}
83
84} // namespace cxsc
85
The Multiple-Precision Data Type l_imatrix_subv.
Definition l_imatrix.hpp:47
The Multiple-Precision Data Type l_imatrix.
The Multiple-Precision Data Type l_interval.
The Multiple-Precision Data Type l_real.
Definition l_real.hpp:78
The namespace cxsc, providing all functionality of the class library C-XSC.
Definition cdot.cpp:29
cimatrix_subv Col(cimatrix &m, const int &i) noexcept
Returns one column of the matrix as a vector.
Definition cimatrix.inl:242
real MaxRelDiam(const imatrix_subv &v)
Computes the relative diameter .
Definition imatrix.cpp:76
cimatrix transp(const cimatrix &A)
Returns the transposed matrix.
Definition cimatrix.cpp:74
real RelDiam(const interval &x)
Computes the relative diameter .
Definition interval.cpp:316
int Ub(const cimatrix &rm, const int &i) noexcept
Returns the upper bound index.
cimatrix_subv Row(cimatrix &m, const int &i) noexcept
Returns one row of the matrix as a vector.
Definition cimatrix.inl:231
void DoubleSize(cimatrix &A)
Doubles the size of the matrix.
Definition cimatrix.cpp:83
cimatrix Id(const cimatrix &A)
Returns the Identity matrix.
Definition cimatrix.cpp:61
void Resize(cimatrix &A) noexcept
Resizes the matrix.
int Lb(const cimatrix &rm, const int &i) noexcept
Returns the lower bound index.