public static void Main(string[] args) { Console.WriteLine("Initializing measurement data.."); var example = new ExampleFunctions(); var measurements = new int[, ] { { 0, 115, 5, 15, 0, 5 }, { 80, 210, 0, 5, 5, 0 }, { 45, 60, 145, 175, 95, 25 }, { 95, 5, 250, 250, 115, 5 }, { 170, 230, 245, 185, 165, 145 }, { 145, 220, 140, 160, 250, 250 }, }; var threshold = 200; Console.WriteLine("Processing measurements.. "); var centers = example.ProcessMeasurements(measurements, threshold); Console.WriteLine("\nThe following centers of mass were identified: "); foreach (var center in centers) { Console.WriteLine($"[ {center.X}, {center.Y} ]"); } Console.WriteLine("\n[ Press any key to exit ]"); Console.ReadKey(); }
static void SeriesImpl(string[] args) { string path = args[0]; int dateColNum = Convert.ToInt32(args[1]); int valsColNum = Convert.ToInt32(args[2]); if (File.Exists(path)) { Series <DateTime, Double> series; string[] lines = File.ReadAllLines(path); DateTime[] dates = lines.Skip(1) .Select(a => DateTime.Parse(a.Split(',')[dateColNum])) .ToArray(); double[] values = lines.Skip(1) .Select(a => Double.Parse(a.Split(',')[valsColNum])) .ToArray(); series = new Series <DateTime, double>(dates, values); Console.WriteLine(ExampleFunctions.AverageOfSeries(series)); } else { Console.WriteLine("path not found"); } Console.ReadLine(); }
// Makes an array, but automatically resizes the result public static object dnaMakeArrayAndResize(int rows, int columns, string unused, string unusedtoo) { object[,] result = ExampleFunctions.dnaMakeArray(rows, columns); return(ArrayResizer.dnaResize(result)); // Can also call Resize via Excel - so if the Resize add-in is not part of this code, it should still work // (though calling direct is better for large arrays - it prevents extra marshaling). // return XlCall.Excel(XlCall.xlUDF, "Resize", result); }
static void ArrayImpl(string[] args) { string path = args[0]; int colNum = Convert.ToInt32(args[1]); if (File.Exists(path)) { double[] series = File.ReadAllLines(path) .Skip(1) .Select(a => Convert.ToDouble(a.Split(',')[colNum])) .ToArray(); Console.WriteLine(ExampleFunctions.AverageOfArray(series)); } else { Console.WriteLine("path not found"); } Console.ReadLine(); }