summaryrefslogtreecommitdiff
path: root/include/kintpoly.h
blob: 5f71c72165f44fe301164aaf797b92a4c699a5d4 (plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#ifndef _KINTPOLY_H
#define _KINTPOLY_H

#include <cassert>
#include <cstdlib>
#include <iostream>

#include <bigint.h>

using namespace std;

class K_INTPOLY
{
//  A class for polynomials with bigint coefficients
  
  unsigned long num_vars;    //  Number of variables
  long*         deg;         //  Max. degree in each variable
  
  unsigned long num_coeffs;  //  Number of coefficients (terms)
  bigint*       coeffs;
  
  //  primitives
  
  long* index_to_powers(const unsigned long i) const;
  //  For an index, i, return the powers, p, of the term
  //  to which the i-th coefficient belongs to.
  
  unsigned long powers_to_index(const long* const p) const;
  //  Return the index of the term of the powers p.
  
  int reduce_deg();
  
  //  arithmetic
  
  K_INTPOLY add(const K_INTPOLY&) const;
  K_INTPOLY sub(const K_INTPOLY&) const;
  K_INTPOLY mul(const K_INTPOLY&) const;
  K_INTPOLY mul(const bigint&) const;
  
	K_INTPOLY neg() const;
  
  //  stream
  
  ostream& output(ostream&) const;
  
public:
  
  //  constructors, assignment and destructor
  
	K_INTPOLY();
  K_INTPOLY(const unsigned long, const long* const);
  K_INTPOLY(const unsigned long, const long* const, const bigint* const);
  
  K_INTPOLY(const K_INTPOLY&);
  K_INTPOLY& operator =(const K_INTPOLY&);
  
  ~K_INTPOLY();
  
  //  stream
  
  friend ostream& operator <<(ostream&, const K_INTPOLY&);
  
	//  arithmetic
  
  friend K_INTPOLY operator +(const K_INTPOLY&, const K_INTPOLY&);
  friend K_INTPOLY operator -(const K_INTPOLY&, const K_INTPOLY&);
  friend K_INTPOLY operator *(const K_INTPOLY&, const K_INTPOLY&);
  friend K_INTPOLY operator *(const K_INTPOLY&, const bigint&);
  friend K_INTPOLY operator *(const bigint&, const K_INTPOLY&);
  
  friend K_INTPOLY operator -(const K_INTPOLY&);
  
  //  other functions
  
  K_INTPOLY derivative(const unsigned long) const;
  K_INTPOLY subst_first_var(const bigint&) const;
  bigint    evaluate(const bigint* const) const;
  int       sgn_at(const bigint* const) const;
  K_INTPOLY subst_val(const unsigned long, const bigint&) const;
  K_INTPOLY subst_expr(const unsigned long, const K_INTPOLY&) const;
  K_INTPOLY subst_expr(const unsigned long,
                       const K_INTPOLY&, const K_INTPOLY&) const;
  
  //  other univariate functions
  
  int sgn_at(const bigint&) const;
};

#endif