SINFONI Pipeline Reference Manual  2.6.0
sinfo_companion.c
1 /*
2  * This file is part of the ESO SINFONI Pipeline
3  * Copyright (C) 2004,2005 European Southern Observatory
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
18  */
19 #ifdef HAVE_CONFIG_H
20 # include <config.h>
21 #endif
22 #include "sinfo_solve_poly_root.h"
23 
39 void
40 sinfo_set_companion_matrix(const double *a, size_t nc, double *m)
41 {
42  size_t i, j;
43 
44  for (i = 0; i < nc; i++)
45  for (j = 0; j < nc; j++)
46  MAT (m, i, j, nc)= 0.0;
47 
48  for (i = 1; i < nc; i++)
49  MAT (m, i, i - 1, nc)= 1.0;
50 
51  for (i = 0; i < nc; i++)
52  MAT (m, i, nc - 1, nc)= -a[i] / a[nc];
53  }