Beispiel #1
0
        public static bool isEquals(DMatrixRBlock A, DMatrixRBlock B, double tol)
        {
            if (A.blockLength != B.blockLength)
            {
                return(false);
            }

            return(MatrixFeatures_DDRM.isEquals(A, B, tol));
        }
Beispiel #2
0
        //public SwitchingEigenDecomposition_DDRM(int matrixSize) : this(matrixSize, true, UtilEjml.TEST_F64)
        //{
        //}

        public bool decompose(DMatrixRMaj orig)
        {
            A.setTo(orig);

            symmetric = MatrixFeatures_DDRM.isSymmetric(A, tol);

            return(symmetric ?
                   symmetricAlg.decompose(A) :
                   generalAlg.decompose(A));
        }
        /**
         * Computes the p=2 norm.  If A is a matrix then the induced norm is computed.
         *
         * @param A Matrix or vector.
         * @return The norm.
         */
        //public static double normP2(DMatrixRMaj A)
        //{
        //    if (MatrixFeatures_DDRM.isVector(A))
        //    {
        //        return normF(A);
        //    }
        //    else
        //    {
        //        return inducedP2(A);
        //    }
        //}

        /**
         * Computes the p=2 norm.  If A is a matrix then the induced norm is computed. This
         * implementation is faster, but more prone to buffer overflow or underflow problems.
         *
         * @param A Matrix or vector.
         * @return The norm.
         */
        //public static double fastNormP2(DMatrixRMaj A)
        //{
        //    if (MatrixFeatures_DDRM.isVector(A))
        //    {
        //        return fastNormF(A);
        //    }
        //    else
        //    {
        //        return inducedP2(A);
        //    }
        //}

        /**
         * Computes the p=∞ norm.  If A is a matrix then the induced norm is computed.
         *
         * @param A Matrix or vector.
         * @return The norm.
         */
        public static double normPInf(DMatrixRMaj A)
        {
            if (MatrixFeatures_DDRM.isVector(A))
            {
                return(CommonOps_DDRM.elementMaxAbs(A));
            }
            else
            {
                return(inducedPInf(A));
            }
        }
        /**
         * <p>
         * Creates a reflector from the provided vector and gamma.<br>
         * <br>
         * Q = I - &gamma; u u<sup>T</sup><br>
         * </p>
         *
         * <p>
         * In practice {@link VectorVectorMult_DDRM#householder(double, DMatrixD1, DMatrixD1, DMatrixD1)}  multHouseholder}
         * should be used for performance reasons since there is no need to calculate Q explicitly.
         * </p>
         *
         * @param u A vector.  Not modified.
         * @param gamma To produce a reflector gamma needs to be equal to 2/||u||.
         * @return An orthogonal reflector.
         */
        public static DMatrixRMaj createReflector(DMatrixRMaj u, double gamma)
        {
            if (!MatrixFeatures_DDRM.isVector(u))
            {
                throw new ArgumentException("u must be a vector");
            }

            DMatrixRMaj Q = CommonOps_DDRM.identity(u.NumElements);

            CommonOps_DDRM.multAddTransB(-gamma, u, u, Q);

            return(Q);
        }
        /**
         * <p>
         * Creates a reflector from the provided vector.<br>
         * <br>
         * Q = I - &gamma; u u<sup>T</sup><br>
         * &gamma; = 2/||u||<sup>2</sup>
         * </p>
         *
         * <p>
         * In practice {@link VectorVectorMult_DDRM#householder(double, DMatrixD1, DMatrixD1, DMatrixD1)}  multHouseholder}
         * should be used for performance reasons since there is no need to calculate Q explicitly.
         * </p>
         *
         * @param u A vector. Not modified.
         * @return An orthogonal reflector.
         */
        public static DMatrixRMaj createReflector(DMatrix1Row u)
        {
            if (!MatrixFeatures_DDRM.isVector(u))
            {
                throw new ArgumentException("u must be a vector");
            }

            double norm  = NormOps_DDRM.fastNormF(u);
            double gamma = -2.0 / (norm * norm);

            DMatrixRMaj Q = CommonOps_DDRM.identity(u.NumElements);

            CommonOps_DDRM.multAddTransB(gamma, u, u, Q);

            return(Q);
        }
Beispiel #6
0
 public bool isIdentical(Matrix A, Matrix B, double tol)
 {
     return(MatrixFeatures_DDRM.isIdentical((DMatrixRMaj)A, (DMatrixRMaj)B, (double)tol));
 }
Beispiel #7
0
 public bool hasUncountable(Matrix M)
 {
     return(MatrixFeatures_DDRM.hasUncountable((DMatrixRMaj)M));
 }