示例#1
0
        /**
         * <p>
         * Puts all the real eigenvectors into the columns of a matrix.  If an eigenvalue is imaginary
         * then the corresponding eigenvector will have zeros in its column.
         * </p>
         *
         * @param eig An eigenvalue decomposition which has already decomposed a matrix.
         * @return An m by m matrix containing eigenvectors in its columns.
         */
        public static FMatrixRMaj createMatrixV(EigenDecomposition_F32 <FMatrixRMaj> eig)
        {
            int N = eig.getNumberOfEigenvalues();

            FMatrixRMaj V = new FMatrixRMaj(N, N);

            for (int i = 0; i < N; i++)
            {
                Complex_F32 c = eig.getEigenvalue(i);

                if (c.isReal())
                {
                    FMatrixRMaj v = eig.getEigenVector(i);

                    if (v != null)
                    {
                        for (int j = 0; j < N; j++)
                        {
                            V.set(j, i, v.get(j, 0));
                        }
                    }
                }
            }

            return(V);
        }
示例#2
0
        /**
         * <p>
         * A diagonal matrix where real diagonal element contains a real eigenvalue.  If an eigenvalue
         * is imaginary then zero is stored in its place.
         * </p>
         *
         * @param eig An eigenvalue decomposition which has already decomposed a matrix.
         * @return A diagonal matrix containing the eigenvalues.
         */
        public static FMatrixRMaj createMatrixD(EigenDecomposition_F32 <FMatrixRMaj> eig)
        {
            int N = eig.getNumberOfEigenvalues();

            FMatrixRMaj D = new FMatrixRMaj(N, N);

            for (int i = 0; i < N; i++)
            {
                Complex_F32 c = eig.getEigenvalue(i);

                if (c.isReal())
                {
                    D.set(i, i, c.real);
                }
            }

            return(D);
        }
 public virtual int getNumberOfEigenvalues()
 {
     return(symmetric ? symmetricAlg.getNumberOfEigenvalues() : generalAlg.getNumberOfEigenvalues());
 }