Add InputByteOutputExpCodingLoop class.

This commit is contained in:
2019-02-11 01:41:10 +00:00
parent 43a06cb6dd
commit 537cb0c27e
2 changed files with 51 additions and 0 deletions

View File

@@ -45,6 +45,7 @@
<Compile Include="CodingLoopBase.cs" />
<Compile Include="Galois.cs" />
<Compile Include="ICodingLoop.cs" />
<Compile Include="InputByteOutputExpCodingLoop.cs" />
<Compile Include="Matrix.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

View File

@@ -0,0 +1,50 @@
/**
* One specific ordering/nesting of the coding loops.
*
* Copyright 2015, Backblaze, Inc. All rights reserved.
* Copyright © 2019 Natalia Portillo
*/
namespace Claunia.ReedSolomon
{
public class InputByteOutputExpCodingLoop : CodingLoopBase
{
public override void CodeSomeShards(byte[][] matrixRows, byte[][] inputs, int inputCount, byte[][] outputs,
int outputCount, int offset, int byteCount)
{
{
int iInput = 0;
byte[] inputShard = inputs[iInput];
for(int iByte = offset; iByte < offset + byteCount; iByte++)
{
byte inputByte = inputShard[iByte];
for(int iOutput = 0; iOutput < outputCount; iOutput++)
{
byte[] outputShard = outputs[iOutput];
byte[] matrixRow = matrixRows[iOutput];
outputShard[iByte] = Galois.Multiply(matrixRow[iInput], inputByte);
}
}
}
for(int iInput = 1; iInput < inputCount; iInput++)
{
byte[] inputShard = inputs[iInput];
for(int iByte = offset; iByte < offset + byteCount; iByte++)
{
byte inputByte = inputShard[iByte];
for(int iOutput = 0; iOutput < outputCount; iOutput++)
{
byte[] outputShard = outputs[iOutput];
byte[] matrixRow = matrixRows[iOutput];
outputShard[iByte] ^= Galois.Multiply(matrixRow[iInput], inputByte);
}
}
}
}
}
}