public void FormDiscreteEquation(out double[,] matrix, out double[] rightPart, Func <double, int, double> matrixModifier = null, Func <double, int, double> rightPartModifier = null) { double H = CalculateDiscreteStep(PointsNumber); // calculate right part vector rightPart = new double[this.PointsNumber]; double ti = 0; for (int i = 0; i < PointsNumber; i++) { rightPart[i] = rightPartModifier?.Invoke(RightPartFunction(ti), i) ?? RightPartFunction(ti); ti += H; } // calculate matrix matrix = new double[PointsNumber, PointsNumber]; double sj = 0; ti = 0; for (int i = 0; i < PointsNumber; i++) { Core.Prepare(ti); sj = 0; for (int j = 0; j < PointsNumber; j++) { matrix[i, j] = matrixModifier?.Invoke(Core.GetValue(sj), j) ?? Core.GetValue(sj); sj += H; } ti += H; } }
public void FormDiscreteEquation(out double[,] matrix, out double[] rightPart, int columnsNumber, Func <double, int, double> rightPartModifier) { double H = CalculateDiscreteStep(PointsNumber); // calculate right part vector rightPart = new double[this.PointsNumber]; double ti = 0; for (int i = 0; i < PointsNumber; i++) { rightPart[i] = rightPartModifier?.Invoke(RightPartFunction(ti), i) ?? RightPartFunction(ti); ti += H; } // calculate matrix int columnsPerCore = columnsNumber / 2; // chebichev polinom power matrix = new double[PointsNumber, columnsNumber]; double sj = 0; ti = 0; for (int i = 0; i < PointsNumber; i++) { CoreFirst.Prepare(ti); CoreSecond.Prepare(ti); for (int k = 0; k < columnsPerCore; k++) { matrix[i, k] = CoreFirst.GetValue(k); matrix[i, k + columnsPerCore] = CoreSecond.GetValue(k); } ti += H; } }