File: polynomial.h

package info (click to toggle)
graphthing 1.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 856 kB
  • ctags: 700
  • sloc: cpp: 7,716; yacc: 209; sh: 206; lex: 188; makefile: 11
file content (69 lines) | stat: -rw-r--r-- 1,510 bytes parent folder | download | duplicates (4)
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
//
//	polynomial.h
//

#ifndef __POLYNOMIAL_H__
#define __POLYNOMIAL_H__

#include "wx/string.h"

#include <iostream>
#include <vector>


class Polynomial
{
private:
	class PolynomialRep
	{
	public:
		std::vector<int> data;
		unsigned int ref;

		PolynomialRep ();
		PolynomialRep (const PolynomialRep *other);
	};

	PolynomialRep *rep;

	void minimise ();
	void unref ();
	void mutator ();

public:
	Polynomial ();
	Polynomial (int x0);
	Polynomial (int x1, int x0);
	Polynomial (int x2, int x1, int x0);
	Polynomial (int x3, int x2, int x1, int x0);
	Polynomial (int x4, int x3, int x2, int x1, int x0);
	Polynomial (int x5, int x4, int x3, int x2, int x1, int x0);
	Polynomial (const Polynomial &other);
	~Polynomial ();


	unsigned int degree () const;
	int eval (int x) const;

	static Polynomial binomial (int n, unsigned int pow);


	const int &operator[] (unsigned int pow) const;
	int &operator[] (unsigned int pow);
	int operator() (int x) const;
	Polynomial &operator= (const Polynomial &other);

	wxString str () const;
	friend std::ostream &operator<< (std::ostream &o, const Polynomial &p);
	friend bool operator== (const Polynomial &p1,
						const Polynomial &p2);
	void operator+= (const Polynomial &other);
	Polynomial operator+ (const Polynomial &other) const;
	void operator-= (const Polynomial &other);
	Polynomial operator- (const Polynomial &other) const;
	void operator*= (const Polynomial &other);
	Polynomial operator* (const Polynomial &other) const;
};


#endif	// __POLYNOMIAL_H__