C-XSC - A C++ Class Library for Extended Scientific Computing 2.5.4
l_rmatrix.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_rmatrix.cpp,v 1.16 2014/01/30 17:23:46 cxsc Exp $ */
25
26#define _CXSC_CPP
27
28#include "l_rmatrix.hpp"
29#include "matrix.inl"
30#include "l_rmatrix.inl"
31#include "lrvecrmat.inl"
32
33namespace cxsc {
34 l_rmatrix Id ( const l_rmatrix& A ) // l_real identity matrix
35 { //-----------------------
36 int i,j;
37 int lbi = Lb(A,1), ubi = Ub(A,1);
38 int lbj = Lb(A,2), ubj = Ub(A,2);
39 l_rmatrix B(lbi,ubi,lbj,ubj);
40
41 for (i = lbi; i <= ubi; i++)
42 for (j = lbj; j <= ubj; j++)
43 B[i][j] = (i==j) ? 1.0 : 0.0;
44 return B;
45 }
46
47 l_rmatrix transp ( const l_rmatrix& A ) // Transposed matrix
48 { //------------------
49 int n;
50 l_rmatrix res(Lb(A,2),Ub(A,2),Lb(A,1),Ub(A,1));
51
52 for (n = Lb(A,1); n <= Ub(A,1); n++) Col(res,n) = Row(A,n);
53 return res;
54 }
55
57 {
58 int n = Lb(A,1);
59 Resize(A,n,2*Ub(A,1)-n+1,Lb(A,2),Ub(A,2));
60 }
61
62} // namespace cxsc
63
The Multiple-Precision Data Type l_rmatrix.
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
cimatrix transp(const cimatrix &A)
Returns the transposed matrix.
Definition cimatrix.cpp:74
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.