Пример #1
0
        //adjoint matrix / conjugate transpose
        public MatrixFixed Adjoint()
        {

            if (this.Rows < 2 || this.Columns < 2)
                throw new MatrixFixedException("Adjoint matrix not available");

            MatrixFixed tempMtx = new MatrixFixed(this.Rows - 1, this.Columns - 1);
            MatrixFixed adjMtx = new MatrixFixed(this.Columns, this.Rows);

            for (int i = 0; i < this.Rows; i++)
            {
                for (int j = 0; j < this.Columns; j++)
                {

                    tempMtx = this.Minor(i, j);

                    //put the determinent of the minor in the transposed position
                    adjMtx[j, i] = (int)Math.Pow(-1, i + j) * tempMtx.Determinant();
                }
            }

            return adjMtx;
        }
Пример #2
0
        //determinent
        public float Determinant()
        {

            float determinent = 0;

            if (this.Rows != this.Columns)
                throw new MatrixFixedException("Attempt to find the determinent of a non square matrix");
            //return 0;

            //get the determinent of a 2x2 matrix
            if (this.Rows == 2 && this.Columns == 2)
            {
                determinent = (m_matrix[0, 0] * m_matrix[1, 1]) - (m_matrix[0, 1] * m_matrix[1, 0]);
                return determinent;
            }

            MatrixFixed tempMtx = new MatrixFixed(Rows - 1, Columns - 1);

            //find the determinent with respect to the first row
            for (int j = 0; j < this.Columns; j++)
            {

                tempMtx = this.Minor(0, j);

                //recursively add the determinents
                determinent += (int)Math.Pow(-1, j) * m_matrix[0, j] * tempMtx.Determinant();

            }

            return determinent;
        }