コード例 #1
0
        public static double[] GetVectorSchwerpunkt(double[][] p)
        {
            double[] x = new double[p[0].Length];

            for (int i = 0; i < p.Length; ++i)
            {
                x = MatrixMafs.ArrAddArr(x, p[i]);
            }

            return(MatrixMafs.ArrDivNum(x, p.Length));
        }
コード例 #2
0
        public static double[] GaussisscherAlgorithmus(double[][] p)
        {
            double[][] x = p.Select(a => a.ToArray()).ToArray();
            double[]   y = new double[x.Length];

            Parallel.For(0, y.Length, i =>
            {
                y[i] = -x[i][0];
            });

            Parallel.For(0, y.Length, i0 =>
            {
                for (int i1 = 0; i1 < x[0].Length - 1; ++i1)
                {
                    x[i0][i1] = x[i0][i1 + 1];
                }
                x[i0][x[0].Length - 1] = 1;
            });

            for (int i = 0; i < x.Length; ++i)
            {
                if (x[i][i] == 0)
                {
                    bool weiter = true;
                    for (int j = 0; j < x.Length && weiter; ++j)
                    {
                        if (x[j][i] != 0)
                        {
                            SwitchPosInArr(x, j, i);
                        }
                    }
                }
            }

            for (int i0 = 0; i0 < x.Length; ++i0)
            {
                y[i0] /= x[i0][i0];
                x[i0]  = MatrixMafs.ArrDivNum(x[i0], x[i0][i0]);

                Parallel.For(0, x.Length, i1 =>
                {
                    if (i1 != i0)
                    {
                        y[i1] /= -x[i1][i0];
                        x[i1]  = MatrixMafs.ArrDivNum(x[i1], -x[i1][i0]);

                        x[i1]  = MatrixMafs.ArrAddArr(x[i1], x[i0]);
                        y[i1] += y[i0];
                    }
                });
            }


            Parallel.For(0, x.Length, i =>
            {
                y[i]   /= x[i][i];
                x[i][i] = 1;
            });

            return(y);
        }