cs_compress.c
Go to the documentation of this file.
1 #include "cs.h"
2 /* C = compressed-column form of a triplet matrix T */
3 cs *cs_compress (const cs *T)
4 {
5  int m, n, nz, p, k, *Cp, *Ci, *w, *Ti, *Tj ;
6  double *Cx, *Tx ;
7  cs *C ;
8  if (!CS_TRIPLET (T)) return (NULL) ; /* check inputs */
9  m = T->m ; n = T->n ; Ti = T->i ; Tj = T->p ; Tx = T->x ; nz = T->nz ;
10  C = cs_spalloc (m, n, nz, Tx != NULL, 0) ; /* allocate result */
11  w = (int*)cs_calloc (n, sizeof (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 (k = 0 ; k < nz ; k++) w [Tj [k]]++ ; /* column counts */
15  cs_cumsum (Cp, w, n) ; /* column pointers */
16  for (k = 0 ; k < nz ; k++)
17  {
18  Ci [p = w [Tj [k]]++] = Ti [k] ; /* A(i,j) is the pth entry in C */
19  if (Cx) Cx [p] = Tx [k] ;
20  }
21  return (cs_done (C, w, NULL, 1)) ; /* success; free w and return C */
22 }
USING_NAMESPACE_ACADO typedef TaylorVariable< Interval > T
cs * cs_spalloc(int m, int n, int nzmax, int values, int triplet)
Definition: cs_util.c:3
cs * cs_done(cs *C, void *w, void *x, int ok)
Definition: cs_util.c:89
int n
Definition: cs.h:20
int nz
Definition: cs.h:24
int * p
Definition: cs.h:21
Definition: cs.h:16
int * i
Definition: cs.h:22
void * cs_calloc(int n, size_t size)
Definition: cs_malloc.c:16
double cs_cumsum(int *p, int *c, int n)
Definition: cs_cumsum.c:3
cs * cs_compress(const cs *T)
Definition: cs_compress.c:3
#define CS_TRIPLET(A)
Definition: cs.h:141
double * x
Definition: cs.h:23
int m
Definition: cs.h:19


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:34:31