Git Product home page Git Product logo

finite-field's Introduction

finite field in JavaScript

A finite field is a finite set on which the four operations multiplication, addition, subtraction and division (excluding division by zero) are defined, satisfying the rules of arithmetic known as the field axioms. The simplest examples of finite fields are the fields of prime order: for each prime number p, the field GF(p) (also denoted Z/pZ, {\displaystyle \mathbb {F} _{p}} \mathbb {F} _{p}, or Fp) of order (that is, size) p may be constructed as the integers modulo p.

The elements of such a field may be represented by integers in the range 0, ..., p โˆ’ 1. The sum, the difference and the product are computed by taking the remainder by p of the integer result. The multiplicative inverse of an element may be computed by using the extended Euclidean algorithm (see Extended Euclidean algorithm ยง Modular integers).

see: https://en.wikipedia.org/wiki/Finite_field

The 4 operations give some interesting results...

This is a work in progress:

To get a local copy of the current code, clone it using git:

$ git clone git://github.com/jeffallen6767/finite-field.git
$ cd finite-field

If everything worked out, install all dependencies:

$ npm install

Run the tests:

C:\Users\Malachi\workspace\finite-field>npm test

> [email protected] test C:\Users\Malachi\workspace\finite-field
> node test.js

Test 1 add x + y mod p for all k in finite field order: 31 = [0, 1, ...30]
     0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
   ---------------------------------------------------------------------------------------------
 0|  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
 1|  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30  0
 2|  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30  0  1
 3|  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30  0  1  2
 4|  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30  0  1  2  3
 5|  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30  0  1  2  3  4
 6|  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30  0  1  2  3  4  5
 7|  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30  0  1  2  3  4  5  6
 8|  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30  0  1  2  3  4  5  6  7
 9|  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30  0  1  2  3  4  5  6  7  8
10| 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30  0  1  2  3  4  5  6  7  8  9
11| 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30  0  1  2  3  4  5  6  7  8  9 10
12| 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30  0  1  2  3  4  5  6  7  8  9 10 11
13| 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30  0  1  2  3  4  5  6  7  8  9 10 11 12
14| 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30  0  1  2  3  4  5  6  7  8  9 10 11 12 13
15| 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14
16| 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
17| 17 18 19 20 21 22 23 24 25 26 27 28 29 30  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16
18| 18 19 20 21 22 23 24 25 26 27 28 29 30  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17
19| 19 20 21 22 23 24 25 26 27 28 29 30  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18
20| 20 21 22 23 24 25 26 27 28 29 30  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19
21| 21 22 23 24 25 26 27 28 29 30  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
22| 22 23 24 25 26 27 28 29 30  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21
23| 23 24 25 26 27 28 29 30  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22
24| 24 25 26 27 28 29 30  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
25| 25 26 27 28 29 30  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
26| 26 27 28 29 30  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
27| 27 28 29 30  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
28| 28 29 30  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
29| 29 30  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
30| 30  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
test number of rows
   PASS! Time: 47 Milliseconds 31 === 31
test number of columns
   PASS! Time: 47 Milliseconds 31 === 31
test values in row 2
   PASS! Time: 47 Milliseconds 17,18,19,20,21,22,23,24,25,26,27,28,29,30,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 === 17,18,19,20,21,22,23,24,25,26,27,28,29,30,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
test number of entries in getRow(2)
   PASS! Time: 47 Milliseconds 31 === 31
test values of entries in getRow(2)
   PASS! Time: 47 Milliseconds 17,18,19,20,21,22,23,24,25,26,27,28,29,30,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 === 17,18,19,20,21,22,23,24,25,26,27,28,29,30,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
test value of 17 + 27 % 31 using getEntry
   PASS! Time: 47 Milliseconds 13 === 13

Test 2 subtract x - y mod p for all k in finite field order: 31 = [0, 1, ...30]
     0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
   ---------------------------------------------------------------------------------------------
 0|  0 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1
 1|  1  0 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10  9  8  7  6  5  4  3  2
 2|  2  1  0 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10  9  8  7  6  5  4  3
 3|  3  2  1  0 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10  9  8  7  6  5  4
 4|  4  3  2  1  0 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10  9  8  7  6  5
 5|  5  4  3  2  1  0 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10  9  8  7  6
 6|  6  5  4  3  2  1  0 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10  9  8  7
 7|  7  6  5  4  3  2  1  0 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10  9  8
 8|  8  7  6  5  4  3  2  1  0 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10  9
 9|  9  8  7  6  5  4  3  2  1  0 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10
