// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. //Simple arithmatic manipulation of one 2D array elements using System; public class Arrayclass { public double[,] a2d; public double[,,] a3d; public Arrayclass(int size) { a2d = new double[size, size]; a3d = new double[size, size + 5, size + 10]; } } public class class1 { public static Random rand; public static int size; public static Arrayclass ima; public static double GenerateDbl() { int e; int op1 = (int)((float)rand.Next() / Int32.MaxValue * 2); if (op1 == 0) e = -rand.Next(0, 14); else e = +rand.Next(0, 14); return Math.Pow(2, e); } public static void Init2DMatrix(out double[,] m, out double[][] refm) { int i, j; i = 0; double temp; m = new double[size, size]; refm = new double[size][]; for (int k = 0; k < refm.Length; k++) refm[k] = new double[size]; while (i < size) { j = 0; while (j < size) { temp = GenerateDbl(); m[i, j] = temp - 60; refm[i][j] = temp - 60; j++; } i++; } } public static void Process2DArray(ref double[,] a2d) { for (int i = 3; i < size + 3; i++) for (int j = -10; j < size - 10; j++) { int b = j + 5; a2d[i - 3, b + 5] += a2d[0, b + 5] + a2d[1, b + 5]; a2d[i - 3, b + 5] *= a2d[i - 3, j + 10] + a2d[2, b + 5]; a2d[i - 3, j + 10] -= a2d[i - 3, b + 5] * a2d[3, j + 10]; if ((a2d[i - 3, b + 5] + a2d[4, j + 10]) != 0) a2d[i - 3, b + 5] /= a2d[i - 3, b + 5] + a2d[4, b + 5]; else a2d[i - 3, j + 10] += a2d[i - 3, j + 10] * a2d[4, j + 10]; for (int k = 5; k < size; k++) a2d[i - 3, b + 5] += a2d[k, j + 10]; } } public static void ProcessJagged2DArray(ref double[][] a2d) { for (int i = 0; i < size; i++) for (int j = 0; j < size; j++) { a2d[i][j] += a2d[0][j] + a2d[1][j]; a2d[i][j] *= a2d[i][j] + a2d[2][j]; a2d[i][j] -= a2d[i][j] * a2d[3][j]; if ((a2d[i][j] + a2d[4][j]) != 0) a2d[i][j] /= a2d[i][j] + a2d[4][j]; else a2d[i][j] += a2d[i][j] * a2d[4][j]; for (int k = 5; k < size; k++) a2d[i][j] += a2d[k][j]; } } public static void Init3DMatrix(double[,,] m, double[][] refm) { int i, j; i = 0; double temp; //m = new double[size, size, size]; //refm = new double[size][]; //for (int k=0; k