Clarify inverse and cofactor

This commit is contained in:
DBotThePony 2022-02-19 21:10:03 +07:00
parent d0b3c7347c
commit d1c71f4a2a
Signed by: DBot
GPG Key ID: DCC23B5715498507
2 changed files with 15 additions and 8 deletions

View File

@ -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.
*

View File

@ -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