Groebner_HFE80/polynomial_store.h

119 lines
3.6 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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]; //<2F><><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>ţ<EFBFBD>data[id[i]]<5D><>ʾ<EFBFBD><CABE>i<EFBFBD><69><EFBFBD><EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD>ʽ
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); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>
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); //<2F><><EFBFBD>ö<EFBFBD><C3B6><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>
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; //ϡ<><CFA1><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>
int count_dense; //<2F><><EFBFBD>ܶ<EFBFBD><DCB6><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>
int count_polys; //<2F><><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>
int type[reductors];//<2F><><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD>ͣ<EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD>1<EFBFBD><31><EFBFBD>ܣ<EFBFBD><32><CFA1>
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) //<2F><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>1<EFBFBD><31><EFBFBD>ܣ<EFBFBD><32><CFA1>
{
if (system_store[mul_poly].poly->degree <= SPARSE_D) //<2F>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD>ж<EFBFBD><D0B6><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Ĭ<EFBFBD><C4AC>Ϊϡ<CEAA><CFA1><EFBFBD><EFBFBD>ʽ
{
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) //<2F><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>1<EFBFBD><31><EFBFBD>ܣ<EFBFBD><32><CFA1>
{
if (system_store[mul_poly].poly->degree <= SPARSE_D) //<2F>˻<EFBFBD><CBBB><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD>ж<EFBFBD><D0B6><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>Ĭ<EFBFBD><C4AC>Ϊϡ<CEAA><CFA1><EFBFBD><EFBFBD>ʽ
{
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); //<2F><><EFBFBD>ö<EFBFBD><C3B6><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>ʹ<EFBFBD><CDB4><EFBFBD>
void sort_data(bool reverse = false);
void clear();
};
#endif