Beispiel #1
0
        /// <summary>
        /// Compute inverse.\  Not efficient.
        /// </summary>
        /// <returns></returns>
        public unsafe MatrixFixed Inverse()
        {
            int         n = A_.Columns;
            MatrixFixed I = new MatrixFixed(A_);

            float[] det = new float[2];
            int     job = 01;

            fixed(float *data = I.Datablock())
            {
                fixed(float *data2 = det)
                {
                    Netlib.dpodi_(data, &n, &n, data2, &job);
                }
            }

            // Copy lower triangle into upper
            for (int i = 0; i < n; ++i)
            {
                for (int j = i + 1; j < n; ++j)
                {
                    I[i, j] = I[j, i];
                }
            }

            return(I);
        }
Beispiel #2
0
        /// <summary>
        /// Compute determinant.
        /// </summary>
        /// <returns></returns>
        public unsafe float Determinant()
        {
            int         n = A_.Columns;
            MatrixFixed I = new MatrixFixed(A_);

            float[] det = new float[2];
            int     job = 10;

            fixed(float *data = I.Datablock())
            {
                fixed(float *data2 = det)
                {
                    Netlib.dpodi_(data, &n, &n, data2, &job);
                }
            }

            return(det[0] * (float)Math.Pow(10.0, det[1]));
        }