libsc  2.8.7
The SC library provides support for parallel scientific applications.
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
sc_polynom.h
1 /*
2  This file is part of the SC Library.
3  The SC Library provides support for parallel scientific applications.
4 
5  Copyright (C) 2010 The University of Texas System
6  Additional copyright (C) 2011 individual authors
7 
8  The SC Library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Lesser General Public
10  License as published by the Free Software Foundation; either
11  version 2.1 of the License, or (at your option) any later version.
12 
13  The SC Library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public
19  License along with the SC Library; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  02110-1301, USA.
22 */
23 
24 #ifndef SC_POLYNOM_H
25 #define SC_POLYNOM_H
26 
27 #include <sc.h>
28 
29 SC_EXTERN_C_BEGIN;
30 
32 typedef struct sc_polynom sc_polynom_t;
33 
40 int sc_polynom_degree (const sc_polynom_t * p);
41 
47 double *sc_polynom_coefficient (sc_polynom_t * p, int i);
48 
55 const double *sc_polynom_coefficient_const (const sc_polynom_t * p,
56  int i);
57 
59 void sc_polynom_destroy (sc_polynom_t * p);
60 
62 sc_polynom_t *sc_polynom_new (void);
63 
64 /* Alternate constructors */
65 
67 sc_polynom_t *sc_polynom_new_constant (double c);
68 
77 sc_polynom_t *sc_polynom_new_lagrange (int degree, int which,
78  const double *points);
79 
84 sc_polynom_t *sc_polynom_new_from_coefficients (int degree,
85  const double
86  *coefficients);
87 
88 /* Alternate constructors using other polynoms */
89 
90 sc_polynom_t *sc_polynom_new_from_polynom (const sc_polynom_t * q);
91 sc_polynom_t *sc_polynom_new_from_scale (const sc_polynom_t * q,
92  int exponent, double factor);
93 sc_polynom_t *sc_polynom_new_from_sum (const sc_polynom_t * q,
94  const sc_polynom_t * r);
95 sc_polynom_t *sc_polynom_new_from_product (const sc_polynom_t * q,
96  const sc_polynom_t * r);
97 
98 /* Manipulating a polynom */
99 
105 void sc_polynom_set_degree (sc_polynom_t * p, int degree);
106 
111 void sc_polynom_set_constant (sc_polynom_t * p, double value);
112 
117 void sc_polynom_set_polynom (sc_polynom_t * p,
118  const sc_polynom_t * q);
119 
124 void sc_polynom_shift (sc_polynom_t * p,
125  int exponent, double factor);
126 
131 void sc_polynom_scale (sc_polynom_t * p,
132  int exponent, double factor);
133 
138 void sc_polynom_add (sc_polynom_t * p, const sc_polynom_t * q);
139 
144 void sc_polynom_sub (sc_polynom_t * p, const sc_polynom_t * q);
145 
151 void sc_polynom_AXPY (double A, const sc_polynom_t * X,
152  sc_polynom_t * Y);
153 
158 void sc_polynom_multiply (sc_polynom_t * p,
159  const sc_polynom_t * q);
160 
161 /***************** investigate properties of polynomials ****************/
162 
168 double sc_polynom_eval (const sc_polynom_t * p, double x);
169 
188 int sc_polynom_roots (const sc_polynom_t * p, double *roots);
189 
190 SC_EXTERN_C_END;
191 
192 #endif /* !SC_POLYNOM_H */
Support for process management (memory allocation, logging, etc.)