Skip to content

Commit

Permalink
pretty print modules and coefficients
Browse files Browse the repository at this point in the history
  • Loading branch information
jlmucb committed Apr 1, 2024
1 parent 4f72467 commit 800b11e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions v2/dilithium/dilithium.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,13 @@ dilithium_parameters::~dilithium_parameters() {
void print_coefficient_vector(coefficient_vector& v) {
if (v.c_.size() == 0)
return;
printf("(%d", v.c_[v.c_.size()-1]);
for (int i = (int)v.c_.size() - 2; i>=0; i--)
printf(", %d", v.c_[i]);
printf(")");
printf("(%d[%d] + ", v.c_[v.c_.size()-1], v.c_.size()-1);
for (int i = (int)v.c_.size() - 2; i>0; i--) {
printf("%d[%d] + ", v.c_[i], i);
if ((i%8) ==0)
printf("\n ");
}
printf("%d[%d])\n", v.c_[0], 0);
}

void print_dilithium_parameters(dilithium_parameters& p) {
Expand Down Expand Up @@ -191,7 +194,7 @@ bool module_apply_array(module_array& A, module_vector& v, module_vector* out) {
void print_module_array(module_array& ma) {
for (int r = 0; r < ma.nr_; r++) {
for (int c = 0; c < ma.nc_; c++) {
printf("A[%d, %d] = ", r, c);
printf("A[%d, %d] = ", r + 1, c + 1);
print_coefficient_vector(*ma.c_[ma.index(r, c)]);
printf("\n");
}
Expand All @@ -201,8 +204,8 @@ void print_module_array(module_array& ma) {

void print_module_vector(module_vector& mv) {
for (int i = 0; i < (int)mv.dim_; i++) {
printf("p[%d] = ", i);
print_coefficient_vector(*mv.c_[i]);
printf("[%d] = ", i);
printf("\n");
}
}
Expand Down

0 comments on commit 800b11e

Please sign in to comment.