41 lines
928 B
Plaintext
41 lines
928 B
Plaintext
#ifndef INTERFACE_CUH
|
|
#define INTERFACE_CUH
|
|
|
|
#include "cuelim.cuh"
|
|
#include <m4rie/m4rie.h>
|
|
|
|
void mzedread(mzed_t *A, gf256::MatGF256 &mat)
|
|
{
|
|
assert(A->nrows == mat.nrows && A->ncols == mat.ncols);
|
|
for (size_t r = 0; r < A->nrows; r++)
|
|
{
|
|
for (size_t cn = 0; cn < A->x->width; cn++)
|
|
{
|
|
*mat.at_base(r, cn) = A->x->rows[r][cn];
|
|
}
|
|
}
|
|
}
|
|
|
|
void mzedwrite(gf256::MatGF256 &mat, mzed_t *A)
|
|
{
|
|
assert(A->nrows == mat.nrows && A->ncols == mat.ncols);
|
|
for (size_t r = 0; r < mat.nrows; r++)
|
|
{
|
|
for (size_t cn = 0; cn < mat.width; cn++)
|
|
{
|
|
A->x->rows[r][cn] = *mat.at_base(r, cn);
|
|
}
|
|
}
|
|
}
|
|
|
|
size_t gpu_mzed_elim(mzed_t *A)
|
|
{
|
|
gf256::MatGF256 mat(A->nrows, A->ncols);
|
|
mzedread(A, mat);
|
|
gf256::GF256 gf256(A->finite_field->minpoly);
|
|
gf256::ElimResult res = mat.gpu_elim(gf256);
|
|
mzedwrite(mat, A);
|
|
return res.rank;
|
|
}
|
|
|
|
#endif |