10| 10  9  8  7  6  5  4  3  2  1  0 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11
11| 11 10  9  8  7  6  5  4  3  2  1  0 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12
12| 12 11 10  9  8  7  6  5  4  3  2  1  0 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13
13| 13 12 11 10  9  8  7  6  5  4  3  2  1  0 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14
14| 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15
15| 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
16| 16 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0 30 29 28 27 26 25 24 23 22 21 20 19 18 17
17| 17 16 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0 30 29 28 27 26 25 24 23 22 21 20 19 18
18| 18 17 16 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0 30 29 28 27 26 25 24 23 22 21 20 19
19| 19 18 17 16 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0 30 29 28 27 26 25 24 23 22 21 20
20| 20 19 18 17 16 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0 30 29 28 27 26 25 24 23 22 21
21| 21 20 19 18 17 16 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0 30 29 28 27 26 25 24 23 22
22| 22 21 20 19 18 17 16 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0 30 29 28 27 26 25 24 23
23| 23 22 21 20 19 18 17 16 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0 30 29 28 27 26 25 24
24| 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0 30 29 28 27 26 25
25| 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0 30 29 28 27 26
26| 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0 30 29 28 27
27| 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0 30 29 28
28| 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0 30 29
29| 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0 30
30| 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0
test number of rows
   PASS! Time: 16 Milliseconds 31 === 31
test number of columns
   PASS! Time: 16 Milliseconds 31 === 31
test values in row 2
   PASS! Time: 16 Milliseconds 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,30,29,28,27,26,25,24,23,22,21,20,19,18 === 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,30,29,28,27,26,25,24,23,22,21,20,19,18
test number of entries in getRow(2)
   PASS! Time: 16 Milliseconds 31 === 31
test values of entries in getRow(2)
   PASS! Time: 16 Milliseconds 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,30,29,28,27,26,25,24,23,22,21,20,19,18 === 17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0,30,29,28,27,26,25,24,23,22,21,20,19,18
test value of 17 - 27 % 31 using getEntry
   PASS! Time: 16 Milliseconds 21 === 21

Test 3 multiply x * y mod p for all k in finite field order: 31 = [0, 1, ...30]
     0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
   ---------------------------------------------------------------------------------------------
 0|  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
 1|  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
 2|  0  2  4  6  8 10 12 14 16 18 20 22 24 26 28 30  1  3  5  7  9 11 13 15 17 19 21 23 25 27 29
 3|  0  3  6  9 12 15 18 21 24 27 30  2  5  8 11 14 17 20 23 26 29  1  4  7 10 13 16 19 22 25 28
 4|  0  4  8 12 16 20 24 28  1  5  9 13 17 21 25 29  2  6 10 14 18 22 26 30  3  7 11 15 19 23 27
 5|  0  5 10 15 20 25 30  4  9 14 19 24 29  3  8 13 18 23 28  2  7 12 17 22 27  1  6 11 16 21 26
 6|  0  6 12 18 24 30  5 11 17 23 29  4 10 16 22 28  3  9 15 21 27  2  8 14 20 26  1  7 13 19 25
 7|  0  7 14 21 28  4 11 18 25  1  8 15 22 29  5 12 19 26  2  9 16 23 30  6 13 20 27  3 10 17 24
 8|  0  8 16 24  1  9 17 25  2 10 18 26  3 11 19 27  4 12 20 28  5 13 21 29  6 14 22 30  7 15 23
 9|  0  9 18 27  5 14 23  1 10 19 28  6 15 24  2 11 20 29  7 16 25  3 12 21 30  8 17 26  4 13 22
