#pragma warning restore #endregion fields & pins //called when data for any output pin is requested public void Evaluate(int SpreadMax) { FInput.Sync(); FVec.Sync(); FBin.Sync(); if (FInput.IsChanged || FVec.IsChanged || FBin.IsChanged) { if (FInput.Length > 0 && FVec.Length > 0 && FBin.Length > 0) { int vecSize = Math.Max(1, FVec.GetReader().Read()); VecBinSpread <double> spread = new VecBinSpread <double>(FInput, vecSize, FBin); FOutput.Length = Math.Max(spread.ItemCount - (spread.Count * vecSize), 0); FOutBin.Length = spread.Count; FOffset.Length = spread.Count * vecSize; using (var offWriter = FOffset.GetWriter()) using (var binWriter = FOutBin.GetWriter()) using (var dataWriter = FOutput.GetWriter()) { int incr = 0; for (int b = 0; b < spread.Count; b++) { if (spread[b].Length > 0) { for (int v = 0; v < vecSize; v++) { dataWriter.Position = incr + v; double[] column = spread.GetBinColumn(b, v).ToArray(); for (int s = 0; s < column.Length - 1; s++) { dataWriter.Write(column[s + 1] - column[s], vecSize); } } incr += spread[b].Length - vecSize; binWriter.Write((spread[b].Length / vecSize) - 1, 1); offWriter.Write(spread.GetBinRow(b, 0).ToArray(), 0, vecSize); } else { binWriter.Write(0, 1); double[] zero = new double[vecSize]; offWriter.Write(zero, 0, vecSize); } } } } else { FOutput.Length = FOutBin.Length = FOffset.Length; } } }
#pragma warning restore #endregion fields & pins //called when data for any output pin is requested public void Evaluate(int SpreadMax) { FInput.Sync(); FVec.Sync(); FBin.Sync(); if (FInput.IsChanged || FVec.IsChanged || FBin.IsChanged) { if (FInput.Length > 0 && FVec.Length > 0 && FBin.Length > 0) { int vecSize = Math.Max(1, FVec.GetReader().Read()); VecBinSpread <double> spread = new VecBinSpread <double>(FInput, vecSize, FBin); FLast.Length = spread.Count * vecSize; if (FLast.Length == spread.ItemCount || spread.ItemCount == 0) { FRemainder.Length = 0; if (spread.ItemCount != 0) { FLast.AssignFrom(FInput); } else { FLast.Length = 0; } } else { FRemainder.Length = spread.ItemCount - FLast.Length; using (var rWriter = FRemainder.GetWriter()) using (var lWriter = FLast.GetWriter()) { for (int b = 0; b < spread.Count; b++) { int rLength = spread[b].Length - vecSize; rWriter.Write(spread[b], 0, rLength); lWriter.Write(spread.GetBinRow(b, rLength / vecSize).ToArray(), 0, vecSize); } } } } else { FRemainder.Length = FLast.Length = 0; } } }
#pragma warning restore #endregion fields & pins //called when data for any output pin is requested public void Evaluate(int SpreadMax) { FInput.Sync(); FVec.Sync(); FBin.Sync(); if (FInput.IsChanged || FVec.IsChanged || FBin.IsChanged || FReverse.IsChanged) { if (FVec.Length > 0) { int vecSize = Math.Max(1, FVec.GetReader().Read()); VecBinSpread <double> spread = new VecBinSpread <double>(FInput, vecSize, FBin, FReverse.SliceCount); FOutput.Length = spread.ItemCount; using (var dataWriter = FOutput.GetWriter()) { for (int b = 0; b < spread.Count; b++) { if (FReverse[b]) { for (int r = (spread[b].Length / vecSize) - 1; r >= 0; r--) { dataWriter.Write(spread.GetBinRow(b, r).ToArray(), 0, vecSize); } } else { dataWriter.Write(spread[b], 0, spread[b].Length); } } } } else { FOutput.Length = 0; } } }