Add out variance to StructureND and some related types, make some unrelated changes
This commit is contained in:
parent
5d2fff6575
commit
d7a4228f5f
19
CHANGELOG.md
19
CHANGELOG.md
@ -20,19 +20,20 @@
|
|||||||
- Space is replaced by Group. Space is reserved for vector spaces.
|
- Space is replaced by Group. Space is reserved for vector spaces.
|
||||||
- VectorSpace is now a vector space
|
- VectorSpace is now a vector space
|
||||||
- Buffer factories for primitives moved to MutableBuffer.Companion
|
- Buffer factories for primitives moved to MutableBuffer.Companion
|
||||||
- NDStructure and NDAlgebra to StructureND and AlgebraND respectively
|
- Rename `NDStructure` and `NDAlgebra` to `StructureND` and `AlgebraND` respectively
|
||||||
- Real -> Double
|
- `Real` -> `Double`
|
||||||
- DataSets are moved from functions to core
|
- DataSets are moved from functions to core
|
||||||
- Redesign advanced Chain API
|
- Redesign advanced Chain API
|
||||||
- Redesign MST. Remove MSTExpression.
|
- Redesign `MST`. Remove `MstExpression`.
|
||||||
- Move MST to core
|
- Move `MST` to core
|
||||||
- Separated benchmarks and examples
|
- Separated benchmarks and examples
|
||||||
- Rewritten EJML module without ejml-simple
|
- Rewrite `kmath-ejml` without `ejml-simple` artifact, support sparse matrices
|
||||||
- Stability of kmath-ast and kmath-kotilngrad promoted to EXPERIMENTAL.
|
- Promote stability of kmath-ast and kmath-kotlingrad to EXPERIMENTAL.
|
||||||
- ColumnarData returns nullable column
|
- ColumnarData returns nullable column
|
||||||
- MST is made sealed interface
|
- `MST` is made sealed interface
|
||||||
- Replaced MST.Symbolic by Symbol, Symbol now implements MST
|
- Replace `MST.Symbolic` by `Symbol`, `Symbol` now implements MST
|
||||||
- Removed Any restriction on polynomials
|
- Remove Any restriction on polynomials
|
||||||
|
- Add `out` variance to type parameters of `StructureND` and its implementations where possible
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
||||||
|
15
README.md
15
README.md
@ -40,7 +40,7 @@ KMath is a modular library. Different modules provide different features with di
|
|||||||
|
|
||||||
* **PROTOTYPE**. On this level there are no compatibility guarantees. All methods and classes form those modules could break any moment. You can still use it, but be sure to fix the specific version.
|
* **PROTOTYPE**. On this level there are no compatibility guarantees. All methods and classes form those modules could break any moment. You can still use it, but be sure to fix the specific version.
|
||||||
* **EXPERIMENTAL**. The general API is decided, but some changes could be made. Volatile API is marked with `@UnstableKmathAPI` or other stability warning annotations.
|
* **EXPERIMENTAL**. The general API is decided, but some changes could be made. Volatile API is marked with `@UnstableKmathAPI` or other stability warning annotations.
|
||||||
* **DEVELOPMENT**. API breaking genrally follows semantic versioning ideology. There could be changes in minor versions, but not in patch versions. API is protected with [binary-compatibility-validator](https://github.com/Kotlin/binary-compatibility-validator) tool.
|
* **DEVELOPMENT**. API breaking generally follows semantic versioning ideology. There could be changes in minor versions, but not in patch versions. API is protected with [binary-compatibility-validator](https://github.com/Kotlin/binary-compatibility-validator) tool.
|
||||||
* **STABLE**. The API stabilized. Breaking changes are allowed only in major releases.
|
* **STABLE**. The API stabilized. Breaking changes are allowed only in major releases.
|
||||||
|
|
||||||
<!--Current feature list is [here](/docs/features.md)-->
|
<!--Current feature list is [here](/docs/features.md)-->
|
||||||
@ -213,7 +213,7 @@ One can still use generic algebras though.
|
|||||||
>
|
>
|
||||||
> **Features:**
|
> **Features:**
|
||||||
> - [differentiable-mst-expression](kmath-kotlingrad/src/main/kotlin/space/kscience/kmath/kotlingrad/DifferentiableMstExpression.kt) : MST based DifferentiableExpression.
|
> - [differentiable-mst-expression](kmath-kotlingrad/src/main/kotlin/space/kscience/kmath/kotlingrad/DifferentiableMstExpression.kt) : MST based DifferentiableExpression.
|
||||||
> - [differentiable-mst-expression](kmath-kotlingrad/src/main/kotlin/space/kscience/kmath/kotlingrad/DifferentiableMstExpression.kt) : Conversions between Kotlin∇'s SFun and MST
|
> - [differentiable-mst-expression](kmath-kotlingrad/src/main/kotlin/space/kscience/kmath/kotlingrad/DifferentiableMstExpression.kt) : Conversions between Kotlin∇'s SFun and MST
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
|
|
||||||
@ -247,10 +247,9 @@ One can still use generic algebras though.
|
|||||||
> **Maturity**: PROTOTYPE
|
> **Maturity**: PROTOTYPE
|
||||||
>
|
>
|
||||||
> **Features:**
|
> **Features:**
|
||||||
> - [tensor algebra](kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/TensorAlgebra.kt) : Interface for basic linear algebra operations on tensors (plus, dot, etc.)
|
> - [tensor algebra](kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/TensorAlgebra.kt) : Basic linear algebra operations on tensors (plus, dot, etc.)
|
||||||
> - [linear algebra operations](kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/LinearOpsTensorAlgebra.kt) : Interface for advanced linear algebra operations like LU decomposition, SVD, etc.
|
> - [tensor algebra with broadcasting](kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/core/algebras/BroadcastDoubleTensorAlgebra.kt) : Basic linear algebra operations implemented with broadcasting.
|
||||||
> - [tensor algebra over Double](kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/core/DoubleTensorAlgebra.kt): Full implementation of operations for tensors over `Double`'s.
|
> - [linear algebra operations](kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/api/LinearOpsTensorAlgebra.kt) : Advanced linear algebra operations like LU decomposition, SVD, etc.
|
||||||
> - [tensor algebra with broadcasting](kmath-tensors/src/commonMain/kotlin/space/kscience/kmath/tensors/core/BroadcastDoubleTensorAlgebra.kt) : Basic linear algebra operations implemented with broadcasting for tensors over `Double`'s.
|
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
|
|
||||||
@ -294,8 +293,8 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
api("space.kscience:kmath-core:0.3.0-dev-8")
|
api("space.kscience:kmath-core:0.3.0-dev-11")
|
||||||
// api("space.kscience:kmath-core-jvm:0.3.0-dev-8") for jvm-specific version
|
// api("space.kscience:kmath-core-jvm:0.3.0-dev-11") for jvm-specific version
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
2
docs/templates/README-TEMPLATE.md
vendored
2
docs/templates/README-TEMPLATE.md
vendored
@ -40,7 +40,7 @@ KMath is a modular library. Different modules provide different features with di
|
|||||||
|
|
||||||
* **PROTOTYPE**. On this level there are no compatibility guarantees. All methods and classes form those modules could break any moment. You can still use it, but be sure to fix the specific version.
|
* **PROTOTYPE**. On this level there are no compatibility guarantees. All methods and classes form those modules could break any moment. You can still use it, but be sure to fix the specific version.
|
||||||
* **EXPERIMENTAL**. The general API is decided, but some changes could be made. Volatile API is marked with `@UnstableKmathAPI` or other stability warning annotations.
|
* **EXPERIMENTAL**. The general API is decided, but some changes could be made. Volatile API is marked with `@UnstableKmathAPI` or other stability warning annotations.
|
||||||
* **DEVELOPMENT**. API breaking genrally follows semantic versioning ideology. There could be changes in minor versions, but not in patch versions. API is protected with [binary-compatibility-validator](https://github.com/Kotlin/binary-compatibility-validator) tool.
|
* **DEVELOPMENT**. API breaking generally follows semantic versioning ideology. There could be changes in minor versions, but not in patch versions. API is protected with [binary-compatibility-validator](https://github.com/Kotlin/binary-compatibility-validator) tool.
|
||||||
* **STABLE**. The API stabilized. Breaking changes are allowed only in major releases.
|
* **STABLE**. The API stabilized. Breaking changes are allowed only in major releases.
|
||||||
|
|
||||||
<!--Current feature list is [here](/docs/features.md)-->
|
<!--Current feature list is [here](/docs/features.md)-->
|
||||||
|
@ -11,7 +11,7 @@ import space.kscience.kmath.tensors.core.BroadcastDoubleTensorAlgebra
|
|||||||
|
|
||||||
// simple PCA
|
// simple PCA
|
||||||
|
|
||||||
fun main() = BroadcastDoubleTensorAlgebra { // work in context with broadcast methods
|
fun main(): Unit = BroadcastDoubleTensorAlgebra { // work in context with broadcast methods
|
||||||
val seed = 100500L
|
val seed = 100500L
|
||||||
|
|
||||||
// assume x is range from 0 until 10
|
// assume x is range from 0 until 10
|
||||||
|
@ -10,7 +10,7 @@ Performance and visualization extensions to MST API.
|
|||||||
|
|
||||||
## Artifact:
|
## Artifact:
|
||||||
|
|
||||||
The Maven coordinates of this project are `space.kscience:kmath-ast:0.3.0-dev-8`.
|
The Maven coordinates of this project are `space.kscience:kmath-ast:0.3.0-dev-11`.
|
||||||
|
|
||||||
**Gradle:**
|
**Gradle:**
|
||||||
```gradle
|
```gradle
|
||||||
@ -20,7 +20,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'space.kscience:kmath-ast:0.3.0-dev-8'
|
implementation 'space.kscience:kmath-ast:0.3.0-dev-11'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
**Gradle Kotlin DSL:**
|
**Gradle Kotlin DSL:**
|
||||||
@ -31,7 +31,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("space.kscience:kmath-ast:0.3.0-dev-8")
|
implementation("space.kscience:kmath-ast:0.3.0-dev-11")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ Complex and hypercomplex number systems in KMath.
|
|||||||
|
|
||||||
## Artifact:
|
## Artifact:
|
||||||
|
|
||||||
The Maven coordinates of this project are `space.kscience:kmath-complex:0.3.0-dev-8`.
|
The Maven coordinates of this project are `space.kscience:kmath-complex:0.3.0-dev-11`.
|
||||||
|
|
||||||
**Gradle:**
|
**Gradle:**
|
||||||
```gradle
|
```gradle
|
||||||
@ -18,7 +18,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'space.kscience:kmath-complex:0.3.0-dev-8'
|
implementation 'space.kscience:kmath-complex:0.3.0-dev-11'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
**Gradle Kotlin DSL:**
|
**Gradle Kotlin DSL:**
|
||||||
@ -29,6 +29,6 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("space.kscience:kmath-complex:0.3.0-dev-8")
|
implementation("space.kscience:kmath-complex:0.3.0-dev-11")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -15,7 +15,7 @@ performance calculations to code generation.
|
|||||||
|
|
||||||
## Artifact:
|
## Artifact:
|
||||||
|
|
||||||
The Maven coordinates of this project are `space.kscience:kmath-core:0.3.0-dev-8`.
|
The Maven coordinates of this project are `space.kscience:kmath-core:0.3.0-dev-11`.
|
||||||
|
|
||||||
**Gradle:**
|
**Gradle:**
|
||||||
```gradle
|
```gradle
|
||||||
@ -25,7 +25,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'space.kscience:kmath-core:0.3.0-dev-8'
|
implementation 'space.kscience:kmath-core:0.3.0-dev-11'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
**Gradle Kotlin DSL:**
|
**Gradle Kotlin DSL:**
|
||||||
@ -36,6 +36,6 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("space.kscience:kmath-core:0.3.0-dev-8")
|
implementation("space.kscience:kmath-core:0.3.0-dev-11")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -8,7 +8,7 @@ package space.kscience.kmath.linear
|
|||||||
import space.kscience.kmath.misc.UnstableKMathAPI
|
import space.kscience.kmath.misc.UnstableKMathAPI
|
||||||
import space.kscience.kmath.operations.Ring
|
import space.kscience.kmath.operations.Ring
|
||||||
|
|
||||||
public class MatrixBuilder<T : Any, A : Ring<T>>(
|
public class MatrixBuilder<T : Any, out A : Ring<T>>(
|
||||||
public val linearSpace: LinearSpace<T, A>,
|
public val linearSpace: LinearSpace<T, A>,
|
||||||
public val rows: Int,
|
public val rows: Int,
|
||||||
public val columns: Int,
|
public val columns: Int,
|
||||||
|
@ -16,7 +16,7 @@ import kotlin.reflect.KClass
|
|||||||
*
|
*
|
||||||
* @param T the type of items.
|
* @param T the type of items.
|
||||||
*/
|
*/
|
||||||
public class MatrixWrapper<T : Any> internal constructor(
|
public class MatrixWrapper<out T : Any> internal constructor(
|
||||||
public val origin: Matrix<T>,
|
public val origin: Matrix<T>,
|
||||||
public val features: Set<MatrixFeature>,
|
public val features: Set<MatrixFeature>,
|
||||||
) : Matrix<T> by origin {
|
) : Matrix<T> by origin {
|
||||||
@ -26,12 +26,11 @@ public class MatrixWrapper<T : Any> internal constructor(
|
|||||||
*/
|
*/
|
||||||
@UnstableKMathAPI
|
@UnstableKMathAPI
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
override fun <F : StructureFeature> getFeature(type: KClass<out F>): F? = features.singleOrNull { type.isInstance(it) } as? F
|
public override fun <F : StructureFeature> getFeature(type: KClass<out F>): F? =
|
||||||
?: origin.getFeature(type)
|
features.singleOrNull(type::isInstance) as? F
|
||||||
|
?: origin.getFeature(type)
|
||||||
|
|
||||||
override fun toString(): String {
|
public override fun toString(): String = "MatrixWrapper(matrix=$origin, features=$features)"
|
||||||
return "MatrixWrapper(matrix=$origin, features=$features)"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -82,7 +81,7 @@ public fun <T : Any> LinearSpace<T, Ring<T>>.zero(
|
|||||||
elementAlgebra.zero
|
elementAlgebra.zero
|
||||||
} + ZeroFeature
|
} + ZeroFeature
|
||||||
|
|
||||||
public class TransposedFeature<T : Any>(public val original: Matrix<T>) : MatrixFeature
|
public class TransposedFeature<out T : Any>(public val original: Matrix<T>) : MatrixFeature
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a virtual transposed matrix without copying anything. `A.transpose().transpose() === A`
|
* Create a virtual transposed matrix without copying anything. `A.transpose().transpose() === A`
|
||||||
|
@ -10,7 +10,7 @@ package space.kscience.kmath.linear
|
|||||||
*
|
*
|
||||||
* @property generator the function that provides elements.
|
* @property generator the function that provides elements.
|
||||||
*/
|
*/
|
||||||
public class VirtualMatrix<T : Any>(
|
public class VirtualMatrix<out T : Any>(
|
||||||
override val rowNum: Int,
|
override val rowNum: Int,
|
||||||
override val colNum: Int,
|
override val colNum: Int,
|
||||||
public val generator: (i: Int, j: Int) -> T,
|
public val generator: (i: Int, j: Int) -> T,
|
||||||
|
@ -26,7 +26,7 @@ public class ShapeMismatchException(public val expected: IntArray, public val ac
|
|||||||
* @param C the type of the element context.
|
* @param C the type of the element context.
|
||||||
* @param N the type of the structure.
|
* @param N the type of the structure.
|
||||||
*/
|
*/
|
||||||
public interface AlgebraND<T, C : Algebra<T>> {
|
public interface AlgebraND<T, out C : Algebra<T>> {
|
||||||
/**
|
/**
|
||||||
* The shape of ND-structures this algebra operates on.
|
* The shape of ND-structures this algebra operates on.
|
||||||
*/
|
*/
|
||||||
@ -121,7 +121,7 @@ internal fun <T, C : Algebra<T>> AlgebraND<T, C>.checkShape(element: StructureND
|
|||||||
* @param N the type of ND structure.
|
* @param N the type of ND structure.
|
||||||
* @param S the type of space of structure elements.
|
* @param S the type of space of structure elements.
|
||||||
*/
|
*/
|
||||||
public interface GroupND<T, S : Group<T>> : Group<StructureND<T>>, AlgebraND<T, S> {
|
public interface GroupND<T, out S : Group<T>> : Group<StructureND<T>>, AlgebraND<T, S> {
|
||||||
/**
|
/**
|
||||||
* Element-wise addition.
|
* Element-wise addition.
|
||||||
*
|
*
|
||||||
@ -189,7 +189,7 @@ public interface GroupND<T, S : Group<T>> : Group<StructureND<T>>, AlgebraND<T,
|
|||||||
* @param N the type of ND structure.
|
* @param N the type of ND structure.
|
||||||
* @param R the type of ring of structure elements.
|
* @param R the type of ring of structure elements.
|
||||||
*/
|
*/
|
||||||
public interface RingND<T, R : Ring<T>> : Ring<StructureND<T>>, GroupND<T, R> {
|
public interface RingND<T, out R : Ring<T>> : Ring<StructureND<T>>, GroupND<T, R> {
|
||||||
/**
|
/**
|
||||||
* Element-wise multiplication.
|
* Element-wise multiplication.
|
||||||
*
|
*
|
||||||
@ -230,7 +230,7 @@ public interface RingND<T, R : Ring<T>> : Ring<StructureND<T>>, GroupND<T, R> {
|
|||||||
* @param N the type of ND structure.
|
* @param N the type of ND structure.
|
||||||
* @param F the type field of structure elements.
|
* @param F the type field of structure elements.
|
||||||
*/
|
*/
|
||||||
public interface FieldND<T, F : Field<T>> : Field<StructureND<T>>, RingND<T, F>, ScaleOperations<StructureND<T>> {
|
public interface FieldND<T, out F : Field<T>> : Field<StructureND<T>>, RingND<T, F>, ScaleOperations<StructureND<T>> {
|
||||||
/**
|
/**
|
||||||
* Element-wise division.
|
* Element-wise division.
|
||||||
*
|
*
|
||||||
|
@ -11,7 +11,7 @@ import space.kscience.kmath.structures.BufferFactory
|
|||||||
import kotlin.contracts.InvocationKind
|
import kotlin.contracts.InvocationKind
|
||||||
import kotlin.contracts.contract
|
import kotlin.contracts.contract
|
||||||
|
|
||||||
public interface BufferAlgebraND<T, A : Algebra<T>> : AlgebraND<T, A> {
|
public interface BufferAlgebraND<T, out A : Algebra<T>> : AlgebraND<T, A> {
|
||||||
public val strides: Strides
|
public val strides: Strides
|
||||||
public val bufferFactory: BufferFactory<T>
|
public val bufferFactory: BufferFactory<T>
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ import space.kscience.kmath.structures.MutableBufferFactory
|
|||||||
* @param strides The strides to access elements of [Buffer] by linear indices.
|
* @param strides The strides to access elements of [Buffer] by linear indices.
|
||||||
* @param buffer The underlying buffer.
|
* @param buffer The underlying buffer.
|
||||||
*/
|
*/
|
||||||
public open class BufferND<T>(
|
public open class BufferND<out T>(
|
||||||
public val strides: Strides,
|
public val strides: Strides,
|
||||||
public val buffer: Buffer<T>,
|
public val buffer: Buffer<T>,
|
||||||
) : StructureND<T> {
|
) : StructureND<T> {
|
||||||
|
@ -15,7 +15,7 @@ import kotlin.jvm.JvmInline
|
|||||||
/**
|
/**
|
||||||
* A structure that is guaranteed to be one-dimensional
|
* A structure that is guaranteed to be one-dimensional
|
||||||
*/
|
*/
|
||||||
public interface Structure1D<T> : StructureND<T>, Buffer<T> {
|
public interface Structure1D<out T> : StructureND<T>, Buffer<T> {
|
||||||
public override val dimension: Int get() = 1
|
public override val dimension: Int get() = 1
|
||||||
|
|
||||||
public override operator fun get(index: IntArray): T {
|
public override operator fun get(index: IntArray): T {
|
||||||
@ -42,7 +42,7 @@ public interface MutableStructure1D<T> : Structure1D<T>, MutableStructureND<T>,
|
|||||||
* A 1D wrapper for nd-structure
|
* A 1D wrapper for nd-structure
|
||||||
*/
|
*/
|
||||||
@JvmInline
|
@JvmInline
|
||||||
private value class Structure1DWrapper<T>(val structure: StructureND<T>) : Structure1D<T> {
|
private value class Structure1DWrapper<out T>(val structure: StructureND<T>) : Structure1D<T> {
|
||||||
override val shape: IntArray get() = structure.shape
|
override val shape: IntArray get() = structure.shape
|
||||||
override val size: Int get() = structure.shape[0]
|
override val size: Int get() = structure.shape[0]
|
||||||
|
|
||||||
@ -68,7 +68,11 @@ private class MutableStructure1DWrapper<T>(val structure: MutableStructureND<T>)
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PerformancePitfall
|
@PerformancePitfall
|
||||||
override fun copy(): MutableBuffer<T> = structure.elements().map { it.second }.toMutableList().asMutableBuffer()
|
override fun copy(): MutableBuffer<T> = structure
|
||||||
|
.elements()
|
||||||
|
.map(Pair<IntArray, T>::second)
|
||||||
|
.toMutableList()
|
||||||
|
.asMutableBuffer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -76,7 +80,7 @@ private class MutableStructure1DWrapper<T>(val structure: MutableStructureND<T>)
|
|||||||
* A structure wrapper for buffer
|
* A structure wrapper for buffer
|
||||||
*/
|
*/
|
||||||
@JvmInline
|
@JvmInline
|
||||||
private value class Buffer1DWrapper<T>(val buffer: Buffer<T>) : Structure1D<T> {
|
private value class Buffer1DWrapper<out T>(val buffer: Buffer<T>) : Structure1D<T> {
|
||||||
override val shape: IntArray get() = intArrayOf(buffer.size)
|
override val shape: IntArray get() = intArrayOf(buffer.size)
|
||||||
override val size: Int get() = buffer.size
|
override val size: Int get() = buffer.size
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ import kotlin.reflect.KClass
|
|||||||
*
|
*
|
||||||
* @param T the type of items.
|
* @param T the type of items.
|
||||||
*/
|
*/
|
||||||
public interface Structure2D<T> : StructureND<T> {
|
public interface Structure2D<out T> : StructureND<T> {
|
||||||
/**
|
/**
|
||||||
* The number of rows in this structure.
|
* The number of rows in this structure.
|
||||||
*/
|
*/
|
||||||
@ -100,7 +100,7 @@ public interface MutableStructure2D<T> : Structure2D<T>, MutableStructureND<T> {
|
|||||||
* A 2D wrapper for nd-structure
|
* A 2D wrapper for nd-structure
|
||||||
*/
|
*/
|
||||||
@JvmInline
|
@JvmInline
|
||||||
private value class Structure2DWrapper<T>(val structure: StructureND<T>) : Structure2D<T> {
|
private value class Structure2DWrapper<out T>(val structure: StructureND<T>) : Structure2D<T> {
|
||||||
override val shape: IntArray get() = structure.shape
|
override val shape: IntArray get() = structure.shape
|
||||||
|
|
||||||
override val rowNum: Int get() = shape[0]
|
override val rowNum: Int get() = shape[0]
|
||||||
|
@ -24,7 +24,7 @@ public interface StructureFeature
|
|||||||
*
|
*
|
||||||
* @param T the type of items.
|
* @param T the type of items.
|
||||||
*/
|
*/
|
||||||
public interface StructureND<T> {
|
public interface StructureND<out T> {
|
||||||
/**
|
/**
|
||||||
* The shape of structure, i.e. non-empty sequence of non-negative integers that specify sizes of dimensions of
|
* The shape of structure, i.e. non-empty sequence of non-negative integers that specify sizes of dimensions of
|
||||||
* this structure.
|
* this structure.
|
||||||
@ -213,9 +213,7 @@ public interface Strides {
|
|||||||
/**
|
/**
|
||||||
* Iterate over ND indices in a natural order
|
* Iterate over ND indices in a natural order
|
||||||
*/
|
*/
|
||||||
public fun indices(): Sequence<IntArray> = (0 until linearSize).asSequence().map {
|
public fun indices(): Sequence<IntArray> = (0 until linearSize).asSequence().map(::index)
|
||||||
index(it)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -283,7 +283,7 @@ public value class ReadOnlyBuffer<T>(public val buffer: MutableBuffer<T>) : Buff
|
|||||||
*
|
*
|
||||||
* @param T the type of elements provided by the buffer.
|
* @param T the type of elements provided by the buffer.
|
||||||
*/
|
*/
|
||||||
public class VirtualBuffer<T>(override val size: Int, private val generator: (Int) -> T) : Buffer<T> {
|
public class VirtualBuffer<out T>(override val size: Int, private val generator: (Int) -> T) : Buffer<T> {
|
||||||
override operator fun get(index: Int): T {
|
override operator fun get(index: Int): T {
|
||||||
if (index < 0 || index >= size) throw IndexOutOfBoundsException("Expected index from 0 to ${size - 1}, but found $index")
|
if (index < 0 || index >= size) throw IndexOutOfBoundsException("Expected index from 0 to ${size - 1}, but found $index")
|
||||||
return generator(index)
|
return generator(index)
|
||||||
|
@ -37,7 +37,7 @@ public enum class ValueFlag(public val mask: Byte) {
|
|||||||
/**
|
/**
|
||||||
* A buffer with flagged values.
|
* A buffer with flagged values.
|
||||||
*/
|
*/
|
||||||
public interface FlaggedBuffer<T> : Buffer<T> {
|
public interface FlaggedBuffer<out T> : Buffer<T> {
|
||||||
public fun getFlag(index: Int): Byte
|
public fun getFlag(index: Int): Byte
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ import kotlin.test.Test
|
|||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
import kotlin.test.assertTrue
|
import kotlin.test.assertTrue
|
||||||
|
|
||||||
class SimpleAutoDiffTest {
|
internal class SimpleAutoDiffTest {
|
||||||
|
|
||||||
fun dx(
|
fun dx(
|
||||||
xBinding: Pair<Symbol, Double>,
|
xBinding: Pair<Symbol, Double>,
|
||||||
|
@ -11,7 +11,7 @@ import space.kscience.kmath.misc.PerformancePitfall
|
|||||||
import space.kscience.kmath.nd.DefaultStrides
|
import space.kscience.kmath.nd.DefaultStrides
|
||||||
import space.kscience.kmath.nd.StructureND
|
import space.kscience.kmath.nd.StructureND
|
||||||
|
|
||||||
public class LazyStructureND<T>(
|
public class LazyStructureND<out T>(
|
||||||
public val scope: CoroutineScope,
|
public val scope: CoroutineScope,
|
||||||
public override val shape: IntArray,
|
public override val shape: IntArray,
|
||||||
public val function: suspend (IntArray) -> T,
|
public val function: suspend (IntArray) -> T,
|
||||||
|
@ -9,7 +9,7 @@ EJML based linear algebra implementation.
|
|||||||
|
|
||||||
## Artifact:
|
## Artifact:
|
||||||
|
|
||||||
The Maven coordinates of this project are `space.kscience:kmath-ejml:0.3.0-dev-8`.
|
The Maven coordinates of this project are `space.kscience:kmath-ejml:0.3.0-dev-11`.
|
||||||
|
|
||||||
**Gradle:**
|
**Gradle:**
|
||||||
```gradle
|
```gradle
|
||||||
@ -19,7 +19,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'space.kscience:kmath-ejml:0.3.0-dev-8'
|
implementation 'space.kscience:kmath-ejml:0.3.0-dev-11'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
**Gradle Kotlin DSL:**
|
**Gradle Kotlin DSL:**
|
||||||
@ -30,6 +30,6 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("space.kscience:kmath-ejml:0.3.0-dev-8")
|
implementation("space.kscience:kmath-ejml:0.3.0-dev-11")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -16,7 +16,7 @@ import space.kscience.kmath.nd.Structure2D
|
|||||||
* @property origin The underlying EJML matrix.
|
* @property origin The underlying EJML matrix.
|
||||||
* @author Iaroslav Postovalov
|
* @author Iaroslav Postovalov
|
||||||
*/
|
*/
|
||||||
public abstract class EjmlMatrix<T, out M : Matrix>(public open val origin: M) : Structure2D<T> {
|
public abstract class EjmlMatrix<out T, out M : Matrix>(public open val origin: M) : Structure2D<T> {
|
||||||
public override val rowNum: Int get() = origin.numRows
|
public override val rowNum: Int get() = origin.numRows
|
||||||
public override val colNum: Int get() = origin.numCols
|
public override val colNum: Int get() = origin.numCols
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ Specialization of KMath APIs for Double numbers.
|
|||||||
|
|
||||||
## Artifact:
|
## Artifact:
|
||||||
|
|
||||||
The Maven coordinates of this project are `space.kscience:kmath-for-real:0.3.0-dev-8`.
|
The Maven coordinates of this project are `space.kscience:kmath-for-real:0.3.0-dev-11`.
|
||||||
|
|
||||||
**Gradle:**
|
**Gradle:**
|
||||||
```gradle
|
```gradle
|
||||||
@ -19,7 +19,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'space.kscience:kmath-for-real:0.3.0-dev-8'
|
implementation 'space.kscience:kmath-for-real:0.3.0-dev-11'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
**Gradle Kotlin DSL:**
|
**Gradle Kotlin DSL:**
|
||||||
@ -30,6 +30,6 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("space.kscience:kmath-for-real:0.3.0-dev-8")
|
implementation("space.kscience:kmath-for-real:0.3.0-dev-11")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -11,7 +11,7 @@ Functions and interpolations.
|
|||||||
|
|
||||||
## Artifact:
|
## Artifact:
|
||||||
|
|
||||||
The Maven coordinates of this project are `space.kscience:kmath-functions:0.3.0-dev-8`.
|
The Maven coordinates of this project are `space.kscience:kmath-functions:0.3.0-dev-11`.
|
||||||
|
|
||||||
**Gradle:**
|
**Gradle:**
|
||||||
```gradle
|
```gradle
|
||||||
@ -21,7 +21,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'space.kscience:kmath-functions:0.3.0-dev-8'
|
implementation 'space.kscience:kmath-functions:0.3.0-dev-11'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
**Gradle Kotlin DSL:**
|
**Gradle Kotlin DSL:**
|
||||||
@ -32,6 +32,6 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("space.kscience:kmath-functions:0.3.0-dev-8")
|
implementation("space.kscience:kmath-functions:0.3.0-dev-11")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Module kmath-kotlingrad
|
# Module kmath-kotlingrad
|
||||||
|
|
||||||
[Kotlin∇](https://github.com/breandan/kotlingrad) integration module.
|
[Kotlin∇](https://www.htmlsymbols.xyz/unicode/U+2207) integration module.
|
||||||
|
|
||||||
- [differentiable-mst-expression](src/main/kotlin/space/kscience/kmath/kotlingrad/DifferentiableMstExpression.kt) : MST based DifferentiableExpression.
|
- [differentiable-mst-expression](src/main/kotlin/space/kscience/kmath/kotlingrad/DifferentiableMstExpression.kt) : MST based DifferentiableExpression.
|
||||||
- [differentiable-mst-expression](src/main/kotlin/space/kscience/kmath/kotlingrad/DifferentiableMstExpression.kt) : Conversions between Kotlin∇'s SFun and MST
|
- [differentiable-mst-expression](src/main/kotlin/space/kscience/kmath/kotlingrad/DifferentiableMstExpression.kt) : Conversions between Kotlin∇'s SFun and MST
|
||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
## Artifact:
|
## Artifact:
|
||||||
|
|
||||||
The Maven coordinates of this project are `space.kscience:kmath-kotlingrad:0.3.0-dev-8`.
|
The Maven coordinates of this project are `space.kscience:kmath-kotlingrad:0.3.0-dev-11`.
|
||||||
|
|
||||||
**Gradle:**
|
**Gradle:**
|
||||||
```gradle
|
```gradle
|
||||||
@ -18,7 +18,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'space.kscience:kmath-kotlingrad:0.3.0-dev-8'
|
implementation 'space.kscience:kmath-kotlingrad:0.3.0-dev-11'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
**Gradle Kotlin DSL:**
|
**Gradle Kotlin DSL:**
|
||||||
@ -29,6 +29,6 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("space.kscience:kmath-kotlingrad:0.3.0-dev-8")
|
implementation("space.kscience:kmath-kotlingrad:0.3.0-dev-11")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -7,6 +7,6 @@ plugins {
|
|||||||
readme {
|
readme {
|
||||||
maturity = ru.mipt.npm.gradle.Maturity.DEVELOPMENT
|
maturity = ru.mipt.npm.gradle.Maturity.DEVELOPMENT
|
||||||
description = """
|
description = """
|
||||||
An API and basic implementation for arranging objects in a continous memory block.
|
An API and basic implementation for arranging objects in a continuous memory block.
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ ND4J based implementations of KMath abstractions.
|
|||||||
|
|
||||||
## Artifact:
|
## Artifact:
|
||||||
|
|
||||||
The Maven coordinates of this project are `space.kscience:kmath-nd4j:0.3.0-dev-8`.
|
The Maven coordinates of this project are `space.kscience:kmath-nd4j:0.3.0-dev-11`.
|
||||||
|
|
||||||
**Gradle:**
|
**Gradle:**
|
||||||
```gradle
|
```gradle
|
||||||
@ -19,7 +19,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'space.kscience:kmath-nd4j:0.3.0-dev-8'
|
implementation 'space.kscience:kmath-nd4j:0.3.0-dev-11'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
**Gradle Kotlin DSL:**
|
**Gradle Kotlin DSL:**
|
||||||
@ -30,7 +30,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("space.kscience:kmath-nd4j:0.3.0-dev-8")
|
implementation("space.kscience:kmath-nd4j:0.3.0-dev-11")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
Common linear algebra operations on tensors.
|
Common linear algebra operations on tensors.
|
||||||
|
|
||||||
- [tensor algebra](src/commonMain/kotlin/space/kscience/kmath/tensors/api/TensorAlgebra.kt) : Interface for basic linear algebra operations on tensors (plus, dot, etc.)
|
- [tensor algebra](src/commonMain/kotlin/space/kscience/kmath/tensors/api/TensorAlgebra.kt) : Basic linear algebra operations on tensors (plus, dot, etc.)
|
||||||
- [linear algebra operations](src/commonMain/kotlin/space/kscience/kmath/tensors/api/LinearOpsTensorAlgebra.kt) : Interface for advanced linear algebra operations like LU decomposition, SVD, etc.
|
- [tensor algebra with broadcasting](src/commonMain/kotlin/space/kscience/kmath/tensors/core/algebras/BroadcastDoubleTensorAlgebra.kt) : Basic linear algebra operations implemented with broadcasting.
|
||||||
- [tensor algebra over Double](src/commonMain/kotlin/space/kscience/kmath/tensors/core/DoubleTensorAlgebra.kt): Full implementation of operations for tensors over `Double`'s.
|
- [linear algebra operations](src/commonMain/kotlin/space/kscience/kmath/tensors/api/LinearOpsTensorAlgebra.kt) : Advanced linear algebra operations like LU decomposition, SVD, etc.
|
||||||
- [tensor algebra with broadcasting](src/commonMain/kotlin/space/kscience/kmath/tensors/core/BroadcastDoubleTensorAlgebra.kt) : Basic linear algebra operations implemented with broadcasting for tensors over `Double`'s.
|
|
||||||
|
|
||||||
## Artifact:
|
## Artifact:
|
||||||
|
|
||||||
The Maven coordinates of this project are `space.kscience:kmath-tensors:0.3.0-dev-8`.
|
The Maven coordinates of this project are `space.kscience:kmath-tensors:0.3.0-dev-11`.
|
||||||
|
|
||||||
**Gradle:**
|
**Gradle:**
|
||||||
```gradle
|
```gradle
|
||||||
@ -19,7 +19,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'space.kscience:kmath-tensors:0.3.0-dev-8'
|
implementation 'space.kscience:kmath-tensors:0.3.0-dev-11'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
**Gradle Kotlin DSL:**
|
**Gradle Kotlin DSL:**
|
||||||
@ -30,6 +30,6 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("space.kscience:kmath-tensors:0.3.0-dev-8")
|
implementation("space.kscience:kmath-tensors:0.3.0-dev-11")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user