예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="wym">dimensions</param>
        /// <param name="s1">basevector, used for rotation</param>
        /// <param name="a">current orthogonal vectors</param>
        public static void Minim(int wym, double[] s1, double[][] a)
        {
            double c1;

            double[][] b = MatrixKniaz.New(wym, wym);
            int        i, j, k;

            for (i = 0; i < wym; i++)
            {
                for (j = 0; j < wym; j++)
                {
                    c1 = 0;
                    for (k = i; k < wym; k++)
                    {
                        c1 += s1[k] * a[k][j];
                    }
                    b[i][j] = c1;
                }
            }
            for (i = 0; i < wym; i++)
            {
                for (j = 0; j < wym; j++)
                {
                    a[i][j] = b[i][j];
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Performs Orthogonalization of the vector
        /// </summary>
        /// <param name="wym">dimensions</param>
        /// <param name="v">current orthogonal vectors, after "minim" was run with basevector</param>
        public static void Ortog(int wym, double[][] v)
        {
            int    i, j, k;
            double lask = 0.0;

            j = 0;

            double[] w1 = new double[wym];

            MatrixKniaz.Wers(wym, j, v);
            for (i = 1; i < wym; i++)
            {
                for (k = 0; k < wym; k++)
                {
                    w1[k] = 0;
                }
                for (j = 0; j <= i - 1; j++)
                {
                    lask = MatrixKniaz.scalarProduct(wym, i, j, v);
                    for (k = 0; k < wym; k++)
                    {
                        w1[k] += v[j][k] * lask;
                    }
                }
                for (k = 0; k < wym; k++)
                {
                    v[i][k] += -w1[k];
                }
                MatrixKniaz.Wers(wym, i, v);
            }
        }
예제 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="k"></param>
        /// <param name="l"></param>
        /// <param name="a"></param>
        public static void Wers(int k, int l, double[][] a)
        {
            int    i;
            double c;

            c = MatrixKniaz.Norma(k, l, a);
            for (i = 0; i < k; i++)
            {
                a[l][i] = a[l][i] / c;
            }
        }
예제 #4
0
        public static double[][] GramSchmidt(double[] basevector, int nVar, double[][] vMoves)
        {
            double[][] rotatedMatrix = new double[nVar][];
            for (int i = 0; i < nVar; i++)
            {
                rotatedMatrix[i] = new double[nVar];
                rotatedMatrix[i] = vMoves[i];
            }

            MatrixKniaz.Minim(nVar, basevector, rotatedMatrix);
            MatrixKniaz.Ortog(nVar, rotatedMatrix);

            return(rotatedMatrix);
        }