示例#1
0
        private void JacobianIteration(MatrixEquasion <Double> eq, Matrix <Double> oldMatrix, Matrix <Double> newMatrix, int i)
        {
            IMatrixDataType <Double> x = new MatrixDouble(0);

            for (int j = 0; j < eq.A.ColCount; j++)
            {
                if (i != j)
                {
                    x = (x.Add(eq.A.ValueMatrix[i][j].Multiply(oldMatrix.ValueMatrix[j][0])));
                }
            }
            x = x.Multiply(MatrixDouble.MINUSONE);
            x = x.Add(eq.B.ValueMatrix[i][0]);
            x = x.Divide(eq.A.ValueMatrix[i][i]);

            newMatrix.ValueMatrix[i][0] = x;
        }
示例#2
0
        private void GaussSeidelIteration(MatrixEquasion <Double> eq, Matrix <Double> newVector, int i)
        {
            IMatrixDataType <double> x = new MatrixDouble(0);

            for (int j = 0; j < eq.A.ColCount; j++)
            {
                if (i != j)
                {
                    x = (x.Add(eq.A.ValueMatrix[i][j].Multiply(newVector.ValueMatrix[j][0])));
                }
            }
            x = x.Multiply(MatrixDouble.MINUSONE);
            x = x.Add(eq.B.ValueMatrix[i][0]);
            x = x.Divide(eq.A.ValueMatrix[i][i]);

            newVector.ValueMatrix[i][0] = x;
        }