-
Notifications
You must be signed in to change notification settings - Fork 0
/
polynomial.h
55 lines (50 loc) · 1.49 KB
/
polynomial.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef _POLYNOM_H
#define _POLYNOM_H
#include <stdio.h>
#include <stdlib.h>
#ifdef _WINDOWS
#include <malloc.h>
#include <inttypes.h>
#endif /* _WINDOWS */
#include <stdint.h>
typedef struct polynom_s polynom_t;
/* A struct representing a polynomial. Supports up to 8 variables
* (indeterminates).
*/
typedef struct polynom_var_s { float v[8]; } polynom_var_t;
/* A struct representing arguments to a function of a polynom_t.
*/
polynom_t *InitPolynomial();
/* Returns a pointer to an initalized polynom_t. Allocates a polynom_t, but none
* of its members. Calls exit() on malloc() failure.
*/
void DestroyPolynomial(
polynom_t *P);
/* Cleans up a polynom_t. Free all members and itself.
*/
int AppendTermPolynomial(
int32_t Coefficent,
uint8_t Variables,
int32_t *Exponents,
polynom_t *P);
/* Returns 0 on success, 1 on failure. Variables represents the spesific
* variable to be used in the term. The 0th set bit aligns with the 0 index in
* Exponents.
*/
float FunctionOfPolynomial(
polynom_t *P,
polynom_var_t *x);
/* Returns the result of P(x) such that P is the function representing the
* polynomial P and x is an int32_t array containing arbitrary values for all
* indeterminates of P.
*/
/*** Helpers ***/
char *StringPolynomial(
polynom_t *P);
/* Returns a string representation of P.
*/
void PrintPolynomial(
polynom_t *P);
/* Prints a string representation of P.
*/
#endif /* _POLYNOM_H */