forked from kscience/kmath
Merge pull request #198 from mipt-npm/commandertvis/fix-lup-capitalization
Fix capitalization of LUP in reference names
This commit is contained in:
commit
6cfabbe7ef
@ -32,9 +32,10 @@
|
|||||||
- Use `Point<Double>` instead of specialized type in `kmath-for-real`
|
- Use `Point<Double>` instead of specialized type in `kmath-for-real`
|
||||||
- Optimized dot product for buffer matrices moved to `kmath-for-real`
|
- Optimized dot product for buffer matrices moved to `kmath-for-real`
|
||||||
- EjmlMatrix context is an object
|
- EjmlMatrix context is an object
|
||||||
- Matrix LUP `inverse` renamed to `inverseWithLUP`
|
- Matrix LUP `inverse` renamed to `inverseWithLup`
|
||||||
- `NumericAlgebra` moved outside of regular algebra chain (`Ring` no longer implements it).
|
- `NumericAlgebra` moved outside of regular algebra chain (`Ring` no longer implements it).
|
||||||
- Features moved to NDStructure and became transparent.
|
- Features moved to NDStructure and became transparent.
|
||||||
|
- Capitalization of LUP in many names changed to Lup.
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
||||||
|
@ -26,8 +26,8 @@ class LinearAlgebraBenchmark {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
fun kmathLUPInversion() {
|
fun kmathLupInversion() {
|
||||||
MatrixContext.real.inverseWithLUP(matrix)
|
MatrixContext.real.inverseWithLup(matrix)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Benchmark
|
@Benchmark
|
||||||
|
@ -151,7 +151,7 @@ public inline fun <reified T : Comparable<T>, F : Field<T>> GenericMatrixContext
|
|||||||
public fun MatrixContext<Double, Matrix<Double>>.lup(matrix: Matrix<Double>): LupDecomposition<Double> =
|
public fun MatrixContext<Double, Matrix<Double>>.lup(matrix: Matrix<Double>): LupDecomposition<Double> =
|
||||||
lup(Buffer.Companion::real, RealField, matrix) { it < 1e-11 }
|
lup(Buffer.Companion::real, RealField, matrix) { it < 1e-11 }
|
||||||
|
|
||||||
public fun <T : Any> LupDecomposition<T>.solveWithLUP(
|
public fun <T : Any> LupDecomposition<T>.solveWithLup(
|
||||||
factory: MutableBufferFactory<T>,
|
factory: MutableBufferFactory<T>,
|
||||||
matrix: Matrix<T>,
|
matrix: Matrix<T>,
|
||||||
): Matrix<T> {
|
): Matrix<T> {
|
||||||
@ -199,14 +199,14 @@ public fun <T : Any> LupDecomposition<T>.solveWithLUP(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public inline fun <reified T : Any> LupDecomposition<T>.solveWithLUP(matrix: Matrix<T>): Matrix<T> =
|
public inline fun <reified T : Any> LupDecomposition<T>.solveWithLup(matrix: Matrix<T>): Matrix<T> =
|
||||||
solveWithLUP(MutableBuffer.Companion::auto, matrix)
|
solveWithLup(MutableBuffer.Companion::auto, matrix)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Solve a linear equation **a*x = b** using LUP decomposition
|
* Solves a system of linear equations *ax = b** using LUP decomposition.
|
||||||
*/
|
*/
|
||||||
@OptIn(UnstableKMathAPI::class)
|
@OptIn(UnstableKMathAPI::class)
|
||||||
public inline fun <reified T : Comparable<T>, F : Field<T>> GenericMatrixContext<T, F, Matrix<T>>.solveWithLUP(
|
public inline fun <reified T : Comparable<T>, F : Field<T>> GenericMatrixContext<T, F, Matrix<T>>.solveWithLup(
|
||||||
a: Matrix<T>,
|
a: Matrix<T>,
|
||||||
b: Matrix<T>,
|
b: Matrix<T>,
|
||||||
noinline bufferFactory: MutableBufferFactory<T> = MutableBuffer.Companion::auto,
|
noinline bufferFactory: MutableBufferFactory<T> = MutableBuffer.Companion::auto,
|
||||||
@ -214,26 +214,26 @@ public inline fun <reified T : Comparable<T>, F : Field<T>> GenericMatrixContext
|
|||||||
): Matrix<T> {
|
): Matrix<T> {
|
||||||
// Use existing decomposition if it is provided by matrix
|
// Use existing decomposition if it is provided by matrix
|
||||||
val decomposition = a.getFeature() ?: lup(bufferFactory, elementContext, a, checkSingular)
|
val decomposition = a.getFeature() ?: lup(bufferFactory, elementContext, a, checkSingular)
|
||||||
return decomposition.solveWithLUP(bufferFactory, b)
|
return decomposition.solveWithLup(bufferFactory, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
public inline fun <reified T : Comparable<T>, F : Field<T>> GenericMatrixContext<T, F, Matrix<T>>.inverseWithLUP(
|
public inline fun <reified T : Comparable<T>, F : Field<T>> GenericMatrixContext<T, F, Matrix<T>>.inverseWithLup(
|
||||||
matrix: Matrix<T>,
|
matrix: Matrix<T>,
|
||||||
noinline bufferFactory: MutableBufferFactory<T> = MutableBuffer.Companion::auto,
|
noinline bufferFactory: MutableBufferFactory<T> = MutableBuffer.Companion::auto,
|
||||||
noinline checkSingular: (T) -> Boolean,
|
noinline checkSingular: (T) -> Boolean,
|
||||||
): Matrix<T> = solveWithLUP(matrix, one(matrix.rowNum, matrix.colNum), bufferFactory, checkSingular)
|
): Matrix<T> = solveWithLup(matrix, one(matrix.rowNum, matrix.colNum), bufferFactory, checkSingular)
|
||||||
|
|
||||||
|
|
||||||
@OptIn(UnstableKMathAPI::class)
|
@OptIn(UnstableKMathAPI::class)
|
||||||
public fun RealMatrixContext.solveWithLUP(a: Matrix<Double>, b: Matrix<Double>): Matrix<Double> {
|
public fun RealMatrixContext.solveWithLup(a: Matrix<Double>, b: Matrix<Double>): Matrix<Double> {
|
||||||
// Use existing decomposition if it is provided by matrix
|
// Use existing decomposition if it is provided by matrix
|
||||||
val bufferFactory: MutableBufferFactory<Double> = MutableBuffer.Companion::real
|
val bufferFactory: MutableBufferFactory<Double> = MutableBuffer.Companion::real
|
||||||
val decomposition: LupDecomposition<Double> = a.getFeature() ?: lup(bufferFactory, RealField, a) { it < 1e-11 }
|
val decomposition: LupDecomposition<Double> = a.getFeature() ?: lup(bufferFactory, RealField, a) { it < 1e-11 }
|
||||||
return decomposition.solveWithLUP(bufferFactory, b)
|
return decomposition.solveWithLup(bufferFactory, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inverses a square matrix using LUP decomposition. Non square matrix will throw a error.
|
* Inverses a square matrix using LUP decomposition. Non square matrix will throw a error.
|
||||||
*/
|
*/
|
||||||
public fun RealMatrixContext.inverseWithLUP(matrix: Matrix<Double>): Matrix<Double> =
|
public fun RealMatrixContext.inverseWithLup(matrix: Matrix<Double>): Matrix<Double> =
|
||||||
solveWithLUP(matrix, one(matrix.rowNum, matrix.colNum))
|
solveWithLup(matrix, one(matrix.rowNum, matrix.colNum))
|
@ -9,7 +9,7 @@ class RealLUSolverTest {
|
|||||||
@Test
|
@Test
|
||||||
fun testInvertOne() {
|
fun testInvertOne() {
|
||||||
val matrix = MatrixContext.real.one(2, 2)
|
val matrix = MatrixContext.real.one(2, 2)
|
||||||
val inverted = MatrixContext.real.inverseWithLUP(matrix)
|
val inverted = MatrixContext.real.inverseWithLup(matrix)
|
||||||
assertEquals(matrix, inverted)
|
assertEquals(matrix, inverted)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ class RealLUSolverTest {
|
|||||||
1.0, 3.0
|
1.0, 3.0
|
||||||
)
|
)
|
||||||
|
|
||||||
val inverted = MatrixContext.real.inverseWithLUP(matrix)
|
val inverted = MatrixContext.real.inverseWithLup(matrix)
|
||||||
|
|
||||||
val expected = Matrix.square(
|
val expected = Matrix.square(
|
||||||
0.375, -0.125,
|
0.375, -0.125,
|
||||||
|
@ -2,7 +2,7 @@ package kscience.kmath.real
|
|||||||
|
|
||||||
import kscience.kmath.linear.MatrixContext
|
import kscience.kmath.linear.MatrixContext
|
||||||
import kscience.kmath.linear.VirtualMatrix
|
import kscience.kmath.linear.VirtualMatrix
|
||||||
import kscience.kmath.linear.inverseWithLUP
|
import kscience.kmath.linear.inverseWithLup
|
||||||
import kscience.kmath.linear.real
|
import kscience.kmath.linear.real
|
||||||
import kscience.kmath.misc.UnstableKMathAPI
|
import kscience.kmath.misc.UnstableKMathAPI
|
||||||
import kscience.kmath.structures.Buffer
|
import kscience.kmath.structures.Buffer
|
||||||
@ -152,7 +152,7 @@ public inline fun RealMatrix.map(transform: (Double) -> Double): RealMatrix =
|
|||||||
/**
|
/**
|
||||||
* Inverse a square real matrix using LUP decomposition
|
* Inverse a square real matrix using LUP decomposition
|
||||||
*/
|
*/
|
||||||
public fun RealMatrix.inverseWithLUP(): RealMatrix = MatrixContext.real.inverseWithLUP(this)
|
public fun RealMatrix.inverseWithLup(): RealMatrix = MatrixContext.real.inverseWithLup(this)
|
||||||
|
|
||||||
//extended operations
|
//extended operations
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user