EpetraExt Development
mattrans.f
Go to the documentation of this file.
00001         subroutine mattrans (m, n, ja, ia, jao, iao)
00002         integer ia(m+1), iao(n+1), ja(*), jao(*)
00003 c-------------------------------------------------------------------
00004 c transpose a matrix stored in a, ja, ia format.
00005 c ---------------
00006 c input arguments:
00007 c m     = row dimension of A.
00008 c n     = column dimension of A.
00009 c ja    = integer array of size nnz containing the column positions
00010 c         of the corresponding elements in a.
00011 c ia    = integer of size n+1. ia(k) contains the position in a, ja of
00012 c         the beginning of the k-th row.
00013 c output arguments:
00014 c jao   = integer array of size nnz containing the column indices.
00015 c iao   = integer array of size m+1 containing the "ia" index array of
00016 c         the transposed matrix.
00017 c--------------------------------------------------------------------
00018 c
00019 c  count the number of elements in every column of a and row of ao
00020 c
00021         do 1 i=1, n+1
00022  1           iao(i) = 0
00023         do 3 i=1, m
00024                 k1 = ia(i)
00025                 k2 = ia(i+1) -1
00026                 do 2 k=k1, k2
00027                         j = ja(k)+1
00028                         iao(j) = iao(j)+1
00029  2              continue
00030  3      continue
00031 c find addresses of new first elements..
00032         iao(1) = 1
00033         do 4 i=1, n
00034  4      iao(i+1) = iao(i) + iao(i+1)
00035 c now do the actual copying.
00036         do 6 i=1, m
00037                 k1 = ia(i)
00038                 k2 = ia(i+1)-1
00039                 do 62 k=k1,k2
00040                         j = ja(k)
00041                         next = iao(j)
00042                         jao(next) = i
00043                         iao(j) = next+1
00044  62             continue
00045  6      continue
00046 c reshift iao
00047         do 7 i = n, 1, -1
00048  7         iao(i+1) = iao(i)
00049         iao(1) = 1
00050 c--------------- end of mattrans ---------------------------------
00051         end
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines