// DETERMINANT // first row expansion public IComplexNumber Determinant(IComplexMatrix matrix) { if (matrix.IsScalar()) { return matrix.getElement(0, 0); } if (matrix.IsSquare()) { IComplexNumber result = ComplexNumberFactory.GenerateZero(); //IComplexNumber negative = ComplexNumberFactory.Operations.SignReversal(ComplexNumberFactory.generateIdentity()); IComplexMatrix tempMatrix; IComplexNumber tempDeterminant; //IComplexNumber tempCoefficient; int count = matrix.getNumCols(); for (int pos = 0; pos < count; pos++) { tempMatrix = ComplexMatrixFactory.Operations.RemoveRowCol(matrix, 0, pos); tempDeterminant = ComplexMatrixFactory.Operations.Determinant(tempMatrix); //tempCoefficient = ComplexNumberFactory.Operations.Power(negative, pos); if (pos % 2 == 0) { result = ComplexNumberFactory.Operations.Add(result, tempDeterminant); } else { result = ComplexNumberFactory.Operations.Substract(result, tempDeterminant); } } return result; } throw new ExceptionMatrixDimension(); }