cs_house.c
Go to the documentation of this file.
1 #include "cs.h"
2 /* create a Householder reflection [v,beta,s]=house(x), overwrite x with v,
3  * where (I-beta*v*v')*x = s*e1. See Algo 5.1.1, Golub & Van Loan, 3rd ed. */
4 double cs_house (double *x, double *beta, int n)
5 {
6  double s, sigma = 0 ;
7  int i ;
8  if (!x || !beta) return (-1) ; /* check inputs */
9  for (i = 1 ; i < n ; i++) sigma += x [i] * x [i] ;
10  if ( fabs( sigma ) <= 3e-16 )
11  {
12  s = fabs (x [0]) ; /* s = |x(0)| */
13  (*beta) = (x [0] <= 0) ? 2 : 0 ;
14  x [0] = 1 ;
15  }
16  else
17  {
18  s = sqrt (x [0] * x [0] + sigma) ; /* s = norm (x) */
19  x [0] = (x [0] <= 0) ? (x [0] - s) : (-sigma / (x [0] + s)) ;
20  (*beta) = -1. / (s * x [0]) ;
21  }
22  return (s) ;
23 }
IntermediateState sqrt(const Expression &arg)
double cs_house(double *x, double *beta, int n)
Definition: cs_house.c:4


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