9
9
#define ROWS M_MAX
10
10
#define COLS K_MAX
11
11
12
- static inline int min (int a , int b )
12
+ static inline uint64_t min (const uint64_t a , const uint64_t b )
13
13
{
14
14
if (a <= b )
15
15
return a ;
16
16
else
17
17
return b ;
18
18
}
19
19
20
- void gen_sub_matrix (unsigned char * out_matrix , int dim , unsigned char * in_matrix , int rows ,
21
- int cols , uint64_t row_indicator , uint64_t col_indicator )
20
+ void gen_sub_matrix (unsigned char * out_matrix , const uint64_t dim , unsigned char * in_matrix ,
21
+ const uint64_t rows , const uint64_t cols , const uint64_t row_indicator ,
22
+ const uint64_t col_indicator )
22
23
{
23
- int i , j , r , s ;
24
+ uint64_t i , j , r , s ;
24
25
25
26
for (i = 0 , r = 0 ; i < rows ; i ++ ) {
26
27
if (!(row_indicator & ((uint64_t ) 1 << i )))
@@ -51,23 +52,23 @@ uint64_t next_subset(uint64_t * subset, uint64_t element_count, uint64_t subsize
51
52
return 0 ;
52
53
}
53
54
54
- int are_submatrices_singular (unsigned char * vmatrix , int rows , int cols )
55
+ int are_submatrices_singular (unsigned char * vmatrix , const uint64_t rows , const uint64_t cols )
55
56
{
56
57
unsigned char matrix [COLS * COLS ];
57
58
unsigned char invert_matrix [COLS * COLS ];
58
- uint64_t row_indicator , col_indicator , subset_init , subsize ;
59
+ uint64_t subsize ;
59
60
60
61
/* Check all square subsize x subsize submatrices of the rows x cols
61
62
* vmatrix for singularity*/
62
63
for (subsize = 1 ; subsize <= min (rows , cols ); subsize ++ ) {
63
- subset_init = (1 << subsize ) - 1 ;
64
- col_indicator = subset_init ;
64
+ const uint64_t subset_init = (1ULL << subsize ) - 1ULL ;
65
+ uint64_t col_indicator = subset_init ;
65
66
do {
66
- row_indicator = subset_init ;
67
+ uint64_t row_indicator = subset_init ;
67
68
do {
68
69
gen_sub_matrix (matrix , subsize , vmatrix , rows ,
69
70
cols , row_indicator , col_indicator );
70
- if (gf_invert_matrix (matrix , invert_matrix , subsize ))
71
+ if (gf_invert_matrix (matrix , invert_matrix , ( int ) subsize ))
71
72
return 1 ;
72
73
73
74
} while (next_subset (& row_indicator , rows , subsize ) == 0 );
@@ -80,7 +81,7 @@ int are_submatrices_singular(unsigned char *vmatrix, int rows, int cols)
80
81
int main (int argc , char * * argv )
81
82
{
82
83
unsigned char vmatrix [(ROWS + COLS ) * COLS ];
83
- int rows , cols ;
84
+ uint64_t rows , cols ;
84
85
85
86
if (K_MAX > MAX_CHECK ) {
86
87
printf ("K_MAX too large for this test\n" );
@@ -108,7 +109,7 @@ int main(int argc, char **argv)
108
109
break ;
109
110
110
111
}
111
- printf (" k = %2d , m <= %2d \n" , cols , rows + cols - 1 );
112
+ printf (" k = %2u , m <= %2u \n" , ( unsigned ) cols , ( unsigned )( rows + cols - 1 ) );
112
113
113
114
}
114
115
return 0 ;
0 commit comments