Debian Codegraph @

gf16_test.go

raw symbols SCIP
1 package reedsolomonscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/
2
3 import "testingscip-go gomod github.com/golang/go/src go1.24 testing/"
4
5 var gf16scip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/gf16. LowLevelscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/LowLevel#
6
7 func TestGF16MulZeroscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/TestGF16MulZero().(t *testingscip-go gomod github.com/golang/go/src go1.24 testing/.Tscip-go gomod github.com/golang/go/src go1.24 testing/T#) {
8 // Anything multiplied by zero is zero.
9 for _, v := range []uint16{0, 1, 2, 100, 65535} {
10 if got := gf16scip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/gf16..GF16Mulscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/LowLevel#GF16Mul().(v, 0); got != 0 {
11 t.Errorfscip-go gomod github.com/golang/go/src go1.24 testing/common#Errorf().("GF16Mul(%d, 0) = %d, want 0", v, got)
12 }
13 if got := gf16scip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/gf16..GF16Mulscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/LowLevel#GF16Mul().(0, v); got != 0 {
14 t.Errorfscip-go gomod github.com/golang/go/src go1.24 testing/common#Errorf().("GF16Mul(0, %d) = %d, want 0", v, got)
15 }
16 }
17 }
18
19 func TestGF16MulOnescip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/TestGF16MulOne().(t *testingscip-go gomod github.com/golang/go/src go1.24 testing/.Tscip-go gomod github.com/golang/go/src go1.24 testing/T#) {
20 initConstantsscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/initConstants().()
21 // Multiplying by 1 (the multiplicative identity) is a no-op.
22 // The identity element in GF(2^16) is 1 (expLUT[0]).
23 one := uint16(expLUTscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/expLUT.[0])
24 for _, v := range []uint16{1, 2, 7, 255, 1000, 65535} {
25 if got := gf16scip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/gf16..GF16Mulscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/LowLevel#GF16Mul().(v, one); got != v {
26 t.Errorfscip-go gomod github.com/golang/go/src go1.24 testing/common#Errorf().("GF16Mul(%d, 1) = %d, want %d", v, got, v)
27 }
28 if got := gf16scip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/gf16..GF16Mulscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/LowLevel#GF16Mul().(one, v); got != v {
29 t.Errorfscip-go gomod github.com/golang/go/src go1.24 testing/common#Errorf().("GF16Mul(1, %d) = %d, want %d", v, got, v)
30 }
31 }
32 }
33
34 func TestGF16MulCommutativityscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/TestGF16MulCommutativity().(t *testingscip-go gomod github.com/golang/go/src go1.24 testing/.Tscip-go gomod github.com/golang/go/src go1.24 testing/T#) {
35 cases := [][2]uint16{
36 {1, 2}, {3, 5}, {255, 256}, {1000, 2000}, {65534, 65535},
37 }
38 for _, c := range cases {
39 a, b := c[0], c[1]
40 ab := gf16scip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/gf16..GF16Mulscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/LowLevel#GF16Mul().(a, b)
41 ba := gf16scip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/gf16..GF16Mulscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/LowLevel#GF16Mul().(b, a)
42 if ab != ba {
43 t.Errorfscip-go gomod github.com/golang/go/src go1.24 testing/common#Errorf().("GF16Mul(%d, %d) = %d != GF16Mul(%d, %d) = %d", a, b, ab, b, a, ba)
44 }
45 }
46 }
47
48 func TestGF16MulAssociativityscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/TestGF16MulAssociativity().(t *testingscip-go gomod github.com/golang/go/src go1.24 testing/.Tscip-go gomod github.com/golang/go/src go1.24 testing/T#) {
49 a, b, c := uint16(3), uint16(5), uint16(7)
50 // (a*b)*c == a*(b*c)
51 lhs := gf16scip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/gf16..GF16Mulscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/LowLevel#GF16Mul().(gf16scip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/gf16..GF16Mulscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/LowLevel#GF16Mul().(a, b), c)
52 rhs := gf16scip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/gf16..GF16Mulscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/LowLevel#GF16Mul().(a, gf16scip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/gf16..GF16Mulscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/LowLevel#GF16Mul().(b, c))
53 if lhs != rhs {
54 t.Errorfscip-go gomod github.com/golang/go/src go1.24 testing/common#Errorf().("associativity failed: (%d*%d)*%d=%d, %d*(%d*%d)=%d", a, b, c, lhs, a, b, c, rhs)
55 }
56 }
57
58 func TestGF16MulDistributivityscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/TestGF16MulDistributivity().(t *testingscip-go gomod github.com/golang/go/src go1.24 testing/.Tscip-go gomod github.com/golang/go/src go1.24 testing/T#) {
59 // Addition in GF(2^16) is XOR. Distributivity: a*(b^c) == a*b ^ a*c.
60 cases := [][3]uint16{
61 {3, 5, 7}, {255, 256, 1000}, {1, 2, 3}, {65534, 65535, 1},
62 }
63 for _, c := range cases {
64 a, b, cc := c[0], c[1], c[2]
65 lhs := gf16scip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/gf16..GF16Mulscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/LowLevel#GF16Mul().(a, b^cc)
66 rhs := gf16scip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/gf16..GF16Mulscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/LowLevel#GF16Mul().(a, b) ^ gf16scip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/gf16..GF16Mulscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/LowLevel#GF16Mul().(a, cc)
67 if lhs != rhs {
68 t.Errorfscip-go gomod github.com/golang/go/src go1.24 testing/common#Errorf().("distributivity failed: %d*(%d^%d)=%d, %d*%d^%d*%d=%d", a, b, cc, lhs, a, b, a, cc, rhs)
69 }
70 }
71 }
72
73 func TestGF16MulConsistentWithInternalscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/TestGF16MulConsistentWithInternal().(t *testingscip-go gomod github.com/golang/go/src go1.24 testing/.Tscip-go gomod github.com/golang/go/src go1.24 testing/T#) {
74 initConstantsscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/initConstants().()
75 // GF16Mul(a, b) should agree with the internal mulLog when b != 0.
76 cases := [][2]uint16{
77 {1, 2}, {3, 5}, {255, 256}, {1000, 2000},
78 }
79 for _, c := range cases {
80 a, b := c[0], c[1]
81 want := uint16(mulLogscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/mulLog().(ffescip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/ffe#(a), logLUTscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/logLUT.[ffescip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/ffe#(b)]))
82 got := gf16scip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/gf16..GF16Mulscip-go gomod github.com/klauspost/reedsolomon . `github.com/klauspost/reedsolomon`/LowLevel#GF16Mul().(a, b)
83 if got != want {
84 t.Errorfscip-go gomod github.com/golang/go/src go1.24 testing/common#Errorf().("GF16Mul(%d, %d) = %d, internal mulLog gives %d", a, b, got, want)
85 }
86 }
87 }