PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • Calculating the determinant of a matrix
MatDeterminant (Example)
Calculating the determinant of a matrix
The following code is used to calculate the determinant of a matrix. The name of the matrix is entered by the user in an edit control (EDT_MatrixName).
We assume that the matrix is already created. The existence of the matrix is checked by MatExist. The number of columns must be equal to the number of rows.
// -- Click code on BTN_Determinant
// Declare the variables
ResDeterminant is real
// Checks the matrix existence
IF MatExist(EDT_MatrixName) = True THEN
// Nb. columns in the matrix = Nb. rows in the matrix?
IF MatNbColumn(EDT_MatrixName) = MatNbRow(EDT_MatrixName) THEN
// Calculate the determinant
ResDeterminant = MatDeterminant(EDT_MatrixName)
IF ResDeterminant <> 0 THEN
Info("The value of the determinant is: " + ResDeterminant)
ELSE
// Error?
IF MatError(EDT_MatrixName) = 0 THEN
Info("The determinant is null")
ELSE
// Display the error message
Error(ErrorInfo(errMessage))
END
END
ELSE
Info("The number of columns is not equal to the number of rows")
END
ELSE
Info("The matrix does not exist")
END
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment