cs_transpose.c
Go to the documentation of this file.
00001 #include "cs.h"
00002 /* C = A' */
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) ;    /* check inputs */
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) ;       /* allocate result */
00011     w = cs_calloc (m, sizeof (int)) ;                      /* get workspace */
00012     if (!C || !w) return (cs_done (C, w, NULL, 0)) ;       /* out of memory */
00013     Cp = C->p ; Ci = C->i ; Cx = C->x ;
00014     for (p = 0 ; p < Ap [n] ; p++) w [Ai [p]]++ ;          /* row counts */
00015     cs_cumsum (Cp, w, m) ;                                 /* row pointers */
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 ; /* place A(i,j) as entry C(j,i) */
00021             if (Cx) Cx [q] = Ax [p] ;
00022         }
00023     }
00024     return (cs_done (C, w, NULL, 1)) ;  /* success; free w and return C */
00025 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


hogman_minimal
Author(s): Maintained by Juergen Sturm
autogenerated on Wed Dec 26 2012 15:36:47