public Vector3 estimate_num_graident(double x, double y, DerivativeEstimationMode mode) { //will need to add in edge cases. Ignore for now. switch (mode) { case DerivativeEstimationMode.GFDM: { return(Vector3.Zero); } case DerivativeEstimationMode.WEIGHTFUNCTION: { double delta_x = (bounds.Xmax - bounds.Xmin) / (Xcount - 1); double delta_y = (bounds.Ymax - bounds.Ymin) / (Ycount - 1); double dzdx = (this.interpolate_at(x + delta_x, y) - this.interpolate_at(x - delta_x, y)) / (2 * delta_x); double dzdy = (this.interpolate_at(x, y + delta_y) - this.interpolate_at(x, y - delta_y)) / (2 * delta_x); return(new Vector3(dzdx, dzdy, 0)); } default: { return(Vector3.Zero); } } }
public Vector3 estimate_num_graident(int i, int j, DerivativeEstimationMode mode) { //will need to add in edge cases. Ignore for now. switch (mode) { case DerivativeEstimationMode.GFDM: { //lacks implementation return(Vector3.Zero); } case DerivativeEstimationMode.TAYLOR_SURPLUS_UPPER_RIGHT: { //clean this up??? NCAMRNode[] stencil = { nodes[i, j], nodes[i + 1, j], nodes[i, j + 1], nodes[i - 1, j], nodes[i, j - 1], nodes[i + 1, j + 1] }; double[] deltas_u = { stencil[1].Value - stencil[0].Value, stencil[2].Value - stencil[0].Value, stencil[3].Value - stencil[0].Value, stencil[4].Value - stencil[0].Value, stencil[5].Value - stencil[0].Value }; double[] deltas_x = { stencil[1].X - stencil[0].X, stencil[2].X - stencil[0].X, stencil[3].X - stencil[0].X, stencil[4].X - stencil[0].X, stencil[5].X - stencil[0].X }; double[] deltas_y = { stencil[1].Y - stencil[0].Y, stencil[2].Y - stencil[0].Y, stencil[3].Y - stencil[0].Y, stencil[4].Y - stencil[0].Y, stencil[5].Y - stencil[0].Y }; double[] matrix_contents = { deltas_x[0], deltas_y[0], 0.5 * sq(deltas_x[0]), 0.5 * sq(deltas_x[0]), deltas_x[0] * deltas_y[0], deltas_x[1], deltas_y[1], 0.5 * sq(deltas_x[1]), 0.5 * sq(deltas_x[1]), deltas_x[1] * deltas_y[1], deltas_x[2], deltas_y[2], 0.5 * sq(deltas_x[2]), 0.5 * sq(deltas_x[2]), deltas_x[2] * deltas_y[2], deltas_x[3], deltas_y[3], 0.5 * sq(deltas_x[3]), 0.5 * sq(deltas_x[3]), deltas_x[3] * deltas_y[3], deltas_x[4], deltas_y[4], 0.5 * sq(deltas_x[4]), 0.5 * sq(deltas_x[4]), deltas_x[4] * deltas_y[4] }; Matrix delta = new Matrix(5, 1); return(Vector3.Zero); } case DerivativeEstimationMode.WEIGHTFUNCTION: { return(Vector3.Zero); } case DerivativeEstimationMode.NAIVE: { double delta_x = (bounds.Xmax - bounds.Xmin) / (Xcount - 1); double delta_y = (bounds.Ymax - bounds.Ymin) / (Ycount - 1); NCAMRNode node = nodes[i, j]; double dzdx = (this.interpolate_at(node.X + delta_x, node.Y) - this.interpolate_at(node.X - delta_x, node.Y)) / (2 * delta_x); double dzdy = (this.interpolate_at(node.X, node.Y + delta_y) - this.interpolate_at(node.X, node.Y - delta_y)) / (2 * delta_x); return(new Vector3(dzdx, dzdy, 0)); } default: { return(Vector3.Zero); } } }