From 065573b8357d602fbf379517aaa6800128814232 Mon Sep 17 00:00:00 2001 From: p04128795 Date: Wed, 22 Nov 2023 00:30:55 +0800 Subject: [PATCH] ADD file via upload --- polynomial_store.h | 119 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 polynomial_store.h diff --git a/polynomial_store.h b/polynomial_store.h new file mode 100644 index 0000000..f41be2b --- /dev/null +++ b/polynomial_store.h @@ -0,0 +1,119 @@ +#ifndef POLYNOMIAL_STORE_H +#define POLYNOMIAL_STORE_H +#include "polynomial.h" +#include "Store.h" +struct Polynomial_Store { + Polynomial* data;// [MAX_POLYS] ; + int id[MAX_POLYS]; //����ʽ��ţ�data[id[i]]��ʾ��i����0����ʽ + int count_polys; + int blank[13-MAX_POLYS%8]; + + Polynomial_Store(int polys = MAX_POLYS) + { + data = new Polynomial[polys]; + clear(); + } + Polynomial& operator [] (int i); + void remove_zero(); + void append(Polynomial& p); + void append(int mul_poly, int mul_mono); + void insert(int mul_poly, int mul_mono, int index); + + int input(istream& in = cin); + int input_sparse(istream& in = cin); //��������Ķ���ʽ���� + void print(ostream& out = cout, int begin = 0, int end = MAX_POLYS); + void print_sparse(ostream& out = cout, int begin = 0, int end = MAX_POLYS); + + void set_leader_degree(int max_leader = M - 1); //���ö���ʽ����ʹ��� + void sort_data(bool reverse = false); + Polynomial& last(); + + void clear(); +}; + +struct Temp_Polynomial_Store { + Polynomial data[reductors]; + Sparse_Polynomial sparse_data[reductors]; + int count_sparse; //ϡ�����ʽ���� + int count_dense; //���ܶ���ʽ���� + int count_polys; //����ʽ���� + int type[reductors];//����ʽ���ͣ�0�����ڣ�1���ܣ�2ϡ�� + Temp_Polynomial_Store(); + //Sparse_Polynomial& operator [] (int i); + void append(Sparse_Polynomial& p); + void append(Polynomial& p); + inline int append(int mul_poly, int mul_mono) //����ֵ��1���ܣ�2ϡ�� + { + if (system_store[mul_poly].poly->degree <= SPARSE_D) //�˻�����ʽ�ж���ʽ���ִ����ϵ���������ʱ��Ĭ��Ϊϡ����ʽ + { + Sparse_Poly_mul(&sparse_data[count_polys], system_store[mul_poly].poly, mul_mono); + + type[count_polys] = 2; + count_polys++; + count_sparse++; + return 2; + } + else + { + Poly_mul(&data[count_polys], system_store[mul_poly].poly, mul_mono); + //data[count_polys] = *(system_store[mul_poly].poly) * mul_mono; + type[count_polys] = 1; + count_polys++; + count_dense++; + return 1; + } + } + inline void set(Sparse_Polynomial& p, int index) + { + sparse_data[index] = p; + type[index] = 2; + } + inline void set(Polynomial& p, int index) + { + data[index] = p; + type[index] = 1; + } + inline int set(int mul_poly, int mul_mono, int index) //����ֵ��1���ܣ�2ϡ�� + { + if (system_store[mul_poly].poly->degree <= SPARSE_D) //�˻�����ʽ�ж���ʽ���ִ����ϵ���������ʱ��Ĭ��Ϊϡ����ʽ + { + Sparse_Poly_mul(&sparse_data[index], system_store[mul_poly].poly, mul_mono); + + type[index] = 2; + return 2; + } + else + { + Poly_mul(&data[index], system_store[mul_poly].poly, mul_mono); + //data[index] = *(system_store[mul_poly].poly) * mul_mono; + type[index] = 1; + return 1; + } + } + inline Polynomial* get_dense(int index) + { + return &data[index]; + } + inline Sparse_Polynomial* get_sparse(int index) + { + return &sparse_data[index]; + } + //Sparse_Polynomial& last(); + Polynomial* last_dense(); + Sparse_Polynomial* last_sparse(); + void clear(); +}; + +struct Polynomial_Input{ + Polynomial data[MAX_INPUT]; + int count_polys; + Polynomial_Input(); + + int input(istream& in = cin); + void set_leader_degree(int max_leader = M - 1); //���ö���ʽ����ʹ��� + void sort_data(bool reverse = false); + void clear(); + +}; + +#endif \ No newline at end of file