libsc 2.8.5.210-64a7
The SC library provides support for parallel scientific applications.
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
29SC_EXTERN_C_BEGIN;
30
32typedef struct sc_polynom sc_polynom_t;
33
40int sc_polynom_degree (const sc_polynom_t * p);
41
47double *sc_polynom_coefficient (sc_polynom_t * p, int i);
48
55const double *sc_polynom_coefficient_const (const sc_polynom_t * p,
56 int i);
57
59void sc_polynom_destroy (sc_polynom_t * p);
60
62sc_polynom_t *sc_polynom_new (void);
63
64/* Alternate constructors */
65
67sc_polynom_t *sc_polynom_new_constant (double c);
68
77sc_polynom_t *sc_polynom_new_lagrange (int degree, int which,
78 const double *points);
79
84sc_polynom_t *sc_polynom_new_from_coefficients (int degree,
85 const double
86 *coefficients);
87
88/* Alternate constructors using other polynoms */
89
90sc_polynom_t *sc_polynom_new_from_polynom (const sc_polynom_t * q);
91sc_polynom_t *sc_polynom_new_from_scale (const sc_polynom_t * q,
92 int exponent, double factor);
93sc_polynom_t *sc_polynom_new_from_sum (const sc_polynom_t * q,
94 const sc_polynom_t * r);
95sc_polynom_t *sc_polynom_new_from_product (const sc_polynom_t * q,
96 const sc_polynom_t * r);
97
98/* Manipulating a polynom */
99
105void sc_polynom_set_degree (sc_polynom_t * p, int degree);
106
111void sc_polynom_set_constant (sc_polynom_t * p, double value);
112
117void sc_polynom_set_polynom (sc_polynom_t * p,
118 const sc_polynom_t * q);
119
124void sc_polynom_shift (sc_polynom_t * p,
125 int exponent, double factor);
126
131void sc_polynom_scale (sc_polynom_t * p,
132 int exponent, double factor);
133
138void sc_polynom_add (sc_polynom_t * p, const sc_polynom_t * q);
139
144void sc_polynom_sub (sc_polynom_t * p, const sc_polynom_t * q);
145
151void sc_polynom_AXPY (double A, const sc_polynom_t * X,
152 sc_polynom_t * Y);
153
158void sc_polynom_multiply (sc_polynom_t * p,
159 const sc_polynom_t * q);
160
161/***************** investigate properties of polynomials ****************/
162
168double sc_polynom_eval (const sc_polynom_t * p, double x);
169
188int sc_polynom_roots (const sc_polynom_t * p, double *roots);
189
190SC_EXTERN_C_END;
191
192#endif /* !SC_POLYNOM_H */
Support for process management (memory allocation, logging, etc.)