The determinant takes a square matrix and returns a number . Interchanging two rows or two columns affects the determinant by multiplying it by â ' 1 . Using these operations , any matrix can be transformed to a lower ( or upper ) triangular matrix , and for such matrices the determinant equals the product of the entries on the main diagonal ; this provides a method to calculate the determinant of any matrix .