cs_norm.c
Go to the documentation of this file.
1 #include "cs.h"
2 /* 1-norm of a sparse matrix = max (sum (abs (A))), largest column sum */
3 double cs_norm (const cs *A)
4 {
5  int p, j, n, *Ap ;
6  double *Ax, norm = 0, s ;
7  if (!CS_CSC (A) || !A->x) return (-1) ; /* check inputs */
8  n = A->n ; Ap = A->p ; Ax = A->x ;
9  for (j = 0 ; j < n ; j++)
10  {
11  for (s = 0, p = Ap [j] ; p < Ap [j+1] ; p++) s += fabs (Ax [p]) ;
12  norm = CS_MAX (norm, s) ;
13  }
14  return (norm) ;
15 }
int n
Definition: cs.h:20
double cs_norm(const cs *A)
Definition: cs_norm.c:3
#define CS_MAX(a, b)
Definition: cs.h:134
#define CS_CSC(A)
Definition: cs.h:140
int * p
Definition: cs.h:21
Definition: cs.h:16
double * x
Definition: cs.h:23


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