Go to the documentation of this file.00001 #include "cs.h"
00002
00003 cs *cs_transpose (const cs *A, int values)
00004 {
00005 int p, q, j, *Cp, *Ci, n, m, *Ap, *Ai, *w ;
00006 double *Cx, *Ax ;
00007 cs *C ;
00008 if (!CS_CSC (A)) return (NULL) ;
00009 m = A->m ; n = A->n ; Ap = A->p ; Ai = A->i ; Ax = A->x ;
00010 C = cs_spalloc (n, m, Ap [n], values && Ax, 0) ;
00011 w = (int*)cs_calloc (m, sizeof (int)) ;
00012 if (!C || !w) return (cs_done (C, w, NULL, 0)) ;
00013 Cp = C->p ; Ci = C->i ; Cx = C->x ;
00014 for (p = 0 ; p < Ap [n] ; p++) w [Ai [p]]++ ;
00015 cs_cumsum (Cp, w, m) ;
00016 for (j = 0 ; j < n ; j++)
00017 {
00018 for (p = Ap [j] ; p < Ap [j+1] ; p++)
00019 {
00020 Ci [q = w [Ai [p]]++] = j ;
00021 if (Cx) Cx [q] = Ax [p] ;
00022 }
00023 }
00024 return (cs_done (C, w, NULL, 1)) ;
00025 }