internal void BeginIteration([NotNull] CalculationState state) { var trans = state.Transform; state.Input = trans.Matrix.Multiply(state.Input).Copy(c: state.Input.C * trans.CmapCorners[0] + trans.CmapCorners[1]); state.Output = new Vertex(0, 0, state.Input.C); }
private void NextTransform(CalculationState calculationState) { calculationState.TransformIndex = _selector.NextIndex(this); calculationState.Transform = _transforms[calculationState.TransformIndex]; Statistics.SetTransform(calculationState.TransformIndex); }
protected override IResult Initialize() { using (_context.PerformanceCounter.EnterMeasureScope("Thread overhead")) { _state = _context.CreateThreadState(); } return(Result.Success); }
internal void EndIteration([NotNull] CalculationState state) { NextTransform(state); Statistics.Update(state); state.Input = state.Output.ResetNaNs(); state.IterationNumber++; PerformanceCounter.Count(); }
internal CalculationState CreateThreadState() { var calculationState = new CalculationState(this); calculationState.Input = new Vertex( Random() * 2 - 1, Random() * 2 - 1, Random() * 2 - 1); NextTransform(calculationState); return(calculationState); }
internal void Update([NotNull] CalculationState state) { if (!IsEnabled) { return; } if (double.IsNaN(state.Output.X) || double.IsNaN(state.Output.Y)) { return; } lock (_stLock) { _min = new Vertex(double.IsNaN(_min.X) ? state.Output.X : Math.Min(state.Output.X, _min.X), double.IsNaN(_min.Y) ? state.Output.Y : Math.Min(state.Output.Y, _min.Y)); _max = new Vertex(double.IsNaN(_max.X) ? state.Output.X : Math.Max(state.Output.X, _max.X), double.IsNaN(_max.Y) ? state.Output.Y : Math.Max(state.Output.Y, _max.Y)); } }
internal void Plot([NotNull] CalculationState state) { var pixelX = (int)((1 + state.Output.X) * _backBuffer.Width * 0.5f); var pixelY = (int)((2 - (1 + state.Output.Y)) * _backBuffer.Height * 0.5f); if (pixelX >= 0 && pixelY >= 0 && pixelX < _backBuffer.Width && pixelY < _backBuffer.Height) { var caddr = (int)Math.Max(0, Math.Min(state.Output.C * (_colors.Length - 1), _colors.Length - 1)); var addr = _backBuffer.Width * pixelY + pixelX; var col = _colors[caddr]; lock (_histogramLock) { var p = Histogram[addr]; p.Red += col.R; p.Green += col.G; p.Blue += col.B; p.Count++; Histogram[addr] = p; } } }
public abstract void Calculate([NotNull] CalculationState calculationState);
protected override void Cleanup(bool wasCancelled) { _state = null; }