Debian Codegraph @

external/gsl/gsl_poly__zsolve.c

raw symbols SCIP
1 /* poly/zsolve.c
2 *
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Brian Gough
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 3 of the License, or (at
8 * your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * 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, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20 /* zsolve.c - finds the complex roots of = 0 */
21
22 #include "gsl__config.h"cxx . . $ `<file>/external/gsl/gsl__config.h`/
23 #include <math.h>
24 #include <stdlib.h>
25 #include "gsl_math.h"cxx . . $ `<file>/external/gsl/gsl_math.h`/
26 #include "gsl_errno.h"cxx . . $ `<file>/external/gsl/gsl_errno.h`/
27 #include "gsl_complex.h"cxx . . $ `<file>/external/gsl/gsl_complex.h`/
28 #include "gsl_poly.h"cxx . . $ `<file>/external/gsl/gsl_poly.h`/
29
30 /* C-style matrix elements */
31 #define MATcxx . . $ `external/gsl/gsl_poly__zsolve.c:31:9`!(m,i,j,n) ((m)[(i)*(n) + (j)])
32
33 /* Fortran-style matrix elements */
34 #define FMATcxx . . $ `external/gsl/gsl_poly__zsolve.c:34:9`!(m,i,j,n) ((m)[((i)-1)*(n) + ((j)-1)])
35
36 #include "gsl_poly__companion.c"cxx . . $ `<file>/external/gsl/gsl_poly__companion.c`/
37 #include "gsl_poly__balance.c"cxx . . $ `<file>/external/gsl/gsl_poly__balance.c`/
38 #include "gsl_poly__qr.c"cxx . . $ `<file>/external/gsl/gsl_poly__qr.c`/
39
40 int
41 gsl_poly_complex_solvecxx . . $ gsl_poly_complex_solve(2d3e07883725725c). (const double *a, size_t n,
42 gsl_poly_complex_workspacecxx . . $ gsl_poly_complex_workspace# * w,
43 gsl_complex_packed_ptrcxx . . $ gsl_complex_packed_ptr# z)
44 {
45 int status;
46 double *m;
47
48 if (n == 0)
49 {
50 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("number of terms must be a positive integer", GSL_EINVAL);
51 }
52
53 if (n == 1)
54 {
55 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("cannot solve for only one term", GSL_EINVAL);
56 }
57
58 if (a[n - 1] == 0)
59 {
60 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("leading term of polynomial must be non-zero", GSL_EINVAL) ;
61 }
62
63 if (w->nccxx . . $ $anonymous_type_a68e025527e5319d_0#nc. != n - 1)
64 {
65 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("size of workspace does not match polynomial", GSL_EINVAL);
66 }
67
68 m = w->matrixcxx . . $ $anonymous_type_a68e025527e5319d_0#matrix.;
69
70 set_companion_matrixcxx . . $ set_companion_matrix(491ba54a98609022). (a, n - 1, m);
71
72 balance_companion_matrixcxx . . $ balance_companion_matrix(3f78977deb701e8b). (m, n - 1);
73
74 status = qr_companioncxx . . $ qr_companion(9d1bc2cd1a3e261b). (m, n - 1, z);
75
76 if (status)
77 {
78 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`!("root solving qr method failed to converge", GSL_EFAILED);
79 }
80
81 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
82 }
83
84
85