10|  0 10 20 30  9 19 29  8 18 28  7 17 27  6 16 26  5 15 25  4 14 24  3 13 23  2 12 22  1 11 21
11|  0 11 22  2 13 24  4 15 26  6 17 28  8 19 30 10 21  1 12 23  3 14 25  5 16 27  7 18 29  9 20
12|  0 12 24  5 17 29 10 22  3 15 27  8 20  1 13 25  6 18 30 11 23  4 16 28  9 21  2 14 26  7 19
13|  0 13 26  8 21  3 16 29 11 24  6 19  1 14 27  9 22  4 17 30 12 25  7 20  2 15 28 10 23  5 18
14|  0 14 28 11 25  8 22  5 19  2 16 30 13 27 10 24  7 21  4 18  1 15 29 12 26  9 23  6 20  3 17
15|  0 15 30 14 29 13 28 12 27 11 26 10 25  9 24  8 23  7 22  6 21  5 20  4 19  3 18  2 17  1 16
16|  0 16  1 17  2 18  3 19  4 20  5 21  6 22  7 23  8 24  9 25 10 26 11 27 12 28 13 29 14 30 15
17|  0 17  3 20  6 23  9 26 12 29 15  1 18  4 21  7 24 10 27 13 30 16  2 19  5 22  8 25 11 28 14
18|  0 18  5 23 10 28 15  2 20  7 25 12 30 17  4 22  9 27 14  1 19  6 24 11 29 16  3 21  8 26 13
19|  0 19  7 26 14  2 21  9 28 16  4 23 11 30 18  6 25 13  1 20  8 27 15  3 22 10 29 17  5 24 12
20|  0 20  9 29 18  7 27 16  5 25 14  3 23 12  1 21 10 30 19  8 28 17  6 26 15  4 24 13  2 22 11
21|  0 21 11  1 22 12  2 23 13  3 24 14  4 25 15  5 26 16  6 27 17  7 28 18  8 29 19  9 30 20 10
22|  0 22 13  4 26 17  8 30 21 12  3 25 16  7 29 20 11  2 24 15  6 28 19 10  1 23 14  5 27 18  9
23|  0 23 15  7 30 22 14  6 29 21 13  5 28 20 12  4 27 19 11  3 26 18 10  2 25 17  9  1 24 16  8
24|  0 24 17 10  3 27 20 13  6 30 23 16  9  2 26 19 12  5 29 22 15  8  1 25 18 11  4 28 21 14  7
25|  0 25 19 13  7  1 26 20 14  8  2 27 21 15  9  3 28 22 16 10  4 29 23 17 11  5 30 24 18 12  6
26|  0 26 21 16 11  6  1 27 22 17 12  7  2 28 23 18 13  8  3 29 24 19 14  9  4 30 25 20 15 10  5
27|  0 27 23 19 15 11  7  3 30 26 22 18 14 10  6  2 29 25 21 17 13  9  5  1 28 24 20 16 12  8  4
28|  0 28 25 22 19 16 13 10  7  4  1 29 26 23 20 17 14 11  8  5  2 30 27 24 21 18 15 12  9  6  3
29|  0 29 27 25 23 21 19 17 15 13 11  9  7  5  3  1 30 28 26 24 22 20 18 16 14 12 10  8  6  4  2
30|  0 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1
test number of rows
   PASS! Time: 31 Milliseconds 31 === 31
test number of columns
   PASS! Time: 31 Milliseconds 31 === 31
test values in row 2
   PASS! Time: 31 Milliseconds 0,17,3,20,6,23,9,26,12,29,15,1,18,4,21,7,24,10,27,13,30,16,2,19,5,22,8,25,11,28,14 === 0,17,3,20,6,23,9,26,12,29,15,1,18,4,21,7,24,10,27,13,30,16,2,19,5,22,8,25,11,28,14
test number of entries in getRow(2)
   PASS! Time: 31 Milliseconds 31 === 31
test values of entries in getRow(2)
   PASS! Time: 31 Milliseconds 0,17,3,20,6,23,9,26,12,29,15,1,18,4,21,7,24,10,27,13,30,16,2,19,5,22,8,25,11,28,14 === 0,17,3,20,6,23,9,26,12,29,15,1,18,4,21,7,24,10,27,13,30,16,2,19,5,22,8,25,11,28,14
test value of 17 * 27 % 31 using getEntry
   PASS! Time: 31 Milliseconds 25 === 25

