public static void Calc_dZdv_n(Double3[,] Z, Double3[,] dZdv, double dv) { int n = Z.GetLength(0); int m = Z.GetLength(1); if ((n != dZdv.GetLength(0)) || (m != dZdv.GetLength(1))) { throw new ArgumentException("dZdv must have the same dimensions as Z."); } { int j = 0; for (int i = 0; i < n; i++) { dZdv[i, j] = Double3.NaN; // default Double3 Z0 = Z[i, j + 0]; Double3 Z1 = Z[i, j + 1]; Double3 Z2 = Z[i, j + 2]; if (Double3.IsNaN(Z0) || Double3.IsNaN(Z1) || Double3.IsNaN(Z2)) { continue; } dZdv[i, j] = 0.5d * (-3d * Z0 + 4d * Z1 - Z2) / dv; } } Parallel.For(1, m - 1, (j) => { for (int i = 0; i < n; i++) { dZdv[i, j] = Double3.NaN; // default Double3 Zm = Z[i, j - 1]; Double3 Zp = Z[i, j + 1]; if (Double3.IsNaN(Zm) || Double3.IsNaN(Zp)) { continue; } dZdv[i, j] = 0.5d * (Zp - Zm) / dv; } }); { int j = m - 1; for (int i = 0; i < n; i++) { dZdv[i, j] = Double3.NaN; // default Double3 Z0 = Z[i, j - 0]; Double3 Z1 = Z[i, j - 1]; Double3 Z2 = Z[i, j - 2]; if (Double3.IsNaN(Z0) || Double3.IsNaN(Z1) || Double3.IsNaN(Z2)) { continue; } dZdv[i, j] = -0.5d * (-3d * Z0 + 4d * Z1 - Z2) / dv; } } }
public static void Calc_dZdu_n(Double3[,] Z, Double3[,] dZdu, double du) { int n = Z.GetLength(0); int m = Z.GetLength(1); if ((n != dZdu.GetLength(0)) || (m != dZdu.GetLength(1))) { throw new ArgumentException("dZdu must have the same dimensions as Z."); } { int i = 0; for (int j = 0; j < m; j++) { dZdu[i, j] = Double3.NaN; // default Double3 Z0 = Z[i + 0, j]; Double3 Z1 = Z[i + 1, j]; Double3 Z2 = Z[i + 2, j]; if (Double3.IsNaN(Z0) || Double3.IsNaN(Z1) || Double3.IsNaN(Z2)) { continue; } dZdu[i, j] = 0.5d * (-3d * Z0 + 4d * Z1 - Z2) / du; } } Parallel.For(1, n - 1, (i) => { for (int j = 0; j < m; j++) { dZdu[i, j] = Double3.NaN; // default Double3 Zm = Z[i - 1, j]; Double3 Zp = Z[i + 1, j]; if (Double3.IsNaN(Zm) || Double3.IsNaN(Zp)) { continue; } dZdu[i, j] = 0.5d * (Zp - Zm) / du; } }); { int i = n - 1; for (int j = 0; j < m; j++) { dZdu[i, j] = Double3.NaN; // default Double3 Z0 = Z[i - 0, j]; Double3 Z1 = Z[i - 1, j]; Double3 Z2 = Z[i - 2, j]; if (Double3.IsNaN(Z0) || Double3.IsNaN(Z1) || Double3.IsNaN(Z2)) { continue; } dZdu[i, j] = -0.5d * (-3d * Z0 + 4d * Z1 - Z2) / du; } } }
public static void Calc_dZdu_p(Double3[,] Z, Double3[,] dZdu, double du) { int n = Z.GetLength(0), m = Z.GetLength(1); if ((n != dZdu.GetLength(0)) || (m != dZdu.GetLength(1))) { throw new ArgumentException("dZdu must have the same dimensions as Z."); } Parallel.For(0, n, (i) => { for (int j = 0; j < m; j++) { dZdu[i, j] = Double3.NaN; // default Double3 Zm = Z[(i - 1).Trim(n), j]; Double3 Zp = Z[(i + 1).Trim(n), j]; if (Double3.IsNaN(Zm) || Double3.IsNaN(Zp)) { continue; } dZdu[i, j] = 0.5d * (Zp - Zm) / du; } }); }
public static void Calc_dZdv_p(Double3[,] Z, Double3[,] dZdv, double dv) { int n = Z.GetLength(0); int m = Z.GetLength(1); if ((n != dZdv.GetLength(0)) || (m != dZdv.GetLength(1))) { throw new ArgumentException("dZdv must have the same dimensions as Z."); } Parallel.For(0, m, (j) => { for (int i = 0; i < n; i++) { dZdv[i, j] = Double3.NaN; // default Double3 Zm = Z[i, (j - 1).Trim(m)]; Double3 Zp = Z[i, (j + 1).Trim(m)]; if (Double3.IsNaN(Zm) || Double3.IsNaN(Zp)) { continue; } dZdv[i, j] = 0.5d * (Zp - Zm) / dv; } }); }