public static double Convolution(double x, FunctionLib.Function f, FunctionLib.Function g, int GridSize, double a) { Vector grid = Vector.CreateUniformGrid(GridSize, a, x); Vector fg = new Vector(GridSize); double h = grid[1] - grid[0]; for (int i = 0; i < GridSize; i++) { fg[i] = f(grid[i]) * g(x - grid[i]); } return(Integrate.Simpson(fg.ToArray, h)); }
public static double Convolution(double x, FunctionLib.Function f, FunctionLib.Function g, Grid grid) { int GridSize = grid.Count; Vector fg = new Vector(GridSize); double h = grid[1] - grid[0]; for (int i = 0; i < GridSize; i++) { fg[i] = f(grid[i]) * g(x - grid[i]); } return(Integrate.Simpson(fg.ToArray, h)); }
public static Matrix GrdientProjectionByF(Matrix f_old, Matrix KSI, double alpha, double R, double h, double tau) { int N = f_old.Length.n; int M = f_old.Length.m; double I = 0; Matrix T = new Matrix(N, M); Matrix f_new = new Matrix(N, M); for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { T[i, j] = Math.Pow(Math.Abs(f_old[i, j] - alpha * KSI[i, j]), 2); } } I = Integrate.IntegrateSurface(T, tau, h); if (I <= R * R) { for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { f_new[i, j] = f_old[i, j] - alpha * KSI[i, j]; } } } else { for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { f_new[i, j] = R * (f_old[i, j] - alpha * KSI[i, j]) / Math.Sqrt(I); } } } return(f_new); }