00001 /* ========================================================================== */ 00002 /* === umfpack_transpose ==================================================== */ 00003 /* ========================================================================== */ 00004 00005 /* -------------------------------------------------------------------------- */ 00006 /* UMFPACK Version 4.3 (Jan. 16, 2004), Copyright (c) 2004 by Timothy A. */ 00007 /* Davis. All Rights Reserved. See ../README for License. */ 00008 /* email: davis@cise.ufl.edu CISE Department, Univ. of Florida. */ 00009 /* web: http://www.cise.ufl.edu/research/sparse/umfpack */ 00010 /* -------------------------------------------------------------------------- */ 00011 00012 int umfpack_di_transpose 00013 ( 00014 int n_row, 00015 int n_col, 00016 const int Ap [ ], 00017 const int Ai [ ], 00018 const double Ax [ ], 00019 const int P [ ], 00020 const int Q [ ], 00021 int Rp [ ], 00022 int Ri [ ], 00023 double Rx [ ] 00024 ) ; 00025 00026 long umfpack_dl_transpose 00027 ( 00028 long n_row, 00029 long n_col, 00030 const long Ap [ ], 00031 const long Ai [ ], 00032 const double Ax [ ], 00033 const long P [ ], 00034 const long Q [ ], 00035 long Rp [ ], 00036 long Ri [ ], 00037 double Rx [ ] 00038 ) ; 00039 00040 int umfpack_zi_transpose 00041 ( 00042 int n_row, 00043 int n_col, 00044 const int Ap [ ], 00045 const int Ai [ ], 00046 const double Ax [ ], const double Az [ ], 00047 const int P [ ], 00048 const int Q [ ], 00049 int Rp [ ], 00050 int Ri [ ], 00051 double Rx [ ], double Rz [ ], 00052 int do_conjugate 00053 ) ; 00054 00055 long umfpack_zl_transpose 00056 ( 00057 long n_row, 00058 long n_col, 00059 const long Ap [ ], 00060 const long Ai [ ], 00061 const double Ax [ ], const double Az [ ], 00062 const long P [ ], 00063 const long Q [ ], 00064 long Rp [ ], 00065 long Ri [ ], 00066 double Rx [ ], double Rz [ ], 00067 long do_conjugate 00068 ) ; 00069 00070 /* 00071 double int Syntax: 00072 00073 #include "umfpack.h" 00074 int n_row, n_col, status, *Ap, *Ai, *P, *Q, *Rp, *Ri ; 00075 double *Ax, *Rx ; 00076 status = umfpack_di_transpose (n_row, n_col, Ap, Ai, Ax, P, Q, Rp, Ri, Rx) ; 00077 00078 double long Syntax: 00079 00080 #include "umfpack.h" 00081 long n_row, n_col, status, *Ap, *Ai, *P, *Q, *Rp, *Ri ; 00082 double *Ax, *Rx ; 00083 status = umfpack_dl_transpose (n_row, n_col, Ap, Ai, Ax, P, Q, Rp, Ri, Rx) ; 00084 00085 complex int Syntax: 00086 00087 #include "umfpack.h" 00088 int n_row, n_col, status, *Ap, *Ai, *P, *Q, *Rp, *Ri, do_conjugate ; 00089 double *Ax, *Az, *Rx, *Rz ; 00090 status = umfpack_zi_transpose (n_row, n_col, Ap, Ai, Ax, Az, P, Q, 00091 Rp, Ri, Rx, Rz, do_conjugate) ; 00092 00093 complex long Syntax: 00094 00095 #include "umfpack.h" 00096 long n_row, n_col, status, *Ap, *Ai, *P, *Q, *Rp, *Ri, do_conjugate ; 00097 double *Ax, *Az, *Rx, *Rz ; 00098 status = umfpack_zl_transpose (n_row, n_col, Ap, Ai, Ax, Az, P, Q, 00099 Rp, Ri, Rx, Rz, do_conjugate) ; 00100 00101 Purpose: 00102 00103 Transposes and optionally permutes a sparse matrix in row or column-form, 00104 R = (PAQ)'. In MATLAB notation, R = (A (P,Q))' or R = (A (P,Q)).' doing 00105 either the linear algebraic transpose or the array transpose. Alternatively, 00106 this routine can be viewed as converting A (P,Q) from column-form to 00107 row-form, or visa versa (for the array transpose). Empty rows and columns 00108 may exist. The matrix A may be singular and/or rectangular. 00109 00110 umfpack_*_transpose is useful if you want to factorize A' or A.' instead of 00111 A. Factorizing A' or A.' instead of A can be much better, particularly if 00112 AA' is much sparser than A'A. You can still solve Ax=b if you factorize 00113 A' or A.', by solving with the sys argument UMFPACK_At or UMFPACK_Aat, 00114 respectively, in umfpack_*_*solve. The umfpack mexFunction (umfpackmex.c) 00115 is one example. To compute x = A/b, it computes x = (A.'\b.').' instead, 00116 by factorizing A.'. It then uses the regular solve, since b.' and x.' are 00117 stored identically as b and x, respectively (both b.' and b are dense 00118 vectors). If b and x were arrays, the umfpack mexFunction would need to 00119 first compute b.' and then transpose the resulting solution. 00120 00121 Returns: 00122 00123 UMFPACK_OK if successful. 00124 UMFPACK_ERROR_out_of_memory if umfpack_*_transpose fails to allocate a 00125 size-max (n_row,n_col) workspace. 00126 UMFPACK_ERROR_argument_missing if Ai, Ap, Ri, and/or Rp are missing. 00127 UMFPACK_ERROR_n_nonpositive if n_row <= 0 or n_col <= 0 00128 UMFPACK_ERROR_invalid_permutation if P and/or Q are invalid. 00129 UMFPACK_ERROR_invalid_matrix if Ap [n_col] < 0, if Ap [0] != 0, 00130 if Ap [j] > Ap [j+1] for any j in the range 0 to n_col-1, 00131 if any row index i is < 0 or >= n_row, or if the row indices 00132 in any column are not in ascending order. 00133 00134 Arguments: 00135 00136 Int n_row ; Input argument, not modified. 00137 Int n_col ; Input argument, not modified. 00138 00139 A is an n_row-by-n_col matrix. Restriction: n_row > 0 and n_col > 0. 00140 00141 Int Ap [n_col+1] ; Input argument, not modified. 00142 00143 The column pointers of the column-oriented form of the matrix A. See 00144 umfpack_*_symbolic for a description. The number of entries in 00145 the matrix is nz = Ap [n_col]. Ap [0] must be zero, Ap [n_col] must be 00146 => 0, and Ap [j] <= Ap [j+1] and Ap [j] <= Ap [n_col] must be true for 00147 all j in the range 0 to n_col-1. Empty columns are OK (that is, Ap [j] 00148 may equal Ap [j+1] for any j in the range 0 to n_col-1). 00149 00150 Int Ai [nz] ; Input argument, not modified, of size nz = Ap [n_col]. 00151 00152 The nonzero pattern (row indices) for column j is stored in 00153 Ai [(Ap [j]) ... (Ap [j+1]-1)]. The row indices in a given column j 00154 must be in ascending order, and no duplicate row indices may be present. 00155 Row indices must be in the range 0 to n_row-1 (the matrix is 0-based). 00156 00157 double Ax [nz] ; Input argument, not modified, of size nz = Ap [n_col]. 00158 double Az [nz] ; Input argument, not modified, for complex versions. 00159 00160 If present, these are the numerical values of the sparse matrix A. 00161 The nonzero pattern (row indices) for column j is stored in 00162 Ai [(Ap [j]) ... (Ap [j+1]-1)], and the corresponding real numerical 00163 values are stored in Ax [(Ap [j]) ... (Ap [j+1]-1)]. The imaginary 00164 values are stored in Az [(Ap [j]) ... (Ap [j+1]-1)]. The values are 00165 transposed only if Ax and Rx are present (for the real version), and 00166 only if all four (Ax, Az, Rx, and Rz) are present for the complex 00167 version. These are not an error conditions; you are able to transpose 00168 and permute just the pattern of a matrix. 00169 00170 Future complex version: if Ax is present and Az is NULL, then both real 00171 and imaginary parts will be contained in Ax[0..2*nz-1], with Ax[2*k] 00172 and Ax[2*k+1] being the real and imaginary part of the kth entry. 00173 00174 Int P [n_row] ; Input argument, not modified. 00175 00176 The permutation vector P is defined as P [k] = i, where the original 00177 row i of A is the kth row of PAQ. If you want to use the identity 00178 permutation for P, simply pass (Int *) NULL for P. This is not an error 00179 condition. P is a complete permutation of all the rows of A; this 00180 routine does not support the creation of a transposed submatrix of A 00181 (R = A (1:3,:)' where A has more than 3 rows, for example, cannot be 00182 done; a future version might support this operation). 00183 00184 Int Q [n_col] ; Input argument, not modified. 00185 00186 The permutation vector Q is defined as Q [k] = j, where the original 00187 column j of A is the kth column of PAQ. If you want to use the identity 00188 permutation for Q, simply pass (Int *) NULL for Q. This is not an error 00189 condition. Q is a complete permutation of all the columns of A; this 00190 routine does not support the creation of a transposed submatrix of A. 00191 00192 Int Rp [n_row+1] ; Output argument. 00193 00194 The column pointers of the matrix R = (A (P,Q))' or (A (P,Q)).', in the 00195 same form as the column pointers Ap for the matrix A. 00196 00197 Int Ri [nz] ; Output argument. 00198 00199 The row indices of the matrix R = (A (P,Q))' or (A (P,Q)).' , in the 00200 same form as the row indices Ai for the matrix A. 00201 00202 double Rx [nz] ; Output argument. 00203 double Rz [nz] ; Output argument, imaginary part for complex versions. 00204 00205 If present, these are the numerical values of the sparse matrix R, 00206 in the same form as the values Ax and Az of the matrix A. 00207 00208 Future complex version: if Rx is present and Rz is NULL, then both real 00209 and imaginary parts will be contained in Rx[0..2*nz-1], with Rx[2*k] 00210 and Rx[2*k+1] being the real and imaginary part of the kth entry. 00211 00212 Int do_conjugate ; Input argument for complex versions only. 00213 00214 If true, and if Ax, Az, Rx, and Rz are all present, then the linear 00215 algebraic transpose is computed (complex conjugate). If false, the 00216 array transpose is computed instead. 00217 */