Ejemplo n.º 1
0
        /// <summary>
        /// Returns the inverse of the matrix using lu factorization.
        /// If the matrix is not invertible, __nmtype__.Zero is returned.
        /// </summary>
        public __nmtype__ LuInverse()
        {
            var lu = new Matrix <double>((double[])this, 0, s_luSize, s_luDelta);
            var p  = lu.LuFactorize();

            if (p == null)
            {
                return(__nmtype__.Zero);
            }
            return((__nmtype__)(lu.LuInverse(p).Data));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Inverts the matrix using lu factorization in place. Returns true
        /// if the matrix was invertible, otherwise the matrix remains unchanged.
        /// </summary>
        public bool LuInvert()
        {
            var lu = new Matrix <double>((double[])this, 0, s_luSize, s_luDelta);
            var p  = lu.LuFactorize();

            if (p == null)
            {
                return(false);
            }
            this = (__nmtype__)(lu.LuInverse(p).Data);
            return(true);
        }