Add InputOutputByteExpCodingLoop class.

This commit is contained in:
2019-02-11 01:41:55 +00:00
parent dd58126f37
commit b237e0a230
2 changed files with 47 additions and 0 deletions

View File

@@ -47,6 +47,7 @@
<Compile Include="ICodingLoop.cs" />
<Compile Include="InputByteOutputExpCodingLoop.cs" />
<Compile Include="InputByteOutputTableCodingLoop.cs" />
<Compile Include="InputOutputByteExpCodingLoop.cs" />
<Compile Include="Matrix.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

View File

@@ -0,0 +1,46 @@
/**
* One specific ordering/nesting of the coding loops.
*
* Copyright 2015, Backblaze, Inc. All rights reserved.
* Copyright © 2019 Natalia Portillo
*/
namespace Claunia.ReedSolomon
{
public class InputOutputByteExpCodingLoop : 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 iOutput = 0; iOutput < outputCount; iOutput++)
{
byte[] outputShard = outputs[iOutput];
byte[] matrixRow = matrixRows[iOutput];
byte matrixByte = matrixRow[iInput];
for(int iByte = offset; iByte < offset + byteCount; iByte++)
outputShard[iByte] = Galois.Multiply(matrixByte, inputShard[iByte]);
}
}
for(int iInput = 1; iInput < inputCount; iInput++)
{
byte[] inputShard = inputs[iInput];
for(int iOutput = 0; iOutput < outputCount; iOutput++)
{
byte[] outputShard = outputs[iOutput];
byte[] matrixRow = matrixRows[iOutput];
byte matrixByte = matrixRow[iInput];
for(int iByte = offset; iByte < offset + byteCount; iByte++)
outputShard[iByte] ^= Galois.Multiply(matrixByte, inputShard[iByte]);
}
}
}
}
}