public void ParallelArray2d() { var alength = 16384; var cpl = 0.00001; var randy = new ThreadSafeRandom(); var sw = new Stopwatch(); var nodeArray = new NodeArray( Enumerable.Range(0, alength) .Select(i => randy.NextDouble() * 2 - 1.0) .ToArray()); for (var k = 0; k < 3; k++) { sw.Start(); for (var s = 0; s < 40; s++) { var noise = 0.1 - 0.002 * s; for (var q = 0; q < 50; q++) { nodeArray = NodeArray.UpdateStar(nodeArray, cpl, noise, randy); nodeArray = NodeArray.UpdateStar(nodeArray, cpl, noise, randy); } // Debug.WriteLine("{0}\t{1}\t{2}", s, noise, Correlo(nodeArray.Current.ToArray())); } sw.Stop(); Debug.WriteLine("Elapsed={0}", sw.Elapsed); sw.Reset(); } }
private async void DoStart() { _cancellationTokenSource = new CancellationTokenSource(); _isRunning = true; CommandManager.InvalidateRequerySuggested(); await Task.Run(() => { _stopwatch.Start(); for (var i = 0; _isRunning; i++) { NodeArray = NodeArray.UpdateStar(NodeArray, StepSizeVm.Value, NoiseLevelVm.Value, Randy); if (_cancellationTokenSource.IsCancellationRequested) { _isRunning = false; _stopwatch.Stop(); CommandManager.InvalidateRequerySuggested(); } if (i % (int)DisplayFrequencySliderVm.Value == 0) { Application.Current.Dispatcher.Invoke ( UpdateUi, DispatcherPriority.Background ); } } }, _cancellationTokenSource.Token); }