From 2e992724e711f23b3c31b0cf667739a9e5a5da4a Mon Sep 17 00:00:00 2001 From: Charles Bouillaguet Date: Tue, 31 Aug 2021 19:20:44 +0200 Subject: [PATCH 2/2] no more access to the rows[...] field of mzd_t objects This code compile and passes test against a modified M4RI that does not even have the rows field. --- src/blm.c | 627 ++++++++++++++++++++++++++++++--------- src/conversion.c | 48 +-- src/conversion_cling16.c | 75 +++-- src/conversion_cling8.c | 60 ++-- src/conversion_slice16.c | 74 ++--- src/conversion_slice8.c | 60 ++-- src/mzed.c | 12 +- src/mzed.h | 6 +- src/newton_john.c | 27 +- tests/testing.h | 25 +- 10 files changed, 692 insertions(+), 322 deletions(-) diff --git a/m4rie/blm.c b/m4rie/blm.c index 1cff88b..5556711 100644 --- a/m4rie/blm.c +++ b/m4rie/blm.c @@ -155,176 +155,529 @@ mzd_t *_small_multiplication_map(const deg_t degree) { switch(degree) { case 1: A = mzd_init(1, 1); - A->rows[0][0] = 0x1; + mzd_row(A, 0)[0] = 0x1; return A; case 2: A = mzd_init(3, 2); - A->rows[0][0] = 0x1; A->rows[1][0] = 0x3; A->rows[2][0] = 0x2; + mzd_row(A, 0)[0] = 0x1; + mzd_row(A, 1)[0] = 0x3; + mzd_row(A, 2)[0] = 0x2; return A; case 3: A = mzd_init(6, 3); - A->rows[0][0] = 0x1; A->rows[1][0] = 0x2; A->rows[2][0] = 0x4; - A->rows[3][0] = 0x3; A->rows[4][0] = 0x5; A->rows[5][0] = 0x6; + mzd_row(A, 0)[0] = 0x1; + mzd_row(A, 1)[0] = 0x2; + mzd_row(A, 2)[0] = 0x4; + mzd_row(A, 3)[0] = 0x3; + mzd_row(A, 4)[0] = 0x5; + mzd_row(A, 5)[0] = 0x6; return A; case 4: A = mzd_init(9, 4); - A->rows[0][0] = 0x1; A->rows[1][0] = 0x2; A->rows[2][0] = 0x4; A->rows[3][0] = 0x8; - A->rows[4][0] = 0xf; A->rows[5][0] = 0x3; A->rows[6][0] = 0x5; A->rows[7][0] = 0xa; A->rows[8][0] = 0xc; + mzd_row(A, 0)[0] = 0x1; + mzd_row(A, 1)[0] = 0x2; + mzd_row(A, 2)[0] = 0x4; + mzd_row(A, 3)[0] = 0x8; + mzd_row(A, 4)[0] = 0xf; + mzd_row(A, 5)[0] = 0x3; + mzd_row(A, 6)[0] = 0x5; + mzd_row(A, 7)[0] = 0xa; + mzd_row(A, 8)[0] = 0xc; return A; case 5: A = mzd_init(13, 5); - A->rows[ 0][0] = 0x01; A->rows[ 1][0] = 0x02; A->rows[ 2][0] = 0x08; A->rows[ 3][0] = 0x10; - A->rows[ 4][0] = 0x11; A->rows[ 5][0] = 0x03; A->rows[ 6][0] = 0x18; A->rows[ 7][0] = 0x16; - A->rows[ 8][0] = 0x0d; A->rows[ 9][0] = 0x1b; A->rows[10][0] = 0x17; A->rows[11][0] = 0x1d; - A->rows[12][0] = 0x1f; + mzd_row(A, 0)[0] = 0x01; + mzd_row(A, 1)[0] = 0x02; + mzd_row(A, 2)[0] = 0x08; + mzd_row(A, 3)[0] = 0x10; + mzd_row(A, 4)[0] = 0x11; + mzd_row(A, 5)[0] = 0x03; + mzd_row(A, 6)[0] = 0x18; + mzd_row(A, 7)[0] = 0x16; + mzd_row(A, 8)[0] = 0x0d; + mzd_row(A, 9)[0] = 0x1b; + mzd_row(A, 10)[0] = 0x17; + mzd_row(A, 11)[0] = 0x1d; + mzd_row(A, 12)[0] = 0x1f; return A; case 6: A = mzd_init(17, 6); - A->rows[ 0][0] = 0x01; A->rows[ 1][0] = 0x02; A->rows[ 2][0] = 0x10; A->rows[ 3][0] = 0x20; - A->rows[ 4][0] = 0x30; A->rows[ 5][0] = 0x03; A->rows[ 6][0] = 0x18; A->rows[ 7][0] = 0x06; - A->rows[ 8][0] = 0x12; A->rows[ 9][0] = 0x0c; A->rows[10][0] = 0x38; A->rows[11][0] = 0x07; - A->rows[12][0] = 0x29; A->rows[13][0] = 0x25; A->rows[14][0] = 0x2d; A->rows[15][0] = 0x1b; - A->rows[16][0] = 0x3f; + mzd_row(A, 0)[0] = 0x01; + mzd_row(A, 1)[0] = 0x02; + mzd_row(A, 2)[0] = 0x10; + mzd_row(A, 3)[0] = 0x20; + mzd_row(A, 4)[0] = 0x30; + mzd_row(A, 5)[0] = 0x03; + mzd_row(A, 6)[0] = 0x18; + mzd_row(A, 7)[0] = 0x06; + mzd_row(A, 8)[0] = 0x12; + mzd_row(A, 9)[0] = 0x0c; + mzd_row(A, 10)[0] = 0x38; + mzd_row(A, 11)[0] = 0x07; + mzd_row(A, 12)[0] = 0x29; + mzd_row(A, 13)[0] = 0x25; + mzd_row(A, 14)[0] = 0x2d; + mzd_row(A, 15)[0] = 0x1b; + mzd_row(A, 16)[0] = 0x3f; return A; case 7: A = mzd_init(22, 7); - A->rows[ 0][0] = 0x7f; A->rows[ 1][0] = 0x6e; A->rows[ 2][0] = 0x3b; A->rows[ 3][0] = 0x5d; - A->rows[ 4][0] = 0x6d; A->rows[ 5][0] = 0x5b; A->rows[ 6][0] = 0x36; A->rows[ 7][0] = 0x03; - A->rows[ 8][0] = 0x05; A->rows[ 9][0] = 0x11; A->rows[10][0] = 0x0a; A->rows[11][0] = 0x44; - A->rows[12][0] = 0x28; A->rows[13][0] = 0x50; A->rows[14][0] = 0x60; A->rows[15][0] = 0x01; - A->rows[16][0] = 0x02; A->rows[17][0] = 0x04; A->rows[18][0] = 0x08; A->rows[19][0] = 0x10; - A->rows[20][0] = 0x20; A->rows[21][0] = 0x40; + mzd_row(A, 0)[0] = 0x7f; + mzd_row(A, 1)[0] = 0x6e; + mzd_row(A, 2)[0] = 0x3b; + mzd_row(A, 3)[0] = 0x5d; + mzd_row(A, 4)[0] = 0x6d; + mzd_row(A, 5)[0] = 0x5b; + mzd_row(A, 6)[0] = 0x36; + mzd_row(A, 7)[0] = 0x03; + mzd_row(A, 8)[0] = 0x05; + mzd_row(A, 9)[0] = 0x11; + mzd_row(A, 10)[0] = 0x0a; + mzd_row(A, 11)[0] = 0x44; + mzd_row(A, 12)[0] = 0x28; + mzd_row(A, 13)[0] = 0x50; + mzd_row(A, 14)[0] = 0x60; + mzd_row(A, 15)[0] = 0x01; + mzd_row(A, 16)[0] = 0x02; + mzd_row(A, 17)[0] = 0x04; + mzd_row(A, 18)[0] = 0x08; + mzd_row(A, 19)[0] = 0x10; + mzd_row(A, 20)[0] = 0x20; + mzd_row(A, 21)[0] = 0x40; return A; case 8: A = mzd_init(27, 8); - A->rows[ 0][0] = 0x01; A->rows[ 1][0] = 0x02; A->rows[ 2][0] = 0x04; A->rows[ 3][0] = 0x08; - A->rows[ 4][0] = 0x10; A->rows[ 5][0] = 0x20; A->rows[ 6][0] = 0x40; A->rows[ 7][0] = 0x80; - A->rows[ 8][0] = 0x05; A->rows[ 9][0] = 0x0c; A->rows[10][0] = 0x44; A->rows[11][0] = 0x30; - A->rows[12][0] = 0xc0; A->rows[13][0] = 0x0f; A->rows[14][0] = 0xa0; A->rows[15][0] = 0x11; - A->rows[16][0] = 0x0a; A->rows[17][0] = 0xaa; A->rows[18][0] = 0x03; A->rows[19][0] = 0x50; - A->rows[20][0] = 0x22; A->rows[21][0] = 0xff; A->rows[22][0] = 0x55; A->rows[23][0] = 0x33; - A->rows[24][0] = 0xcc; A->rows[25][0] = 0x88; A->rows[26][0] = 0xf0; + mzd_row(A, 0)[0] = 0x01; + mzd_row(A, 1)[0] = 0x02; + mzd_row(A, 2)[0] = 0x04; + mzd_row(A, 3)[0] = 0x08; + mzd_row(A, 4)[0] = 0x10; + mzd_row(A, 5)[0] = 0x20; + mzd_row(A, 6)[0] = 0x40; + mzd_row(A, 7)[0] = 0x80; + mzd_row(A, 8)[0] = 0x05; + mzd_row(A, 9)[0] = 0x0c; + mzd_row(A, 10)[0] = 0x44; + mzd_row(A, 11)[0] = 0x30; + mzd_row(A, 12)[0] = 0xc0; + mzd_row(A, 13)[0] = 0x0f; + mzd_row(A, 14)[0] = 0xa0; + mzd_row(A, 15)[0] = 0x11; + mzd_row(A, 16)[0] = 0x0a; + mzd_row(A, 17)[0] = 0xaa; + mzd_row(A, 18)[0] = 0x03; + mzd_row(A, 19)[0] = 0x50; + mzd_row(A, 20)[0] = 0x22; + mzd_row(A, 21)[0] = 0xff; + mzd_row(A, 22)[0] = 0x55; + mzd_row(A, 23)[0] = 0x33; + mzd_row(A, 24)[0] = 0xcc; + mzd_row(A, 25)[0] = 0x88; + mzd_row(A, 26)[0] = 0xf0; return A; case 9: A = mzd_init(31, 9); - A->rows[ 0][0] = 0x100; A->rows[ 1][0] = 0x001; A->rows[ 2][0] = 0x002; A->rows[ 3][0] = 0x003; - A->rows[ 4][0] = 0x155; A->rows[ 5][0] = 0x0aa; A->rows[ 6][0] = 0x1ff; A->rows[ 7][0] = 0x16d; - A->rows[ 8][0] = 0x1b6; A->rows[ 9][0] = 0x0db; A->rows[10][0] = 0x0e9; A->rows[11][0] = 0x13a; - A->rows[12][0] = 0x074; A->rows[13][0] = 0x1d3; A->rows[14][0] = 0x09d; A->rows[15][0] = 0x14e; - A->rows[16][0] = 0x0b9; A->rows[17][0] = 0x172; A->rows[18][0] = 0x05c; A->rows[19][0] = 0x1cb; - A->rows[20][0] = 0x0e5; A->rows[21][0] = 0x12e; A->rows[22][0] = 0x191; A->rows[23][0] = 0x0b2; - A->rows[24][0] = 0x164; A->rows[25][0] = 0x0c8; A->rows[26][0] = 0x08f; A->rows[27][0] = 0x123; - A->rows[28][0] = 0x0f5; A->rows[29][0] = 0x07a; A->rows[30][0] = 0x1ac; + mzd_row(A, 0)[0] = 0x100; + mzd_row(A, 1)[0] = 0x001; + mzd_row(A, 2)[0] = 0x002; + mzd_row(A, 3)[0] = 0x003; + mzd_row(A, 4)[0] = 0x155; + mzd_row(A, 5)[0] = 0x0aa; + mzd_row(A, 6)[0] = 0x1ff; + mzd_row(A, 7)[0] = 0x16d; + mzd_row(A, 8)[0] = 0x1b6; + mzd_row(A, 9)[0] = 0x0db; + mzd_row(A, 10)[0] = 0x0e9; + mzd_row(A, 11)[0] = 0x13a; + mzd_row(A, 12)[0] = 0x074; + mzd_row(A, 13)[0] = 0x1d3; + mzd_row(A, 14)[0] = 0x09d; + mzd_row(A, 15)[0] = 0x14e; + mzd_row(A, 16)[0] = 0x0b9; + mzd_row(A, 17)[0] = 0x172; + mzd_row(A, 18)[0] = 0x05c; + mzd_row(A, 19)[0] = 0x1cb; + mzd_row(A, 20)[0] = 0x0e5; + mzd_row(A, 21)[0] = 0x12e; + mzd_row(A, 22)[0] = 0x191; + mzd_row(A, 23)[0] = 0x0b2; + mzd_row(A, 24)[0] = 0x164; + mzd_row(A, 25)[0] = 0x0c8; + mzd_row(A, 26)[0] = 0x08f; + mzd_row(A, 27)[0] = 0x123; + mzd_row(A, 28)[0] = 0x0f5; + mzd_row(A, 29)[0] = 0x07a; + mzd_row(A, 30)[0] = 0x1ac; return A; case 10: A = mzd_init(36, 10); - A->rows[ 0][0] = 0x200; A->rows[ 1][0] = 0x001; A->rows[ 2][0] = 0x3ff; A->rows[ 3][0] = 0x36d; - A->rows[ 4][0] = 0x1b6; A->rows[ 5][0] = 0x2db; A->rows[ 6][0] = 0x0e9; A->rows[ 7][0] = 0x13a; - A->rows[ 8][0] = 0x274; A->rows[ 9][0] = 0x1d3; A->rows[10][0] = 0x29d; A->rows[11][0] = 0x34e; - A->rows[12][0] = 0x0b9; A->rows[13][0] = 0x172; A->rows[14][0] = 0x25c; A->rows[15][0] = 0x1cb; - A->rows[16][0] = 0x2e5; A->rows[17][0] = 0x32e; A->rows[18][0] = 0x191; A->rows[19][0] = 0x2b2; - A->rows[20][0] = 0x164; A->rows[21][0] = 0x2c8; A->rows[22][0] = 0x08f; A->rows[23][0] = 0x323; - A->rows[24][0] = 0x0f5; A->rows[25][0] = 0x07a; A->rows[26][0] = 0x3ac; A->rows[27][0] = 0x2f1; - A->rows[28][0] = 0x1e2; A->rows[29][0] = 0x3c4; A->rows[30][0] = 0x178; A->rows[31][0] = 0x1af; - A->rows[32][0] = 0x313; A->rows[33][0] = 0x135; A->rows[34][0] = 0x09a; A->rows[35][0] = 0x2bc; + mzd_row(A, 0)[0] = 0x200; + mzd_row(A, 1)[0] = 0x001; + mzd_row(A, 2)[0] = 0x3ff; + mzd_row(A, 3)[0] = 0x36d; + mzd_row(A, 4)[0] = 0x1b6; + mzd_row(A, 5)[0] = 0x2db; + mzd_row(A, 6)[0] = 0x0e9; + mzd_row(A, 7)[0] = 0x13a; + mzd_row(A, 8)[0] = 0x274; + mzd_row(A, 9)[0] = 0x1d3; + mzd_row(A, 10)[0] = 0x29d; + mzd_row(A, 11)[0] = 0x34e; + mzd_row(A, 12)[0] = 0x0b9; + mzd_row(A, 13)[0] = 0x172; + mzd_row(A, 14)[0] = 0x25c; + mzd_row(A, 15)[0] = 0x1cb; + mzd_row(A, 16)[0] = 0x2e5; + mzd_row(A, 17)[0] = 0x32e; + mzd_row(A, 18)[0] = 0x191; + mzd_row(A, 19)[0] = 0x2b2; + mzd_row(A, 20)[0] = 0x164; + mzd_row(A, 21)[0] = 0x2c8; + mzd_row(A, 22)[0] = 0x08f; + mzd_row(A, 23)[0] = 0x323; + mzd_row(A, 24)[0] = 0x0f5; + mzd_row(A, 25)[0] = 0x07a; + mzd_row(A, 26)[0] = 0x3ac; + mzd_row(A, 27)[0] = 0x2f1; + mzd_row(A, 28)[0] = 0x1e2; + mzd_row(A, 29)[0] = 0x3c4; + mzd_row(A, 30)[0] = 0x178; + mzd_row(A, 31)[0] = 0x1af; + mzd_row(A, 32)[0] = 0x313; + mzd_row(A, 33)[0] = 0x135; + mzd_row(A, 34)[0] = 0x09a; + mzd_row(A, 35)[0] = 0x2bc; return A; case 11: A = mzd_init(40, 11); - A->rows[ 0][0] = 0x001; A->rows[ 1][0] = 0x36d; A->rows[ 2][0] = 0x5b6; A->rows[ 3][0] = 0x6db; - A->rows[ 4][0] = 0x555; A->rows[ 5][0] = 0x2aa; A->rows[ 6][0] = 0x7ff; A->rows[ 7][0] = 0x400; - A->rows[ 8][0] = 0x200; A->rows[ 9][0] = 0x600; A->rows[10][0] = 0x4e9; A->rows[11][0] = 0x53a; - A->rows[12][0] = 0x274; A->rows[13][0] = 0x1d3; A->rows[14][0] = 0x69d; A->rows[15][0] = 0x74e; - A->rows[16][0] = 0x4b9; A->rows[17][0] = 0x172; A->rows[18][0] = 0x65c; A->rows[19][0] = 0x5cb; - A->rows[20][0] = 0x2e5; A->rows[21][0] = 0x72e; A->rows[22][0] = 0x591; A->rows[23][0] = 0x6b2; - A->rows[24][0] = 0x564; A->rows[25][0] = 0x2c8; A->rows[26][0] = 0x48f; A->rows[27][0] = 0x323; - A->rows[28][0] = 0x0f5; A->rows[29][0] = 0x47a; A->rows[30][0] = 0x7ac; A->rows[31][0] = 0x2f1; - A->rows[32][0] = 0x5e2; A->rows[33][0] = 0x3c4; A->rows[34][0] = 0x578; A->rows[35][0] = 0x1af; - A->rows[36][0] = 0x713; A->rows[37][0] = 0x135; A->rows[38][0] = 0x09a; A->rows[39][0] = 0x6bc; + mzd_row(A, 0)[0] = 0x001; + mzd_row(A, 1)[0] = 0x36d; + mzd_row(A, 2)[0] = 0x5b6; + mzd_row(A, 3)[0] = 0x6db; + mzd_row(A, 4)[0] = 0x555; + mzd_row(A, 5)[0] = 0x2aa; + mzd_row(A, 6)[0] = 0x7ff; + mzd_row(A, 7)[0] = 0x400; + mzd_row(A, 8)[0] = 0x200; + mzd_row(A, 9)[0] = 0x600; + mzd_row(A, 10)[0] = 0x4e9; + mzd_row(A, 11)[0] = 0x53a; + mzd_row(A, 12)[0] = 0x274; + mzd_row(A, 13)[0] = 0x1d3; + mzd_row(A, 14)[0] = 0x69d; + mzd_row(A, 15)[0] = 0x74e; + mzd_row(A, 16)[0] = 0x4b9; + mzd_row(A, 17)[0] = 0x172; + mzd_row(A, 18)[0] = 0x65c; + mzd_row(A, 19)[0] = 0x5cb; + mzd_row(A, 20)[0] = 0x2e5; + mzd_row(A, 21)[0] = 0x72e; + mzd_row(A, 22)[0] = 0x591; + mzd_row(A, 23)[0] = 0x6b2; + mzd_row(A, 24)[0] = 0x564; + mzd_row(A, 25)[0] = 0x2c8; + mzd_row(A, 26)[0] = 0x48f; + mzd_row(A, 27)[0] = 0x323; + mzd_row(A, 28)[0] = 0x0f5; + mzd_row(A, 29)[0] = 0x47a; + mzd_row(A, 30)[0] = 0x7ac; + mzd_row(A, 31)[0] = 0x2f1; + mzd_row(A, 32)[0] = 0x5e2; + mzd_row(A, 33)[0] = 0x3c4; + mzd_row(A, 34)[0] = 0x578; + mzd_row(A, 35)[0] = 0x1af; + mzd_row(A, 36)[0] = 0x713; + mzd_row(A, 37)[0] = 0x135; + mzd_row(A, 38)[0] = 0x09a; + mzd_row(A, 39)[0] = 0x6bc; return A; case 12: A = mzd_init(45, 12); - A->rows[ 0][0] = 0xb6d; A->rows[ 1][0] = 0xdb6; A->rows[ 2][0] = 0x6db; A->rows[ 3][0] = 0x001; - A->rows[ 4][0] = 0x002; A->rows[ 5][0] = 0x003; A->rows[ 6][0] = 0x555; A->rows[ 7][0] = 0xaaa; - A->rows[ 8][0] = 0xfff; A->rows[ 9][0] = 0x800; A->rows[10][0] = 0x400; A->rows[11][0] = 0xc00; - A->rows[12][0] = 0x4e9; A->rows[13][0] = 0xd3a; A->rows[14][0] = 0xa74; A->rows[15][0] = 0x9d3; - A->rows[16][0] = 0xe9d; A->rows[17][0] = 0x74e; A->rows[18][0] = 0x591; A->rows[19][0] = 0xeb2; - A->rows[20][0] = 0xd64; A->rows[21][0] = 0xac8; A->rows[22][0] = 0xc8f; A->rows[23][0] = 0xb23; - A->rows[24][0] = 0x8f5; A->rows[25][0] = 0x47a; A->rows[26][0] = 0x7ac; A->rows[27][0] = 0xaf1; - A->rows[28][0] = 0x5e2; A->rows[29][0] = 0xbc4; A->rows[30][0] = 0xd78; A->rows[31][0] = 0x9af; - A->rows[32][0] = 0xf13; A->rows[33][0] = 0x135; A->rows[34][0] = 0x89a; A->rows[35][0] = 0x6bc; - A->rows[36][0] = 0x631; A->rows[37][0] = 0xa52; A->rows[38][0] = 0x294; A->rows[39][0] = 0x318; - A->rows[40][0] = 0xdef; A->rows[41][0] = 0xc63; A->rows[42][0] = 0x4a5; A->rows[43][0] = 0x94a; - A->rows[44][0] = 0x18c; + mzd_row(A, 0)[0] = 0xb6d; + mzd_row(A, 1)[0] = 0xdb6; + mzd_row(A, 2)[0] = 0x6db; + mzd_row(A, 3)[0] = 0x001; + mzd_row(A, 4)[0] = 0x002; + mzd_row(A, 5)[0] = 0x003; + mzd_row(A, 6)[0] = 0x555; + mzd_row(A, 7)[0] = 0xaaa; + mzd_row(A, 8)[0] = 0xfff; + mzd_row(A, 9)[0] = 0x800; + mzd_row(A, 10)[0] = 0x400; + mzd_row(A, 11)[0] = 0xc00; + mzd_row(A, 12)[0] = 0x4e9; + mzd_row(A, 13)[0] = 0xd3a; + mzd_row(A, 14)[0] = 0xa74; + mzd_row(A, 15)[0] = 0x9d3; + mzd_row(A, 16)[0] = 0xe9d; + mzd_row(A, 17)[0] = 0x74e; + mzd_row(A, 18)[0] = 0x591; + mzd_row(A, 19)[0] = 0xeb2; + mzd_row(A, 20)[0] = 0xd64; + mzd_row(A, 21)[0] = 0xac8; + mzd_row(A, 22)[0] = 0xc8f; + mzd_row(A, 23)[0] = 0xb23; + mzd_row(A, 24)[0] = 0x8f5; + mzd_row(A, 25)[0] = 0x47a; + mzd_row(A, 26)[0] = 0x7ac; + mzd_row(A, 27)[0] = 0xaf1; + mzd_row(A, 28)[0] = 0x5e2; + mzd_row(A, 29)[0] = 0xbc4; + mzd_row(A, 30)[0] = 0xd78; + mzd_row(A, 31)[0] = 0x9af; + mzd_row(A, 32)[0] = 0xf13; + mzd_row(A, 33)[0] = 0x135; + mzd_row(A, 34)[0] = 0x89a; + mzd_row(A, 35)[0] = 0x6bc; + mzd_row(A, 36)[0] = 0x631; + mzd_row(A, 37)[0] = 0xa52; + mzd_row(A, 38)[0] = 0x294; + mzd_row(A, 39)[0] = 0x318; + mzd_row(A, 40)[0] = 0xdef; + mzd_row(A, 41)[0] = 0xc63; + mzd_row(A, 42)[0] = 0x4a5; + mzd_row(A, 43)[0] = 0x94a; + mzd_row(A, 44)[0] = 0x18c; return A; case 13: A = mzd_init(49, 13); - A->rows[ 0][0] = 0x0001; A->rows[ 1][0] = 0x1b6d; A->rows[ 2][0] = 0x0db6; A->rows[ 3][0] = 0x16db; - A->rows[ 4][0] = 0x1555; A->rows[ 5][0] = 0x0aaa; A->rows[ 6][0] = 0x1fff; A->rows[ 7][0] = 0x1000; - A->rows[ 8][0] = 0x0800; A->rows[ 9][0] = 0x1800; A->rows[10][0] = 0x14e9; A->rows[11][0] = 0x1d3a; - A->rows[12][0] = 0x1a74; A->rows[13][0] = 0x09d3; A->rows[14][0] = 0x0e9d; A->rows[15][0] = 0x074e; - A->rows[16][0] = 0x1cb9; A->rows[17][0] = 0x1972; A->rows[18][0] = 0x0e5c; A->rows[19][0] = 0x05cb; - A->rows[20][0] = 0x12e5; A->rows[21][0] = 0x172e; A->rows[22][0] = 0x1591; A->rows[23][0] = 0x1eb2; - A->rows[24][0] = 0x1d64; A->rows[25][0] = 0x1ac8; A->rows[26][0] = 0x0c8f; A->rows[27][0] = 0x0b23; - A->rows[28][0] = 0x08f5; A->rows[29][0] = 0x047a; A->rows[30][0] = 0x07ac; A->rows[31][0] = 0x1af1; - A->rows[32][0] = 0x15e2; A->rows[33][0] = 0x0bc4; A->rows[34][0] = 0x0d78; A->rows[35][0] = 0x09af; - A->rows[36][0] = 0x0f13; A->rows[37][0] = 0x1135; A->rows[38][0] = 0x189a; A->rows[39][0] = 0x06bc; - A->rows[40][0] = 0x0631; A->rows[41][0] = 0x0a52; A->rows[42][0] = 0x1294; A->rows[43][0] = 0x0318; - A->rows[44][0] = 0x1def; A->rows[45][0] = 0x0c63; A->rows[46][0] = 0x14a5; A->rows[47][0] = 0x094a; - A->rows[48][0] = 0x118c; + mzd_row(A, 0)[0] = 0x0001; + mzd_row(A, 1)[0] = 0x1b6d; + mzd_row(A, 2)[0] = 0x0db6; + mzd_row(A, 3)[0] = 0x16db; + mzd_row(A, 4)[0] = 0x1555; + mzd_row(A, 5)[0] = 0x0aaa; + mzd_row(A, 6)[0] = 0x1fff; + mzd_row(A, 7)[0] = 0x1000; + mzd_row(A, 8)[0] = 0x0800; + mzd_row(A, 9)[0] = 0x1800; + mzd_row(A, 10)[0] = 0x14e9; + mzd_row(A, 11)[0] = 0x1d3a; + mzd_row(A, 12)[0] = 0x1a74; + mzd_row(A, 13)[0] = 0x09d3; + mzd_row(A, 14)[0] = 0x0e9d; + mzd_row(A, 15)[0] = 0x074e; + mzd_row(A, 16)[0] = 0x1cb9; + mzd_row(A, 17)[0] = 0x1972; + mzd_row(A, 18)[0] = 0x0e5c; + mzd_row(A, 19)[0] = 0x05cb; + mzd_row(A, 20)[0] = 0x12e5; + mzd_row(A, 21)[0] = 0x172e; + mzd_row(A, 22)[0] = 0x1591; + mzd_row(A, 23)[0] = 0x1eb2; + mzd_row(A, 24)[0] = 0x1d64; + mzd_row(A, 25)[0] = 0x1ac8; + mzd_row(A, 26)[0] = 0x0c8f; + mzd_row(A, 27)[0] = 0x0b23; + mzd_row(A, 28)[0] = 0x08f5; + mzd_row(A, 29)[0] = 0x047a; + mzd_row(A, 30)[0] = 0x07ac; + mzd_row(A, 31)[0] = 0x1af1; + mzd_row(A, 32)[0] = 0x15e2; + mzd_row(A, 33)[0] = 0x0bc4; + mzd_row(A, 34)[0] = 0x0d78; + mzd_row(A, 35)[0] = 0x09af; + mzd_row(A, 36)[0] = 0x0f13; + mzd_row(A, 37)[0] = 0x1135; + mzd_row(A, 38)[0] = 0x189a; + mzd_row(A, 39)[0] = 0x06bc; + mzd_row(A, 40)[0] = 0x0631; + mzd_row(A, 41)[0] = 0x0a52; + mzd_row(A, 42)[0] = 0x1294; + mzd_row(A, 43)[0] = 0x0318; + mzd_row(A, 44)[0] = 0x1def; + mzd_row(A, 45)[0] = 0x0c63; + mzd_row(A, 46)[0] = 0x14a5; + mzd_row(A, 47)[0] = 0x094a; + mzd_row(A, 48)[0] = 0x118c; return A; case 14: A = mzd_init(55, 14); - A->rows[ 0][0] = 0x0001; A->rows[ 1][0] = 0x1b6d; A->rows[ 2][0] = 0x2db6; A->rows[ 3][0] = 0x36db; - A->rows[ 4][0] = 0x1555; A->rows[ 5][0] = 0x2aaa; A->rows[ 6][0] = 0x3fff; A->rows[ 7][0] = 0x34e9; - A->rows[ 8][0] = 0x1d3a; A->rows[ 9][0] = 0x3a74; A->rows[10][0] = 0x29d3; A->rows[11][0] = 0x0e9d; - A->rows[12][0] = 0x274e; A->rows[13][0] = 0x1cb9; A->rows[14][0] = 0x3972; A->rows[15][0] = 0x2e5c; - A->rows[16][0] = 0x25cb; A->rows[17][0] = 0x32e5; A->rows[18][0] = 0x172e; A->rows[19][0] = 0x3591; - A->rows[20][0] = 0x1eb2; A->rows[21][0] = 0x3d64; A->rows[22][0] = 0x3ac8; A->rows[23][0] = 0x2c8f; - A->rows[24][0] = 0x2b23; A->rows[25][0] = 0x08f5; A->rows[26][0] = 0x247a; A->rows[27][0] = 0x07ac; - A->rows[28][0] = 0x1af1; A->rows[29][0] = 0x35e2; A->rows[30][0] = 0x2bc4; A->rows[31][0] = 0x0d78; - A->rows[32][0] = 0x09af; A->rows[33][0] = 0x2f13; A->rows[34][0] = 0x3135; A->rows[35][0] = 0x389a; - A->rows[36][0] = 0x26bc; A->rows[37][0] = 0x0631; A->rows[38][0] = 0x0a52; A->rows[39][0] = 0x1294; - A->rows[40][0] = 0x2318; A->rows[41][0] = 0x3def; A->rows[42][0] = 0x0c63; A->rows[43][0] = 0x14a5; - A->rows[44][0] = 0x294a; A->rows[45][0] = 0x318c; A->rows[46][0] = 0x2000; A->rows[47][0] = 0x1000; - A->rows[48][0] = 0x0800; A->rows[49][0] = 0x0400; A->rows[50][0] = 0x3c00; A->rows[51][0] = 0x3000; - A->rows[52][0] = 0x2800; A->rows[53][0] = 0x1400; A->rows[54][0] = 0x0c00; + mzd_row(A, 0)[0] = 0x0001; + mzd_row(A, 1)[0] = 0x1b6d; + mzd_row(A, 2)[0] = 0x2db6; + mzd_row(A, 3)[0] = 0x36db; + mzd_row(A, 4)[0] = 0x1555; + mzd_row(A, 5)[0] = 0x2aaa; + mzd_row(A, 6)[0] = 0x3fff; + mzd_row(A, 7)[0] = 0x34e9; + mzd_row(A, 8)[0] = 0x1d3a; + mzd_row(A, 9)[0] = 0x3a74; + mzd_row(A, 10)[0] = 0x29d3; + mzd_row(A, 11)[0] = 0x0e9d; + mzd_row(A, 12)[0] = 0x274e; + mzd_row(A, 13)[0] = 0x1cb9; + mzd_row(A, 14)[0] = 0x3972; + mzd_row(A, 15)[0] = 0x2e5c; + mzd_row(A, 16)[0] = 0x25cb; + mzd_row(A, 17)[0] = 0x32e5; + mzd_row(A, 18)[0] = 0x172e; + mzd_row(A, 19)[0] = 0x3591; + mzd_row(A, 20)[0] = 0x1eb2; + mzd_row(A, 21)[0] = 0x3d64; + mzd_row(A, 22)[0] = 0x3ac8; + mzd_row(A, 23)[0] = 0x2c8f; + mzd_row(A, 24)[0] = 0x2b23; + mzd_row(A, 25)[0] = 0x08f5; + mzd_row(A, 26)[0] = 0x247a; + mzd_row(A, 27)[0] = 0x07ac; + mzd_row(A, 28)[0] = 0x1af1; + mzd_row(A, 29)[0] = 0x35e2; + mzd_row(A, 30)[0] = 0x2bc4; + mzd_row(A, 31)[0] = 0x0d78; + mzd_row(A, 32)[0] = 0x09af; + mzd_row(A, 33)[0] = 0x2f13; + mzd_row(A, 34)[0] = 0x3135; + mzd_row(A, 35)[0] = 0x389a; + mzd_row(A, 36)[0] = 0x26bc; + mzd_row(A, 37)[0] = 0x0631; + mzd_row(A, 38)[0] = 0x0a52; + mzd_row(A, 39)[0] = 0x1294; + mzd_row(A, 40)[0] = 0x2318; + mzd_row(A, 41)[0] = 0x3def; + mzd_row(A, 42)[0] = 0x0c63; + mzd_row(A, 43)[0] = 0x14a5; + mzd_row(A, 44)[0] = 0x294a; + mzd_row(A, 45)[0] = 0x318c; + mzd_row(A, 46)[0] = 0x2000; + mzd_row(A, 47)[0] = 0x1000; + mzd_row(A, 48)[0] = 0x0800; + mzd_row(A, 49)[0] = 0x0400; + mzd_row(A, 50)[0] = 0x3c00; + mzd_row(A, 51)[0] = 0x3000; + mzd_row(A, 52)[0] = 0x2800; + mzd_row(A, 53)[0] = 0x1400; + mzd_row(A, 54)[0] = 0x0c00; return A; case 15: A = mzd_init(60, 15); - A->rows[ 0][0] = 0x0001; A->rows[ 1][0] = 0x7fff; A->rows[ 2][0] = 0x5b6d; A->rows[ 3][0] = 0x6db6; - A->rows[ 4][0] = 0x36db; A->rows[ 5][0] = 0x4000; A->rows[ 6][0] = 0x2000; A->rows[ 7][0] = 0x6000; - A->rows[ 8][0] = 0x74e9; A->rows[ 9][0] = 0x1d3a; A->rows[10][0] = 0x3a74; A->rows[11][0] = 0x69d3; - A->rows[12][0] = 0x4e9d; A->rows[13][0] = 0x274e; A->rows[14][0] = 0x5cb9; A->rows[15][0] = 0x3972; - A->rows[16][0] = 0x2e5c; A->rows[17][0] = 0x65cb; A->rows[18][0] = 0x72e5; A->rows[19][0] = 0x172e; - A->rows[20][0] = 0x7591; A->rows[21][0] = 0x1eb2; A->rows[22][0] = 0x3d64; A->rows[23][0] = 0x7ac8; - A->rows[24][0] = 0x2c8f; A->rows[25][0] = 0x6b23; A->rows[26][0] = 0x48f5; A->rows[27][0] = 0x647a; - A->rows[28][0] = 0x47ac; A->rows[29][0] = 0x1af1; A->rows[30][0] = 0x35e2; A->rows[31][0] = 0x6bc4; - A->rows[32][0] = 0x4d78; A->rows[33][0] = 0x09af; A->rows[34][0] = 0x2f13; A->rows[35][0] = 0x7135; - A->rows[36][0] = 0x789a; A->rows[37][0] = 0x26bc; A->rows[38][0] = 0x4631; A->rows[39][0] = 0x4a52; - A->rows[40][0] = 0x5294; A->rows[41][0] = 0x6318; A->rows[42][0] = 0x3def; A->rows[43][0] = 0x0c63; - A->rows[44][0] = 0x14a5; A->rows[45][0] = 0x294a; A->rows[46][0] = 0x318c; A->rows[47][0] = 0x4d21; - A->rows[48][0] = 0x1a42; A->rows[49][0] = 0x7348; A->rows[50][0] = 0x6690; A->rows[51][0] = 0x2bb1; - A->rows[52][0] = 0x5763; A->rows[53][0] = 0x15d8; A->rows[54][0] = 0x0576; A->rows[55][0] = 0x47cd; - A->rows[56][0] = 0x42bb; A->rows[57][0] = 0x4857; A->rows[58][0] = 0x215d; A->rows[59][0] = 0x3b1f; + mzd_row(A, 0)[0] = 0x0001; + mzd_row(A, 1)[0] = 0x7fff; + mzd_row(A, 2)[0] = 0x5b6d; + mzd_row(A, 3)[0] = 0x6db6; + mzd_row(A, 4)[0] = 0x36db; + mzd_row(A, 5)[0] = 0x4000; + mzd_row(A, 6)[0] = 0x2000; + mzd_row(A, 7)[0] = 0x6000; + mzd_row(A, 8)[0] = 0x74e9; + mzd_row(A, 9)[0] = 0x1d3a; + mzd_row(A, 10)[0] = 0x3a74; + mzd_row(A, 11)[0] = 0x69d3; + mzd_row(A, 12)[0] = 0x4e9d; + mzd_row(A, 13)[0] = 0x274e; + mzd_row(A, 14)[0] = 0x5cb9; + mzd_row(A, 15)[0] = 0x3972; + mzd_row(A, 16)[0] = 0x2e5c; + mzd_row(A, 17)[0] = 0x65cb; + mzd_row(A, 18)[0] = 0x72e5; + mzd_row(A, 19)[0] = 0x172e; + mzd_row(A, 20)[0] = 0x7591; + mzd_row(A, 21)[0] = 0x1eb2; + mzd_row(A, 22)[0] = 0x3d64; + mzd_row(A, 23)[0] = 0x7ac8; + mzd_row(A, 24)[0] = 0x2c8f; + mzd_row(A, 25)[0] = 0x6b23; + mzd_row(A, 26)[0] = 0x48f5; + mzd_row(A, 27)[0] = 0x647a; + mzd_row(A, 28)[0] = 0x47ac; + mzd_row(A, 29)[0] = 0x1af1; + mzd_row(A, 30)[0] = 0x35e2; + mzd_row(A, 31)[0] = 0x6bc4; + mzd_row(A, 32)[0] = 0x4d78; + mzd_row(A, 33)[0] = 0x09af; + mzd_row(A, 34)[0] = 0x2f13; + mzd_row(A, 35)[0] = 0x7135; + mzd_row(A, 36)[0] = 0x789a; + mzd_row(A, 37)[0] = 0x26bc; + mzd_row(A, 38)[0] = 0x4631; + mzd_row(A, 39)[0] = 0x4a52; + mzd_row(A, 40)[0] = 0x5294; + mzd_row(A, 41)[0] = 0x6318; + mzd_row(A, 42)[0] = 0x3def; + mzd_row(A, 43)[0] = 0x0c63; + mzd_row(A, 44)[0] = 0x14a5; + mzd_row(A, 45)[0] = 0x294a; + mzd_row(A, 46)[0] = 0x318c; + mzd_row(A, 47)[0] = 0x4d21; + mzd_row(A, 48)[0] = 0x1a42; + mzd_row(A, 49)[0] = 0x7348; + mzd_row(A, 50)[0] = 0x6690; + mzd_row(A, 51)[0] = 0x2bb1; + mzd_row(A, 52)[0] = 0x5763; + mzd_row(A, 53)[0] = 0x15d8; + mzd_row(A, 54)[0] = 0x0576; + mzd_row(A, 55)[0] = 0x47cd; + mzd_row(A, 56)[0] = 0x42bb; + mzd_row(A, 57)[0] = 0x4857; + mzd_row(A, 58)[0] = 0x215d; + mzd_row(A, 59)[0] = 0x3b1f; return A; case 16: A = mzd_init(64, 16); - A->rows[ 0][0] = 0xdb6d; A->rows[ 1][0] = 0x6db6; A->rows[ 2][0] = 0xb6db; A->rows[ 3][0] = 0x0001; - A->rows[ 4][0] = 0x0002; A->rows[ 5][0] = 0x0003; A->rows[ 6][0] = 0x5555; A->rows[ 7][0] = 0xaaaa; - A->rows[ 8][0] = 0xffff; A->rows[ 9][0] = 0x8000; A->rows[10][0] = 0x4000; A->rows[11][0] = 0xc000; - A->rows[12][0] = 0x74e9; A->rows[13][0] = 0x9d3a; A->rows[14][0] = 0x3a74; A->rows[15][0] = 0xe9d3; - A->rows[16][0] = 0x4e9d; A->rows[17][0] = 0xa74e; A->rows[18][0] = 0x5cb9; A->rows[19][0] = 0xb972; - A->rows[20][0] = 0x2e5c; A->rows[21][0] = 0xe5cb; A->rows[22][0] = 0x72e5; A->rows[23][0] = 0x972e; - A->rows[24][0] = 0xf591; A->rows[25][0] = 0x1eb2; A->rows[26][0] = 0x3d64; A->rows[27][0] = 0x7ac8; - A->rows[28][0] = 0xac8f; A->rows[29][0] = 0xeb23; A->rows[30][0] = 0xc8f5; A->rows[31][0] = 0x647a; - A->rows[32][0] = 0x47ac; A->rows[33][0] = 0x9af1; A->rows[34][0] = 0x35e2; A->rows[35][0] = 0x6bc4; - A->rows[36][0] = 0x4d78; A->rows[37][0] = 0x89af; A->rows[38][0] = 0xaf13; A->rows[39][0] = 0xf135; - A->rows[40][0] = 0x789a; A->rows[41][0] = 0x26bc; A->rows[42][0] = 0xc631; A->rows[43][0] = 0x4a52; - A->rows[44][0] = 0x5294; A->rows[45][0] = 0x6318; A->rows[46][0] = 0xbdef; A->rows[47][0] = 0x8c63; - A->rows[48][0] = 0x94a5; A->rows[49][0] = 0x294a; A->rows[50][0] = 0x318c; A->rows[51][0] = 0xcd21; - A->rows[52][0] = 0x9a42; A->rows[53][0] = 0xf348; A->rows[54][0] = 0xe690; A->rows[55][0] = 0x2bb1; - A->rows[56][0] = 0x5763; A->rows[57][0] = 0x15d8; A->rows[58][0] = 0x8576; A->rows[59][0] = 0xc7cd; - A->rows[60][0] = 0x42bb; A->rows[61][0] = 0x4857; A->rows[62][0] = 0x215d; A->rows[63][0] = 0xbb1f; + mzd_row(A, 0)[0] = 0xdb6d; + mzd_row(A, 1)[0] = 0x6db6; + mzd_row(A, 2)[0] = 0xb6db; + mzd_row(A, 3)[0] = 0x0001; + mzd_row(A, 4)[0] = 0x0002; + mzd_row(A, 5)[0] = 0x0003; + mzd_row(A, 6)[0] = 0x5555; + mzd_row(A, 7)[0] = 0xaaaa; + mzd_row(A, 8)[0] = 0xffff; + mzd_row(A, 9)[0] = 0x8000; + mzd_row(A, 10)[0] = 0x4000; + mzd_row(A, 11)[0] = 0xc000; + mzd_row(A, 12)[0] = 0x74e9; + mzd_row(A, 13)[0] = 0x9d3a; + mzd_row(A, 14)[0] = 0x3a74; + mzd_row(A, 15)[0] = 0xe9d3; + mzd_row(A, 16)[0] = 0x4e9d; + mzd_row(A, 17)[0] = 0xa74e; + mzd_row(A, 18)[0] = 0x5cb9; + mzd_row(A, 19)[0] = 0xb972; + mzd_row(A, 20)[0] = 0x2e5c; + mzd_row(A, 21)[0] = 0xe5cb; + mzd_row(A, 22)[0] = 0x72e5; + mzd_row(A, 23)[0] = 0x972e; + mzd_row(A, 24)[0] = 0xf591; + mzd_row(A, 25)[0] = 0x1eb2; + mzd_row(A, 26)[0] = 0x3d64; + mzd_row(A, 27)[0] = 0x7ac8; + mzd_row(A, 28)[0] = 0xac8f; + mzd_row(A, 29)[0] = 0xeb23; + mzd_row(A, 30)[0] = 0xc8f5; + mzd_row(A, 31)[0] = 0x647a; + mzd_row(A, 32)[0] = 0x47ac; + mzd_row(A, 33)[0] = 0x9af1; + mzd_row(A, 34)[0] = 0x35e2; + mzd_row(A, 35)[0] = 0x6bc4; + mzd_row(A, 36)[0] = 0x4d78; + mzd_row(A, 37)[0] = 0x89af; + mzd_row(A, 38)[0] = 0xaf13; + mzd_row(A, 39)[0] = 0xf135; + mzd_row(A, 40)[0] = 0x789a; + mzd_row(A, 41)[0] = 0x26bc; + mzd_row(A, 42)[0] = 0xc631; + mzd_row(A, 43)[0] = 0x4a52; + mzd_row(A, 44)[0] = 0x5294; + mzd_row(A, 45)[0] = 0x6318; + mzd_row(A, 46)[0] = 0xbdef; + mzd_row(A, 47)[0] = 0x8c63; + mzd_row(A, 48)[0] = 0x94a5; + mzd_row(A, 49)[0] = 0x294a; + mzd_row(A, 50)[0] = 0x318c; + mzd_row(A, 51)[0] = 0xcd21; + mzd_row(A, 52)[0] = 0x9a42; + mzd_row(A, 53)[0] = 0xf348; + mzd_row(A, 54)[0] = 0xe690; + mzd_row(A, 55)[0] = 0x2bb1; + mzd_row(A, 56)[0] = 0x5763; + mzd_row(A, 57)[0] = 0x15d8; + mzd_row(A, 58)[0] = 0x8576; + mzd_row(A, 59)[0] = 0xc7cd; + mzd_row(A, 60)[0] = 0x42bb; + mzd_row(A, 61)[0] = 0x4857; + mzd_row(A, 62)[0] = 0x215d; + mzd_row(A, 63)[0] = 0xbb1f; return A; default: @@ -354,7 +707,7 @@ mzd_t *_crt_modred_mat(const deg_t length, const word poly, const deg_t d) { for(deg_t i=0; irows[0][i/m4ri_radix] = __M4RI_TWOPOW(i%m4ri_radix); + mzd_row(f, 0)[i/m4ri_radix] = __M4RI_TWOPOW(i%m4ri_radix); word ii = i; while(ii >= d) { /* f ^= gf2x_mul((1ULL<<(ii-d)), poly, length); */ @@ -366,14 +719,14 @@ mzd_t *_crt_modred_mat(const deg_t length, const word poly, const deg_t d) { /* ii = gf2x_deg(f); */ ii = 0; for(wi_t j=f->width-1; j>=0; j--) { - if (f->rows[0][j]) { - ii = gf2x_deg(f->rows[0][j]) + m4ri_radix*j; + if (mzd_row(f, 0)[j]) { + ii = gf2x_deg(mzd_row(f, 0)[j]) + m4ri_radix*j; break; } } } for(deg_t j=0; j<= ii; j++) - mzd_write_bit(A, j, i, (f->rows[0][j/m4ri_radix]>>(j%m4ri_radix)) & 0x1); + mzd_write_bit(A, j, i, (mzd_row(f, 0)[j/m4ri_radix]>>(j%m4ri_radix)) & 0x1); } return A; } @@ -406,10 +759,10 @@ blm_t *_blm_finish_polymult(const gf2e *ff, blm_t *f) { while(rank < m) { /* x^v = (0, 0, ... , 1, ..., 0, 0) * F_T -> select row v */ for(wi_t j=0; j< C->width; j++) - C->rows[r][j] = F_T->rows[v][j] & G_T->rows[w][j]; + mzd_row(C, r)[j] = mzd_row(F_T, v)[j] & mzd_row(G_T, w)[j]; - pivots->rows[r][0] = v; - pivots->rows[r][1] = w; + mzd_row(pivots, r)[0] = v; + mzd_row(pivots, r)[1] = w; w++; if (w == (word)f->G->ncols) { @@ -435,10 +788,10 @@ blm_t *_blm_finish_polymult(const gf2e *ff, blm_t *f) { for(r=0; r select row v */ - v = pivots->rows[r][0]; - w = pivots->rows[r][1]; + v = mzd_row(pivots, r)[0]; + w = mzd_row(pivots, r)[1]; for(wi_t j=0; j< C->width; j++) - C->rows[r][j] = F_T->rows[v][j] & G_T->rows[w][j]; + mzd_row(C, r)[j] = mzd_row(F_T, v)[j] & mzd_row(G_T, w)[j]; } mzd_free(F_T); mzd_free(G_T); @@ -455,8 +808,8 @@ blm_t *_blm_finish_polymult(const gf2e *ff, blm_t *f) { for(rci_t i=0; inrows; i++) { mzd_set_ui(a, 0); for(rci_t j=0; jrows[j][0]; - w = pivots->rows[j][1]; + v = mzd_row(pivots, j)[0]; + w = mzd_row(pivots, j)[1]; if ((v+w) == (word)i) mzd_write_bit(a, 0, j, 1); } diff --git a/m4rie/conversion.c b/m4rie/conversion.c index 55a72b9..5e59b03 100644 --- a/m4rie/conversion.c +++ b/m4rie/conversion.c @@ -129,9 +129,9 @@ mzd_slice_t *_mzed_slice2(mzd_slice_t *T, const mzed_t *F) { return T; for(size_t i=0; inrows; i++) { - word *t0 = T->x[0]->rows[i]; - word *t1 = T->x[1]->rows[i]; - const word *f = F->x->rows[i]; + word *t0 = mzd_row(T->x[0], i); + word *t1 = mzd_row(T->x[1], i); + const word *f = mzd_row(F->x, i); /* bulk of work */ for(j=0, j2=0; j+2 < F->x->width; j+=2,j2++) { @@ -188,9 +188,9 @@ mzed_t *_mzed_cling2(mzed_t *T, const mzd_slice_t *F) { return T; for(size_t i=0; inrows; i++) { - const word *f0 = F->x[0]->rows[i]; - const word *f1 = F->x[1]->rows[i]; - word *t = T->x->rows[i]; + const word *f0 = mzd_row(F->x[0], i); + const word *f1 = mzd_row(F->x[1], i); + word *t = mzd_row(T->x, i); for(j=0, j2=0; j+2 < T->x->width; j+=2, j2++) { t[j+0] = (word_cling_64_02(f0[j2]<<32)>>1) | (word_cling_64_02(f1[j2]<<32)>>0); @@ -223,10 +223,10 @@ mzd_slice_t *_mzed_slice4(mzd_slice_t *T, const mzed_t *F) { if (T->depth == 3) { for(size_t i=0; inrows; i++) { - word *t0 = T->x[0]->rows[i]; - word *t1 = T->x[1]->rows[i]; - word *t2 = T->x[2]->rows[i]; - const word * const f = F->x->rows[i]; + word *t0 = mzd_row(T->x[0], i); + word *t1 = mzd_row(T->x[1], i); + word *t2 = mzd_row(T->x[2], i); + const word * const f = mzd_row(F->x, i); /* bulk of work */ for(j=0, j2=0; j+4 < F->x->width; j+=4,j2++) { @@ -265,11 +265,11 @@ mzd_slice_t *_mzed_slice4(mzd_slice_t *T, const mzed_t *F) { } } else { for(size_t i=0; inrows; i++) { - word *t0 = T->x[0]->rows[i]; - word *t1 = T->x[1]->rows[i]; - word *t2 = T->x[2]->rows[i]; - word *t3 = T->x[3]->rows[i]; - const word * const f = F->x->rows[i]; + word *t0 = mzd_row(T->x[0], i); + word *t1 = mzd_row(T->x[1], i); + word *t2 = mzd_row(T->x[2], i); + word *t3 = mzd_row(T->x[3], i); + const word * const f = mzd_row(F->x, i); /* bulk of work */ for(j=0, j2=0; j+4 < F->x->width; j+=4,j2++) { @@ -327,11 +327,11 @@ mzed_t *_mzed_cling4(mzed_t *T, const mzd_slice_t *F) { if (F->finite_field->degree == 4) { for(rci_t i=0; inrows; i++) { - const word *f0 = F->x[0]->rows[i]; - const word *f1 = F->x[1]->rows[i]; - const word *f2 = F->x[2]->rows[i]; - const word *f3 = F->x[3]->rows[i]; - word *t = T->x->rows[i]; + const word *f0 = mzd_row(F->x[0], i); + const word *f1 = mzd_row(F->x[1], i); + const word *f2 = mzd_row(F->x[2], i); + const word *f3 = mzd_row(F->x[3], i); + word *t = mzd_row(T->x, i); for(j=0, j2=0; j+4 < T->x->width; j+=4, j2++) { t[j+0] = (word_cling_64_04(f0[j2]<<48)>>3) | (word_cling_64_04(f1[j2]<<48)>>2) | (word_cling_64_04(f2[j2]<<48)>>1) | (word_cling_64_04(f3[j2]<<48)>>0); @@ -370,10 +370,10 @@ mzed_t *_mzed_cling4(mzed_t *T, const mzd_slice_t *F) { } } else { //degree == 3 for(rci_t i=0; inrows; i++) { - const word *f0 = F->x[0]->rows[i]; - const word *f1 = F->x[1]->rows[i]; - const word *f2 = F->x[2]->rows[i]; - word *t = T->x->rows[i]; + const word *f0 = mzd_row(F->x[0], i); + const word *f1 = mzd_row(F->x[1], i); + const word *f2 = mzd_row(F->x[2], i); + word *t = mzd_row(T->x, i); for(j=0, j2=0; j+4 < T->x->width; j+=4, j2++) { t[j+0] = (word_cling_64_04(f0[j2]<<48)>>3) | (word_cling_64_04(f1[j2]<<48)>>2) | (word_cling_64_04(f2[j2]<<48)>>1); diff --git a/m4rie/conversion_cling16.c b/m4rie/conversion_cling16.c index 89a81a5..50deef7 100644 --- a/m4rie/conversion_cling16.c +++ b/m4rie/conversion_cling16.c @@ -34,15 +34,15 @@ mzed_t *_mzed_cling16(mzed_t *T, const mzd_slice_t *F) { return T; for(rci_t i=0; inrows; i++) { - const word *f00 = F->x[ 0]->rows[i]; - const word *f01 = F->x[ 1]->rows[i]; - const word *f02 = F->x[ 2]->rows[i]; - const word *f03 = F->x[ 3]->rows[i]; - const word *f04 = F->x[ 4]->rows[i]; - const word *f05 = F->x[ 5]->rows[i]; - const word *f06 = F->x[ 6]->rows[i]; - const word *f07 = F->x[ 7]->rows[i]; - word *t = T->x->rows[i]; + const word *f00 = mzd_row(F->x[0], i); + const word *f01 = mzd_row(F->x[1], i); + const word *f02 = mzd_row(F->x[2], i); + const word *f03 = mzd_row(F->x[3], i); + const word *f04 = mzd_row(F->x[4], i); + const word *f05 = mzd_row(F->x[5], i); + const word *f06 = mzd_row(F->x[6], i); + const word *f07 = mzd_row(F->x[7], i); + word *t = mzd_row(T->x, i); for(j=0, j2=0; j+16 < T->x->width; j+=16, j2++) { t[j+ 0] = (word_cling_64_16(f00[j2]<<60)>>15) | (word_cling_64_16(f01[j2]<<60)>>14) | (word_cling_64_16(f02[j2]<<60)>>13) | (word_cling_64_16(f03[j2]<<60)>>12) \ @@ -124,8 +124,8 @@ mzed_t *_mzed_cling16(mzed_t *T, const mzd_slice_t *F) { switch(T->finite_field->degree) { case 9: { for(rci_t i=0; inrows; i++) { - const word *f00 = F->x[ 8]->rows[i]; - word *t = T->x->rows[i]; + const word *f00 = mzd_row(F->x[8], i); + word *t = mzd_row(T->x, i); for(j=0, j2=0; j+16 < T->x->width; j+=16, j2++) { t[j+ 0] |= (word_cling_64_16(f00[j2]<<60)>>7); @@ -174,9 +174,9 @@ mzed_t *_mzed_cling16(mzed_t *T, const mzd_slice_t *F) { break; case 10: { for(rci_t i=0; inrows; i++) { - const word *f00 = F->x[ 8]->rows[i]; - const word *f01 = F->x[ 9]->rows[i]; - word *t = T->x->rows[i]; + const word *f00 = mzd_row(F->x[8], i); + const word *f01 = mzd_row(F->x[9], i); + word *t = mzd_row(T->x, i); for(j=0, j2=0; j+16 < T->x->width; j+=16, j2++) { t[j+ 0] |= (word_cling_64_16(f00[j2]<<60)>>7) | (word_cling_64_16(f01[j2]<<60)>>6); @@ -225,11 +225,10 @@ mzed_t *_mzed_cling16(mzed_t *T, const mzd_slice_t *F) { break; case 11: { for(rci_t i=0; inrows; i++) { - const word *f00 = F->x[ 8]->rows[i]; - const word *f01 = F->x[ 9]->rows[i]; - const word *f02 = F->x[10]->rows[i]; - word *t = T->x->rows[i]; - + const word *f00 = mzd_row(F->x[ 8], i); + const word *f01 = mzd_row(F->x[ 9], i); + const word *f02 = mzd_row(F->x[10], i); + word *t = mzd_row(T->x, i); for(j=0, j2=0; j+16 < T->x->width; j+=16, j2++) { t[j+ 0] |= (word_cling_64_16(f00[j2]<<60)>>7) | (word_cling_64_16(f01[j2]<<60)>>6) | (word_cling_64_16(f02[j2]<<60)>>5); t[j+ 1] |= (word_cling_64_16(f00[j2]<<56)>>7) | (word_cling_64_16(f01[j2]<<56)>>6) | (word_cling_64_16(f02[j2]<<56)>>5); @@ -278,11 +277,11 @@ mzed_t *_mzed_cling16(mzed_t *T, const mzd_slice_t *F) { } } else { for(rci_t i=0; inrows; i++) { - const word *f00 = F->x[ 8]->rows[i]; - const word *f01 = F->x[ 9]->rows[i]; - const word *f02 = F->x[10]->rows[i]; - const word *f03 = F->x[11]->rows[i]; - word *t = T->x->rows[i]; + const word *f00 = mzd_row(F->x[ 8], i); + const word *f01 = mzd_row(F->x[ 9], i); + const word *f02 = mzd_row(F->x[10], i); + const word *f03 = mzd_row(F->x[11], i); + word *t = mzd_row(T->x, i); for(j=0, j2=0; j+16 < T->x->width; j+=16, j2++) { t[j+ 0] |= (word_cling_64_16(f00[j2]<<60)>>7) | (word_cling_64_16(f01[j2]<<60)>>6) | (word_cling_64_16(f02[j2]<<60)>>5) | (word_cling_64_16(f03[j2]<<60)>>4); @@ -330,8 +329,8 @@ mzed_t *_mzed_cling16(mzed_t *T, const mzd_slice_t *F) { switch(T->finite_field->degree) { case 13: { for(rci_t i=0; inrows; i++) { - const word *f00 = F->x[12]->rows[i]; - word *t = T->x->rows[i]; + const word *f00 = mzd_row(F->x[12], i); + word *t = mzd_row(T->x, i); for(j=0, j2=0; j+16 < T->x->width; j+=16, j2++) { t[j+ 0] |= (word_cling_64_16(f00[j2]<<60)>>3); @@ -380,9 +379,9 @@ mzed_t *_mzed_cling16(mzed_t *T, const mzd_slice_t *F) { break; case 14: { for(rci_t i=0; inrows; i++) { - const word *f00 = F->x[12]->rows[i]; - const word *f01 = F->x[13]->rows[i]; - word *t = T->x->rows[i]; + const word *f00 = mzd_row(F->x[12], i); + const word *f01 = mzd_row(F->x[13], i); + word *t = mzd_row(T->x, i); for(j=0, j2=0; j+16 < T->x->width; j+=16, j2++) { t[j+ 0] |= (word_cling_64_16(f00[j2]<<60)>>3) | (word_cling_64_16(f01[j2]<<60)>>2); @@ -431,10 +430,10 @@ mzed_t *_mzed_cling16(mzed_t *T, const mzd_slice_t *F) { break; case 15: { for(rci_t i=0; inrows; i++) { - const word *f00 = F->x[12]->rows[i]; - const word *f01 = F->x[13]->rows[i]; - const word *f02 = F->x[14]->rows[i]; - word *t = T->x->rows[i]; + const word *f00 = mzd_row(F->x[12], i); + const word *f01 = mzd_row(F->x[13], i); + const word *f02 = mzd_row(F->x[14], i); + word *t = mzd_row(T->x, i); for(j=0, j2=0; j+16 < T->x->width; j+=16, j2++) { t[j+ 0] |= (word_cling_64_16(f00[j2]<<60)>>3) | (word_cling_64_16(f01[j2]<<60)>>2) | (word_cling_64_16(f02[j2]<<60)>>1); @@ -483,11 +482,11 @@ mzed_t *_mzed_cling16(mzed_t *T, const mzd_slice_t *F) { break; case 16: { for(rci_t i=0; inrows; i++) { - const word *f00 = F->x[12]->rows[i]; - const word *f01 = F->x[13]->rows[i]; - const word *f02 = F->x[14]->rows[i]; - const word *f03 = F->x[15]->rows[i]; - word *t = T->x->rows[i]; + const word *f00 = mzd_row(F->x[12], i); + const word *f01 = mzd_row(F->x[13], i); + const word *f02 = mzd_row(F->x[14], i); + const word *f03 = mzd_row(F->x[15], i); + word *t = mzd_row(T->x, i); for(j=0, j2=0; j+16 < T->x->width; j+=16, j2++) { t[j+ 0] |= (word_cling_64_16(f00[j2]<<60)>>3) | (word_cling_64_16(f01[j2]<<60)>>2) | (word_cling_64_16(f02[j2]<<60)>>1) | (word_cling_64_16(f03[j2]<<60)>>0); diff --git a/m4rie/conversion_cling8.c b/m4rie/conversion_cling8.c index 27e9318..245f6d8 100644 --- a/m4rie/conversion_cling8.c +++ b/m4rie/conversion_cling8.c @@ -37,15 +37,15 @@ mzed_t *_mzed_cling8(mzed_t *T, const mzd_slice_t *F) { switch (F->finite_field->degree) { case 8: { for(rci_t i=0; inrows; i++) { - const word *f0 = F->x[0]->rows[i]; - const word *f1 = F->x[1]->rows[i]; - const word *f2 = F->x[2]->rows[i]; - const word *f3 = F->x[3]->rows[i]; - const word *f4 = F->x[4]->rows[i]; - const word *f5 = F->x[5]->rows[i]; - const word *f6 = F->x[6]->rows[i]; - const word *f7 = F->x[7]->rows[i]; - word *t = T->x->rows[i]; + const word *f0 = mzd_row(F->x[0], i); + const word *f1 = mzd_row(F->x[1], i); + const word *f2 = mzd_row(F->x[2], i); + const word *f3 = mzd_row(F->x[3], i); + const word *f4 = mzd_row(F->x[4], i); + const word *f5 = mzd_row(F->x[5], i); + const word *f6 = mzd_row(F->x[6], i); + const word *f7 = mzd_row(F->x[7], i); + word *t = mzd_row(T->x, i); for(j=0, j2=0; j+8 < T->x->width; j+=8, j2++) { t[j+0] = (word_cling_64_08(f0[j2]<<56)>>7) | (word_cling_64_08(f1[j2]<<56)>>6) | (word_cling_64_08(f2[j2]<<56)>>5) | (word_cling_64_08(f3[j2]<<56)>>4) \ @@ -103,14 +103,14 @@ mzed_t *_mzed_cling8(mzed_t *T, const mzd_slice_t *F) { case 7: { for(rci_t i=0; inrows; i++) { - const word *f0 = F->x[0]->rows[i]; - const word *f1 = F->x[1]->rows[i]; - const word *f2 = F->x[2]->rows[i]; - const word *f3 = F->x[3]->rows[i]; - const word *f4 = F->x[4]->rows[i]; - const word *f5 = F->x[5]->rows[i]; - const word *f6 = F->x[6]->rows[i]; - word *t = T->x->rows[i]; + const word *f0 = mzd_row(F->x[0], i); + const word *f1 = mzd_row(F->x[1], i); + const word *f2 = mzd_row(F->x[2], i); + const word *f3 = mzd_row(F->x[3], i); + const word *f4 = mzd_row(F->x[4], i); + const word *f5 = mzd_row(F->x[5], i); + const word *f6 = mzd_row(F->x[6], i); + word *t = mzd_row(T->x, i); for(j=0, j2=0; j+8 < T->x->width; j+=8, j2++) { t[j+0] = (word_cling_64_08(f0[j2]<<56)>>7) | (word_cling_64_08(f1[j2]<<56)>>6) | (word_cling_64_08(f2[j2]<<56)>>5) | (word_cling_64_08(f3[j2]<<56)>>4) \ @@ -168,13 +168,13 @@ mzed_t *_mzed_cling8(mzed_t *T, const mzd_slice_t *F) { case 6: { for(rci_t i=0; inrows; i++) { - const word *f0 = F->x[0]->rows[i]; - const word *f1 = F->x[1]->rows[i]; - const word *f2 = F->x[2]->rows[i]; - const word *f3 = F->x[3]->rows[i]; - const word *f4 = F->x[4]->rows[i]; - const word *f5 = F->x[5]->rows[i]; - word *t = T->x->rows[i]; + const word *f0 = mzd_row(F->x[0], i); + const word *f1 = mzd_row(F->x[1], i); + const word *f2 = mzd_row(F->x[2], i); + const word *f3 = mzd_row(F->x[3], i); + const word *f4 = mzd_row(F->x[4], i); + const word *f5 = mzd_row(F->x[5], i); + word *t = mzd_row(T->x, i); for(j=0, j2=0; j+8 < T->x->width; j+=8, j2++) { t[j+0] = (word_cling_64_08(f0[j2]<<56)>>7) | (word_cling_64_08(f1[j2]<<56)>>6) | (word_cling_64_08(f2[j2]<<56)>>5) | (word_cling_64_08(f3[j2]<<56)>>4) \ @@ -232,12 +232,12 @@ mzed_t *_mzed_cling8(mzed_t *T, const mzd_slice_t *F) { case 5: { for(rci_t i=0; inrows; i++) { - const word *f0 = F->x[0]->rows[i]; - const word *f1 = F->x[1]->rows[i]; - const word *f2 = F->x[2]->rows[i]; - const word *f3 = F->x[3]->rows[i]; - const word *f4 = F->x[4]->rows[i]; - word *t = T->x->rows[i]; + const word *f0 = mzd_row(F->x[0], i); + const word *f1 = mzd_row(F->x[1], i); + const word *f2 = mzd_row(F->x[2], i); + const word *f3 = mzd_row(F->x[3], i); + const word *f4 = mzd_row(F->x[4], i); + word *t = mzd_row(T->x, i); for(j=0, j2=0; j+8 < T->x->width; j+=8, j2++) { t[j+0] = (word_cling_64_08(f0[j2]<<56)>>7) | (word_cling_64_08(f1[j2]<<56)>>6) | (word_cling_64_08(f2[j2]<<56)>>5) | (word_cling_64_08(f3[j2]<<56)>>4) | (word_cling_64_08(f4[j2]<<56)>>3); diff --git a/m4rie/conversion_slice16.c b/m4rie/conversion_slice16.c index 92f4cf9..85483a6 100644 --- a/m4rie/conversion_slice16.c +++ b/m4rie/conversion_slice16.c @@ -61,15 +61,15 @@ mzd_slice_t *_mzed_slice16(mzd_slice_t *T, const mzed_t *F) { bits */ for(size_t i=0; inrows; i++) { - word *t0 = T->x[0]->rows[i]; - word *t1 = T->x[1]->rows[i]; - word *t2 = T->x[2]->rows[i]; - word *t3 = T->x[3]->rows[i]; - word *t4 = T->x[4]->rows[i]; - word *t5 = T->x[5]->rows[i]; - word *t6 = T->x[6]->rows[i]; - word *t7 = T->x[7]->rows[i]; - const word * const f = F->x->rows[i]; + word *t0 = mzd_row(T->x[0], i); + word *t1 = mzd_row(T->x[1], i); + word *t2 = mzd_row(T->x[2], i); + word *t3 = mzd_row(T->x[3], i); + word *t4 = mzd_row(T->x[4], i); + word *t5 = mzd_row(T->x[5], i); + word *t6 = mzd_row(T->x[6], i); + word *t7 = mzd_row(T->x[7], i); + const word * const f = mzd_row(F->x, i); /* bulk of work */ for(j=0, j2=0; j+16 < F->x->width; j+=16,j2++) { @@ -115,11 +115,11 @@ mzd_slice_t *_mzed_slice16(mzd_slice_t *T, const mzed_t *F) { } if(T->depth >= 12) { for(size_t i=0; inrows; i++) { - word *t0 = T->x[ 8]->rows[i]; - word *t1 = T->x[ 9]->rows[i]; - word *t2 = T->x[10]->rows[i]; - word *t3 = T->x[11]->rows[i]; - const word * const f = F->x->rows[i]; + word *t0 = mzd_row(T->x[ 8], i); + word *t1 = mzd_row(T->x[ 9], i); + word *t2 = mzd_row(T->x[10], i); + word *t3 = mzd_row(T->x[11], i); + const word * const f = mzd_row(F->x, i); /* bulk of work */ for(j=0, j2=0; j+16 < F->x->width; j+=16,j2++) { @@ -159,11 +159,11 @@ mzd_slice_t *_mzed_slice16(mzd_slice_t *T, const mzed_t *F) { switch(T->depth) { case 16: { for(size_t i=0; inrows; i++) { - word *t0 = T->x[12]->rows[i]; - word *t1 = T->x[13]->rows[i]; - word *t2 = T->x[14]->rows[i]; - word *t3 = T->x[15]->rows[i]; - const word * const f = F->x->rows[i]; + word *t0 = mzd_row(T->x[12], i); + word *t1 = mzd_row(T->x[13], i); + word *t2 = mzd_row(T->x[14], i); + word *t3 = mzd_row(T->x[15], i); + const word * const f = mzd_row(F->x, i); /* bulk of work */ for(j=0, j2=0; j+16 < F->x->width; j+=16,j2++) { @@ -202,10 +202,10 @@ mzd_slice_t *_mzed_slice16(mzd_slice_t *T, const mzed_t *F) { } break; case 15: { for(size_t i=0; inrows; i++) { - word *t0 = T->x[12]->rows[i]; - word *t1 = T->x[13]->rows[i]; - word *t2 = T->x[14]->rows[i]; - const word * const f = F->x->rows[i]; + word *t0 = mzd_row(T->x[12], i); + word *t1 = mzd_row(T->x[13], i); + word *t2 = mzd_row(T->x[14], i); + const word * const f = mzd_row(F->x, i); /* bulk of work */ for(j=0, j2=0; j+16 < F->x->width; j+=16,j2++) { @@ -242,9 +242,9 @@ mzd_slice_t *_mzed_slice16(mzd_slice_t *T, const mzed_t *F) { } break; case 14: { for(size_t i=0; inrows; i++) { - word *t0 = T->x[12]->rows[i]; - word *t1 = T->x[13]->rows[i]; - const word * const f = F->x->rows[i]; + word *t0 = mzd_row(T->x[12], i); + word *t1 = mzd_row(T->x[13], i); + const word * const f = mzd_row(F->x, i); /* bulk of work */ for(j=0, j2=0; j+16 < F->x->width; j+=16,j2++) { @@ -279,8 +279,8 @@ mzd_slice_t *_mzed_slice16(mzd_slice_t *T, const mzed_t *F) { } break; case 13: { for(size_t i=0; inrows; i++) { - word *t0 = T->x[12]->rows[i]; - const word * const f = F->x->rows[i]; + word *t0 = mzd_row(T->x[12], i); + const word * const f = mzd_row(F->x, i); /* bulk of work */ for(j=0, j2=0; j+16 < F->x->width; j+=16,j2++) { @@ -316,10 +316,10 @@ mzd_slice_t *_mzed_slice16(mzd_slice_t *T, const mzed_t *F) { switch(T->depth) { case 11: { for(size_t i=0; inrows; i++) { - word *t0 = T->x[ 8]->rows[i]; - word *t1 = T->x[ 9]->rows[i]; - word *t2 = T->x[10]->rows[i]; - const word * const f = F->x->rows[i]; + word *t0 = mzd_row(T->x[ 8], i); + word *t1 = mzd_row(T->x[ 9], i); + word *t2 = mzd_row(T->x[10], i); + const word * const f = mzd_row(F->x, i); /* bulk of work */ for(j=0, j2=0; j+16 < F->x->width; j+=16,j2++) { @@ -356,9 +356,9 @@ mzd_slice_t *_mzed_slice16(mzd_slice_t *T, const mzed_t *F) { } break; case 10: { for(size_t i=0; inrows; i++) { - word *t0 = T->x[ 8]->rows[i]; - word *t1 = T->x[ 9]->rows[i]; - const word * const f = F->x->rows[i]; + word *t0 = mzd_row(T->x[ 8], i); + word *t1 = mzd_row(T->x[ 9], i); + const word * const f = mzd_row(F->x, i); /* bulk of work */ for(j=0, j2=0; j+16 < F->x->width; j+=16,j2++) { @@ -393,8 +393,8 @@ mzd_slice_t *_mzed_slice16(mzd_slice_t *T, const mzed_t *F) { } break; case 9: { for(size_t i=0; inrows; i++) { - word *t0 = T->x[ 8]->rows[i]; - const word * const f = F->x->rows[i]; + word *t0 = mzd_row(T->x[ 8], i); + const word * const f = mzd_row(F->x, i); /* bulk of work */ for(j=0, j2=0; j+16 < F->x->width; j+=16,j2++) { diff --git a/m4rie/conversion_slice8.c b/m4rie/conversion_slice8.c index 1600570..63e8282 100644 --- a/m4rie/conversion_slice8.c +++ b/m4rie/conversion_slice8.c @@ -39,15 +39,15 @@ mzd_slice_t *_mzed_slice8(mzd_slice_t *T, const mzed_t *F) { switch(T->depth) { case 8: { for(size_t i=0; inrows; i++) { - word *t0 = T->x[0]->rows[i]; - word *t1 = T->x[1]->rows[i]; - word *t2 = T->x[2]->rows[i]; - word *t3 = T->x[3]->rows[i]; - word *t4 = T->x[4]->rows[i]; - word *t5 = T->x[5]->rows[i]; - word *t6 = T->x[6]->rows[i]; - word *t7 = T->x[7]->rows[i]; - const word * const f = F->x->rows[i]; + word *t0 = mzd_row(T->x[0], i); + word *t1 = mzd_row(T->x[1], i); + word *t2 = mzd_row(T->x[2], i); + word *t3 = mzd_row(T->x[3], i); + word *t4 = mzd_row(T->x[4], i); + word *t5 = mzd_row(T->x[5], i); + word *t6 = mzd_row(T->x[6], i); + word *t7 = mzd_row(T->x[7], i); + const word * const f = mzd_row(F->x, i); /* bulk of work */ for(j=0, j2=0; j+8 < F->x->width; j+=8,j2++) { @@ -183,14 +183,14 @@ mzd_slice_t *_mzed_slice8(mzd_slice_t *T, const mzed_t *F) { case 7: { for(size_t i=0; inrows; i++) { - word *t0 = T->x[0]->rows[i]; - word *t1 = T->x[1]->rows[i]; - word *t2 = T->x[2]->rows[i]; - word *t3 = T->x[3]->rows[i]; - word *t4 = T->x[4]->rows[i]; - word *t5 = T->x[5]->rows[i]; - word *t6 = T->x[6]->rows[i]; - const word * const f = F->x->rows[i]; + word *t0 = mzd_row(T->x[0], i); + word *t1 = mzd_row(T->x[1], i); + word *t2 = mzd_row(T->x[2], i); + word *t3 = mzd_row(T->x[3], i); + word *t4 = mzd_row(T->x[4], i); + word *t5 = mzd_row(T->x[5], i); + word *t6 = mzd_row(T->x[6], i); + const word * const f = mzd_row(F->x, i); /* bulk of work */ for(j=0, j2=0; j+8 < F->x->width; j+=8,j2++) { @@ -312,13 +312,13 @@ mzd_slice_t *_mzed_slice8(mzd_slice_t *T, const mzed_t *F) { case 6: { for(size_t i=0; inrows; i++) { - word *t0 = T->x[0]->rows[i]; - word *t1 = T->x[1]->rows[i]; - word *t2 = T->x[2]->rows[i]; - word *t3 = T->x[3]->rows[i]; - word *t4 = T->x[4]->rows[i]; - word *t5 = T->x[5]->rows[i]; - const word * const f = F->x->rows[i]; + word *t0 = mzd_row(T->x[0], i); + word *t1 = mzd_row(T->x[1], i); + word *t2 = mzd_row(T->x[2], i); + word *t3 = mzd_row(T->x[3], i); + word *t4 = mzd_row(T->x[4], i); + word *t5 = mzd_row(T->x[5], i); + const word * const f = mzd_row(F->x, i); /* bulk of work */ for(j=0, j2=0; j+8 < F->x->width; j+=8,j2++) { @@ -426,12 +426,12 @@ mzd_slice_t *_mzed_slice8(mzd_slice_t *T, const mzed_t *F) { case 5: { for(size_t i=0; inrows; i++) { - word *t0 = T->x[0]->rows[i]; - word *t1 = T->x[1]->rows[i]; - word *t2 = T->x[2]->rows[i]; - word *t3 = T->x[3]->rows[i]; - word *t4 = T->x[4]->rows[i]; - const word * const f = F->x->rows[i]; + word *t0 = mzd_row(T->x[0], i); + word *t1 = mzd_row(T->x[1], i); + word *t2 = mzd_row(T->x[2], i); + word *t3 = mzd_row(T->x[3], i); + word *t4 = mzd_row(T->x[4], i); + const word * const f = mzd_row(F->x, i); /* bulk of work */ for(j=0, j2=0; j+8 < F->x->width; j+=8,j2++) { diff --git a/m4rie/mzed.c b/m4rie/mzed.c index 093b9ee..4084548 100644 --- a/m4rie/mzed.c +++ b/m4rie/mzed.c @@ -169,8 +169,8 @@ mzed_t *mzed_mul_scalar(mzed_t *C, const word a, const mzed_t *B) { */ for(rci_t i=0; inrows; i++) { - word *c_row = C->x->rows[i]; - const word *b_row = B->x->rows[i]; + word *c_row = mzd_row(C->x, i); + const word *b_row = mzd_row(B->x, i); for(wi_t j=0; jx->width-1; j++) { const word tmp = b_row[j]; const word a0 = tmp & mask_16; @@ -288,8 +288,8 @@ void mzed_add_multiple_of_row(mzed_t *A, rci_t ar, const mzed_t *B, rci_t br, wo mzd_t *from_x = B->x; mzd_t *to_x = A->x; - word *_f = from_x->rows[br]; - word *_t = to_x->rows[ar]; + word *_f = mzd_row(from_x, br); + word *_t = mzd_row(to_x, ar); wi_t j; register word __f = _f[startblock]>>(start%m4ri_radix); @@ -555,8 +555,8 @@ void mzed_add_multiple_of_row(mzed_t *A, rci_t ar, const mzed_t *B, rci_t br, wo } else if (A->w == 16) { mzd_t *from_x = B->x; mzd_t *to_x = A->x; - word *_f = from_x->rows[br]; - word *_t = to_x->rows[ar]; + word *_f = mzd_row(from_x, br); + word *_t = mzd_row(to_x, ar); size_t j; register word __t, __f; diff --git a/m4rie/mzed.h b/m4rie/mzed.h index 282297b..eb491c2 100644 --- a/m4rie/mzed.h +++ b/m4rie/mzed.h @@ -521,8 +521,8 @@ static inline void mzed_add_row(mzed_t *A, rci_t ar, const mzed_t *B, rci_t br, const word bitmask_begin = __M4RI_RIGHT_BITMASK(m4ri_radix - (start%m4ri_radix)); const word bitmask_end = A->x->high_bitmask; - word *_a = A->x->rows[ar]; - const word *_b = B->x->rows[br]; + word *_a = mzd_row(A->x, ar); + const word *_b = mzd_row(B->x, br); wi_t j; if (A->x->width - startblock > 1) { @@ -552,7 +552,7 @@ static inline void mzed_rescale_row(mzed_t *A, rci_t r, rci_t start_col, const w const gf2e *ff = A->finite_field; const rci_t start = A->w*start_col; const wi_t startblock = start/m4ri_radix; - word *_a = A->x->rows[r]; + word *_a = mzd_row(A->x, r); const word bitmask_begin = __M4RI_RIGHT_BITMASK(m4ri_radix - (start%m4ri_radix)); const word bitmask_end = A->x->high_bitmask; register word __a = _a[startblock]>>(start%m4ri_radix); diff --git a/m4rie/newton_john.c b/m4rie/newton_john.c index 500723a..3593273 100644 --- a/m4rie/newton_john.c +++ b/m4rie/newton_john.c @@ -61,8 +61,12 @@ void njt_mzed_free(njt_mzed_t *T) { static inline void mzed_combine4(mzed_t *C, rci_t rc, mzed_t *T0, rci_t r0, mzed_t *T1, rci_t r1, mzed_t *T2, rci_t r2, mzed_t *T3, rci_t r3) { - const word *t[4] = {T0->x->rows[r0], T1->x->rows[r1], T2->x->rows[r2], T3->x->rows[r3]}; - _mzd_combine_4(C->x->rows[rc], t, C->x->width); + const word *t[4]; + t[0] = mzd_row(T0->x, r0); + t[1] = mzd_row(T1->x, r1); + t[2] = mzd_row(T2->x, r2); + t[3] = mzd_row(T3->x, r3); + _mzd_combine_4(mzd_row(C->x, rc), t, C->x->width); } /** @@ -91,9 +95,16 @@ static inline void mzed_combine4(mzed_t *C, rci_t rc, static inline void mzed_combine8(mzed_t *C, rci_t rc, mzed_t *T0, rci_t r0, mzed_t *T1, rci_t r1, mzed_t *T2, rci_t r2, mzed_t *T3, rci_t r3, mzed_t *T4, rci_t r4, mzed_t *T5, rci_t r5, mzed_t *T6, rci_t r6, mzed_t *T7, rci_t r7) { - const word *t[8] = {T0->x->rows[r0], T1->x->rows[r1], T2->x->rows[r2], T3->x->rows[r3], - T4->x->rows[r4], T5->x->rows[r5], T6->x->rows[r6], T7->x->rows[r7]}; - _mzd_combine_8(C->x->rows[rc], t, C->x->width); + const word *t[8]; + t[0] = mzd_row(T0->x, r0); + t[1] = mzd_row(T1->x, r1); + t[2] = mzd_row(T2->x, r2); + t[3] = mzd_row(T3->x, r3); + t[4] = mzd_row(T4->x, r4); + t[5] = mzd_row(T5->x, r5); + t[6] = mzd_row(T6->x, r6); + t[7] = mzd_row(T7->x, r7); + _mzd_combine_8(mzd_row(C->x, rc), t, C->x->width); } @@ -181,14 +192,14 @@ njt_mzed_t *mzed_make_table(njt_mzed_t *T, const mzed_t *A, const rci_t r, const } for(rci_t i=1; i < T->T->nrows; ++i) { - word *ti = T->T->x->rows[i] + homeblock; - word *ti1 = T->T->x->rows[i-1] + homeblock; + word *ti = mzd_row(T->T->x, i) + homeblock; + word *ti1 = mzd_row(T->T->x, i-1) + homeblock; const rci_t rowneeded = m4ri_codebook[degree]->inc[i - 1]; const int id = m4ri_codebook[degree]->ord[i]; T->L[id] = i; - word *m = T->M->x->rows[rowneeded] + homeblock; + word *m = mzd_row(T->M->x, rowneeded) + homeblock; /* there might still be stuff left over from the previous table creation, here we assume that this is at most 8 * m4ri_radix bits away. */ diff --git a/tests/testing.h b/tests/testing.h index 91fd9f0..6c8b136 100644 --- a/tests/testing.h +++ b/tests/testing.h @@ -2,7 +2,7 @@ #include #define m4rie_check(expr) \ - if (!expr) { \ + if (!(expr)) { \ fail_ret += 1; \ printf("\n%s in %s:%d failed\n", #expr, __FILE__, __LINE__); \ } @@ -38,7 +38,8 @@ static inline void mzed_set_canary(mzed_t *A) { const rci_t n = A->x->width-1; for(rci_t i=0; inrows; i++) { - A->x->rows[i][n] = (A->x->rows[i][n] & mask_end) | (m4rie_canary & mask_field & ~mask_end); + word *row = mzd_row(A->x, i); + row[n] = (row[n] & mask_end) | (m4rie_canary & mask_field & ~mask_end); } } @@ -47,7 +48,8 @@ static inline void mzed_clear_canary(mzed_t *A) { const rci_t n = A->x->width-1; for(rci_t i=0; inrows; i++) { - A->x->rows[i][n] &= mask_end; + word *row = mzd_row(A->x, i); + row[n] &= mask_end; } } @@ -57,7 +59,8 @@ static inline int mzed_canary_is_alive(mzed_t *A) { const rci_t n = A->x->width-1; for(rci_t i=0; inrows; i++) { - if ((A->x->rows[i][n] & ~mask_end) != (m4rie_canary & mask_field & ~mask_end)) { + word *row = mzd_row(A->x, i); + if ((row[n] & ~mask_end) != (m4rie_canary & mask_field & ~mask_end)) { return 0; } } @@ -68,11 +71,12 @@ static inline int mzed_interval_clean(mzed_t *A) { const word mask_end = __M4RI_LEFT_BITMASK(A->x->ncols % m4ri_radix); const word mask_field = field_mask(A->finite_field); for(rci_t i=0; inrows; i++) { + word *row = mzd_row(A->x, i); for(wi_t j=0; jx->width-1; j++) { - if (A->x->rows[i][j] & mask_field) + if (row[j] & mask_field) return 0; } - if (A->x->rows[i][A->x->width-1] & mask_field & mask_end) + if (row[A->x->width-1] & mask_field & mask_end) return 0; } return 1; @@ -84,7 +88,8 @@ static inline void mzd_slice_set_canary(mzd_slice_t *A) { for(unsigned int e=0; efinite_field->degree; e++) { for(rci_t i=0; inrows; i++) { - A->x[e]->rows[i][n] = (A->x[e]->rows[i][n] & mask_end) | (m4rie_canary & ~mask_end); + word *row = mzd_row(A->x[e], i); + row[n] = (row[n] & mask_end) | (m4rie_canary & ~mask_end); } } } @@ -95,7 +100,8 @@ static inline void mzd_slice_clear_canary(mzd_slice_t *A) { for(int e=0; efinite_field->degree; e++) { for(rci_t i=0; inrows; i++) { - A->x[e]->rows[i][n] &=mask_end; + word *row = mzd_row(A->x[e], i); + row[n] &=mask_end; } } } @@ -106,7 +112,8 @@ static inline int mzd_slice_canary_is_alive(mzd_slice_t *A) { for(unsigned int e=0; efinite_field->degree; e++) { for(rci_t i=0; inrows; i++) { - if ((A->x[e]->rows[i][n] & ~mask_end) != (m4rie_canary & ~mask_end)) { + word *row = mzd_row(A->x[e], i); + if ((row[n] & ~mask_end) != (m4rie_canary & ~mask_end)) { return 0; } } -- 2.46.2