Test 4 divide x / y mod p for all k in finite field order: 31 = [0, 1, ...30]
     0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
   ---------------------------------------------------------------------------------------------
 0|  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
 1|  0  1 16 21  8 25 26  9  4  7 28 17 13 12 20 29  2 11 19 18 14  3 24 27 22  5  6 23 10 15 30
 2|  0  2  1 11 16 19 21 18  8 14 25  3 26 24  9 27  4 22  7  5 28  6 17 23 13 10 12 15 20 30 29
 3|  0  3 17  1 24 13 16 27 12 21 22 20  8  5 29 25  6  2 26 23 11  9 10 19  4 15 18  7 30 14 28
 4|  0  4  2 22  1  7 11  5 16 28 19  6 21 17 18 23  8 13 14 10 25 12  3 15 26 20 24 30  9 29 27
 5|  0  5 18 12  9  1  6 14 20  4 16 23  3 29  7 21 10 24  2 28  8 15 27 11 17 25 30 22 19 13 26
 6|  0  6  3  2 17 26  1 23 24 11 13  9 16 10 27 19 12  4 21 15 22 18 20  7  8 30  5 14 29 28 25
 7|  0  7 19 23 25 20 27  1 28 18 10 26 29 22 16 17 14 15  9  2  5 21 13  3 30  4 11  6  8 12 24
 8|  0  8  4 13  2 14 22 10  1 25  7 12 11  3  5 15 16 26 28 20 19 24  6 30 21  9 17 29 18 27 23
 9|  0  9 20  3 10  8 17 19  5  1  4 29 24 15 25 13 18  6 16  7  2 27 30 26 12 14 23 21 28 11 22
10|  0 10  5 24 18  2 12 28  9  8  1 15  6 27 14 11 20 17  4 25 16 30 23 22  3 19 29 13  7 26 21
11|  0 11 21 14 26 27  7  6 13 15 29  1 19  8  3  9 22 28 23 12 30  2 16 18 25 24  4  5 17 10 20
12|  0 12  6  4  3 21  2 15 17 22 26 18  1 20 23  7 24  8 11 30 13  5  9 14 16 29 10 28 27 25 19
13|  0 13 22 25 11 15 28 24 21 29 23  4 14  1 12  5 26 19 30 17 27  8  2 10  7  3 16 20  6  9 18
14|  0 14  7 15 19  9 23  2 25  5 20 21 27 13  1  3 28 30 18  4 10 11 26  6 29  8 22 12 16 24 17
15|  0 15 23  5 27  3 18 11 29 12 17  7  9 25 21  1 30 10  6 22 24 14 19  2 20 13 28  4 26  8 16
16|  0 16  8 26  4 28 13 20  2 19 14 24 22  6 10 30  1 21 25  9  7 17 12 29 11 18  3 27  5 23 15
17|  0 17 24 16 12 22  8 29  6 26 11 10  4 18 30 28  3  1 13 27 21 20  5 25  2 23  9 19 15  7 14
18|  0 18  9  6 20 16  3  7 10  2  8 27 17 30 19 26  5 12  1 14  4 23 29 21 24 28 15 11 25 22 13
19|  0 19 25 27 28 10 29 16 14  9  5 13 30 11  8 24  7 23 20  1 18 26 22 17 15  2 21  3  4  6 12
20|  0 20 10 17  5  4 24 25 18 16  2 30 12 23 28 22  9  3  8 19  1 29 15 13  6  7 27 26 14 21 11
21|  0 21 26  7 13 29 19  3 22 23 30 16 25  4 17 20 11 14 27  6 15  1  8  9 28 12  2 18 24  5 10
22|  0 22 11 28 21 23 14 12 26 30 27  2  7 16  6 18 13 25 15 24 29  4  1  5 19 17  8 10  3 20  9
23|  0 23 27 18 29 17  9 21 30  6 24 19 20 28 26 16 15  5  3 11 12  7 25  1 10 22 14  2 13  4  8
24|  0 24 12  8  6 11  4 30  3 13 21  5  2  9 15 14 17 16 22 29 26 10 18 28  1 27 20 25 23 19  7
25|  0 25 28 29 14  5 30  8  7 20 18 22 15 21  4 12 19 27 10 16  9 13 11 24 23  1 26 17  2  3  6
26|  0 26 13 19 22 30 25 17 11 27 15  8 28  2 24 10 21  7 29  3 23 16  4 20 14  6  1  9 12 18  5
27|  0 27 29  9 30 24 20 26 15  3 12 25 10 14 13  8 23 18 17 21  6 19 28 16  5 11  7  1 22  2  4
28|  0 28 14 30  7 18 15  4 19 10  9 11 23 26  2  6 25 29  5  8 20 22 21 12 27 16 13 24  1 17  3
29|  0 29 30 20 15 12 10 13 23 17  6 28  5  7 22  4 27  9 24 26  3 25 14  8 18 21 19 16 11  1  2
30|  0 30 15 10 23  6  5 22 27 24  3 14 18 19 11  2 29 20 12 13 17 28  7  4  9 26 25  8 21 16  1
test number of rows
   PASS! Time: 47 Milliseconds 31 === 31
