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