Compare commits
13 Commits
add-contra
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 72b0d9edc9 | |||
| f8b23261e1 | |||
| d64a117a9f | |||
| 845aea0cd7 | |||
| 7267880126 | |||
| f3e9e338bf | |||
| 73a6ad28c3 | |||
| 9c22b51fa5 | |||
| 26dfdf39df | |||
| 58a3f749a7 | |||
| 5abc90a4ba | |||
| 7d08aed5eb | |||
| b9c1947b70 |
9
.github/workflows/pages.yml
vendored
9
.github/workflows/pages.yml
vendored
@@ -15,13 +15,8 @@ jobs:
|
||||
with:
|
||||
java-version: 21
|
||||
distribution: liberica
|
||||
- name: Cache konan
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.konan
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('*.gradle.kts') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradle-
|
||||
- name: Gradle Wrapper Validation
|
||||
uses: gradle/wrapper-validation-action@v1.0.4
|
||||
- uses: gradle/gradle-build-action@v3
|
||||
with:
|
||||
arguments: dokkaGenerate --no-parallel
|
||||
|
||||
18
CHANGELOG.md
18
CHANGELOG.md
@@ -3,10 +3,8 @@
|
||||
## Unreleased
|
||||
|
||||
### Added
|
||||
- Fit accessors with Attribute
|
||||
|
||||
### Changed
|
||||
- Upgrade tensorflow version to 1.0.0
|
||||
|
||||
### Deprecated
|
||||
|
||||
@@ -16,6 +14,22 @@
|
||||
|
||||
### Security
|
||||
|
||||
## 0.5.0 - 2026-01-09
|
||||
|
||||
### Added
|
||||
|
||||
- More statistics functions by @qwazer
|
||||
- Fit accessors with Attribute
|
||||
|
||||
### Changed
|
||||
|
||||
- Flag attributes are replaced with boolean attributes to properly support missing values
|
||||
- Upgrade tensorflow version to 1.0.0
|
||||
|
||||
### Removed
|
||||
|
||||
- Support for ND4J
|
||||
|
||||
## 0.4.2 - 2025-01-27
|
||||
|
||||
### Added
|
||||
|
||||
71
README.md
71
README.md
@@ -5,10 +5,7 @@
|
||||
|
||||
# KMath
|
||||
|
||||
Could be pronounced as `key-math`. The **K**otlin **Math**ematics library was initially intended as a Kotlin-based
|
||||
analog to Python's NumPy library. Later we found that kotlin is much more flexible language and allows superior
|
||||
architecture designs. In contrast to `numpy` and `scipy` it is modular and has a lightweight core. The `numpy`-like
|
||||
experience could be achieved with [kmath-for-real](/kmath-for-real) extension module.
|
||||
Could be pronounced as `key-math`. The **K**otlin **Math**ematics library was initially intended as a Kotlin-based analog to Python's NumPy library. Later we found that kotlin is a much more flexible language and allows superior architecture designs. In contrast to `numpy` and `scipy` it is modular and has a lightweight core. The `numpy`-like experience could be achieved with [kmath-for-real](kmath-for-real) extension module.
|
||||
|
||||
[Documentation site](https://SciProgCentre.github.io/kmath/)
|
||||
|
||||
@@ -34,15 +31,17 @@ experience could be achieved with [kmath-for-real](/kmath-for-real) extension mo
|
||||
* Be like NumPy. It was the idea at the beginning, but we decided that we can do better in API.
|
||||
* Provide the best performance out of the box. We have specialized libraries for that. Need only API wrappers for them.
|
||||
* Cover all cases as immediately and in one bundle. We will modularize everything and add new features gradually.
|
||||
* Provide specialized behavior in the core. API is made generic on purpose, so one needs to specialize for types, like
|
||||
for `Double` in the core. For that we will have specialization modules like `kmath-for-real`, which will give better
|
||||
experience for those, who want to work with specific types.
|
||||
* Provide specialized behavior in the core. API is made generic on purpose, so one needs to specialize for types, like for `Float64` in the core. For that we will have specialization modules like [kmath-for-real](kmath-for-real), which will give a better experience for those who want to work with specific types.
|
||||
|
||||
## Contributing
|
||||
|
||||
The project requires a lot of additional work. The most important thing we need is feedback about what features are required the most. Feel free to create feature requests. We are also welcome to code contributions, especially in issues marked with [good first issue](https://github.com/SciProgCentre/kmath/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) label.
|
||||
|
||||
Project roadmap will be available at [GitHub Projects](https://github.com/orgs/SciProgCentre/projects/3).
|
||||
|
||||
## Features and stability
|
||||
|
||||
KMath is a modular library. Different modules provide different features with different API stability guarantees. All
|
||||
core modules are released with the same version, but with different API change policy. The features are described in
|
||||
module definitions below. The module stability could have the following levels:
|
||||
KMath is a modular library. Different modules provide different features with different API stability guarantees. All core modules are released with the same version, but with different API change policy. The features are described in module definitions below. The module stability could have the following levels:
|
||||
|
||||
* **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.
|
||||
@@ -50,7 +49,7 @@ module definitions below. The module stability could have the following levels:
|
||||
with `@UnstableKMathAPI` or other stability warning annotations.
|
||||
* **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.
|
||||
with [binary-compatibility-validator](https://kotlinlang.org/docs/gradle-binary-compatibility-validation.html) tool.
|
||||
* **STABLE**. The API stabilized. Breaking changes are allowed only in major releases.
|
||||
|
||||
## Modules
|
||||
@@ -60,10 +59,6 @@ module definitions below. The module stability could have the following levels:
|
||||
>
|
||||
> **Maturity**: EXPERIMENTAL
|
||||
|
||||
### [examples](examples)
|
||||
>
|
||||
> **Maturity**: EXPERIMENTAL
|
||||
|
||||
### [kmath-ast](kmath-ast)
|
||||
>
|
||||
> **Maturity**: EXPERIMENTAL
|
||||
@@ -98,9 +93,9 @@ module definitions below. The module stability could have the following levels:
|
||||
> **Features:**
|
||||
> - [algebras](kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/Algebra.kt) : Algebraic structures like rings, spaces and fields.
|
||||
> - [nd](kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/StructureND.kt) : Many-dimensional structures and operations on them.
|
||||
> - [linear](kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/Algebra.kt) : Basic linear algebra operations (sums, products, etc.), backed by the `Space` API. Advanced linear algebra operations like matrix inversion and LU decomposition.
|
||||
> - [linear](kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/Algebra.kt) : Basic linear algebra operations (sums, products, etc.), backed by the `Space` API.
|
||||
> - [buffers](kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/Buffers.kt) : One-dimensional structure
|
||||
> - [expressions](kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions) : By writing a single mathematical expression once, users will be able to apply different types of
|
||||
> - [expressions](kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions) : By writing a single mathematical expression once, users will be able to apply different types of
|
||||
> - [domains](kmath-core/src/commonMain/kotlin/space/kscience/kmath/domains) : Domains
|
||||
> - [autodiff](kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/SimpleAutoDiff.kt) : Automatic differentiation
|
||||
> - [Parallel linear algebra](kmath-core/#) : Parallel implementation for `LinearAlgebra`
|
||||
@@ -183,17 +178,6 @@ One can still use generic algebras though.
|
||||
>
|
||||
> **Maturity**: PROTOTYPE
|
||||
|
||||
### [kmath-nd4j](kmath-nd4j)
|
||||
> ND4J NDStructure implementation and according NDAlgebra classes
|
||||
>
|
||||
> **Maturity**: DEPRECATED
|
||||
>
|
||||
> **Features:**
|
||||
> - [nd4jarraystructure](kmath-nd4j/#) : NDStructure wrapper for INDArray
|
||||
> - [nd4jarrayrings](kmath-nd4j/#) : Rings over Nd4jArrayStructure of Int and Long
|
||||
> - [nd4jarrayfields](kmath-nd4j/#) : Fields over Nd4jArrayStructure of Float and Double
|
||||
|
||||
|
||||
### [kmath-ojalgo](kmath-ojalgo)
|
||||
> Ojalgo bindings for kmath
|
||||
>
|
||||
@@ -239,34 +223,21 @@ One can still use generic algebras though.
|
||||
|
||||
## Multi-platform support
|
||||
|
||||
KMath is developed as a multi-platform library, which means that most of the interfaces are declared in the
|
||||
[common source sets](/kmath-core/src/commonMain) and implemented there wherever it is possible. In some cases, features
|
||||
are delegated to platform-specific implementations even if they could be provided in the common module for performance
|
||||
reasons. Currently, Kotlin/JVM is the primary platform, however, Kotlin/Native and Kotlin/JS contributions and
|
||||
feedback are also welcome.
|
||||
KMath is developed as a multi-platform library, which means that most of the interfaces are declared in common source sets like [common source sets](kmath-core/src/commonMain) and implemented there wherever it is possible. In some cases, features are delegated to platform-specific implementations even if they could be provided in the common module for performance reasons. Currently, Kotlin/JVM is the primary platform, however, Kotlin/Native, Kotlin/JS and Kotlin/Wasm contributions and feedback are also welcome.
|
||||
|
||||
## Performance
|
||||
|
||||
Calculation of performance is one of the major goals of KMath in the future, but in some cases it is impossible to
|
||||
achieve both
|
||||
performance and flexibility.
|
||||
Performance of mathematical operations is hard to achieve without a lot of effort. KMath focus is to provide a reasonable performance for common cases, out of the box and good interoperability with optimized libraries for edge cases. For example, one could prototype an algorithm using KMath core implementations and then use Multik or Ojalgo for performance-critical parts just by adding a dependency and algebra context switch.
|
||||
|
||||
We expect to focus on creating a convenient universal API first and then work on increasing performance for specific
|
||||
cases. We expect the worst KMath benchmarks will perform better than native Python, but worse than optimized
|
||||
native/SciPy (mostly due to boxing operations on primitive numbers). The best performance of optimized parts could be
|
||||
better than SciPy.
|
||||
As for core implementations, we expect to focus on creating a convenient universal API first and then work on increasing performance for specific cases. We expect the worst KMath benchmarks will perform better than native Python, but worse than optimized native/SciPy (mostly due to boxing operations on primitive numbers). The best performance of optimized parts could be better than SciPy.
|
||||
|
||||
## Requirements
|
||||
|
||||
KMath currently relies on JDK 11 for compilation and execution of Kotlin-JVM part. We recommend using GraalVM-CE or
|
||||
Oracle GraalVM for execution to get better performance.
|
||||
KMath currently relies on JDK 21 for compilation and execution of Kotlin-JVM part.
|
||||
|
||||
### Repositories
|
||||
|
||||
Release and development artifacts are accessible from mipt-npm [Space](https://www.jetbrains.com/space/)
|
||||
repository `https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven` (see documentation of
|
||||
[Kotlin Multiplatform](https://kotlinlang.org/docs/reference/multiplatform.html) for more details). The repository could
|
||||
be reached through [repo.kotlin.link](https://repo.kotlin.link) proxy:
|
||||
Intermediate releases are published to [Kotlin.Link](https://repo.kotlin.link) repository.
|
||||
|
||||
```kotlin
|
||||
repositories {
|
||||
@@ -278,11 +249,3 @@ dependencies {
|
||||
// api("space.kscience:kmath-core-jvm:$version") for jvm-specific version
|
||||
}
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
The project requires a lot of additional work. The most important thing we need is feedback about what features are
|
||||
required the most. Feel free to create feature requests. We are also welcome to code contributions, especially in issues
|
||||
marked
|
||||
with [good first issue](hhttps://github.com/SciProgCentre/kmath/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)
|
||||
label.
|
||||
@@ -1,121 +1,122 @@
|
||||
# Module KMath-Benchmarks
|
||||
|
||||
# BenchmarksResult
|
||||
|
||||
## Report for benchmark configuration <code>main</code>
|
||||
|
||||
* Run on OpenJDK 64-Bit Server VM (build 17.0.11+9) with Java process:
|
||||
* Run on OpenJDK 64-Bit Server VM (build 21.0.9+10-LTS) with Java process:
|
||||
|
||||
```
|
||||
C:\Users\altavir\scoop\apps\gradle\current\.gradle\jdks\eclipse_adoptium-17-amd64-windows.2\bin\java.exe -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant
|
||||
C:\Users\altavir\.gradle\jdks\eclipse_adoptium-21-amd64-windows.2\bin\java.exe -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant
|
||||
```
|
||||
* JMH 1.21 was used in `thrpt` mode with 5 warmup iterations by 10 s and 5 measurement iterations by 10 s.
|
||||
* JMH 1.37 was used in `thrpt` mode with 5 warmup iterations by 10 s and 5 measurement iterations by 10 s.
|
||||
### [ArrayBenchmark](src/jvmMain/kotlin/space/kscience/kmath/benchmarks/ArrayBenchmark.kt)
|
||||
|
||||
| Benchmark | Score |
|
||||
|:---------:|:-----:|
|
||||
|`benchmarkArrayRead`|3.9E+06 ± 3.4E+05 ops/s|
|
||||
|`benchmarkBufferRead`|4.0E+06 ± 3.2E+05 ops/s|
|
||||
|`nativeBufferRead`|3.9E+06 ± 2.0E+05 ops/s|
|
||||
|`benchmarkArrayRead`|3.9E+06 ± 1.1E+06 ops/s|
|
||||
|`benchmarkBufferRead`|4.0E+06 ± 2.2E+05 ops/s|
|
||||
|`nativeBufferRead`|4.0E+06 ± 1.7E+05 ops/s|
|
||||
### [BigIntBenchmark](src/jvmMain/kotlin/space/kscience/kmath/benchmarks/BigIntBenchmark.kt)
|
||||
|
||||
| Benchmark | Score |
|
||||
|:---------:|:-----:|
|
||||
|`jvmAdd`|3.1E+07 ± 1.8E+07 ops/s|
|
||||
|`jvmAddLarge`|4.5E+04 ± 5.5E+03 ops/s|
|
||||
|`jvmMultiply`|3.6E+07 ± 1.7E+07 ops/s|
|
||||
|`jvmMultiplyLarge`|1.9E+02 ± 95 ops/s|
|
||||
|`jvmParsing10`|4.0E+06 ± 8.8E+05 ops/s|
|
||||
|`jvmParsing16`|3.6E+06 ± 6.5E+05 ops/s|
|
||||
|`jvmPower`|25 ± 1.4 ops/s|
|
||||
|`jvmSmallAdd`|5.7E+07 ± 9.7E+05 ops/s|
|
||||
|`kmAdd`|2.6E+07 ± 8.8E+05 ops/s|
|
||||
|`kmAddLarge`|2.3E+04 ± 1.2E+03 ops/s|
|
||||
|`kmMultiply`|3.8E+07 ± 5.5E+06 ops/s|
|
||||
|`kmMultiplyLarge`|36 ± 3.8 ops/s|
|
||||
|`kmParsing10`|2.5E+06 ± 1.4E+05 ops/s|
|
||||
|`kmParsing16`|3.7E+06 ± 4.7E+05 ops/s|
|
||||
|`kmPower`|6.6 ± 1.0 ops/s|
|
||||
|`kmSmallAdd`|2.0E+07 ± 1.7E+06 ops/s|
|
||||
|`jvmAdd`|2.9E+07 ± 2.8E+06 ops/s|
|
||||
|`jvmAddLarge`|3.8E+04 ± 6.4E+03 ops/s|
|
||||
|`jvmMultiply`|5.3E+07 ± 6.1E+06 ops/s|
|
||||
|`jvmMultiplyLarge`|2.2E+02 ± 1.9 ops/s|
|
||||
|`jvmParsing10`|3.9E+06 ± 4.7E+05 ops/s|
|
||||
|`jvmParsing16`|3.1E+06 ± 4.6E+05 ops/s|
|
||||
|`jvmPower`|24 ± 1.7 ops/s|
|
||||
|`jvmSmallAdd`|4.7E+07 ± 4.6E+06 ops/s|
|
||||
|`kmAdd`|2.3E+07 ± 5.1E+06 ops/s|
|
||||
|`kmAddLarge`|2.6E+04 ± 3.0E+02 ops/s|
|
||||
|`kmMultiply`|3.7E+07 ± 2.9E+06 ops/s|
|
||||
|`kmMultiplyLarge`|34 ± 2.8 ops/s|
|
||||
|`kmParsing10`|2.5E+06 ± 1.5E+05 ops/s|
|
||||
|`kmParsing16`|4.0E+06 ± 2.4E+05 ops/s|
|
||||
|`kmPower`|6.5 ± 0.69 ops/s|
|
||||
|`kmSmallAdd`|1.6E+07 ± 8.0E+05 ops/s|
|
||||
### [BufferBenchmark](src/jvmMain/kotlin/space/kscience/kmath/benchmarks/BufferBenchmark.kt)
|
||||
|
||||
| Benchmark | Score |
|
||||
|:---------:|:-----:|
|
||||
|`bufferViewReadWrite`|6.0E+06 ± 7.4E+05 ops/s|
|
||||
|`bufferViewReadWriteSpecialized`|7.6E+05 ± 1.1E+04 ops/s|
|
||||
|`complexBufferReadWrite`|2.4E+06 ± 2.7E+05 ops/s|
|
||||
|`doubleArrayReadWrite`|7.3E+06 ± 4.3E+05 ops/s|
|
||||
|`doubleBufferReadWrite`|7.3E+06 ± 3.4E+05 ops/s|
|
||||
|`bufferViewReadWrite`|5.4E+06 ± 3.8E+05 ops/s|
|
||||
|`bufferViewReadWriteSpecialized`|5.0E+06 ± 1.2E+06 ops/s|
|
||||
|`complexBufferReadWrite`|2.2E+06 ± 5.7E+04 ops/s|
|
||||
|`doubleArrayReadWrite`|6.9E+06 ± 1.2E+06 ops/s|
|
||||
|`doubleBufferReadWrite`|6.6E+06 ± 1.1E+06 ops/s|
|
||||
### [DotBenchmark](src/jvmMain/kotlin/space/kscience/kmath/benchmarks/DotBenchmark.kt)
|
||||
|
||||
| Benchmark | Score |
|
||||
|:---------:|:-----:|
|
||||
|`bufferedDot`|1.3 ± 0.032 ops/s|
|
||||
|`cmDot`|0.42 ± 0.20 ops/s|
|
||||
|`cmDotWithConversion`|0.83 ± 0.12 ops/s|
|
||||
|`ejmlDot`|2.6 ± 0.049 ops/s|
|
||||
|`ejmlDotWithConversion`|2.5 ± 0.075 ops/s|
|
||||
|`multikDot`|25 ± 0.52 ops/s|
|
||||
|`ojalgoDot`|11 ± 1.3 ops/s|
|
||||
|`parallelDot`|11 ± 0.17 ops/s|
|
||||
|`tensorDot`|1.1 ± 0.028 ops/s|
|
||||
|`tfDot`|4.7 ± 0.14 ops/s|
|
||||
|`bufferedDot`|1.2 ± 0.20 ops/s|
|
||||
|`cmDot`|0.36 ± 0.14 ops/s|
|
||||
|`cmDotWithConversion`|0.80 ± 0.092 ops/s|
|
||||
|`ejmlDot`|2.9 ± 0.61 ops/s|
|
||||
|`ejmlDotWithConversion`|2.7 ± 0.15 ops/s|
|
||||
|`multikDot`|23 ± 2.4 ops/s|
|
||||
|`ojalgoDot`|11 ± 0.79 ops/s|
|
||||
|`parallelDot`|9.4 ± 1.3 ops/s|
|
||||
|`tensorDot`|1.0 ± 0.15 ops/s|
|
||||
|`tfDot`|3.9 ± 0.90 ops/s|
|
||||
### [ExpressionsInterpretersBenchmark](src/jvmMain/kotlin/space/kscience/kmath/benchmarks/ExpressionsInterpretersBenchmark.kt)
|
||||
|
||||
| Benchmark | Score |
|
||||
|:---------:|:-----:|
|
||||
|`asmGenericExpression`|12 ± 0.099 ops/s|
|
||||
|`asmPrimitiveExpression`|26 ± 0.57 ops/s|
|
||||
|`asmPrimitiveExpressionArray`|74 ± 1.7 ops/s|
|
||||
|`functionalExpression`|5.3 ± 0.015 ops/s|
|
||||
|`justCalculate`|74 ± 0.85 ops/s|
|
||||
|`mstExpression`|4.2 ± 0.10 ops/s|
|
||||
|`rawExpression`|25 ± 0.74 ops/s|
|
||||
|`asmGenericExpression`|15 ± 1.8 ops/s|
|
||||
|`asmPrimitiveExpression`|27 ± 0.98 ops/s|
|
||||
|`asmPrimitiveExpressionArray`|78 ± 14 ops/s|
|
||||
|`functionalExpression`|4.4 ± 0.25 ops/s|
|
||||
|`justCalculate`|79 ± 5.4 ops/s|
|
||||
|`mstExpression`|4.2 ± 0.93 ops/s|
|
||||
|`rawExpression`|25 ± 5.0 ops/s|
|
||||
### [IntegrationBenchmark](src/jvmMain/kotlin/space/kscience/kmath/benchmarks/IntegrationBenchmark.kt)
|
||||
|
||||
| Benchmark | Score |
|
||||
|:---------:|:-----:|
|
||||
|`complexIntegration`|2.6E+03 ± 46 ops/s|
|
||||
|`doubleIntegration`|2.8E+03 ± 1.1E+02 ops/s|
|
||||
|`complexIntegration`|2.2E+03 ± 3.0E+02 ops/s|
|
||||
|`doubleIntegration`|2.3E+03 ± 6.4E+02 ops/s|
|
||||
### [MatrixInverseBenchmark](src/jvmMain/kotlin/space/kscience/kmath/benchmarks/MatrixInverseBenchmark.kt)
|
||||
|
||||
| Benchmark | Score |
|
||||
|:---------:|:-----:|
|
||||
|`cmLUPInversion`|2.1E+03 ± 35 ops/s|
|
||||
|`ejmlInverse`|1.2E+03 ± 27 ops/s|
|
||||
|`kmathLupInversion`|4.0E+02 ± 52 ops/s|
|
||||
|`kmathParallelLupInversion`|4.0E+02 ± 9.6 ops/s|
|
||||
|`ojalgoInverse`|2.1E+03 ± 3.3E+02 ops/s|
|
||||
### [MinStatisticBenchmark.kt](src/jvmMain/kotlin/space/kscience/kmath/benchmarks/MinStatisticBenchmark.kt)
|
||||
|`cmLUPInversion`|2.0E+03 ± 1.1E+02 ops/s|
|
||||
|`ejmlInverse`|1.2E+03 ± 29 ops/s|
|
||||
|`kmathLupInversion`|3.9E+02 ± 92 ops/s|
|
||||
|`kmathParallelLupInversion`|55 ± 5.0 ops/s|
|
||||
|`ojalgoInverse`|1.7E+03 ± 35 ops/s|
|
||||
### [MinStatisticBenchmark](src/jvmMain/kotlin/space/kscience/kmath/benchmarks/MinStatisticBenchmark.kt)
|
||||
|
||||
| Benchmark | Score |
|
||||
|:---------:|:-----:|
|
||||
|`kotlinArrayMin`| 1875.7 ± 401.5 ops/s |
|
||||
|`minBlocking`| 1357.9 ± 72.0 ops/s |
|
||||
|
||||
|`kotlinArrayMin`|1.6E+03 ± 3.0E+02 ops/s|
|
||||
|`minBlocking`|1.2E+03 ± 1.2E+02 ops/s|
|
||||
### [NDFieldBenchmark](src/jvmMain/kotlin/space/kscience/kmath/benchmarks/NDFieldBenchmark.kt)
|
||||
|
||||
| Benchmark | Score |
|
||||
|:---------:|:-----:|
|
||||
|`boxingFieldAdd`|1.7 ± 0.11 ops/s|
|
||||
|`multikAdd`|7.0 ± 0.41 ops/s|
|
||||
|`multikInPlaceAdd`|34 ± 1.7 ops/s|
|
||||
|`specializedFieldAdd`|7.2 ± 1.2 ops/s|
|
||||
|`tensorAdd`|7.2 ± 1.6 ops/s|
|
||||
|`tensorInPlaceAdd`|7.4 ± 4.9 ops/s|
|
||||
|`viktorAdd`|5.8 ± 0.65 ops/s|
|
||||
|`boxingFieldAdd`|1.9 ± 0.089 ops/s|
|
||||
|`multikAdd`|6.8 ± 1.0 ops/s|
|
||||
|`multikInPlaceAdd`|32 ± 4.7 ops/s|
|
||||
|`specializedFieldAdd`|6.7 ± 0.98 ops/s|
|
||||
|`tensorAdd`|7.9 ± 1.1 ops/s|
|
||||
|`tensorInPlaceAdd`|11 ± 3.4 ops/s|
|
||||
|`viktorAdd`|6.4 ± 0.41 ops/s|
|
||||
### [ViktorBenchmark](src/jvmMain/kotlin/space/kscience/kmath/benchmarks/ViktorBenchmark.kt)
|
||||
|
||||
| Benchmark | Score |
|
||||
|:---------:|:-----:|
|
||||
|`doubleFieldAddition`|7.1 ± 2.0 ops/s|
|
||||
|`rawViktor`|6.2 ± 1.0 ops/s|
|
||||
|`viktorFieldAddition`|6.4 ± 0.29 ops/s|
|
||||
|`doubleFieldAddition`|7.3 ± 1.1 ops/s|
|
||||
|`rawViktor`|6.0 ± 0.88 ops/s|
|
||||
|`viktorFieldAddition`|6.7 ± 0.47 ops/s|
|
||||
### [ViktorLogBenchmark](src/jvmMain/kotlin/space/kscience/kmath/benchmarks/ViktorLogBenchmark.kt)
|
||||
|
||||
| Benchmark | Score |
|
||||
|:---------:|:-----:|
|
||||
|`rawViktorLog`|1.3 ± 0.016 ops/s|
|
||||
|`realFieldLog`|1.3 ± 0.019 ops/s|
|
||||
|`viktorFieldLog`|1.3 ± 0.020 ops/s|
|
||||
|`rawViktorLog`|1.3 ± 0.40 ops/s|
|
||||
|`realFieldLog`|1.2 ± 0.34 ops/s|
|
||||
|`viktorFieldLog`|1.3 ± 0.0073 ops/s|
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
# Module KMath-Benchmarks
|
||||
|
||||
# BenchmarksResult
|
||||
|
||||
${benchmarkMain}
|
||||
|
||||
@@ -15,7 +15,7 @@ allprojects {
|
||||
}
|
||||
|
||||
group = "space.kscience"
|
||||
version = "0.4.3-dev-1"
|
||||
version = "0.5.0"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -91,7 +91,7 @@ kscienceProject {
|
||||
@OptIn(ExperimentalAbiValidation::class)
|
||||
abiValidation {
|
||||
filters {
|
||||
excluded{
|
||||
excluded {
|
||||
annotatedWith.add("space.kscience.kmath.UnstableKMathAPI")
|
||||
}
|
||||
}
|
||||
|
||||
53
docs/templates/README-TEMPLATE.md
vendored
53
docs/templates/README-TEMPLATE.md
vendored
@@ -2,14 +2,10 @@
|
||||
[](https://zenodo.org/badge/latestdoi/129486382)
|
||||

|
||||
[](https://search.maven.org/search?q=g:%22space.kscience%22)
|
||||
[](https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven/space/kscience/)
|
||||
|
||||
# KMath
|
||||
|
||||
Could be pronounced as `key-math`. The **K**otlin **Math**ematics library was initially intended as a Kotlin-based
|
||||
analog to Python's NumPy library. Later we found that kotlin is much more flexible language and allows superior
|
||||
architecture designs. In contrast to `numpy` and `scipy` it is modular and has a lightweight core. The `numpy`-like
|
||||
experience could be achieved with [kmath-for-real](/kmath-for-real) extension module.
|
||||
Could be pronounced as `key-math`. The **K**otlin **Math**ematics library was initially intended as a Kotlin-based analog to Python's NumPy library. Later we found that kotlin is a much more flexible language and allows superior architecture designs. In contrast to `numpy` and `scipy` it is modular and has a lightweight core. The `numpy`-like experience could be achieved with [kmath-for-real](kmath-for-real) extension module.
|
||||
|
||||
[Documentation site](https://SciProgCentre.github.io/kmath/)
|
||||
|
||||
@@ -35,15 +31,17 @@ experience could be achieved with [kmath-for-real](/kmath-for-real) extension mo
|
||||
* Be like NumPy. It was the idea at the beginning, but we decided that we can do better in API.
|
||||
* Provide the best performance out of the box. We have specialized libraries for that. Need only API wrappers for them.
|
||||
* Cover all cases as immediately and in one bundle. We will modularize everything and add new features gradually.
|
||||
* Provide specialized behavior in the core. API is made generic on purpose, so one needs to specialize for types, like
|
||||
for `Double` in the core. For that we will have specialization modules like `kmath-for-real`, which will give better
|
||||
experience for those, who want to work with specific types.
|
||||
* Provide specialized behavior in the core. API is made generic on purpose, so one needs to specialize for types, like for `Float64` in the core. For that we will have specialization modules like [kmath-for-real](kmath-for-real), which will give a better experience for those who want to work with specific types.
|
||||
|
||||
## Contributing
|
||||
|
||||
The project requires a lot of additional work. The most important thing we need is feedback about what features are required the most. Feel free to create feature requests. We are also welcome to code contributions, especially in issues marked with [good first issue](https://github.com/SciProgCentre/kmath/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) label.
|
||||
|
||||
Project roadmap will be available at [GitHub Projects](https://github.com/orgs/SciProgCentre/projects/3).
|
||||
|
||||
## Features and stability
|
||||
|
||||
KMath is a modular library. Different modules provide different features with different API stability guarantees. All
|
||||
core modules are released with the same version, but with different API change policy. The features are described in
|
||||
module definitions below. The module stability could have the following levels:
|
||||
KMath is a modular library. Different modules provide different features with different API stability guarantees. All core modules are released with the same version, but with different API change policy. The features are described in module definitions below. The module stability could have the following levels:
|
||||
|
||||
* **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.
|
||||
@@ -51,7 +49,7 @@ module definitions below. The module stability could have the following levels:
|
||||
with `@UnstableKMathAPI` or other stability warning annotations.
|
||||
* **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.
|
||||
with [binary-compatibility-validator](https://kotlinlang.org/docs/gradle-binary-compatibility-validation.html) tool.
|
||||
* **STABLE**. The API stabilized. Breaking changes are allowed only in major releases.
|
||||
|
||||
## Modules
|
||||
@@ -60,34 +58,21 @@ ${modules}
|
||||
|
||||
## Multi-platform support
|
||||
|
||||
KMath is developed as a multi-platform library, which means that most of the interfaces are declared in the
|
||||
[common source sets](/kmath-core/src/commonMain) and implemented there wherever it is possible. In some cases, features
|
||||
are delegated to platform-specific implementations even if they could be provided in the common module for performance
|
||||
reasons. Currently, Kotlin/JVM is the primary platform, however, Kotlin/Native and Kotlin/JS contributions and
|
||||
feedback are also welcome.
|
||||
KMath is developed as a multi-platform library, which means that most of the interfaces are declared in common source sets like [common source sets](kmath-core/src/commonMain) and implemented there wherever it is possible. In some cases, features are delegated to platform-specific implementations even if they could be provided in the common module for performance reasons. Currently, Kotlin/JVM is the primary platform, however, Kotlin/Native, Kotlin/JS and Kotlin/Wasm contributions and feedback are also welcome.
|
||||
|
||||
## Performance
|
||||
|
||||
Calculation of performance is one of the major goals of KMath in the future, but in some cases it is impossible to
|
||||
achieve both
|
||||
performance and flexibility.
|
||||
Performance of mathematical operations is hard to achieve without a lot of effort. KMath focus is to provide a reasonable performance for common cases, out of the box and good interoperability with optimized libraries for edge cases. For example, one could prototype an algorithm using KMath core implementations and then use Multik or Ojalgo for performance-critical parts just by adding a dependency and algebra context switch.
|
||||
|
||||
We expect to focus on creating a convenient universal API first and then work on increasing performance for specific
|
||||
cases. We expect the worst KMath benchmarks will perform better than native Python, but worse than optimized
|
||||
native/SciPy (mostly due to boxing operations on primitive numbers). The best performance of optimized parts could be
|
||||
better than SciPy.
|
||||
As for core implementations, we expect to focus on creating a convenient universal API first and then work on increasing performance for specific cases. We expect the worst KMath benchmarks will perform better than native Python, but worse than optimized native/SciPy (mostly due to boxing operations on primitive numbers). The best performance of optimized parts could be better than SciPy.
|
||||
|
||||
## Requirements
|
||||
|
||||
KMath currently relies on JDK 11 for compilation and execution of Kotlin-JVM part. We recommend using GraalVM-CE or
|
||||
Oracle GraalVM for execution to get better performance.
|
||||
KMath currently relies on JDK 21 for compilation and execution of Kotlin-JVM part.
|
||||
|
||||
### Repositories
|
||||
|
||||
Release and development artifacts are accessible from mipt-npm [Space](https://www.jetbrains.com/space/)
|
||||
repository `https://maven.pkg.jetbrains.space/mipt-npm/p/sci/maven` (see documentation of
|
||||
[Kotlin Multiplatform](https://kotlinlang.org/docs/reference/multiplatform.html) for more details). The repository could
|
||||
be reached through [repo.kotlin.link](https://repo.kotlin.link) proxy:
|
||||
Intermediate releases are published to [Kotlin.Link](https://repo.kotlin.link) repository.
|
||||
|
||||
```kotlin
|
||||
repositories {
|
||||
@@ -99,11 +84,3 @@ dependencies {
|
||||
// api("${group}:kmath-core-jvm:$version") for jvm-specific version
|
||||
}
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
The project requires a lot of additional work. The most important thing we need is feedback about what features are
|
||||
required the most. Feel free to create feature requests. We are also welcome to code contributions, especially in issues
|
||||
marked
|
||||
with [good first issue](hhttps://github.com/SciProgCentre/kmath/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)
|
||||
label.
|
||||
@@ -12,4 +12,4 @@ kotlin.native.ignoreDisabledTargets=true
|
||||
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
|
||||
kotlin.native.enableKlibsCrossCompilation=true
|
||||
|
||||
toolsVersion=0.20.0-kotlin-2.3.0-Beta1
|
||||
toolsVersion=0.20.2-kotlin-2.3.0
|
||||
@@ -3,10 +3,10 @@
|
||||
commons-rng = "1.6"
|
||||
multik = "0.2.3"
|
||||
nd4j = "1.0.0-M2.1"
|
||||
tensorflow = "1.0.0"
|
||||
tensorflow = "1.1.0"
|
||||
|
||||
[libraries]
|
||||
attributes = "space.kscience:attributes-kt:0.3.0"
|
||||
attributes = "space.kscience:attributes-kt:0.4.0"
|
||||
|
||||
commons-math = "org.apache.commons:commons-math3:3.6.1"
|
||||
|
||||
@@ -19,7 +19,7 @@ multik-default = { module = "org.jetbrains.kotlinx:multik-default", version.ref
|
||||
nd4j-api = { module = "org.nd4j:nd4j-api", version.ref = "nd4j" }
|
||||
nd4j-native-platform = { module = "org.nd4j:nd4j-native-platform", version.ref = "nd4j" }
|
||||
|
||||
ojalgo = "org.ojalgo:ojalgo:55.1.0"
|
||||
ojalgo = "org.ojalgo:ojalgo:56.2.0"
|
||||
|
||||
|
||||
tensorflow-core-api = {module = "org.tensorflow:tensorflow-core-api", version.ref="tensorflow"}
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -10,7 +10,7 @@ Extensions to MST API: transformations, dynamic compilation and visualization.
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-ast:0.4.2`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-ast:0.5.0`.
|
||||
|
||||
**Gradle Kotlin DSL:**
|
||||
```kotlin
|
||||
@@ -20,7 +20,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-ast:0.4.2")
|
||||
implementation("space.kscience:kmath-ast:0.5.0")
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -5,11 +5,16 @@
|
||||
|
||||
package space.kscience.kmath.asm.internal
|
||||
|
||||
import org.objectweb.asm.*
|
||||
import org.objectweb.asm.ClassWriter
|
||||
import org.objectweb.asm.FieldVisitor
|
||||
import org.objectweb.asm.Opcodes.*
|
||||
import org.objectweb.asm.Type
|
||||
import org.objectweb.asm.Type.*
|
||||
import org.objectweb.asm.commons.InstructionAdapter
|
||||
import space.kscience.kmath.expressions.*
|
||||
import space.kscience.kmath.expressions.Expression
|
||||
import space.kscience.kmath.expressions.MST
|
||||
import space.kscience.kmath.expressions.Symbol
|
||||
import space.kscience.kmath.expressions.invoke
|
||||
import java.lang.invoke.MethodHandles
|
||||
import java.lang.invoke.MethodType
|
||||
import java.nio.file.Paths
|
||||
@@ -24,6 +29,7 @@ import kotlin.io.path.writeBytes
|
||||
* @property expressionResultCallback the function to apply to this object when generating expression value.
|
||||
* @author Iaroslav Postovalov
|
||||
*/
|
||||
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
|
||||
internal class GenericAsmBuilder<T>(
|
||||
classOfT: Class<*>,
|
||||
private val className: String,
|
||||
|
||||
@@ -6,7 +6,7 @@ Commons math binding for kmath
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-commons:0.4.2`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-commons:0.5.0`.
|
||||
|
||||
**Gradle Kotlin DSL:**
|
||||
```kotlin
|
||||
@@ -16,6 +16,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-commons:0.4.2")
|
||||
implementation("space.kscience:kmath-commons:0.5.0")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -8,7 +8,7 @@ Complex and hypercomplex number systems in KMath.
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-complex:0.4.2`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-complex:0.5.0`.
|
||||
|
||||
**Gradle Kotlin DSL:**
|
||||
```kotlin
|
||||
@@ -18,6 +18,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-complex:0.4.2")
|
||||
implementation("space.kscience:kmath-complex:0.5.0")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -4,9 +4,9 @@ The core interfaces of KMath.
|
||||
|
||||
- [algebras](src/commonMain/kotlin/space/kscience/kmath/operations/Algebra.kt) : Algebraic structures like rings, spaces and fields.
|
||||
- [nd](src/commonMain/kotlin/space/kscience/kmath/structures/StructureND.kt) : Many-dimensional structures and operations on them.
|
||||
- [linear](src/commonMain/kotlin/space/kscience/kmath/operations/Algebra.kt) : Basic linear algebra operations (sums, products, etc.), backed by the `Space` API. Advanced linear algebra operations like matrix inversion and LU decomposition.
|
||||
- [linear](src/commonMain/kotlin/space/kscience/kmath/operations/Algebra.kt) : Basic linear algebra operations (sums, products, etc.), backed by the `Space` API.
|
||||
- [buffers](src/commonMain/kotlin/space/kscience/kmath/structures/Buffers.kt) : One-dimensional structure
|
||||
- [expressions](src/commonMain/kotlin/space/kscience/kmath/expressions) : By writing a single mathematical expression once, users will be able to apply different types of
|
||||
- [expressions](src/commonMain/kotlin/space/kscience/kmath/expressions) : By writing a single mathematical expression once, users will be able to apply different types of
|
||||
- [domains](src/commonMain/kotlin/space/kscience/kmath/domains) : Domains
|
||||
- [autodiff](src/commonMain/kotlin/space/kscience/kmath/expressions/SimpleAutoDiff.kt) : Automatic differentiation
|
||||
- [Parallel linear algebra](#) : Parallel implementation for `LinearAlgebra`
|
||||
@@ -14,7 +14,7 @@ The core interfaces of KMath.
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-core:0.4.2`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-core:0.5.0`.
|
||||
|
||||
**Gradle Kotlin DSL:**
|
||||
```kotlin
|
||||
@@ -24,6 +24,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-core:0.4.2")
|
||||
implementation("space.kscience:kmath-core:0.5.0")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -44,7 +44,12 @@ readme {
|
||||
feature(
|
||||
id = "linear",
|
||||
ref = "src/commonMain/kotlin/space/kscience/kmath/operations/Algebra.kt",
|
||||
) { "Basic linear algebra operations (sums, products, etc.), backed by the `Space` API. Advanced linear algebra operations like matrix inversion and LU decomposition." }
|
||||
) {
|
||||
"""
|
||||
Basic linear algebra operations (sums, products, etc.), backed by the `Space` API.
|
||||
Advanced linear algebra operations like matrix inversion and LU decomposition.
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
feature(
|
||||
id = "buffers",
|
||||
@@ -56,7 +61,7 @@ readme {
|
||||
ref = "src/commonMain/kotlin/space/kscience/kmath/expressions"
|
||||
) {
|
||||
"""
|
||||
By writing a single mathematical expression once, users will be able to apply different types of
|
||||
By writing a single mathematical expression once, users will be able to apply different types of
|
||||
objects to the expression by providing a context. Expressions can be used for a wide variety of purposes from high
|
||||
performance calculations to code generation.
|
||||
""".trimIndent()
|
||||
|
||||
@@ -15,7 +15,9 @@ import space.kscience.kmath.PerformancePitfall
|
||||
import space.kscience.kmath.UnstableKMathAPI
|
||||
import space.kscience.kmath.nd.*
|
||||
import space.kscience.kmath.operations.*
|
||||
import space.kscience.kmath.structures.*
|
||||
import space.kscience.kmath.structures.Float64
|
||||
import space.kscience.kmath.structures.IntBuffer
|
||||
import space.kscience.kmath.structures.asBuffer
|
||||
|
||||
public interface LupDecomposition<T> {
|
||||
public val pivot: IntBuffer
|
||||
@@ -47,7 +49,7 @@ public class GenericLupDecomposition<T>(
|
||||
|
||||
|
||||
override val l: Matrix<T>
|
||||
get() = VirtualMatrix(lu.rowNum, lu.colNum, attributes = Attributes(LowerTriangular)) { i, j ->
|
||||
get() = VirtualMatrix(lu.rowNum, lu.colNum, attributes = Attributes(LowerTriangular, true)) { i, j ->
|
||||
when {
|
||||
j < i -> lu[i, j]
|
||||
j == i -> elementAlgebra.one
|
||||
@@ -56,7 +58,7 @@ public class GenericLupDecomposition<T>(
|
||||
}
|
||||
|
||||
override val u: Matrix<T>
|
||||
get() = VirtualMatrix(lu.rowNum, lu.colNum, attributes = Attributes(UpperTriangular)) { i, j ->
|
||||
get() = VirtualMatrix(lu.rowNum, lu.colNum, attributes = Attributes(UpperTriangular,true)) { i, j ->
|
||||
if (j >= i) lu[i, j] else elementAlgebra.zero
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ public fun <T, A : Ring<T>> MatrixBuilder<T, A>.diagonal(
|
||||
builder: A.(Int) -> T
|
||||
): Matrix<T> = with(linearSpace.elementAlgebra) {
|
||||
require(colNum == rowNum) { "In order to build symmetric matrix, number of rows $rowNum should be equal to number of columns $colNum" }
|
||||
return VirtualMatrix(rowNum, colNum, attributes = Attributes(IsDiagonal)) { i, j ->
|
||||
return VirtualMatrix(rowNum, colNum, attributes = Attributes(IsDiagonal, true)) { i, j ->
|
||||
check(i in 0 until rowNum) { "$i out of bounds: 0..<$rowNum" }
|
||||
check(j in 0 until colNum) { "$j out of bounds: 0..<$colNum" }
|
||||
if (i == j) {
|
||||
@@ -97,7 +97,8 @@ public fun <T, A : Ring<T>> MatrixBuilder<T, A>.diagonal(
|
||||
@UnstableKMathAPI
|
||||
public fun <T> MatrixBuilder<T, Ring<T>>.diagonal(vararg elements: T): Matrix<T> {
|
||||
require(colNum == rowNum) { "In order to build symmetric matrix, number of rows $rowNum should be equal to number of columns $colNum" }
|
||||
return return VirtualMatrix(rowNum, colNum, attributes = Attributes(IsDiagonal)) { i, j ->
|
||||
|
||||
return VirtualMatrix(rowNum, colNum, attributes = Attributes(IsDiagonal,true)) { i, j ->
|
||||
check(i in 0 until rowNum) { "$i out of bounds: 0..<$rowNum" }
|
||||
check(j in 0 until colNum) { "$j out of bounds: 0..<$colNum" }
|
||||
if (i == j) {
|
||||
|
||||
@@ -36,8 +36,8 @@ public val <T : Any> Matrix<T>.origin: Matrix<T>
|
||||
/**
|
||||
* Add a single feature to a [Matrix]
|
||||
*/
|
||||
public fun <T, A : Attribute<T>> Matrix<T>.withAttribute(
|
||||
attribute: A,
|
||||
public fun <T> Matrix<T>.withAttribute(
|
||||
attribute: Attribute<T>,
|
||||
attrValue: T,
|
||||
): MatrixWrapper<T> = if (this is MatrixWrapper) {
|
||||
MatrixWrapper(origin, attributes.withAttribute(attribute, attrValue))
|
||||
@@ -45,14 +45,26 @@ public fun <T, A : Attribute<T>> Matrix<T>.withAttribute(
|
||||
MatrixWrapper(this, Attributes(attribute, attrValue))
|
||||
}
|
||||
|
||||
public fun <T, A : Attribute<Unit>> Matrix<T>.withAttribute(
|
||||
attribute: A,
|
||||
public fun <T> Matrix<T>.withAttribute(
|
||||
attribute: Attribute<Unit>,
|
||||
): MatrixWrapper<T> = if (this is MatrixWrapper) {
|
||||
MatrixWrapper(origin, attributes.withFlag(attribute))
|
||||
} else {
|
||||
MatrixWrapper(this, Attributes(attribute, Unit))
|
||||
}
|
||||
|
||||
/**
|
||||
* Add boolean attribute with default value `true`
|
||||
*/
|
||||
public fun <T> Matrix<T>.withAttribute(
|
||||
attribute: Attribute<Boolean>,
|
||||
value: Boolean = true
|
||||
): MatrixWrapper<T> = if (this is MatrixWrapper) {
|
||||
MatrixWrapper(origin, attributes.withAttribute(attribute, value))
|
||||
} else {
|
||||
MatrixWrapper(this, Attributes(attribute, value))
|
||||
}
|
||||
|
||||
/**
|
||||
* Modify matrix attributes
|
||||
*/
|
||||
|
||||
@@ -23,11 +23,14 @@ public interface MatrixScope<T> : WithType<T>
|
||||
*/
|
||||
public interface MatrixAttribute<T> : StructureAttribute<T>
|
||||
|
||||
public typealias BooleanAttribute = Attribute<Boolean>
|
||||
|
||||
|
||||
/**
|
||||
* Matrices with this feature are symmetric, meaning `matrix[i,j] == matrix[j,i]`
|
||||
*/
|
||||
public interface Symmetric : MatrixAttribute<Unit>, FlagAttribute{
|
||||
public companion object: Symmetric
|
||||
public interface Symmetric : MatrixAttribute<Boolean> {
|
||||
public companion object : Symmetric
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,12 +75,12 @@ public val <T> MatrixScope<T>.Determinant: Determinant<T> get() = Determinant(ty
|
||||
/**
|
||||
* Matrices with this feature are lower triangular ones.
|
||||
*/
|
||||
public object LowerTriangular : MatrixAttribute<Unit>, FlagAttribute
|
||||
public object LowerTriangular : MatrixAttribute<Boolean>
|
||||
|
||||
/**
|
||||
* Matrices with this feature are upper triangular ones.
|
||||
*/
|
||||
public object UpperTriangular : MatrixAttribute<Unit>, FlagAttribute
|
||||
public object UpperTriangular : MatrixAttribute<Boolean>
|
||||
|
||||
/**
|
||||
* Matrices with this feature support LU factorization: *a = [l] · [u]* where *a* is the owning matrix.
|
||||
@@ -102,7 +105,7 @@ public val <T> MatrixScope<T>.LU: LuDecompositionAttribute<T> get() = LuDecompos
|
||||
* Matrices with this feature are orthogonal ones: *a · a<sup>T</sup> = u* where *a* is the owning matrix, *u*
|
||||
* is the unit matrix ([IsUnit]).
|
||||
*/
|
||||
public object OrthogonalAttribute : MatrixAttribute<Unit>, FlagAttribute
|
||||
public object OrthogonalAttribute : MatrixAttribute<Boolean>
|
||||
|
||||
|
||||
public interface QRDecomposition<out T> {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-coroutines:0.4.2`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-coroutines:0.5.0`.
|
||||
|
||||
**Gradle Kotlin DSL:**
|
||||
```kotlin
|
||||
@@ -16,6 +16,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-coroutines:0.4.2")
|
||||
implementation("space.kscience:kmath-coroutines:0.5.0")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -6,7 +6,7 @@ A proof of concept module for adding type-safe dimensions to structures
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-dimensions:0.4.2`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-dimensions:0.5.0`.
|
||||
|
||||
**Gradle Kotlin DSL:**
|
||||
```kotlin
|
||||
@@ -16,6 +16,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-dimensions:0.4.2")
|
||||
implementation("space.kscience:kmath-dimensions:0.5.0")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -9,7 +9,7 @@ EJML based linear algebra implementation.
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-ejml:0.4.2`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-ejml:0.5.0`.
|
||||
|
||||
**Gradle Kotlin DSL:**
|
||||
```kotlin
|
||||
@@ -19,6 +19,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-ejml:0.4.2")
|
||||
implementation("space.kscience:kmath-ejml:0.5.0")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -9,7 +9,7 @@ Specialization of KMath APIs for Double numbers.
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-for-real:0.4.2`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-for-real:0.5.0`.
|
||||
|
||||
**Gradle Kotlin DSL:**
|
||||
```kotlin
|
||||
@@ -19,6 +19,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-for-real:0.4.2")
|
||||
implementation("space.kscience:kmath-for-real:0.5.0")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -11,7 +11,7 @@ Functions and interpolations.
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-functions:0.4.2`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-functions:0.5.0`.
|
||||
|
||||
**Gradle Kotlin DSL:**
|
||||
```kotlin
|
||||
@@ -21,6 +21,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-functions:0.4.2")
|
||||
implementation("space.kscience:kmath-functions:0.5.0")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-geometry:0.4.2`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-geometry:0.5.0`.
|
||||
|
||||
**Gradle Kotlin DSL:**
|
||||
```kotlin
|
||||
@@ -16,6 +16,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-geometry:0.4.2")
|
||||
implementation("space.kscience:kmath-geometry:0.5.0")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-histograms:0.4.2`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-histograms:0.5.0`.
|
||||
|
||||
**Gradle Kotlin DSL:**
|
||||
```kotlin
|
||||
@@ -16,6 +16,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-histograms:0.4.2")
|
||||
implementation("space.kscience:kmath-histograms:0.5.0")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-jupyter:0.4.2`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-jupyter:0.5.0`.
|
||||
|
||||
**Gradle Kotlin DSL:**
|
||||
```kotlin
|
||||
@@ -16,6 +16,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-jupyter:0.4.2")
|
||||
implementation("space.kscience:kmath-jupyter:0.5.0")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1,19 +1,25 @@
|
||||
plugins {
|
||||
id("space.kscience.gradle.jvm")
|
||||
id("space.kscience.gradle.mpp")
|
||||
alias(spclibs.plugins.kotlin.jupyter.api)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(spclibs.kotlinx.html)
|
||||
api(project(":kmath-ast"))
|
||||
api(project(":kmath-complex"))
|
||||
api(project(":kmath-for-real"))
|
||||
kscience {
|
||||
jvm()
|
||||
|
||||
jvmMain {
|
||||
api(spclibs.kotlinx.html)
|
||||
api(project(":kmath-ast"))
|
||||
api(project(":kmath-complex"))
|
||||
api(project(":kmath-for-real"))
|
||||
}
|
||||
}
|
||||
|
||||
readme {
|
||||
maturity = space.kscience.gradle.Maturity.PROTOTYPE
|
||||
}
|
||||
|
||||
tasks.processJupyterApiResources {
|
||||
libraryProducers = listOf("space.kscience.kmath.jupyter.KMathJupyter")
|
||||
kotlinJupyter {
|
||||
integrations {
|
||||
producer("space.kscience.kmath.jupyter.KMathJupyter")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-kotlingrad:0.4.2`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-kotlingrad:0.5.0`.
|
||||
|
||||
**Gradle Kotlin DSL:**
|
||||
```kotlin
|
||||
@@ -18,6 +18,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-kotlingrad:0.4.2")
|
||||
implementation("space.kscience:kmath-kotlingrad:0.5.0")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-memory:0.4.2`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-memory:0.5.0`.
|
||||
|
||||
**Gradle Kotlin DSL:**
|
||||
```kotlin
|
||||
@@ -16,6 +16,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-memory:0.4.2")
|
||||
implementation("space.kscience:kmath-memory:0.5.0")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -6,7 +6,7 @@ JetBrains Multik connector
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-multik:0.4.2`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-multik:0.5.0`.
|
||||
|
||||
**Gradle Kotlin DSL:**
|
||||
```kotlin
|
||||
@@ -16,6 +16,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-multik:0.4.2")
|
||||
implementation("space.kscience:kmath-multik:0.5.0")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -6,7 +6,7 @@ Ojalgo bindings for kmath
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-ojalgo:0.4.2`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-ojalgo:0.5.0`.
|
||||
|
||||
**Gradle Kotlin DSL:**
|
||||
```kotlin
|
||||
@@ -16,6 +16,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-ojalgo:0.4.2")
|
||||
implementation("space.kscience:kmath-ojalgo:0.5.0")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-optimization:0.4.2`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-optimization:0.5.0`.
|
||||
|
||||
**Gradle Kotlin DSL:**
|
||||
```kotlin
|
||||
@@ -16,6 +16,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-optimization:0.4.2")
|
||||
implementation("space.kscience:kmath-optimization:0.5.0")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-stat:0.4.2`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-stat:0.5.0`.
|
||||
|
||||
**Gradle Kotlin DSL:**
|
||||
```kotlin
|
||||
@@ -16,6 +16,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-stat:0.4.2")
|
||||
implementation("space.kscience:kmath-stat:0.5.0")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -6,7 +6,7 @@ Symja integration module
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-symja:0.4.2`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-symja:0.5.0`.
|
||||
|
||||
**Gradle Kotlin DSL:**
|
||||
```kotlin
|
||||
@@ -16,6 +16,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-symja:0.4.2")
|
||||
implementation("space.kscience:kmath-symja:0.5.0")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -6,7 +6,7 @@ Google tensorflow connector
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-tensorflow:0.4.2`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-tensorflow:0.5.0`.
|
||||
|
||||
**Gradle Kotlin DSL:**
|
||||
```kotlin
|
||||
@@ -16,6 +16,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-tensorflow:0.4.2")
|
||||
implementation("space.kscience:kmath-tensorflow:0.5.0")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
plugins {
|
||||
id("space.kscience.gradle.jvm")
|
||||
id("space.kscience.gradle.mpp")
|
||||
}
|
||||
|
||||
description = "Google tensorflow connector"
|
||||
|
||||
dependencies {
|
||||
api(projects.kmathTensors)
|
||||
api(libs.tensorflow.core.api)
|
||||
testImplementation(libs.tensorflow.core.platform)
|
||||
kscience {
|
||||
jvm()
|
||||
|
||||
jvmMain {
|
||||
api(projects.kmathTensors)
|
||||
api(libs.tensorflow.core.api)
|
||||
}
|
||||
|
||||
jvmTest {
|
||||
implementation(libs.tensorflow.core.platform)
|
||||
}
|
||||
}
|
||||
|
||||
readme {
|
||||
|
||||
@@ -9,7 +9,7 @@ Common linear algebra operations on tensors.
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-tensors:0.4.2`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-tensors:0.5.0`.
|
||||
|
||||
**Gradle Kotlin DSL:**
|
||||
```kotlin
|
||||
@@ -19,6 +19,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-tensors:0.4.2")
|
||||
implementation("space.kscience:kmath-tensors:0.5.0")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -6,7 +6,7 @@ Binding for https://github.com/JetBrains-Research/viktor
|
||||
|
||||
## Artifact:
|
||||
|
||||
The Maven coordinates of this project are `space.kscience:kmath-viktor:0.4.2`.
|
||||
The Maven coordinates of this project are `space.kscience:kmath-viktor:0.5.0`.
|
||||
|
||||
**Gradle Kotlin DSL:**
|
||||
```kotlin
|
||||
@@ -16,6 +16,6 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("space.kscience:kmath-viktor:0.4.2")
|
||||
implementation("space.kscience:kmath-viktor:0.5.0")
|
||||
}
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user