public static DZcs cs_permute ( DZcs A , int [ ] pinv , int [ ] q , boolean values ) { int t , j , k , nz = 0 , m , n , Ap [ ] , Ai [ ] , Cp [ ] , Ci [ ] ; DZcsa Cx = new DZcsa ( ) , Ax = new DZcsa ( ) ; DZcs C ; if ( ! CS_CSC ( A ) ) return ( null ) ; /* check inputs */ m = A . m ; n = A . n ; Ap = A . p ; Ai = A . i ; Ax . x = A . x ; C = cs_spalloc ( m , n , Ap [ n ] , values && Ax . x != null , false ) ; /* alloc result */ Cp = C . p ; Ci = C . i ; Cx . x = C . x ; for ( k = 0 ; k < n ; k ++ ) { Cp [ k ] = nz ; /* column k of C is column q[k] of A */ j = q != null ? ( q [ k ] ) : k ; for ( t = Ap [ j ] ; t < Ap [ j + 1 ] ; t ++ ) { if ( Cx . x != null ) Cx . set ( nz , Ax . get ( t ) ) ; /* row i of A is row pinv[i] of C */ Ci [ nz ++ ] = pinv != null ? ( pinv [ Ai [ t ] ] ) : Ai [ t ] ; } } Cp [ n ] = nz ; /* finalize the last column of C */ return C ; }
Permutes a sparse matrix C = PAQ .