Beispiel #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 DMatrixRMaj createMatrixV(EigenDecomposition_F64 <DMatrixRMaj> eig)
        {
            int N = eig.getNumberOfEigenvalues();

            DMatrixRMaj V = new DMatrixRMaj(N, N);

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

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

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

            return(V);
        }
        public virtual DMatrixRMaj getEigenVector(int index)
        {
            if (!computeVectors)
            {
                throw new ArgumentException("Configured to not compute eignevectors");
            }

            return(symmetric ? symmetricAlg.getEigenVector(index) : generalAlg.getEigenVector(index));
        }