ADD file via upload

This commit is contained in:
p04128795 2023-11-22 00:30:45 +08:00
parent 0f2b7a3a05
commit 92dab4c404
1 changed files with 85 additions and 0 deletions

85
Store.cpp Normal file
View File

@ -0,0 +1,85 @@
#include "Store.h"
Store::Store()
{
for (int i = 0; i < M; i++)
{
data[i].type = -1;
data[i].mul_poly = -1;
data[i].mul_mono = -1;
data[i].reductor = -1;
data[i].poly = NULL;
}
}
void Store::Store_Polynomial(Polynomial* p, int id)
{
p->set_leader_degree();
int temp = p->leader_order;
if (data[temp].type == 0)
cout << "Error!";
data[temp].poly = p;
data[temp].type = 0;
data[temp].reductor = temp;
data[temp].id = id + 1;
}
Store_item& Store::operator[](int i)
{
return data[i];
}
void Store::clear()
{
for (int i = 0; i < M; i++)
{
data[i].type = -1;
data[i].mul_poly = -1;
data[i].mul_mono = -1;
data[i].reductor = -1;
data[i].poly = NULL;
}
}
MPTS::MPTS()
{
memset(data, 0, sizeof(data));
polys = 0;
}
void MPTS::append(int mul_poly, int mul_mono)
{
this->data[polys].first = mul_poly;
this->data[polys].second = mul_mono;
polys++;
}
void MPTS::insert(int mul_poly, int mul_mono, int index)
{
data[index].first = mul_poly;
data[index].second = mul_mono;
}
void MPTS::remove_null(int max_polys)
{
int index = 0;
for (int i = 0; i < max_polys; i++)
{
if (data[i].first > 0)
{
data[index] = data[i];
index++;
}
}
polys = index;
}
pair<int, int>& MPTS::operator[](int i)
{
return data[i];
}
void MPTS::clear()
{
memset(data, 0, sizeof(data));
polys = 0;
}