diff --git a/src/kvector/kotlin/ru/dbotthepony/kvector/matrix/functions.kt b/src/kvector/kotlin/ru/dbotthepony/kvector/matrix/functions.kt index 2d9ee255..8bf8599e 100644 --- a/src/kvector/kotlin/ru/dbotthepony/kvector/matrix/functions.kt +++ b/src/kvector/kotlin/ru/dbotthepony/kvector/matrix/functions.kt @@ -459,8 +459,9 @@ fun complementMatrix(input: IMatrixGetterLong, column: Int, row: Int, buffer: Lo * Computes cofactor matrix of specified square matrix [input], * returning result as [Double2Dimensional] * - * This operation requires n * n determinant calculations of matrix, - * so do cache result of this function in performance critical context. + * This operation requires **O(n!)** determinant calculations of matrix, + * so do cache result of this function in performance critical context, + * because it is calculated analytically. * * @throws IllegalArgumentException if provided [input] is not a square matrix * @return 2d array containing result matrix @@ -497,8 +498,9 @@ fun cofactorMatrix(input: IMatrixGetterDouble): Double2Dimensional { * Computes cofactor matrix of specified square matrix [input], * returning result as [Float2Dimensional] * - * This operation requires n * n determinant calculations of matrix, - * so do cache result of this function in performance critical context. + * This operation requires **O(n!)** determinant calculations of matrix, + * so do cache result of this function in performance critical context, + * because it is calculated analytically. * * @throws IllegalArgumentException if provided [input] is not a square matrix * @return 2d array containing result matrix @@ -569,8 +571,9 @@ fun adjugateMatrix(input: IMatrixGetterFloat): Float2Dimensional { * Computes inverse matrix of specified square matrix [input], * returning result as [Double2Dimensional], * - * This operation requires 1 + n * n determinant calculations of original matrix, - * so do cache result of this function in performance critical context. + * This operation requires **O(n! + 1)** determinant calculations of original matrix, + * so do cache result of this function in performance critical context, + * because it is calculated analytically. * * If determinant is zero, null is returned. * @@ -601,8 +604,9 @@ fun inverseMatrix(input: IMatrixGetterDouble): Double2Dimensional? { * Computes inverse matrix of specified square matrix [input], * returning result as [Float2Dimensional], * - * This operation requires 1 + n * n determinant calculations of original matrix, - * so do cache result of this function in performance critical context. + * This operation requires **O(n! + 1)** determinant calculations of original matrix, + * so do cache result of this function in performance critical context, + * because it is calculated analytically. * * If determinant is zero, null is returned. * diff --git a/src/test/kotlin/ru/dbotthepony/kstarbound/test/MathTests.kt b/src/test/kotlin/ru/dbotthepony/kstarbound/test/MathTests.kt index 5e6bb18e..1633c4a7 100644 --- a/src/test/kotlin/ru/dbotthepony/kstarbound/test/MathTests.kt +++ b/src/test/kotlin/ru/dbotthepony/kstarbound/test/MathTests.kt @@ -10,7 +10,10 @@ import ru.dbotthepony.kstarbound.world.ChunkPos import ru.dbotthepony.kvector.matrix.adjugateMatrix import ru.dbotthepony.kvector.matrix.multiplyMatrix import ru.dbotthepony.kvector.matrix.inverseMatrix +import ru.dbotthepony.kvector.matrix.ndouble.MatrixVd +import ru.dbotthepony.kvector.matrix.ndouble.MutableMatrixVd import ru.dbotthepony.kvector.narray.Double2Dimensional +import java.util.* object MathTests { @Test