public override void Solve(int N, Complex[] Exp, Complex[] D, double[] W, Complex[] H, out double[] result) { double[] vector = new double[N]; double[,] matrix = new double[N, N]; Complex[] fr = new Complex[D.Length]; Complex[] fc = new Complex[D.Length]; for (int j = 0; j < D.Length; j++) { fr[j] = new Complex(1, 0); } for (int r = 0; r < N; r++) { for (int j = 0; j < D.Length; j++) { vector[r] += (W[j] * (Complex.AbsSqr(D[j]) - Complex.AbsSqr(H[j])) * Complex.Conjugate(H[j]) * fr[j]).re; fc[j] = new Complex(1, 0); for (int c = 0; c < N; c++) { matrix[r, c] += (W[j] * (Complex.Conjugate(H[j] * H[j]) * fc[j] + (2 * Complex.AbsSqr(H[j]) - Complex.AbsSqr(D[j])) * Complex.Conjugate(fc[j])) * fr[j]).re; fc[j] *= Exp[j]; } fr[j] *= Exp[j]; } } SolveNbyN solveNbyN = new SolveNbyN(); solveNbyN.Solve(N, matrix, vector, out result); }
public override void Solve(int N, int P, out double[] result) { if (Ad == null || Dd == null) { throw new InvalidOperationException("Missing event handlers"); } double[,] matrix = new double[N, N]; double[] vector = new double[N]; for (int p = 0; p < P; p++) { double Dp = Dd(p); for (int r = 0; r < N; r++) { double Arp = Ad(r, p); for (int c = 0; c < N; c++) { matrix[r, c] += Ad(c, p) * Arp; } vector[r] += Dp * Arp; } } SolveNbyN solve = new SolveNbyN(); solve.Solve(N, matrix, vector, out result); }
public override void Solve(int N, int P, out double[] result) { if (Ac == null || Dc == null) { throw new InvalidOperationException("Missing event handlers"); } double[,] matrix = new double[N, N]; double[] vector = new double[N]; for (int r = 0; r < N; r++) { for (int j = 0; j < P; j++) { Complex Arj = Ac(r, j); for (int c = 0; c < N; c++) { matrix[r, c] += (Arj * Complex.Conjugate(Ac(c, j))).re; } vector[r] += (Arj * Complex.Conjugate(Dc(j))).re; } } SolveNbyN solve = new SolveNbyN(); solve.Solve(N, matrix, vector, out result); }
public override void Solve(int N, int P, Complex[] Exp, Complex[] D, double[] W, Complex[] H, Complex[] A, out double[] result) { double[] vector = new double[N]; double[,] matrix = new double[N, N]; Complex[] fr = new Complex[D.Length]; Complex[] fc = new Complex[D.Length]; for (int j = 0; j < D.Length; j++) { fr[j] = 1 / A[j]; } for (int r = 0; r < N; r++) { for (int j = 0; j < D.Length; j++) { vector[r] += (W[j] * Complex.Conjugate(D[j] - H[j]) * fr[j]).re; fc[j] = 1 / A[j]; for (int c = 0; c < N; c++) { matrix[r, c] += (W[j] * Complex.Conjugate(fc[j]) * fr[j]).re; if (c != P - 1) { fc[j] *= Exp[j]; } else { fc[j] = -H[j] / A[j] * Exp[j]; } } if (r != P - 1) { fr[j] *= Exp[j]; } else { fr[j] = -H[j] / A[j] * Exp[j]; } } } SolveNbyN solveNbyN = new SolveNbyN(); solveNbyN.Solve(N, matrix, vector, out result); }