Merge pull request #183 from mipt-npm/commandertvis/hermitian-conjugate

Add transposeConjugate function for Complex and Double (conjugates are not cached). Minor refactoring of MatrixContext and API reference changes
This commit is contained in:
Alexander Nozik 2021-02-11 11:06:38 +03:00 committed by GitHub
commit bca36529a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 2 deletions

View File

@ -9,7 +9,10 @@ import kscience.kmath.structures.BufferFactory
import kscience.kmath.structures.asSequence import kscience.kmath.structures.asSequence
/** /**
* Basic operations on matrices. Operates on [Matrix] * Basic operations on matrices. Operates on [Matrix].
*
* @param T the type of items in the matrices.
* @param M the type of operated matrices.
*/ */
public interface MatrixContext<T : Any, out M : Matrix<T>> : SpaceOperations<Matrix<T>> { public interface MatrixContext<T : Any, out M : Matrix<T>> : SpaceOperations<Matrix<T>> {
/** /**
@ -83,9 +86,16 @@ public interface MatrixContext<T : Any, out M : Matrix<T>> : SpaceOperations<Mat
} }
} }
/**
* Partial implementation of [MatrixContext] for matrices of [Ring].
*
* @param T the type of items in the matrices.
* @param R the type of ring of matrix elements.
* @param M the type of operated matrices.
*/
public interface GenericMatrixContext<T : Any, R : Ring<T>, out M : Matrix<T>> : MatrixContext<T, M> { public interface GenericMatrixContext<T : Any, R : Ring<T>, out M : Matrix<T>> : MatrixContext<T, M> {
/** /**
* The ring context for matrix elements * The ring over matrix elements.
*/ */
public val elementContext: R public val elementContext: R

View File

@ -1,5 +1,10 @@
package kscience.kmath.linear package kscience.kmath.linear
/**
* The matrix where each element is evaluated each time when is being accessed.
*
* @property generator the function that provides elements.
*/
public class VirtualMatrix<T : Any>( public class VirtualMatrix<T : Any>(
override val rowNum: Int, override val rowNum: Int,
override val colNum: Int, override val colNum: Int,

View File

@ -86,3 +86,10 @@ public fun <T> NDStructure<T>.as2D(): Structure2D<T> = if (shape.size == 2)
Structure2DWrapper(this) Structure2DWrapper(this)
else else
error("Can't create 2d-structure from ${shape.size}d-structure") error("Can't create 2d-structure from ${shape.size}d-structure")
/**
* Alias for [Structure2D] with more familiar name.
*
* @param T the type of items in the matrix.
*/
public typealias Matrix<T> = Structure2D<T>