moving definition of k in GFp_Givaro

parent e83fdd97
......@@ -49,7 +49,7 @@ void initF4(std::string wdir, const std::string& sys_file, std::ostream &out) {
TINYGB_TRY(tinygb::load_glob_params(tinygb::WORKDIR + "/global_parameters.txt"), "f4launcher");
GivaroWrapper::k = GivaroWrapper::ring_t(Givaro::Integer(FIELD_CARD));
GFp_Givaro::k = GFp_Givaro::ring_t(Givaro::Integer(FIELD_CARD));
std::cout << NB_VARS << std::endl;
std::cout << FIELD_CARD << std::endl;
......
......@@ -2,10 +2,10 @@
namespace tinygb {
GivaroWrapper::ring_t GivaroWrapper::k;
GFp_Givaro::ring_t GFp_Givaro::k;
std::ostream& operator<<(std::ostream& o, const GivaroWrapper &e) {
return GivaroWrapper::k.write(o, e.v);
return GFp_Givaro::k.write(o, e.v);
}
std::istream& operator>>(std::istream& i, GivaroWrapper& x) {
......
......@@ -12,15 +12,16 @@ namespace tinygb {
class GFp_Givaro : public AbstractField<GFp_Givaro> {
public:
typedef Givaro::Integer elt_t;
typedef Givaro::Modular<Givaro::Integer> ring_t;
std::string description() const {
return "Finite field of prime cardinality p";}
static ring_t k;
class Element : public AbstractField<GFp_Givaro>::Element<GFp_Givaro::Element> {
public:
typedef Givaro::Integer elt_t;
typedef Givaro::Modular<Givaro::Integer> ring_t;
static ring_t k;
elt_t v;
// Constructors
......
......@@ -27,7 +27,7 @@ void load_glob_params(const std::string& filename) {
file_params >> NB_VARS;
file_params >> FIELD_CARD;
file_params >> MONOMIAL_ORDERING;
GivaroWrapper::k = GivaroWrapper::ring_t(Givaro::Integer(FIELD_CARD));
GFp_Givaro::k = GFp_Givaro::ring_t(Givaro::Integer(FIELD_CARD));
file_params.close();
}
......
......@@ -23,16 +23,16 @@ matmulsub(
ReadRowMajMat(&pC, matC_file);
ReadRowMajMat(&pD, matD_file);
FFLAS::fgemm(GivaroWrapper::k,
FFLAS::fgemm(GFp_Givaro::k,
FFLAS::FflasNoTrans,
FFLAS::FflasNoTrans,
pD->row_size(),
pB->column_size(),
pB->row_size(),
GivaroWrapper::k.mOne,
GFp_Givaro::k.mOne,
pC->entries_, pB->row_size(),
pB->entries_, pB->column_size(),
GivaroWrapper::k.one,
GFp_Givaro::k.one,
pD->entries_, pD->column_size());
WriteRowMajMat(*pD, res_file);
......
......@@ -47,7 +47,7 @@ std::uint64_t uchar_to_uint64_trunc(const unsigned char* tc, std::size_t B)
}
void write_entries_rowmajmat(std::ofstream& file,
const GivaroWrapper::ring_t::Element* t,
const GFp_Givaro::ring_t::Element* t,
std::size_t n,
std::size_t B)
{
......@@ -61,7 +61,7 @@ void write_entries_rowmajmat(std::ofstream& file,
}
void read_entries_rowmajmat(const unsigned char* array,
GivaroWrapper::ring_t::Element* t,
GFp_Givaro::ring_t::Element* t,
std::size_t n,
std::size_t B)
{
......
......@@ -19,13 +19,13 @@ void uint64_to_char_trunc(char* tc, std::uint64_t x, std::size_t B);
std::uint64_t uchar_to_uint64_trunc(const unsigned char* tc, std::size_t B);
void write_entries_rowmajmat(std::ofstream& file,
const GivaroWrapper::ring_t::Element* t,
const GFp_Givaro::ring_t::Element* t,
std::size_t n,
std::size_t B);
//TODO: not very clean, should take an std::ifstream as main arg.
void read_entries_rowmajmat(const unsigned char* array,
GivaroWrapper::ring_t::Element* t,
GFp_Givaro::ring_t::Element* t,
std::size_t n,
std::size_t B);
} // namespace tinygb
......
This diff is collapsed.
......@@ -29,7 +29,7 @@ class RowMajMat {
std::size_t row_size,
std::size_t column_size)
: row_size_(row_size), column_size_(column_size) {
entries_ = FFLAS::fflas_new(GivaroWrapper::k, row_size_, column_size_);
entries_ = FFLAS::fflas_new(GFp_Givaro::k, row_size_, column_size_);
}
~RowMajMat() {
......@@ -45,22 +45,22 @@ class RowMajMat {
}
// TODO(pj): This should not be public.
GivaroWrapper::ring_t::Element* entries() {
GFp_Givaro::ring_t::Element* entries() {
return entries_;
}
const GivaroWrapper::ring_t::Element* entries() const {
const GFp_Givaro::ring_t::Element* entries() const {
return entries_;
}
GivaroWrapper::ring_t::Element& operator()(std::size_t i, std::size_t j) {
GFp_Givaro::ring_t::Element& operator()(std::size_t i, std::size_t j) {
assert (i < row_size_);
assert (j < column_size_);
return entries_[i*column_size_ + j];
}
const GivaroWrapper::ring_t::Element& operator()(std::size_t i, std::size_t j) const {
const GFp_Givaro::ring_t::Element& operator()(std::size_t i, std::size_t j) const {
assert (i < row_size_);
assert (j < column_size_);
return entries_[i*column_size_ + j];
......@@ -77,7 +77,7 @@ class RowMajMat {
void Print() const;
void Compress();
void RemoveColumns(const std::list<std::size_t>&);
void SetEntry(std::size_t i, std::size_t j, const GivaroWrapper::ring_t::Element &v) {
void SetEntry(std::size_t i, std::size_t j, const GFp_Givaro::ring_t::Element &v) {
entries_[i*column_size_ + j] = v;
}
......@@ -85,7 +85,7 @@ class RowMajMat {
std::size_t nb_nonzero_elts = 0;
for (std::size_t i = 0; i < row_size(); ++i)
for (std::size_t j = 0; j < column_size(); ++j)
if (!GivaroWrapper::k.isZero((*this)(i, j)))
if (!GFp_Givaro::k.isZero((*this)(i, j)))
nb_nonzero_elts++;
return (double)nb_nonzero_elts/(double)row_size()/(double)column_size();
}
......@@ -96,7 +96,7 @@ class RowMajMat {
// TODO(pj): should be private
std::size_t row_size_;
std::size_t column_size_;
GivaroWrapper::ring_t::Element* entries_;
GFp_Givaro::ring_t::Element* entries_;
std::vector<Monomial> col_dec_; // column decorations
std::vector<Monomial> row_dec_; // row decorations
......
......@@ -13,11 +13,11 @@ class SpMatEntry {
public:
std::size_t i_;
std::size_t j_;
GivaroWrapper::ring_t::Element v_;
GFp_Givaro::ring_t::Element v_;
SpMatEntry(): i_(0), j_(0) {}
SpMatEntry(std::size_t i, std::size_t j, const GivaroWrapper::ring_t::Element &v)
: i_(i), j_(j) { GivaroWrapper::k.assign(v_, v); }
SpMatEntry(std::size_t i, std::size_t j, const GFp_Givaro::ring_t::Element &v)
: i_(i), j_(j) { GFp_Givaro::k.assign(v_, v); }
};
// TODO: we only need square matrices
......
......@@ -75,7 +75,7 @@ int main(int argc, char **argv) {
file >> tinygb::FIELD_CARD;
tinygb::MONOMIAL_ORDERING = "grevlex";
std::system(("mkdir -p " + tinygb::WORKDIR + "/matrices").c_str());
tinygb::GivaroWrapper::k = tinygb::GivaroWrapper::ring_t(Givaro::Integer(tinygb::FIELD_CARD));
tinygb::GFp_Givaro::k = tinygb::GFp_Givaro::ring_t(Givaro::Integer(tinygb::FIELD_CARD));
TINYGB_TRY(tinygb::save_glob_params(tinygb::WORKDIR + "/global_parameters.txt"), "tinygb_init");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment