forked from templexxx/reedsolomon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmul.go
30 lines (24 loc) · 720 Bytes
/
mul.go
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
// Copyright (c) 2017 Temple3x ([email protected])
//
// Use of this source code is governed by the MIT License
// that can be found in the LICENSE file.
package reedsolomon
// Coefficient multiply by vector(d) in basic way (byte by byte search multiply table).
// Then write result(p).
func mulVectBase(c byte, d, p []byte) {
t := mulTbl[c][:256]
for i := 0; i < len(d); i++ {
p[i] = t[d[i]]
}
}
// Coefficient multiply by vector(d) in basic method (byte by byte search multiply table).
// Then update result(p) by XOR old result(p).
func mulVectXORBase(c byte, d, p []byte) {
t := mulTbl[c][:256]
for i := 0; i < len(d); i++ {
p[i] ^= t[d[i]]
}
}
func gfmul(a, b uint8) uint8 {
return mulTbl[a][b]
}