test number of columns
   PASS! Time: 47 Milliseconds 31 === 31
test values in row 2
   PASS! Time: 47 Milliseconds 0,17,24,16,12,22,8,29,6,26,11,10,4,18,30,28,3,1,13,27,21,20,5,25,2,23,9,19,15,7,14 === 0,17,24,16,12,22,8,29,6,26,11,10,4,18,30,28,3,1,13,27,21,20,5,25,2,23,9,19,15,7,14
test number of entries in getRow(2)
   PASS! Time: 47 Milliseconds 31 === 31
test values of entries in getRow(2)
   PASS! Time: 47 Milliseconds 0,17,24,16,12,22,8,29,6,26,11,10,4,18,30,28,3,1,13,27,21,20,5,25,2,23,9,19,15,7,14 === 0,17,24,16,12,22,8,29,6,26,11,10,4,18,30,28,3,1,13,27,21,20,5,25,2,23,9,19,15,7,14
test value of 17 / 27 % 31 using getEntry
   PASS! Time: 47 Milliseconds 19 === 19

Test 5 pow x ^ y mod p for all k in finite field order: 31 = [0, 1, ...30]
     0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
   ---------------------------------------------------------------------------------------------
 0|  1  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
 1|  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1
 2|  1  2  4  8 16  1  2  4  8 16  1  2  4  8 16  1  2  4  8 16  1  2  4  8 16  1  2  4  8 16  1
 3|  1  3  9 27 19 26 16 17 20 29 25 13  8 24 10 30 28 22  4 12  5 15 14 11  2  6 18 23  7 21  1
 4|  1  4 16  2  8  1  4 16  2  8  1  4 16  2  8  1  4 16  2  8  1  4 16  2  8  1  4 16  2  8  1
 5|  1  5 25  1  5 25  1  5 25  1  5 25  1  5 25  1  5 25  1  5 25  1  5 25  1  5 25  1  5 25  1
 6|  1  6  5 30 25 26  1  6  5 30 25 26  1  6  5 30 25 26  1  6  5 30 25 26  1  6  5 30 25 26  1
 7|  1  7 18  2 14  5  4 28 10  8 25 20 16 19  9  1  7 18  2 14  5  4 28 10  8 25 20 16 19  9  1
 8|  1  8  2 16  4  1  8  2 16  4  1  8  2 16  4  1  8  2 16  4  1  8  2 16  4  1  8  2 16  4  1
 9|  1  9 19 16 20 25  8 10 28  4  5 14  2 18  7  1  9 19 16 20 25  8 10 28  4  5 14  2 18  7  1
