diff --git a/Claunia.ReedSolomon/Claunia.ReedSolomon.csproj b/Claunia.ReedSolomon/Claunia.ReedSolomon.csproj index cd41250..eddcc6b 100644 --- a/Claunia.ReedSolomon/Claunia.ReedSolomon.csproj +++ b/Claunia.ReedSolomon/Claunia.ReedSolomon.csproj @@ -50,6 +50,7 @@ + diff --git a/Claunia.ReedSolomon/OutputByteInputExpCodingLoop.cs b/Claunia.ReedSolomon/OutputByteInputExpCodingLoop.cs new file mode 100644 index 0000000..b629f20 --- /dev/null +++ b/Claunia.ReedSolomon/OutputByteInputExpCodingLoop.cs @@ -0,0 +1,35 @@ +/** + * One specific ordering/nesting of the coding loops. + * + * Copyright 2015, Backblaze, Inc. All rights reserved. + * Copyright © 2019 Natalia Portillo + */ + +namespace Claunia.ReedSolomon +{ + public class OutputByteInputExpCodingLoop : CodingLoopBase + { + public override void CodeSomeShards(byte[][] matrixRows, byte[][] inputs, int inputCount, byte[][] outputs, + int outputCount, int offset, int byteCount) + { + for(int iOutput = 0; iOutput < outputCount; iOutput++) + { + byte[] outputShard = outputs[iOutput]; + byte[] matrixRow = matrixRows[iOutput]; + + for(int iByte = offset; iByte < offset + byteCount; iByte++) + { + int value = 0; + + for(int iInput = 0; iInput < inputCount; iInput++) + { + byte[] inputShard = inputs[iInput]; + value ^= Galois.Multiply(matrixRow[iInput], inputShard[iByte]); + } + + outputShard[iByte] = (byte)value; + } + } + } + } +} \ No newline at end of file