public void Perform(HistoryData data, double input, IPresenter presenter) { if (data.list.Count == 0) { presenter.ShowStatus(0, ""); return; } double[] old = data.Current(); double[] block = new double[old.Length]; for (uint i = 0; i < block.Length; ++i) { block[i] = old[i] + input; if ((i + 1) % 100 == 0 || i + 1 == block.Length) { presenter.ShowStatus((double)(i + 1) / block.Length, "Performing plus."); } } data.Add(block); presenter.ShowStatus(1, "Plus done."); }
public void perform(HistoryData data, String argument, IPresenter presenter) { if (data.list.Count == 0) { presenter.showStatus(0, ""); return; } try { using (StreamWriter stream = new StreamWriter(argument)) { double[] old = data.Current(); for (uint i = 0; i < old.Length; ++i) { stream.Write(old[i].ToString() + (i + 1 < old.Length ? " " : "")); if ((i + 1) % 100 == 0 || i + 1 == old.Length) { presenter.showStatus((double)(i + 1) / old.Length, "Performing save."); } } } } catch (Exception e) { presenter.showStatus(0, e.ToString()); } presenter.showStatus(1, "Done."); }
public void perform(HistoryData data, double input, IPresenter presenter) { if (data.list.Count == 0) { presenter.showStatus(0, ""); return; } double[] old = data.Current(); double[] block = new double[1] { 0 }; for (uint i = 0; i < block.Length; ++i) { block[0] += old[i]; if ((i + 1) % 100 == 0 || i + 1 == block.Length) { presenter.showStatus((double)(i + 1) / block.Length, "Performing mean."); } } if (block.Length > 0) { block[0] /= block.Length; } data.Add(block); presenter.showStatus(1, "Done."); }
public void perform(HistoryData data, double input, IPresenter presenter) { if (data.list.Count == 0) { double[] block = new double[1] { input }; data.Add(block); presenter.showStatus(1, "Готово."); return; } else { double[] old = data.Current(); double[] block = new double[old.Length + 1]; for (uint i = 0; i < old.Length; ++i) { block[i] = old[i]; } block[old.Length] = input; data.Add(block); presenter.showStatus(1, "Готово."); } }
public void Perform(HistoryData data, double input, IPresenter presenter) { if (data.list.Count == 0) { presenter.ShowStatus(0, ""); return; } double[] old = data.Current(); double[] block = new double[old.Length]; for (uint i = 0; i < block.Length; ++i) { if (old[i] < 0) { presenter.ShowStatus(0, "Bad number."); return; } block[i] = Math.Pow(Math.Abs(old[i]), input); if ((i + 1) % 100 == 0 || i + 1 == block.Length) { presenter.ShowStatus((double)(i + 1) / block.Length, "Performing power."); } } data.Add(block); presenter.ShowStatus(1, "Pow done."); }
public void perform(HistoryData data, double input, IPresenter presenter) { if (data.list.Count == 0) { presenter.showStatus(0, ""); return; } double[] old = data.Current(); double[] block = new double[old.Length]; for (uint i = 0; i < block.Length; ++i) { if (old[i] < 0 || Math.Floor(old[i]) != old[i]) { presenter.showStatus(0, "Bad number."); return; } block[i] = 1; for (double f = old[i]; f > 1; --f) { block[i] *= f; } if ((i + 1) % 100 == 0 || i + 1 == block.Length) { presenter.showStatus((double)(i + 1) / block.Length, "Performing factorial."); } } data.Add(block); presenter.showStatus(1, "Done."); }
public void perform(HistoryData data, double input, IPresenter presenter) { if (data.list.Count == 0) { presenter.showStatus(0, ""); return; } double[] old = data.Current(); double[] block = new double[1] { 0 }; double m2 = 0; double mean = 0; for (uint i = 0; i < old.Length; ++i) { mean = +old[i]; } mean /= old.Length; for (uint i = 0; i < old.Length; ++i) { m2 += (old[i] - mean) * (old[i] - mean); if ((i + 1) % 100 == 0 || i + 1 == block.Length) { presenter.showStatus((double)(i + 1) / block.Length, "Performing stddev."); } } if (old.Length > 0) { m2 /= old.Length; block[0] = Math.Sqrt(m2); } data.Add(block); presenter.showStatus(1, "Done."); }
public void Perform(HistoryData data, double input, IPresenter presenter) { if (data.list.Count == 0) { presenter.ShowStatus(0, ""); return; } double[] old = data.Current(); double[] block = new double[1] { 0 }; double m2 = 0; for (uint i = 0; i < old.Length; ++i) { block[0] += old[i]; m2 += old[i] * old[i]; if ((i + 1) % 100 == 0 || i + 1 == block.Length) { presenter.ShowStatus((double)(i + 1) / block.Length, "Performing stddev."); } } if (block.Length > 0) { block[0] /= block.Length; block[0] *= block[0]; m2 /= block.Length; block[0] = Math.Sqrt(m2 - block[0]); } data.Add(block); presenter.ShowStatus(1, "Calculating stddev done."); }
public void perform(HistoryData data, double input, IPresenter presenter) { if (data.list.Count == 0) { presenter.showStatus(0, ""); return; } int mult = (int)Math.Floor(input); double[] old = data.Current(); if (mult != input || input < 0 || old.Length * mult > 1e6) { presenter.showStatus(0, "Bad argument"); return; } double[] block = new double[old.Length * mult]; for (uint i = 0; i < old.Length; ++i) { for (uint j = 0; j < mult; ++j) { block[j * old.Length + i] = old[i]; } if ((i + 1) % 100 == 0 || i + 1 == block.Length) { presenter.showStatus((double)(i + 1) / block.Length, "Performing clone."); } } data.Add(block); presenter.showStatus(1, "Done."); }
public void perform(HistoryData data, double input, IPresenter presenter) { if (data.list.Count == 0) { presenter.showStatus(0, ""); return; } if (input <= 0) { presenter.showStatus(0, "Bad argument."); return; } double[] old = data.Current(); double[] block = new double[old.Length]; for (uint i = 0; i < block.Length; ++i) { if (old[i] <= 0) { presenter.showStatus(0, "Bad number."); return; } block[i] = old[i] + input; if ((i + 1) % 100 == 0 || i + 1 == block.Length) { presenter.showStatus((double)(i + 1) / block.Length, "Performing log."); } } data.Add(block); presenter.showStatus(1, "Done."); }