10|  1 10  7  8 18 25  2 20 14 16  5 19  4  9 28  1 10  7  8 18 25  2 20 14 16  5 19  4  9 28  1
11|  1 11 28 29  9  6  4 13 19 23  5 24 16 21 14 30 20  3  2 22 25 27 18 12  8 26  7 15 10 17  1
12|  1 12 20 23 28 26  2 24  9 15 25 21  4 17 18 30 19 11  8  3  5 29  7 22 16  6 10 27 14 13  1
13|  1 13 14 27 10  6 16 22  7 29  5  3  8 11 19 30 18 17  4 21 25 15  9 24  2 26 28 23 20 12  1
14|  1 14 10 16  7  5  8 19 18  4 25  9  2 28 20  1 14 10 16  7  5  8 19 18  4 25  9  2 28 20  1
15|  1 15  8 27  2 30 16 23  4 29  1 15  8 27  2 30 16 23  4 29  1 15  8 27  2 30 16 23  4 29  1
16|  1 16  8  4  2  1 16  8  4  2  1 16  8  4  2  1 16  8  4  2  1 16  8  4  2  1 16  8  4  2  1
17|  1 17 10 15  7 26  8 12 18 27 25 22  2  3 20 30 14 21 16 24  5 23 19 13  4  6  9 29 28 11  1
18|  1 18 14  4 10 25 16  9  7  2  5 28  8 20 19  1 18 14  4 10 25 16  9  7  2  5 28  8 20 19  1
19|  1 19 20  8 28  5  2  7  9 16 25 10  4 14 18  1 19 20  8 28  5  2  7  9 16 25 10  4 14 18  1
20|  1 20 28  2  9 25  4 18 19  8  5  7 16 10 14  1 20 28  2  9 25  4 18 19  8  5  7 16 10 14  1
21|  1 21  7 23 18  6  2 11 14 15  5 12  4 22 28 30 10 24  8 13 25 29 20 17 16 26 19 27  9  3  1
22|  1 22 19 15 20  6  8 21 28 27  5 17  2 13  7 30  9 12 16 11 25 23 10  3  4 26 14 29 18 24  1
23|  1 23  2 15  4 30  8 29 16 27  1 23  2 15  4 30  8 29 16 27  1 23  2 15  4 30  8 29 16 27  1
24|  1 24 18 29 14 26  4  3 10 23 25 11 16 12  9 30  7 13  2 17  5 27 28 21  8  6 20 15 19 22  1
25|  1 25  5  1 25  5  1 25  5  1 25  5  1 25  5  1 25  5  1 25  5  1 25  5  1 25  5  1 25  5  1
26|  1 26 25 30  5  6  1 26 25 30  5  6  1 26 25 30  5  6  1 26 25 30  5  6  1 26 25 30  5  6  1
27|  1 27 16 29  8 30  4 15  2 23  1 27 16 29  8 30  4 15  2 23  1 27 16 29  8 30  4 15  2 23  1
28|  1 28  9  4 19  5 16 14 20  2 25 18  8  7 10  1 28  9  4 19  5 16 14 20  2 25 18  8  7 10  1
29|  1 29  4 23 16 30  2 27  8 15  1 29  4 23 16 30  2 27  8 15  1 29  4 23 16 30  2 27  8 15  1
30|  1 30  1 30  1 30  1 30  1 30  1 30  1 30  1 30  1 30  1 30  1 30  1 30  1 30  1 30  1 30  1
test number of rows
   PASS! Time: 78 Milliseconds 31 === 31
test number of columns
   PASS! Time: 78 Milliseconds 31 === 31
test values in row 2
   PASS! Time: 78 Milliseconds 1,17,10,15,7,26,8,12,18,27,25,22,2,3,20,30,14,21,16,24,5,23,19,13,4,6,9,29,28,11,1 === 1,17,10,15,7,26,8,12,18,27,25,22,2,3,20,30,14,21,16,24,5,23,19,13,4,6,9,29,28,11,1
test number of entries in getRow(2)
   PASS! Time: 78 Milliseconds 31 === 31
test values of entries in getRow(2)
   PASS! Time: 78 Milliseconds 1,17,10,15,7,26,8,12,18,27,25,22,2,3,20,30,14,21,16,24,5,23,19,13,4,6,9,29,28,11,1 === 1,17,10,15,7,26,8,12,18,27,25,22,2,3,20,30,14,21,16,24,5,23,19,13,4,6,9,29,28,11,1
test value of 17 ^ 27 % 31 using getEntry
   PASS! Time: 78 Milliseconds 29 === 29

Test 6 compute 24 * 19 % 31 in finite field order: 31 = [0, 1, ...30]
test value of 24 * 19 % 31 using getEntry
   PASS! Time: 0 Milliseconds 22 === 22

Test 7 compute 17 ^ 3 % 31 in finite field order: 31 = [0, 1, ...30]
test value of 17 ^ 3 % 31 using getEntry
   PASS! Time: 0 Milliseconds 15 === 15

Test 8 compute 5 ^ 5 * 18 % 31 in finite field order: 31 = [0, 1, ...30]
test value of 5 ^ 5 * 18 % 31 using getEntry
   PASS! Time: 0 Milliseconds 16 === 16

Test 9 k^30 % 31 for all k ( except zero ) in in finite field order: 31 = [0, 1, ...30]
test values in row 30
   PASS! Time: 0 Milliseconds 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 === 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1

results:
    34 tests
    34 pass
    0 fail
    Time: 329 Milliseconds


Copyright (c) 2017 Jeffrey David Allen

Licensed under MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

finite-field's People

Contributors

jeffallen6767 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.