Skip to content

Commit b2eb209

Browse files
committed
Add License Violation
1 parent c215724 commit b2eb209

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Untitled.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include "cs.h"
2+
/* C = A' */
3+
cs *cs_transpose (const cs *A, CS_INT values)
4+
{
5+
CS_INT p, q, j, *Cp, *Ci, n, m, *Ap, *Ai, *w ;
6+
CS_ENTRY *Cx, *Ax ;
7+
cs *C ;
8+
if (!CS_CSC (A)) return (NULL) ; /* check inputs */
9+
m = A->m ; n = A->n ; Ap = A->p ; Ai = A->i ; Ax = A->x ;
10+
C = cs_spalloc (n, m, Ap [n], values && Ax, 0) ; /* allocate result */
11+
w = cs_calloc (m, sizeof (CS_INT)) ; /* get workspace */
12+
if (!C || !w) return (cs_done (C, w, NULL, 0)) ; /* out of memory */
13+
Cp = C->p ; Ci = C->i ; Cx = C->x ;
14+
for (p = 0 ; p < Ap [n] ; p++) w [Ai [p]]++ ; /* row counts */
15+
cs_cumsum (Cp, w, m) ; /* row pointers */
16+
for (j = 0 ; j < n ; j++)
17+
{
18+
for (p = Ap [j] ; p < Ap [j+1] ; p++)
19+
{
20+
Ci [q = w [Ai [p]]++] = j ; /* place A(i,j) as entry C(j,i) */
21+
if (Cx) Cx [q] = (values > 0) ? CS_CONJ (Ax [p]) : Ax [p] ;
22+
}
23+
}
24+
return (cs_done (C, w, NULL, 1)) ; /* success; free w and return C */
25+
}

0 commit comments

Comments
 (0)