diff --git a/README.md b/README.md
index a15c4384f..db069d4e0 100644
--- a/README.md
+++ b/README.md
@@ -6,10 +6,10 @@
# 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 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 (**WIP**)](https://mipt-npm.github.io/kmath/)
@@ -21,26 +21,33 @@ be achieved with [kmath-for-real](/kmath-for-real) extension module.
# Goal
-* Provide a flexible and powerful API to work with mathematics abstractions in Kotlin-multiplatform (JVM, JS and Native).
+* Provide a flexible and powerful API to work with mathematics abstractions in Kotlin-multiplatform (JVM, JS and Native)
+ .
* Provide basic multiplatform implementations for those abstractions (without significant performance optimization).
* Provide bindings and wrappers with those abstractions for popular optimized platform libraries.
## Non-goals
-* Be like NumPy. It was the idea at the beginning, but we decided that we can do better in terms of API.
+* 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 `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.
## 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 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.
-* **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 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.
+* **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.
+* **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.
@@ -161,7 +168,7 @@ performance calculations to code generation.
* ### [kmath-for-real](kmath-for-real)
-> Extension module that should be used to achieve numpy-like behavior.
+> Extension module that should be used to achieve numpy-like behavior.
All operations are specialized to work with `Double` numbers without declaring algebraic contexts.
One can still use generic algebras though.
>
@@ -278,30 +285,33 @@ 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, the Kotlin/JVM is the primary platform, however Kotlin/Native and Kotlin/JS contributions and
+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, the Kotlin/JVM is the primary platform, however Kotlin/Native and Kotlin/JS contributions and
feedback are also welcome.
## Performance
-Calculation performance is one of major goals of KMath in the future, but in some cases it is impossible to achieve
-both performance and flexibility.
+Calculation performance is one of major goals of KMath in the future, but in some cases it is impossible to achieve both
+performance and flexibility.
-We expect to focus on creating 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
+We expect to focus on creating 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 to use GraalVM-CE 11 for execution in order to get better performance.
+KMath currently relies on JDK 11 for compilation and execution of Kotlin-JVM part. We recommend to use GraalVM-CE 11 for
+execution to get better performance.
### 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:
+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:
```kotlin
repositories {
@@ -318,7 +328,7 @@ Gradle `6.0+` is required for multiplatform artifacts.
## Contributing
-The project requires a lot of additional work. The most important thing we need is a 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
+The project requires a lot of additional work. The most important thing we need is a 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
[waiting for a hero](https://github.com/mipt-npm/kmath/labels/waiting%20for%20a%20hero) label.
diff --git a/docs/algebra.md b/docs/algebra.md
index 84693bb81..20158a125 100644
--- a/docs/algebra.md
+++ b/docs/algebra.md
@@ -1,85 +1,45 @@
# Algebraic Structures and Algebraic Elements
-The mathematical operations in KMath are generally separated from mathematical objects. This means that to perform an
-operation, say `+`, one needs two objects of a type `T` and an algebra context, which draws appropriate operation up,
-say `Space`. Next one needs to run the actual operation in the context:
+The mathematical operations in KMath are generally separated from mathematical objects. This means that to perform an
+operation, say `+`, one needs two objects of a type `T` and an algebra context, which draws appropriate operation up,
+say `Group`. Next one needs to run the actual operation in the context:
```kotlin
import space.kscience.kmath.operations.*
val a: T = ...
val b: T = ...
-val space: Space = ...
+val group: Group = ...
-val c = space { a + b }
+val c = group { a + b }
```
-At first glance, this distinction seems to be a needless complication, but in fact one needs to remember that in
-mathematics, one could draw up different operations on same objects. For example, one could use different types of
+At first glance, this distinction seems to be a needless complication, but in fact one needs to remember that in
+mathematics, one could draw up different operations on same objects. For example, one could use different types of
geometry for vectors.
## Algebraic Structures
-Mathematical contexts have the following hierarchy:
+Primary mathematical contexts have the following hierarchy:
-**Algebra** ← **Space** ← **Ring** ← **Field**
+`Field <: Ring <: Group <: Algebra`
These interfaces follow real algebraic structures:
-- [Space](https://mathworld.wolfram.com/VectorSpace.html) defines addition, its neutral element (i.e. 0) and scalar
-multiplication;
-- [Ring](http://mathworld.wolfram.com/Ring.html) adds multiplication and its neutral element (i.e. 1);
+- [Group](https://mathworld.wolfram.com/Group.html) defines addition, its identity element (i.e., 0) and additive
+ inverse (-x);
+- [Ring](http://mathworld.wolfram.com/Ring.html) adds multiplication and its identity element (i.e., 1);
- [Field](http://mathworld.wolfram.com/Field.html) adds division operation.
A typical implementation of `Field` is the `DoubleField` which works on doubles, and `VectorSpace` for `Space`.
In some cases algebra context can hold additional operations like `exp` or `sin`, and then it inherits appropriate
-interface. Also, contexts may have operations, which produce elements outside of the context. For example, `Matrix.dot`
-operation produces a matrix with new dimensions, which can be incompatible with initial matrix in terms of linear
-operations.
-
-## Algebraic Element
-
-To achieve more familiar behavior (where you apply operations directly to mathematical objects), without involving
-contexts KMath submits special type objects called `MathElement`. A `MathElement` is basically some object coupled to
-a mathematical context. For example `Complex` is the pair of real numbers representing real and imaginary parts,
-but it also holds reference to the `ComplexField` singleton, which allows performing direct operations on `Complex`
-numbers without explicit involving the context like:
-
-```kotlin
-import space.kscience.kmath.operations.*
-
-// Using elements
-val c1 = Complex(1.0, 1.0)
-val c2 = Complex(1.0, -1.0)
-val c3 = c1 + c2 + 3.0.toComplex()
-
-// Using context
-val c4 = ComplexField { c1 + i - 2.0 }
-```
-
-Both notations have their pros and cons.
-
-The hierarchy for algebraic elements follows the hierarchy for the corresponding algebraic structures.
-
-**MathElement** ← **SpaceElement** ← **RingElement** ← **FieldElement**
-
-`MathElement` is the generic common ancestor of the class with context.
-
-One major distinction between algebraic elements and algebraic contexts is that elements have three type
-parameters:
-
-1. The type of elements, the field operates on.
-2. The self-type of the element returned from operation (which has to be an algebraic element).
-3. The type of the algebra over first type-parameter.
-
-The middle type is needed for of algebra members do not store context. For example, it is impossible to add a context
-to regular `Double`. The element performs automatic conversions from context types and back. One should use context
-operations in all performance-critical places. The performance of element operations is not guaranteed.
+interface. Also, contexts may have operations, which produce elements outside the context. For example, `Matrix.dot`
+operation produces a matrix with new dimensions, which can be incompatible with initial matrix in linear operations.
## Spaces and Fields
-KMath submits both contexts and elements for builtin algebraic structures:
+KMath introduces contexts for builtin algebraic structures:
```kotlin
import space.kscience.kmath.operations.*
@@ -102,13 +62,13 @@ val c2 = ComplexField { c1 - 1.0 } // Returns: Complex(re=0.0, im=2.0)
val c3 = ComplexField { c1 - i * 2.0 }
```
-**Note**: In theory it is possible to add behaviors directly to the context, but as for now Kotlin does not support
-that. Watch [KT-10468](https://youtrack.jetbrains.com/issue/KT-10468) and
+**Note**: In theory it is possible to add behaviors directly to the context, but as for now Kotlin does not support
+that. Watch [KT-10468](https://youtrack.jetbrains.com/issue/KT-10468) and
[KEEP-176](https://github.com/Kotlin/KEEP/pull/176) for updates.
## Nested fields
-Contexts allow one to build more complex structures. For example, it is possible to create a `Matrix` from complex
+Contexts allow one to build more complex structures. For example, it is possible to create a `Matrix` from complex
elements like so:
```kotlin
@@ -118,8 +78,9 @@ val element = NDElement.complex(shape = intArrayOf(2, 2)) { index: IntArray ->
```
The `element` in this example is a member of the `Field` of 2D structures, each element of which is a member of its own
-`ComplexField`. It is important one does not need to create a special n-d class to hold complex
-numbers and implement operations on it, one just needs to provide a field for its elements.
+`ComplexField`. It is important one does not need to create a special n-d class to hold complex numbers and implement
+operations on it, one just needs to provide a field for its elements.
-**Note**: Fields themselves do not solve the problem of JVM boxing, but it is possible to solve with special contexts like
+**Note**: Fields themselves do not solve the problem of JVM boxing, but it is possible to solve with special contexts
+like
`MemorySpec`.
diff --git a/docs/buffers.md b/docs/buffers.md
index 679bd4e78..e7573497e 100644
--- a/docs/buffers.md
+++ b/docs/buffers.md
@@ -1,17 +1,20 @@
# Buffers
-Buffer is one of main building blocks of kmath. It is a basic interface allowing random-access read and write (with `MutableBuffer`).
-There are different types of buffers:
+Buffer is one of main building blocks of kmath. It is a basic interface allowing random-access read and write (
+with `MutableBuffer`). There are different types of buffers:
-* Primitive buffers wrapping like `RealBuffer` which are wrapping primitive arrays.
+* Primitive buffers wrapping like `DoubleBuffer` which are wrapping primitive arrays.
* Boxing `ListBuffer` wrapping a list
* Functionally defined `VirtualBuffer` which does not hold a state itself, but provides a function to calculate value
* `MemoryBuffer` allows direct allocation of objects in continuous memory block.
-Some kmath features require a `BufferFactory` class to operate properly. A general convention is to use functions defined in
-`Buffer` and `MutableBuffer` companion classes. For example factory `Buffer.Companion::auto` in most cases creates the most suitable
-buffer for given reified type (for types with custom memory buffer it still better to use their own `MemoryBuffer.create()` factory).
+Some kmath features require a `BufferFactory` class to operate properly. A general convention is to use functions
+defined in
+`Buffer` and `MutableBuffer` companion classes. For example factory `Buffer.Companion::auto` in most cases creates the
+most suitable buffer for given reified type (for types with custom memory buffer it still better to use their
+own `MemoryBuffer.create()` factory).
## Buffer performance
-One should avoid using default boxing buffer wherever it is possible. Try to use primitive buffers or memory buffers instead
+One should avoid using default boxing buffer wherever it is possible. Try to use primitive buffers or memory buffers
+instead .
diff --git a/docs/codestyle.md b/docs/codestyle.md
index 541dc4973..73ba5f754 100644
--- a/docs/codestyle.md
+++ b/docs/codestyle.md
@@ -1,26 +1,20 @@
# Coding Conventions
-KMath code follows general [Kotlin conventions](https://kotlinlang.org/docs/reference/coding-conventions.html), but
-with a number of small changes and clarifications.
+Generally, KMath code follows general [Kotlin coding conventions](https://kotlinlang.org/docs/reference/coding-conventions.html), but with a number of small changes and clarifications.
## Utility Class Naming
-Filename should coincide with a name of one of the classes contained in the file or start with small letter and
-describe its contents.
+Filename should coincide with a name of one of the classes contained in the file or start with small letter and describe its contents.
-The code convention [here](https://kotlinlang.org/docs/reference/coding-conventions.html#source-file-names) says that
-file names should start with a capital letter even if file does not contain classes. Yet starting utility classes and
-aggregators with a small letter seems to be a good way to visually separate those files.
+The code convention [here](https://kotlinlang.org/docs/reference/coding-conventions.html#source-file-names) says that file names should start with a capital letter even if file does not contain classes. Yet starting utility classes and aggregators with a small letter seems to be a good way to visually separate those files.
This convention could be changed in future in a non-breaking way.
## Private Variable Naming
-Private variables' names may start with underscore `_` for of the private mutable variable is shadowed by the public
-read-only value with the same meaning.
+Private variables' names may start with underscore `_` for of the private mutable variable is shadowed by the public read-only value with the same meaning.
-This rule does not permit underscores in names, but it is sometimes useful to "underscore" the fact that public and
-private versions draw up the same entity. It is allowed only for private variables.
+This rule does not permit underscores in names, but it is sometimes useful to "underscore" the fact that public and private versions draw up the same entity. It is allowed only for private variables.
This convention could be changed in future in a non-breaking way.
@@ -30,5 +24,4 @@ Use one-liners when they occupy single code window line both for functions and p
`val b: String get() = "fff"`. The same should be performed with multiline expressions when they could be
cleanly separated.
-There is no universal consensus whenever use `fun a() = ...` or `fun a() { return ... }`. Yet from reader outlook
-one-lines seem to better show that the property or function is easily calculated.
+There is no universal consensus whenever use `fun a() = ...` or `fun a() { return ... }`. Yet from reader outlook one-lines seem to better show that the property or function is easily calculated.
diff --git a/docs/contexts.md b/docs/contexts.md
index 58b198046..c26333860 100644
--- a/docs/contexts.md
+++ b/docs/contexts.md
@@ -2,18 +2,17 @@
## The problem
-A known problem for implementing mathematics in statically-typed languages (but not only in them) is that different
-sets of mathematical operators can be defined on the same mathematical objects. Sometimes there is no single way to
-treat some operations, including basic arithmetic operations, on a Java/Kotlin `Number`. Sometimes there are different ways to
-define the same structure, such as Euclidean and elliptic geometry vector spaces over real vectors. Another problem arises when
-one wants to add some kind of behavior to an existing entity. In dynamic languages those problems are usually solved
-by adding dynamic context-specific behaviors at runtime, but this solution has a lot of drawbacks.
+A known problem for implementing mathematics in statically-typed languages (but not only in them) is that different sets
+of mathematical operators can be defined on the same mathematical objects. Sometimes there is no single way to treat
+some operations, including basic arithmetic operations, on a Java/Kotlin `Number`. Sometimes there are different ways to
+define the same structure, such as Euclidean and elliptic geometry vector spaces over real vectors. Another problem
+arises when one wants to add some kind of behavior to an existing entity. In dynamic languages those problems are
+usually solved by adding dynamic context-specific behaviors at runtime, but this solution has a lot of drawbacks.
## Context-oriented approach
-One possible solution to these problems is to divorce numerical representations from behaviors.
-For example in Kotlin one can define a separate class which represents some entity without any operations,
-ex. a complex number:
+One possible solution to these problems is to divorce numerical representations from behaviors. For example in Kotlin
+one can define a separate class representing some entity without any operations, ex. a complex number:
```kotlin
data class Complex(val re: Double, val im: Double)
@@ -28,9 +27,10 @@ object ComplexOperations {
}
```
-In Java, applying such external operations could be very cumbersome, but Kotlin has a unique feature which allows us
-implement this naturally: [extensions with receivers](https://kotlinlang.org/docs/reference/extensions.html#extension-functions).
-In Kotlin, an operation on complex number could be implemented as:
+In Java, applying such external operations could be cumbersome, but Kotlin has a unique feature that allows us
+implement this
+naturally: [extensions with receivers](https://kotlinlang.org/docs/reference/extensions.html#extension-functions). In
+Kotlin, an operation on complex number could be implemented as:
```kotlin
with(ComplexOperations) { c1 + c2 - c3 }
@@ -52,20 +52,20 @@ In KMath, contexts are not only responsible for operations, but also for raw obj
### Type classes
-An obvious candidate to get more or less the same functionality is the type class, which allows one to bind a behavior to
-a specific type without modifying the type itself. On the plus side, type classes do not require explicit context
+An obvious candidate to get more or less the same functionality is the type class, which allows one to bind a behavior
+to a specific type without modifying the type itself. On the plus side, type classes do not require explicit context
declaration, so the code looks cleaner. On the minus side, if there are different sets of behaviors for the same types,
-it is impossible to combine them into one module. Also, unlike type classes, context can have parameters or even
-state. For example in KMath, sizes and strides for `NDElement` or `Matrix` could be moved to context to optimize
-performance in case of a large amount of structures.
+it is impossible to combine them into one module. Also, unlike type classes, context can have parameters or even state.
+For example in KMath, sizes and strides for `NDElement` or `Matrix` could be moved to context to optimize performance in
+case of a large amount of structures.
### Wildcard imports and importing-on-demand
-Sometimes, one may wish to use a single context throughout a file. In this case, is possible to import all members
-from a package or file, via `import context.complex.*`. Effectively, this is the same as enclosing an entire file
-with a single context. However when using multiple contexts, this technique can introduce operator ambiguity, due to
-namespace pollution. If there are multiple scoped contexts which define the same operation, it is still possible to
-to import specific operations as needed, without using an explicit context with extension functions, for example:
+Sometimes, one may wish to use a single context throughout a file. In this case, is possible to import all members from
+a package or file, via `import context.complex.*`. Effectively, this is the same as enclosing an entire file with a
+single context. However, when using multiple contexts, this technique can introduce operator ambiguity, due to namespace
+pollution. If there are multiple scoped contexts that define the same operation, it is still possible to import
+specific operations as needed, without using an explicit context with extension functions, for example:
```
import context.complex.op1
diff --git a/docs/expressions.md b/docs/expressions.md
index 1e05e5340..e6250110c 100644
--- a/docs/expressions.md
+++ b/docs/expressions.md
@@ -1,26 +1,21 @@
# Expressions
-**Experimental: this API is in early stage and could change any time**
-
-Expressions is an experimental feature which allows to construct lazily or immediately calculated parametric mathematical
-expressions.
+Expressions is a feature, which allows constructing lazily or immediately calculated parametric mathematical expressions.
The potential use-cases for it (so far) are following:
-* Lazy evaluation (in general simple lambda is better, but there are some border cases)
+* lazy evaluation (in general simple lambda is better, but there are some border cases);
+* automatic differentiation in single-dimension and in multiple dimensions;
+* generation of mathematical syntax trees with subsequent code generation for other languages;
+* symbolic computations, especially differentiation (and some other actions with `kmath-symja` integration with Symja's `IExpr`—integration, simplification, and more);
+* visualization with `kmath-jupyter`.
-* Automatic differentiation in single-dimension and in multiple dimensions
-
-* Generation of mathematical syntax trees with subsequent code generation for other languages
-
-* Maybe symbolic computations (needs additional research)
-
-The workhorse of this API is `Expression` interface which exposes single `operator fun invoke(arguments: Map): T`
-method. `ExpressionContext` is used to generate expressions and introduce variables.
+The workhorse of this API is `Expression` interface, which exposes single `operator fun invoke(arguments: Map): T`
+method. `ExpressionAlgebra` is used to generate expressions and introduce variables.
Currently there are two implementations:
* Generic `ExpressionField` in `kmath-core` which allows construction of custom lazy expressions
-* Auto-differentiation expression in `kmath-commons` module allows to use full power of `DerivativeStructure`
+* Auto-differentiation expression in `kmath-commons` module allows using full power of `DerivativeStructure`
from commons-math. **TODO: add example**
diff --git a/docs/features.md b/docs/features.md
deleted file mode 100644
index 1068a4417..000000000
--- a/docs/features.md
+++ /dev/null
@@ -1,14 +0,0 @@
-# Features
-
-* [Algebra](algebra.md) - [Context-based](contexts.md) operations on different primitives and structures.
-
-* [NDStructures](nd-structure.md)
-
-* [Linear algebra](linear.md) - Matrices, operations and linear equations solving. To be moved to separate module. Currently supports basic
-api and multiple library back-ends.
-
-* [Histograms](histograms.md) - Multidimensional histogram calculation and operations.
-
-* [Expressions](expressions.md)
-
-* Commons math integration
diff --git a/docs/linear.md b/docs/linear.md
index 6ccc6caac..2a05499ef 100644
--- a/docs/linear.md
+++ b/docs/linear.md
@@ -1,19 +1,31 @@
## Basic linear algebra layout
-KMath support for linear algebra organized in a context-oriented way. Meaning that operations are in most cases declared
-in context classes, and are not the members of classes that store data. This allows more flexible approach to maintain multiple
-back-ends. The new operations added as extensions to contexts instead of being member functions of data structures.
+KMath support for linear algebra organized in a context-oriented way, which means that operations are in most cases declared in context classes, and are not the members of classes that store data. This allows more flexible approach to maintain multiple back-ends. The new operations added as extensions to contexts instead of being member functions of data structures.
-Two major contexts used for linear algebra and hyper-geometry:
+The main context for linear algebra over matrices and vectors is `LinearSpace`, which defines addition and dot products of matrices and vectors:
-* `VectorSpace` forms a mathematical space on top of array-like structure (`Buffer` and its type alias `Point` used for geometry).
+```kotlin
+import space.kscience.kmath.linear.*
-* `MatrixContext` forms a space-like context for 2d-structures. It does not store matrix size and therefore does not implement
-`Space` interface (it is impossible to create zero element without knowing the matrix size).
+LinearSpace.Companion.real {
+ val vec = buildVector(10) { i -> i.toDouble() }
+ val mat = buildMatrix(10, 10) { i, j -> i.toDouble() + j }
-## Vector spaces
+ // Addition
+ vec + vec
+ mat + mat
+ // Multiplication by scalar
+ vec * 2.0
+ mat * 2.0
-## Matrix operations
+ // Dot product
+ mat dot vec
+ mat dot mat
+}
+```
-## Back-end overview
\ No newline at end of file
+## Backends overview
+
+### EJML
+### Commons Math
diff --git a/docs/nd-structure.md b/docs/nd-structure.md
index ab214094e..3e9203ec0 100644
--- a/docs/nd-structure.md
+++ b/docs/nd-structure.md
@@ -11,16 +11,16 @@ Let us consider following contexts:
```kotlin
// automatically build context most suited for given type.
val autoField = NDField.auto(DoubleField, dim, dim)
- // specialized nd-field for Double. It works as generic Double field as well
+ // specialized nd-field for Double. It works as generic Double field as well.
val specializedField = NDField.real(dim, dim)
//A generic boxing field. It should be used for objects, not primitives.
val genericField = NDField.buffered(DoubleField, dim, dim)
```
-Now let us perform several tests and see which implementation is best suited for each case:
+Now let us perform several tests and see, which implementation is best suited for each case:
## Test case
-In order to test performance we will take 2d-structures with `dim = 1000` and add a structure filled with `1.0`
+To test performance we will take 2d-structures with `dim = 1000` and add a structure filled with `1.0`
to it `n = 1000` times.
## Specialized
@@ -35,8 +35,8 @@ The code to run this looks like:
```
The performance of this code is the best of all tests since it inlines all operations and is specialized for operation
with doubles. We will measure everything else relative to this one, so time for this test will be `1x` (real time
-on my computer is about 4.5 seconds). The only problem with this approach is that it requires to specify type
-from the beginning. Everyone do so anyway, so it is the recommended approach.
+on my computer is about 4.5 seconds). The only problem with this approach is that it requires specifying type
+from the beginning. Everyone does so anyway, so it is the recommended approach.
## Automatic
Let's do the same with automatic field inference:
@@ -49,7 +49,7 @@ Let's do the same with automatic field inference:
}
```
Ths speed of this operation is approximately the same as for specialized case since `NDField.auto` just
-returns the same `RealNDField` in this case. Of course it is usually better to use specialized method to be sure.
+returns the same `RealNDField` in this case. Of course, it is usually better to use specialized method to be sure.
## Lazy
Lazy field does not produce a structure when asked, instead it generates an empty structure and fills it on-demand
@@ -63,7 +63,7 @@ When one calls
}
}
```
-The result will be calculated almost immediately but the result will be empty. In order to get the full result
+The result will be calculated almost immediately but the result will be empty. To get the full result
structure one needs to call all its elements. In this case computation overhead will be huge. So this field never
should be used if one expects to use the full result structure. Though if one wants only small fraction, it could
save a lot of time.
@@ -94,7 +94,7 @@ The boxing field produced by
}
}
```
-obviously is the slowest one, because it requires to box and unbox the `double` on each operation. It takes about
+is the slowest one, because it requires boxing and unboxing the `double` on each operation. It takes about
`15x` time (**TODO: there seems to be a problem here, it should be slow, but not that slow**). This field should
never be used for primitives.
@@ -123,6 +123,6 @@ for i in range(1000):
```
gives the completion time of about `1.1x`, which means that specialized kotlin code in fact is working faster (I think it is
because better memory management). Of course if one writes `res += 1.0`, the performance will be different,
-but it would be differenc case, because numpy overrides `+=` with in-place operations. In-place operations are
+but it would be different case, because numpy overrides `+=` with in-place operations. In-place operations are
available in `kmath` with `MutableNDStructure` but there is no field for it (one can still work with mapping
functions).
\ No newline at end of file
diff --git a/docs/readme.md b/docs/readme.md
new file mode 100644
index 000000000..2953b7113
--- /dev/null
+++ b/docs/readme.md
@@ -0,0 +1,14 @@
+# Documentation
+
+* [Algebra](algebra.md): [context-based](contexts.md) operations on different primitives and structures.
+
+* [NDStructures](nd-structure.md)
+
+* [Linear algebra](linear.md): matrices, operations and linear equations solving. To be moved to separate module.
+ Currently, supports basic API and multiple library back-ends.
+
+* [Histograms](histograms.md): multidimensional histogram calculation and operations.
+
+* [Expressions](expressions.md)
+
+* Commons math integration
diff --git a/docs/templates/README-TEMPLATE.md b/docs/templates/README-TEMPLATE.md
index bad11a31a..e75d4c5ed 100644
--- a/docs/templates/README-TEMPLATE.md
+++ b/docs/templates/README-TEMPLATE.md
@@ -6,10 +6,10 @@
# 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 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 (**WIP**)](https://mipt-npm.github.io/kmath/)
@@ -21,26 +21,33 @@ be achieved with [kmath-for-real](/kmath-for-real) extension module.
# Goal
-* Provide a flexible and powerful API to work with mathematics abstractions in Kotlin-multiplatform (JVM, JS and Native).
+* Provide a flexible and powerful API to work with mathematics abstractions in Kotlin-multiplatform (JVM, JS and Native)
+ .
* Provide basic multiplatform implementations for those abstractions (without significant performance optimization).
* Provide bindings and wrappers with those abstractions for popular optimized platform libraries.
## Non-goals
-* Be like NumPy. It was the idea at the beginning, but we decided that we can do better in terms of API.
+* 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 `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.
## 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 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.
-* **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 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.
+* **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.
+* **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.
@@ -78,30 +85,33 @@ $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, the Kotlin/JVM is the primary platform, however Kotlin/Native and Kotlin/JS contributions and
+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, the Kotlin/JVM is the primary platform, however Kotlin/Native and Kotlin/JS contributions and
feedback are also welcome.
## Performance
-Calculation performance is one of major goals of KMath in the future, but in some cases it is impossible to achieve
-both performance and flexibility.
+Calculation performance is one of major goals of KMath in the future, but in some cases it is impossible to achieve both
+performance and flexibility.
-We expect to focus on creating 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
+We expect to focus on creating 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 to use GraalVM-CE 11 for execution in order to get better performance.
+KMath currently relies on JDK 11 for compilation and execution of Kotlin-JVM part. We recommend to use GraalVM-CE 11 for
+execution to get better performance.
### 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:
+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:
```kotlin
repositories {
@@ -118,7 +128,7 @@ Gradle `6.0+` is required for multiplatform artifacts.
## Contributing
-The project requires a lot of additional work. The most important thing we need is a 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
+The project requires a lot of additional work. The most important thing we need is a 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
[waiting for a hero](https://github.com/mipt-npm/kmath/labels/waiting%20for%20a%20hero) label.
diff --git a/examples/src/main/kotlin/space/kscience/kmath/ast/kotlingradSupport.kt b/examples/src/main/kotlin/space/kscience/kmath/ast/kotlingradSupport.kt
index 6ceaa962a..dec3bfb81 100644
--- a/examples/src/main/kotlin/space/kscience/kmath/ast/kotlingradSupport.kt
+++ b/examples/src/main/kotlin/space/kscience/kmath/ast/kotlingradSupport.kt
@@ -13,8 +13,8 @@ import space.kscience.kmath.kotlingrad.toKotlingradExpression
import space.kscience.kmath.operations.DoubleField
/**
- * In this example, x^2-4*x-44 function is differentiated with Kotlin∇, and the autodiff result is compared with
- * valid derivative in a certain point.
+ * In this example, *x2 − 4 x − 44* function is differentiated with Kotlin∇, and the
+ * derivation result is compared with valid derivative in a certain point.
*/
fun main() {
val actualDerivative = "x^2-4*x-44"
diff --git a/examples/src/main/kotlin/space/kscience/kmath/ast/symjaSupport.kt b/examples/src/main/kotlin/space/kscience/kmath/ast/symjaSupport.kt
index a9eca0500..7e09faeff 100644
--- a/examples/src/main/kotlin/space/kscience/kmath/ast/symjaSupport.kt
+++ b/examples/src/main/kotlin/space/kscience/kmath/ast/symjaSupport.kt
@@ -13,8 +13,8 @@ import space.kscience.kmath.operations.DoubleField
import space.kscience.kmath.symja.toSymjaExpression
/**
- * In this example, x^2-4*x-44 function is differentiated with Symja, and the autodiff result is compared with
- * valid derivative in a certain point.
+ * In this example, *x2 − 4 x − 44* function is differentiated with Symja, and the
+ * derivation result is compared with valid derivative in a certain point.
*/
fun main() {
val actualDerivative = "x^2-4*x-44"
diff --git a/examples/src/main/kotlin/space/kscience/kmath/commons/fit/fitWithAutoDiff.kt b/examples/src/main/kotlin/space/kscience/kmath/commons/fit/fitWithAutoDiff.kt
index 5e64235e3..9118d09ae 100644
--- a/examples/src/main/kotlin/space/kscience/kmath/commons/fit/fitWithAutoDiff.kt
+++ b/examples/src/main/kotlin/space/kscience/kmath/commons/fit/fitWithAutoDiff.kt
@@ -25,8 +25,7 @@ import space.kscience.plotly.models.TraceValues
import kotlin.math.pow
import kotlin.math.sqrt
-//Forward declaration of symbols that will be used in expressions.
-// This declaration is required for
+// Forward declaration of symbols that will be used in expressions.
private val a by symbol
private val b by symbol
private val c by symbol
diff --git a/examples/src/main/kotlin/space/kscience/kmath/jafama/JafamaDemo.kt b/examples/src/main/kotlin/space/kscience/kmath/jafama/JafamaDemo.kt
new file mode 100644
index 000000000..9c3d0fdbe
--- /dev/null
+++ b/examples/src/main/kotlin/space/kscience/kmath/jafama/JafamaDemo.kt
@@ -0,0 +1,15 @@
+/*
+ * Copyright 2018-2021 KMath contributors.
+ * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
+ */
+
+package space.kscience.kmath.jafama
+
+import space.kscience.kmath.operations.invoke
+
+fun main() {
+ val a = 2.0
+ val b = StrictJafamaDoubleField { exp(a) }
+ println(JafamaDoubleField { b + a })
+ println(StrictJafamaDoubleField { ln(b) })
+}
diff --git a/examples/src/main/kotlin/space/kscience/kmath/jafama/KMathaJafamaDemo.kt b/examples/src/main/kotlin/space/kscience/kmath/jafama/KMathaJafamaDemo.kt
deleted file mode 100644
index 879aab08f..000000000
--- a/examples/src/main/kotlin/space/kscience/kmath/jafama/KMathaJafamaDemo.kt
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright 2018-2021 KMath contributors.
- * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
- */
-
-package space.kscience.kmath.jafama
-
-import net.jafama.FastMath
-
-
-fun main(){
- val a = JafamaDoubleField.number(2.0)
- val b = StrictJafamaDoubleField.power(FastMath.E,a)
-
- println(JafamaDoubleField.add(b,a))
- println(StrictJafamaDoubleField.ln(b))
-}
diff --git a/examples/src/main/kotlin/space/kscience/kmath/stat/DistributionDemo.kt b/examples/src/main/kotlin/space/kscience/kmath/stat/DistributionDemo.kt
index b319766e3..bde83cea9 100644
--- a/examples/src/main/kotlin/space/kscience/kmath/stat/DistributionDemo.kt
+++ b/examples/src/main/kotlin/space/kscience/kmath/stat/DistributionDemo.kt
@@ -10,9 +10,6 @@ import space.kscience.kmath.chains.Chain
import space.kscience.kmath.chains.collectWithState
import space.kscience.kmath.distributions.NormalDistribution
-/**
- * The state of distribution averager.
- */
private data class AveragingChainState(var num: Int = 0, var value: Double = 0.0)
/**
diff --git a/examples/src/main/kotlin/space/kscience/kmath/structures/NDField.kt b/examples/src/main/kotlin/space/kscience/kmath/structures/NDField.kt
index 501bf98db..e1621d477 100644
--- a/examples/src/main/kotlin/space/kscience/kmath/structures/NDField.kt
+++ b/examples/src/main/kotlin/space/kscience/kmath/structures/NDField.kt
@@ -32,7 +32,7 @@ fun main() {
// automatically build context most suited for given type.
val autoField = AlgebraND.auto(DoubleField, dim, dim)
- // specialized nd-field for Double. It works as generic Double field as well
+ // specialized nd-field for Double. It works as generic Double field as well.
val realField = AlgebraND.real(dim, dim)
//A generic boxing field. It should be used for objects, not primitives.
val boxingField = AlgebraND.field(DoubleField, Buffer.Companion::boxing, dim, dim)
diff --git a/examples/src/main/kotlin/space/kscience/kmath/tensors/DataSetNormalization.kt b/examples/src/main/kotlin/space/kscience/kmath/tensors/DataSetNormalization.kt
index 74795cc68..ad6890b15 100644
--- a/examples/src/main/kotlin/space/kscience/kmath/tensors/DataSetNormalization.kt
+++ b/examples/src/main/kotlin/space/kscience/kmath/tensors/DataSetNormalization.kt
@@ -17,7 +17,7 @@ fun main() = BroadcastDoubleTensorAlgebra { // work in context with broadcast m
dataset += fromArray(
intArrayOf(5),
- doubleArrayOf(0.0, 1.0, 1.5, 3.0, 5.0) // rows means
+ doubleArrayOf(0.0, 1.0, 1.5, 3.0, 5.0) // row means
)
@@ -28,7 +28,7 @@ fun main() = BroadcastDoubleTensorAlgebra { // work in context with broadcast m
println("Mean:\n$mean")
println("Standard deviation:\n$std")
- // also we can calculate other statistic as minimum and maximum of rows
+ // also, we can calculate other statistic as minimum and maximum of rows
println("Minimum:\n${dataset.min(0, false)}")
println("Maximum:\n${dataset.max(0, false)}")
diff --git a/examples/src/main/kotlin/space/kscience/kmath/tensors/LinearSystemSolvingWithLUP.kt b/examples/src/main/kotlin/space/kscience/kmath/tensors/LinearSystemSolvingWithLUP.kt
index 6453ca44e..3e6a60c31 100644
--- a/examples/src/main/kotlin/space/kscience/kmath/tensors/LinearSystemSolvingWithLUP.kt
+++ b/examples/src/main/kotlin/space/kscience/kmath/tensors/LinearSystemSolvingWithLUP.kt
@@ -42,7 +42,7 @@ fun main() = BroadcastDoubleTensorAlgebra {// work in context with linear operat
// get P, L, U such that PA = LU
val (p, l, u) = a.lu()
- // check that P is permutation matrix
+ // check P is permutation matrix
println("P:\n$p")
// L is lower triangular matrix and U is upper triangular matrix
println("L:\n$l")
diff --git a/examples/src/main/kotlin/space/kscience/kmath/tensors/NeuralNetwork.kt b/examples/src/main/kotlin/space/kscience/kmath/tensors/NeuralNetwork.kt
index b262bee02..55a9aa67a 100644
--- a/examples/src/main/kotlin/space/kscience/kmath/tensors/NeuralNetwork.kt
+++ b/examples/src/main/kotlin/space/kscience/kmath/tensors/NeuralNetwork.kt
@@ -186,7 +186,7 @@ fun main() = BroadcastDoubleTensorAlgebra {
x += fromArray(
intArrayOf(5),
- doubleArrayOf(0.0, -1.0, -2.5, -3.0, 5.5) // rows means
+ doubleArrayOf(0.0, -1.0, -2.5, -3.0, 5.5) // row means
)
diff --git a/examples/src/main/kotlin/space/kscience/kmath/tensors/PCA.kt b/examples/src/main/kotlin/space/kscience/kmath/tensors/PCA.kt
index 411e048d7..b973abdef 100644
--- a/examples/src/main/kotlin/space/kscience/kmath/tensors/PCA.kt
+++ b/examples/src/main/kotlin/space/kscience/kmath/tensors/PCA.kt
@@ -65,8 +65,8 @@ fun main(): Unit = BroadcastDoubleTensorAlgebra { // work in context with broad
val datasetReduced = v dot stack(listOf(xScaled, yScaled))
println("Reduced data:\n$datasetReduced")
- // we can restore original data from reduced data.
- // for example, find 7th element of dataset
+ // we can restore original data from reduced data;
+ // for example, find 7th element of dataset.
val n = 7
val restored = (datasetReduced[n] dot v.view(intArrayOf(1, 2))) * std + mean
println("Original value:\n${dataset[n]}")
diff --git a/kmath-ast/README.md b/kmath-ast/README.md
index c3c4c38a1..686506f6f 100644
--- a/kmath-ast/README.md
+++ b/kmath-ast/README.md
@@ -106,7 +106,7 @@ var executable = function (constants, arguments) {
};
```
-JS also supports very experimental expression optimization with [WebAssembly](https://webassembly.org/) IR generation.
+JS also supports experimental expression optimization with [WebAssembly](https://webassembly.org/) IR generation.
Currently, only expressions inside `DoubleField` and `IntRing` are supported.
```kotlin
@@ -161,7 +161,10 @@ public fun main() {
Result LaTeX:
+
+
![](https://latex.codecogs.com/gif.latex?%5Coperatorname{exp}%5C,%5Cleft(%5Csqrt{x}%5Cright)-%5Cfrac{%5Cfrac{%5Coperatorname{arcsin}%5C,%5Cleft(2%5C,x%5Cright)}{2%5Ctimes10^{10}%2Bx^{3}}}{12}+x^{2/3})
+
Result MathML (can be used with MathJax or other renderers):
diff --git a/kmath-ast/docs/README-TEMPLATE.md b/kmath-ast/docs/README-TEMPLATE.md
index b90f8ff08..9494af63a 100644
--- a/kmath-ast/docs/README-TEMPLATE.md
+++ b/kmath-ast/docs/README-TEMPLATE.md
@@ -77,7 +77,7 @@ var executable = function (constants, arguments) {
};
```
-JS also supports very experimental expression optimization with [WebAssembly](https://webassembly.org/) IR generation.
+JS also supports experimental expression optimization with [WebAssembly](https://webassembly.org/) IR generation.
Currently, only expressions inside `DoubleField` and `IntRing` are supported.
```kotlin
@@ -132,7 +132,10 @@ public fun main() {
Result LaTeX:
+
+
![](https://latex.codecogs.com/gif.latex?%5Coperatorname{exp}%5C,%5Cleft(%5Csqrt{x}%5Cright)-%5Cfrac{%5Cfrac{%5Coperatorname{arcsin}%5C,%5Cleft(2%5C,x%5Cright)}{2%5Ctimes10^{10}%2Bx^{3}}}{12}+x^{2/3})
+
Result MathML (can be used with MathJax or other renderers):
diff --git a/kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/rendering/MathSyntax.kt b/kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/rendering/MathSyntax.kt
index 38450403d..ee23ab408 100644
--- a/kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/rendering/MathSyntax.kt
+++ b/kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/rendering/MathSyntax.kt
@@ -8,7 +8,7 @@ package space.kscience.kmath.ast.rendering
import space.kscience.kmath.misc.UnstableKMathAPI
/**
- * Mathematical typography syntax node.
+ * Syntax node for mathematical typography.
*
* @author Iaroslav Postovalov
*/
@@ -301,7 +301,7 @@ public data class BinaryPlusSyntax(
}
/**
- * Represents binary, infix subtraction (*42 - 42*).
+ * Represents binary, infix subtraction (*42 − 42*).
*
* @param left The minuend.
* @param right The subtrahend.
diff --git a/kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/rendering/SyntaxRenderer.kt b/kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/rendering/SyntaxRenderer.kt
index fb2b3b66f..362c07d72 100644
--- a/kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/rendering/SyntaxRenderer.kt
+++ b/kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/rendering/SyntaxRenderer.kt
@@ -9,7 +9,7 @@ import space.kscience.kmath.misc.UnstableKMathAPI
/**
* Abstraction of writing [MathSyntax] as a string of an actual markup language. Typical implementation should
- * involve traversal of MathSyntax with handling each its subtype.
+ * involve traversal of MathSyntax with handling each subtype.
*
* @author Iaroslav Postovalov
*/
diff --git a/kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/rendering/features.kt b/kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/rendering/features.kt
index 37e9a8c19..8a4804916 100644
--- a/kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/rendering/features.kt
+++ b/kmath-ast/src/commonMain/kotlin/space/kscience/kmath/ast/rendering/features.kt
@@ -49,7 +49,7 @@ else
NumberSyntax(string = s)
/**
- * Special printing for numeric types which are printed in form of
+ * Special printing for numeric types that are printed in form of
* *('-'? (DIGIT+ ('.' DIGIT+)? ('E' '-'? DIGIT+)? | 'Infinity')) | 'NaN'*.
*
* @property types The suitable types.
@@ -110,7 +110,7 @@ public class PrettyPrintFloats(public val types: Set>) : Rend
}
/**
- * Special printing for numeric types which are printed in form of *'-'? DIGIT+*.
+ * Special printing for numeric types that are printed in form of *'-'? DIGIT+*.
*
* @property types The suitable types.
* @author Iaroslav Postovalov
@@ -155,7 +155,7 @@ public class PrettyPrintPi(public val symbols: Set) : RenderFeature {
}
/**
- * Abstract printing of unary operations which discards [MST] if their operation is not in [operations] or its type is
+ * Abstract printing of unary operations that discards [MST] if their operation is not in [operations] or its type is
* not [MST.Unary].
*
* @param operations the allowed operations. If `null`, any operation is accepted.
@@ -176,7 +176,7 @@ public abstract class Unary(public val operations: Collection?) : Render
}
/**
- * Abstract printing of unary operations which discards [MST] if their operation is not in [operations] or its type is
+ * Abstract printing of unary operations that discards [MST] if their operation is not in [operations] or its type is
* not [MST.Binary].
*
* @property operations the allowed operations. If `null`, any operation is accepted.
diff --git a/kmath-ast/src/jvmMain/kotlin/space/kscience/kmath/asm/internal/codegenUtils.kt b/kmath-ast/src/jvmMain/kotlin/space/kscience/kmath/asm/internal/codegenUtils.kt
index a84248f63..06e040e93 100644
--- a/kmath-ast/src/jvmMain/kotlin/space/kscience/kmath/asm/internal/codegenUtils.kt
+++ b/kmath-ast/src/jvmMain/kotlin/space/kscience/kmath/asm/internal/codegenUtils.kt
@@ -57,13 +57,13 @@ internal fun MethodVisitor.label(): Label = Label().also(::visitLabel)
/**
* Creates a class name for [Expression] subclassed to implement [mst] provided.
*
- * This methods helps to avoid collisions of class name to prevent loading several classes with the same name. If there
+ * These methods help to avoid collisions of class name to prevent loading several classes with the same name. If there
* is a colliding class, change [collision] parameter or leave it `0` to check existing classes recursively.
*
* @author Iaroslav Postovalov
*/
internal tailrec fun buildName(mst: MST, collision: Int = 0): String {
- val name = "space.kscience.kmath.asm.generated.AsmCompiledExpression_${mst.hashCode()}_$collision"
+ val name = "space.kscience.kmath.asm.generated.CompiledExpression_${mst.hashCode()}_$collision"
try {
Class.forName(name)
diff --git a/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/expressions/DerivativeStructureExpression.kt b/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/expressions/DerivativeStructureExpression.kt
index 0925fee7e..d5473063a 100644
--- a/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/expressions/DerivativeStructureExpression.kt
+++ b/kmath-commons/src/main/kotlin/space/kscience/kmath/commons/expressions/DerivativeStructureExpression.kt
@@ -31,7 +31,7 @@ public class DerivativeStructureField(
override fun number(value: Number): DerivativeStructure = const(value.toDouble())
/**
- * A class that implements both [DerivativeStructure] and a [Symbol]
+ * A class implementing both [DerivativeStructure] and [Symbol].
*/
public inner class DerivativeStructureSymbol(
size: Int,
diff --git a/kmath-commons/src/test/kotlin/space/kscience/kmath/commons/expressions/DerivativeStructureExpressionTest.kt b/kmath-commons/src/test/kotlin/space/kscience/kmath/commons/expressions/DerivativeStructureExpressionTest.kt
index 0bf1d53f0..3c57f5467 100644
--- a/kmath-commons/src/test/kotlin/space/kscience/kmath/commons/expressions/DerivativeStructureExpressionTest.kt
+++ b/kmath-commons/src/test/kotlin/space/kscience/kmath/commons/expressions/DerivativeStructureExpressionTest.kt
@@ -34,7 +34,7 @@ internal class AutoDiffTest {
println(z.derivative(x))
println(z.derivative(y, x))
assertEquals(z.derivative(x, y), z.derivative(y, x))
- //check that improper order cause failure
+ // check improper order cause failure
assertFails { z.derivative(x, x, y) }
}
}
diff --git a/kmath-commons/src/test/kotlin/space/kscience/kmath/commons/optimization/OptimizeTest.kt b/kmath-commons/src/test/kotlin/space/kscience/kmath/commons/optimization/OptimizeTest.kt
index 15c9120ec..b0e5d7904 100644
--- a/kmath-commons/src/test/kotlin/space/kscience/kmath/commons/optimization/OptimizeTest.kt
+++ b/kmath-commons/src/test/kotlin/space/kscience/kmath/commons/optimization/OptimizeTest.kt
@@ -27,7 +27,7 @@ internal class OptimizeTest {
fun testGradientOptimization() {
val result = normal.optimize(x, y) {
initialGuess(x to 1.0, y to 1.0)
- //no need to select optimizer. Gradient optimizer is used by default because gradients are provided by function
+ // no need to select optimizer. Gradient optimizer is used by default because gradients are provided by function.
}
println(result.point)
println(result.value)
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/DifferentiableExpression.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/DifferentiableExpression.kt
index ce1265b2f..19befe6e6 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/DifferentiableExpression.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/DifferentiableExpression.kt
@@ -6,7 +6,7 @@
package space.kscience.kmath.expressions
/**
- * Represents expression which structure can be differentiated.
+ * Represents expression, which structure can be differentiated.
*
* @param T the type this expression takes as argument and returns.
*/
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/Expression.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/Expression.kt
index 84e66918f..5105c2bec 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/Expression.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/Expression.kt
@@ -43,7 +43,7 @@ public operator fun Expression.invoke(vararg pairs: Pair): T =
/**
* Calls this expression from arguments.
*
- * @param pairs the pairs of arguments' names to values.
+ * @param pairs the pairs of arguments' names to value.
* @return a value.
*/
@JvmName("callByString")
@@ -60,7 +60,7 @@ public operator fun Expression.invoke(vararg pairs: Pair): T =
public interface ExpressionAlgebra : Algebra {
/**
- * A constant expression which does not depend on arguments
+ * A constant expression that does not depend on arguments.
*/
public fun const(value: T): E
}
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/FunctionalExpressionAlgebra.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/FunctionalExpressionAlgebra.kt
index 5935424b6..838118339 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/FunctionalExpressionAlgebra.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/expressions/FunctionalExpressionAlgebra.kt
@@ -18,7 +18,7 @@ public abstract class FunctionalExpressionAlgebra>(
public val algebra: A,
) : ExpressionAlgebra> {
/**
- * Builds an Expression of constant expression which does not depend on arguments.
+ * Builds an Expression of constant expression that does not depend on arguments.
*/
override fun const(value: T): Expression = Expression { value }
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/LinearSolver.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/LinearSolver.kt
index 9c3ffd819..d63f141ba 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/LinearSolver.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/LinearSolver.kt
@@ -8,8 +8,8 @@ package space.kscience.kmath.linear
import space.kscience.kmath.nd.as1D
/**
- * A group of methods to solve for *X* in equation *X = A -1 · B*, where *A* and *B* are matrices or
- * vectors.
+ * A group of methods to solve for *X* in equation *X = A−1 · B*, where *A* and *B* are
+ * matrices or vectors.
*
* @param T the type of items.
*/
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/LinearSpace.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/LinearSpace.kt
index badf2794e..63b881105 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/LinearSpace.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/LinearSpace.kt
@@ -164,7 +164,7 @@ public interface LinearSpace> {
public operator fun T.times(v: Point): Point = v * this
/**
- * Get a feature of the structure in this scope. Structure features take precedence other context features
+ * Get a feature of the structure in this scope. Structure features take precedence other context features.
*
* @param F the type of feature.
* @param structure the structure.
@@ -195,7 +195,7 @@ public interface LinearSpace> {
}
/**
- * Get a feature of the structure in this scope. Structure features take precedence other context features
+ * Get a feature of the structure in this scope. Structure features take precedence other context features.
*
* @param T the type of items in the matrices.
* @param F the type of feature.
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/LupDecomposition.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/LupDecomposition.kt
index f3653d394..25f53f65d 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/LupDecomposition.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/LupDecomposition.kt
@@ -114,7 +114,7 @@ public fun > LinearSpace>.lup(
for (i in 0 until col) sum -= luRow[i] * lu[i, col]
luRow[col] = sum
- // maintain best permutation choice
+ // maintain the best permutation choice
if (abs(sum) > largest) {
largest = abs(sum)
max = row
@@ -241,7 +241,7 @@ public fun LinearSpace.solveWithLup(a: Matrix, b: M
}
/**
- * Inverses a square matrix using LUP decomposition. Non square matrix will throw a error.
+ * Inverses a square matrix using LUP decomposition. Non square matrix will throw an error.
*/
public fun LinearSpace.inverseWithLup(matrix: Matrix): Matrix =
solveWithLup(matrix, one(matrix.rowNum, matrix.colNum))
\ No newline at end of file
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/MatrixFeatures.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/MatrixFeatures.kt
index e0d733a66..b70e9d8a9 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/MatrixFeatures.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/MatrixFeatures.kt
@@ -31,7 +31,7 @@ public object ZeroFeature : DiagonalFeature
public object UnitFeature : DiagonalFeature
/**
- * Matrices with this feature can be inverted: [inverse] = `a`-1 where `a` is the owning matrix.
+ * Matrices with this feature can be inverted: *[inverse] = a−1* where *a* is the owning matrix.
*
* @param T the type of matrices' items.
*/
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/MatrixWrapper.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/MatrixWrapper.kt
index 4b624b6a0..df3852d72 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/MatrixWrapper.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/linear/MatrixWrapper.kt
@@ -22,7 +22,8 @@ public class MatrixWrapper internal constructor(
) : Matrix by origin {
/**
- * Get the first feature matching given class. Does not guarantee that matrix has only one feature matching the criteria
+ * Get the first feature matching given class. Does not guarantee that matrix has only one feature matching the
+ * criteria.
*/
@UnstableKMathAPI
@Suppress("UNCHECKED_CAST")
@@ -61,7 +62,7 @@ public operator fun Matrix.plus(newFeatures: Collection LinearSpace>.one(
rows: Int,
@@ -87,7 +88,7 @@ public class TransposedFeature(public val original: Matrix) : Ma
* Create a virtual transposed matrix without copying anything. `A.transpose().transpose() === A`
*/
@OptIn(UnstableKMathAPI::class)
-public fun Matrix.transpose(): Matrix = getFeature>()?.original ?: VirtualMatrix(
+public fun Matrix.transpose(): Matrix = getFeature>()?.original ?: (VirtualMatrix(
colNum,
rowNum,
-) { i, j -> get(j, i) } + TransposedFeature(this)
\ No newline at end of file
+) { i, j -> get(j, i) } + TransposedFeature(this))
\ No newline at end of file
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/misc/annotations.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/misc/annotations.kt
index e521e6237..99f959c86 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/misc/annotations.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/misc/annotations.kt
@@ -7,8 +7,8 @@ package space.kscience.kmath.misc
/**
* Marks declarations that are still experimental in the KMath APIs, which means that the design of the corresponding
- * declarations has open issues which may (or may not) lead to their changes in the future. Roughly speaking, there is
- * a chance that those declarations will be deprecated in the near future or the semantics of their behavior may change
+ * declarations has open issues that may (or may not) lead to their changes in the future. Roughly speaking, there is
+ * a chance of those declarations will be deprecated in the near future or the semantics of their behavior may change
* in some way that may break some code.
*/
@MustBeDocumented
@@ -17,7 +17,7 @@ package space.kscience.kmath.misc
public annotation class UnstableKMathAPI
/**
- * Marks API which could cause performance problems. The code, marked by this API is not necessary slow, but could cause
+ * Marks API that could cause performance problems. The code marked by this API is unnecessary slow but could cause
* slow-down in some cases. Refer to the documentation and benchmark it to be sure.
*/
@MustBeDocumented
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/AlgebraND.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/AlgebraND.kt
index 7b0b06a58..454a33e86 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/AlgebraND.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/AlgebraND.kt
@@ -11,7 +11,7 @@ import space.kscience.kmath.structures.*
import kotlin.reflect.KClass
/**
- * An exception is thrown when the expected ans actual shape of NDArray differs.
+ * An exception is thrown when the expected and actual shape of NDArray differ.
*
* @property expected the expected shape.
* @property actual the actual shape.
@@ -63,7 +63,7 @@ public interface AlgebraND> {
structure.map { value -> this@invoke(value) }
/**
- * Get a feature of the structure in this scope. Structure features take precedence other context features
+ * Get a feature of the structure in this scope. Structure features take precedence other context features.
*
* @param F the type of feature.
* @param structure the structure.
@@ -79,7 +79,7 @@ public interface AlgebraND> {
/**
- * Get a feature of the structure in this scope. Structure features take precedence other context features
+ * Get a feature of the structure in this scope. Structure features take precedence other context features.
*
* @param T the type of items in the matrices.
* @param F the type of feature.
@@ -130,15 +130,6 @@ public interface GroupND> : Group>, AlgebraND
override fun add(a: StructureND, b: StructureND): StructureND =
combine(a, b) { aValue, bValue -> add(aValue, bValue) }
-// /**
-// * Element-wise multiplication by scalar.
-// *
-// * @param a the multiplicand.
-// * @param k the multiplier.
-// * @return the product.
-// */
-// override fun multiply(a: NDStructure, k: Number): NDStructure = a.map { multiply(it, k) }
-
// TODO move to extensions after KEEP-176
/**
@@ -226,7 +217,7 @@ public interface RingND> : Ring>, GroupND> : Field>, RingND, ScaleOperations> {
+public interface FieldND> : Field>, RingND {
/**
* Element-wise division.
*
@@ -256,6 +247,15 @@ public interface FieldND> : Field>, RingND): StructureND = arg.map { divide(it, this@div) }
+ /**
+ * Element-wise scaling.
+ *
+ * @param a the multiplicand.
+ * @param value the multiplier.
+ * @return the product.
+ */
+ override fun scale(a: StructureND, value: Double): StructureND = a.map { scale(it, value) }
+
// @ThreadLocal
// public companion object {
// private val realNDFieldCache: MutableMap = hashMapOf()
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/Structure1D.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/Structure1D.kt
index d916bc0d6..1af80149c 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/Structure1D.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/Structure1D.kt
@@ -110,7 +110,7 @@ internal class MutableBuffer1DWrapper(val buffer: MutableBuffer) : Mutable
}
/**
- * Represent a [StructureND] as [Structure1D]. Throw error in case of dimension mismatch
+ * Represent a [StructureND] as [Structure1D]. Throw error in case of dimension mismatch.
*/
public fun StructureND.as1D(): Structure1D = this as? Structure1D ?: if (shape.size == 1) {
when (this) {
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/Structure2D.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/Structure2D.kt
index cb69bdc00..293faaeda 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/Structure2D.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/Structure2D.kt
@@ -144,13 +144,16 @@ private class MutableStructure2DWrapper(val structure: MutableStructureND)
}
/**
- * Represent a [StructureND] as [Structure1D]. Throw error in case of dimension mismatch
+ * Represents a [StructureND] as [Structure2D]. Throws runtime error in case of dimension mismatch.
*/
public fun StructureND.as2D(): Structure2D = this as? Structure2D ?: when (shape.size) {
2 -> Structure2DWrapper(this)
else -> error("Can't create 2d-structure from ${shape.size}d-structure")
}
+/**
+ * Represents a [StructureND] as [Structure2D]. Throws runtime error in case of dimension mismatch.
+ */
public fun MutableStructureND.as2D(): MutableStructure2D = this as? MutableStructure2D ?: when (shape.size) {
2 -> MutableStructure2DWrapper(this)
else -> error("Can't create 2d-structure from ${shape.size}d-structure")
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/StructureND.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/StructureND.kt
index 1ad8289bc..716bd15f3 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/StructureND.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/nd/StructureND.kt
@@ -16,7 +16,7 @@ import kotlin.reflect.KClass
public interface StructureFeature
/**
- * Represents n-dimensional structure, i.e. multidimensional container of items of the same type and size. The number
+ * Represents n-dimensional structure i.e., multidimensional container of items of the same type and size. The number
* of dimensions and items in an array is defined by its shape, which is a sequence of non-negative integers that
* specify the sizes of each dimension.
*
@@ -26,7 +26,7 @@ public interface StructureFeature
*/
public interface StructureND {
/**
- * 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.
*/
public val shape: IntArray
@@ -53,8 +53,8 @@ public interface StructureND {
public fun elements(): Sequence>
/**
- * Feature is some additional structure information which allows to access it special properties or hints.
- * If the feature is not present, null is returned.
+ * Feature is some additional structure information that allows to access it special properties or hints.
+ * If the feature is not present, `null` is returned.
*/
@UnstableKMathAPI
public fun getFeature(type: KClass): F? = null
@@ -177,7 +177,7 @@ public inline fun MutableStructureND.mapInPlace(action: (IntArray, T) ->
elements().forEach { (index, oldValue) -> this[index] = action(index, oldValue) }
/**
- * A way to convert ND index to linear one and back.
+ * A way to convert ND indices to linear one and back.
*/
public interface Strides {
/**
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/Algebra.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/Algebra.kt
index cef34dce2..1009742e1 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/Algebra.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/Algebra.kt
@@ -23,15 +23,13 @@ public interface Algebra {
* Wraps a raw string to [T] object. This method is designed for three purposes:
*
* 1. Mathematical constants (`e`, `pi`).
- * 2. Variables for expression-like contexts (`a`, `b`, `c`...).
- * 3. Literals (`{1, 2}`, (`(3; 4)`)).
+ * 1. Variables for expression-like contexts (`a`, `b`, `c`…).
+ * 1. Literals (`{1, 2}`, (`(3; 4)`)).
*
- * In case if algebra can't parse the string, this method must throw [kotlin.IllegalStateException].
- *
- * Returns `null` if symbol could not be bound to the context
+ * If algebra can't parse the string, then this method must throw [kotlin.IllegalStateException].
*
* @param value the raw string.
- * @return an object.
+ * @return an object or `null` if symbol could not be bound to the context.
*/
public fun bindSymbolOrNull(value: String): T? = null
@@ -42,13 +40,12 @@ public interface Algebra {
bindSymbolOrNull(value) ?: error("Symbol '$value' is not supported in $this")
/**
- * Dynamically dispatches an unary operation with the certain name.
+ * Dynamically dispatches a unary operation with the certain name.
*
- * This function must has two features:
+ * Implementations must fulfil the following requirements:
*
- * 1. In case operation is not defined in the structure, the function throws [kotlin.IllegalStateException].
- * 2. This function is symmetric with second `unaryOperation` overload:
- * i.e. `unaryOperationFunction(a)(b) == unaryOperation(a, b)`.
+ * 1. If operation is not defined in the structure, then the function throws [kotlin.IllegalStateException].
+ * 1. Equivalence to [unaryOperation]: for any `a` and `b`, `unaryOperationFunction(a)(b) == unaryOperation(a, b)`.
*
* @param operation the name of operation.
* @return an operation.
@@ -57,13 +54,13 @@ public interface Algebra {
error("Unary operation $operation not defined in $this")
/**
- * Dynamically invokes an unary operation with the certain name.
+ * Dynamically invokes a unary operation with the certain name.
*
- * This function must follow two properties:
+ * Implementations must fulfil the following requirements:
*
- * 1. In case if operation is not defined in the structure, the function throws [kotlin.IllegalStateException].
- * 2. This function is symmetric with second [unaryOperationFunction] overload:
- * i.e. `unaryOperationFunction(a)(b) == unaryOperation(a, b)`.
+ * 1. If operation is not defined in the structure, then the function throws [kotlin.IllegalStateException].
+ * 1. Equivalence to [unaryOperationFunction]: i.e., for any `a` and `b`,
+ * `unaryOperationFunction(a)(b) == unaryOperation(a, b)`.
*
* @param operation the name of operation.
* @param arg the argument of operation.
@@ -74,11 +71,11 @@ public interface Algebra {
/**
* Dynamically dispatches a binary operation with the certain name.
*
- * This function must follow two properties:
+ * Implementations must fulfil the following requirements:
*
- * 1. In case if operation is not defined in the structure, the function throws [kotlin.IllegalStateException].
- * 2. This function is symmetric with second [binaryOperationFunction] overload:
- * i.e. `binaryOperationFunction(a)(b, c) == binaryOperation(a, b, c)`.
+ * 1. If operation is not defined in the structure, then the function throws [kotlin.IllegalStateException].
+ * 1. Equivalence to [binaryOperation]: for any `a`, `b`, and `c`,
+ * `binaryOperationFunction(a)(b, c) == binaryOperation(a, b, c)`.
*
* @param operation the name of operation.
* @return an operation.
@@ -89,11 +86,11 @@ public interface Algebra {
/**
* Dynamically invokes a binary operation with the certain name.
*
- * This function must follow two properties:
+ * Implementations must fulfil the following requirements:
*
- * 1. In case if operation is not defined in the structure, the function throws [kotlin.IllegalStateException].
- * 2. This function is symmetric with second [binaryOperationFunction] overload:
- * i.e. `binaryOperationFunction(a)(b, c) == binaryOperation(a, b, c)`.
+ * 1. If operation is not defined in the structure, then the function throws [kotlin.IllegalStateException].
+ * 1. Equivalence to [binaryOperationFunction]: for any `a`, `b`, and `c`,
+ * `binaryOperationFunction(a)(b, c) == binaryOperation(a, b, c)`.
*
* @param operation the name of operation.
* @param left the first argument of operation.
@@ -115,7 +112,7 @@ public fun Algebra.bindSymbol(symbol: Symbol): T = bindSymbol(symbol.iden
public inline operator fun , R> A.invoke(block: A.() -> R): R = run(block)
/**
- * Represents group without neutral element (also known as inverse semigroup), i.e. algebraic structure with
+ * Represents group without neutral element (also known as inverse semigroup) i.e., algebraic structure with
* associative, binary operation [add].
*
* @param T the type of element of this semispace.
@@ -130,7 +127,7 @@ public interface GroupOperations : Algebra {
*/
public fun add(a: T, b: T): T
- // Operations to be performed in this context. Could be moved to extensions in case of KEEP-176
+ // Operations to be performed in this context. Could be moved to extensions in case of KEEP-176.
/**
* The negation of this element.
@@ -192,7 +189,7 @@ public interface GroupOperations : Algebra {
}
/**
- * Represents group, i.e. algebraic structure with associative, binary operation [add].
+ * Represents group i.e., algebraic structure with associative, binary operation [add].
*
* @param T the type of element of this semispace.
*/
@@ -204,7 +201,7 @@ public interface Group : GroupOperations {
}
/**
- * Represents ring without multiplicative and additive identities, i.e. algebraic structure with
+ * Represents ring without multiplicative and additive identities i.e., algebraic structure with
* associative, binary, commutative operation [add] and associative, operation [multiply] distributive over [add].
*
* @param T the type of element of this semiring.
@@ -240,7 +237,7 @@ public interface RingOperations : GroupOperations {
}
/**
- * Represents ring, i.e. algebraic structure with two associative binary operations called "addition" and
+ * Represents ring i.e., algebraic structure with two associative binary operations called "addition" and
* "multiplication" and their neutral elements.
*
* @param T the type of element of this ring.
@@ -253,8 +250,9 @@ public interface Ring : Group, RingOperations {
}
/**
- * Represents field without without multiplicative and additive identities, i.e. algebraic structure with associative, binary, commutative operations
- * [add] and [multiply]; binary operation [divide] as multiplication of left operand by reciprocal of right one.
+ * Represents field without multiplicative and additive identities i.e., algebraic structure with associative, binary,
+ * commutative operations [add] and [multiply]; binary operation [divide] as multiplication of left operand by
+ * reciprocal of right one.
*
* @param T the type of element of this semifield.
*/
@@ -291,7 +289,7 @@ public interface FieldOperations : RingOperations {
}
/**
- * Represents field, i.e. algebraic structure with three operations: associative, commutative addition and
+ * Represents field i.e., algebraic structure with three operations: associative, commutative addition and
* multiplication, and division. **This interface differs from the eponymous mathematical definition: fields in KMath
* also support associative multiplication by scalar.**
*
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/AlgebraElements.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/AlgebraElements.kt
index 403a9c9b1..6b0e2cabd 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/AlgebraElements.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/AlgebraElements.kt
@@ -8,7 +8,7 @@ package space.kscience.kmath.operations
import space.kscience.kmath.misc.UnstableKMathAPI
/**
- * The generic mathematics elements which is able to store its context
+ * The generic mathematics elements that is able to store its context
*
* @param C the type of mathematical context for this element.
* @param T the type wrapped by this wrapper.
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/BigInt.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/BigInt.kt
index 4ccbfc531..8111691aa 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/BigInt.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/BigInt.kt
@@ -121,7 +121,7 @@ public class BigInt internal constructor(
var r = ZERO
val bitSize =
- (BASE_SIZE * (this.magnitude.size - 1) + log2(this.magnitude.lastOrNull()?.toFloat() ?: 0f + 1)).toInt()
+ (BASE_SIZE * (this.magnitude.size - 1) + log2(this.magnitude.lastOrNull()?.toFloat() ?: (0f + 1))).toInt()
for (i in bitSize downTo 0) {
r = r shl 1
@@ -442,7 +442,7 @@ public fun UIntArray.toBigInt(sign: Byte): BigInt {
}
/**
- * Returns null if a valid number can not be read from a string
+ * Returns `null` if a valid number cannot be read from a string
*/
public fun String.parseBigInteger(): BigInt? {
if (isEmpty()) return null
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/NumericAlgebra.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/NumericAlgebra.kt
index 7a8fa5668..92070b33d 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/NumericAlgebra.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/NumericAlgebra.kt
@@ -26,11 +26,11 @@ public interface NumericAlgebra : Algebra {
/**
* Dynamically dispatches a binary operation with the certain name with numeric first argument.
*
- * This function must follow two properties:
+ * Implementations must fulfil the following requirements:
*
- * 1. In case if operation is not defined in the structure, the function throws [kotlin.IllegalStateException].
- * 2. This function is symmetric with the other [leftSideNumberOperation] overload:
- * i.e. `leftSideNumberOperationFunction(a)(b, c) == leftSideNumberOperation(a, b)`.
+ * 1. If operation is not defined in the structure, then function throws [kotlin.IllegalStateException].
+ * 1. Equivalence to [leftSideNumberOperation]: for any `a`, `b`, and `c`,
+ * `leftSideNumberOperationFunction(a)(b, c) == leftSideNumberOperation(a, b)`.
*
* @param operation the name of operation.
* @return an operation.
@@ -41,11 +41,11 @@ public interface NumericAlgebra : Algebra {
/**
* Dynamically invokes a binary operation with the certain name with numeric first argument.
*
- * This function must follow two properties:
+ * Implementations must fulfil the following requirements:
*
- * 1. In case if operation is not defined in the structure, the function throws [kotlin.IllegalStateException].
- * 2. This function is symmetric with second [leftSideNumberOperation] overload:
- * i.e. `leftSideNumberOperationFunction(a)(b, c) == leftSideNumberOperation(a, b, c)`.
+ * 1. If operation is not defined in the structure, then the function throws [kotlin.IllegalStateException].
+ * 1. Equivalence to [leftSideNumberOperation]: for any `a`, `b`, and `c`,
+ * `leftSideNumberOperationFunction(a)(b, c) == leftSideNumberOperation(a, b, c)`.
*
* @param operation the name of operation.
* @param left the first argument of operation.
@@ -58,11 +58,11 @@ public interface NumericAlgebra : Algebra {
/**
* Dynamically dispatches a binary operation with the certain name with numeric first argument.
*
- * This function must follow two properties:
+ * Implementations must fulfil the following requirements:
*
- * 1. In case if operation is not defined in the structure, the function throws [kotlin.IllegalStateException].
- * 2. This function is symmetric with the other [rightSideNumberOperationFunction] overload:
- * i.e. `rightSideNumberOperationFunction(a)(b, c) == leftSideNumberOperation(a, b, c)`.
+ * 1. If operation is not defined in the structure, then the function throws [kotlin.IllegalStateException].
+ * 1. Equivalence to [rightSideNumberOperation]: for any `a`, `b`, and `c`,
+ * `rightSideNumberOperationFunction(a)(b, c) == leftSideNumberOperation(a, b, c)`.
*
* @param operation the name of operation.
* @return an operation.
@@ -73,11 +73,11 @@ public interface NumericAlgebra : Algebra {
/**
* Dynamically invokes a binary operation with the certain name with numeric second argument.
*
- * This function must follow two properties:
+ * Implementations must fulfil the following requirements:
*
- * 1. In case if operation is not defined in the structure, the function throws [kotlin.IllegalStateException].
- * 2. This function is symmetric with the other [rightSideNumberOperationFunction] overload:
- * i.e. `rightSideNumberOperationFunction(a)(b, c) == rightSideNumberOperation(a, b, c)`.
+ * 1. If operation is not defined in the structure, then the function throws [kotlin.IllegalStateException].
+ * 1. Equivalence to [rightSideNumberOperationFunction]: for any `a`, `b`, and `c`,
+ * `rightSideNumberOperationFunction(a)(b, c) == rightSideNumberOperation(a, b, c)`.
*
* @param operation the name of operation.
* @param left the first argument of operation.
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/OptionalOperations.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/OptionalOperations.kt
index 86365394f..31bd47bc3 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/OptionalOperations.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/operations/OptionalOperations.kt
@@ -330,13 +330,13 @@ public fun >> atanh(arg: T):
*/
public interface Norm {
/**
- * Computes the norm of [arg] (i.e. absolute value or vector length).
+ * Computes the norm of [arg] (i.e., absolute value or vector length).
*/
public fun norm(arg: T): R
}
/**
- * Computes the norm of [arg] (i.e. absolute value or vector length).
+ * Computes the norm of [arg] (i.e., absolute value or vector length).
*/
@UnstableKMathAPI
public fun >, R> norm(arg: T): R = arg.context.norm(arg)
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/DoubleBuffer.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/DoubleBuffer.kt
index b4ef37598..7a79663c4 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/DoubleBuffer.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/DoubleBuffer.kt
@@ -32,7 +32,7 @@ public value class DoubleBuffer(public val array: DoubleArray) : MutableBuffer Double): DoubleBuffer = DoubleBuffer(DoubleArray(size) { init(it) })
@@ -47,7 +47,7 @@ public fun DoubleBuffer(vararg doubles: Double): DoubleBuffer = DoubleBuffer(dou
public fun DoubleBuffer.contentEquals(vararg doubles: Double): Boolean = array.contentEquals(doubles)
/**
- * Returns a new [DoubleArray] containing all of the elements of this [Buffer].
+ * Returns a new [DoubleArray] containing all the elements of this [Buffer].
*/
public fun Buffer.toDoubleArray(): DoubleArray = when (this) {
is DoubleBuffer -> array.copyOf()
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/FlaggedBuffer.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/FlaggedBuffer.kt
index 0b16a3afc..efb8504c2 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/FlaggedBuffer.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/FlaggedBuffer.kt
@@ -51,7 +51,7 @@ public fun FlaggedBuffer<*>.hasFlag(index: Int, flag: ValueFlag): Boolean = (get
public fun FlaggedBuffer<*>.isMissing(index: Int): Boolean = hasFlag(index, ValueFlag.MISSING)
/**
- * A real buffer which supports flags for each value like NaN or Missing
+ * A [Double] buffer that supports flags for each value like `NaN` or Missing.
*/
public class FlaggedDoubleBuffer(public val values: DoubleArray, public val flags: ByteArray) : FlaggedBuffer,
Buffer {
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/FloatBuffer.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/FloatBuffer.kt
index 58b7c6aea..e7e98fc71 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/FloatBuffer.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/FloatBuffer.kt
@@ -34,7 +34,7 @@ public value class FloatBuffer(public val array: FloatArray) : MutableBuffer Float): FloatBuffer = FloatBuffer(FloatArray(size) { init(it) })
@@ -44,7 +44,7 @@ public inline fun FloatBuffer(size: Int, init: (Int) -> Float): FloatBuffer = Fl
public fun FloatBuffer(vararg floats: Float): FloatBuffer = FloatBuffer(floats)
/**
- * Returns a new [FloatArray] containing all of the elements of this [Buffer].
+ * Returns a new [FloatArray] containing all the elements of this [Buffer].
*/
public fun Buffer.toFloatArray(): FloatArray = when (this) {
is FloatBuffer -> array.copyOf()
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/IntBuffer.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/IntBuffer.kt
index 57b6cfde3..35b722e2b 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/IntBuffer.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/IntBuffer.kt
@@ -33,7 +33,7 @@ public value class IntBuffer(public val array: IntArray) : MutableBuffer {
* [init] function.
*
* The function [init] is called for each array element sequentially starting from the first one.
- * It should return the value for an buffer element given its index.
+ * It should return the value for a buffer element given its index.
*/
public inline fun IntBuffer(size: Int, init: (Int) -> Int): IntBuffer = IntBuffer(IntArray(size) { init(it) })
@@ -43,7 +43,7 @@ public inline fun IntBuffer(size: Int, init: (Int) -> Int): IntBuffer = IntBuffe
public fun IntBuffer(vararg ints: Int): IntBuffer = IntBuffer(ints)
/**
- * Returns a new [IntArray] containing all of the elements of this [Buffer].
+ * Returns a new [IntArray] containing all the elements of this [Buffer].
*/
public fun Buffer.toIntArray(): IntArray = when (this) {
is IntBuffer -> array.copyOf()
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/LongBuffer.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/LongBuffer.kt
index 57affa1c5..c69f4646d 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/LongBuffer.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/LongBuffer.kt
@@ -33,7 +33,7 @@ public value class LongBuffer(public val array: LongArray) : MutableBuffer
* [init] function.
*
* The function [init] is called for each array element sequentially starting from the first one.
- * It should return the value for an buffer element given its index.
+ * It should return the value for a buffer element given its index.
*/
public inline fun LongBuffer(size: Int, init: (Int) -> Long): LongBuffer = LongBuffer(LongArray(size) { init(it) })
@@ -43,7 +43,7 @@ public inline fun LongBuffer(size: Int, init: (Int) -> Long): LongBuffer = LongB
public fun LongBuffer(vararg longs: Long): LongBuffer = LongBuffer(longs)
/**
- * Returns a new [LongArray] containing all of the elements of this [Buffer].
+ * Returns a new [LongArray] containing all the elements of this [Buffer].
*/
public fun Buffer.toLongArray(): LongArray = when (this) {
is LongBuffer -> array.copyOf()
diff --git a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/ShortBuffer.kt b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/ShortBuffer.kt
index 8dadecff7..20691511b 100644
--- a/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/ShortBuffer.kt
+++ b/kmath-core/src/commonMain/kotlin/space/kscience/kmath/structures/ShortBuffer.kt
@@ -31,7 +31,7 @@ public value class ShortBuffer(public val array: ShortArray) : MutableBuffer Short): ShortBuffer = ShortBuffer(ShortArray(size) { init(it) })
@@ -41,7 +41,7 @@ public inline fun ShortBuffer(size: Int, init: (Int) -> Short): ShortBuffer = Sh
public fun ShortBuffer(vararg shorts: Short): ShortBuffer = ShortBuffer(shorts)
/**
- * Returns a new [ShortArray] containing all of the elements of this [Buffer].
+ * Returns a new [ShortArray] containing all the elements of this [Buffer].
*/
public fun Buffer.toShortArray(): ShortArray = when (this) {
is ShortBuffer -> array.copyOf()
diff --git a/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/chains/Chain.kt b/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/chains/Chain.kt
index 8523ac864..f8d2549e5 100644
--- a/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/chains/Chain.kt
+++ b/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/chains/Chain.kt
@@ -13,7 +13,7 @@ import kotlinx.coroutines.sync.withLock
/**
* A not-necessary-Markov chain of some type
- * @param T - the chain element type
+ * @param T the chain element type
*/
public interface Chain : Flow {
/**
@@ -22,7 +22,7 @@ public interface Chain : Flow {
public suspend fun next(): T
/**
- * Create a copy of current chain state. Consuming resulting chain does not affect initial chain
+ * Create a copy of current chain state. Consuming resulting chain does not affect initial chain.
*/
public suspend fun fork(): Chain
@@ -62,9 +62,11 @@ public class MarkovChain(private val seed: suspend () -> R, private
}
/**
- * A chain with possibly mutable state. The state must not be changed outside the chain. Two chins should never share the state
- * @param S - the state of the chain
- * @param forkState - the function to copy current state without modifying it
+ * A chain with possibly mutable state. The state must not be changed outside the chain. Two chins should never share
+ * the state.
+ *
+ * @param S the state of the chain.
+ * @param forkState the function to copy current state without modifying it.
*/
public class StatefulChain(
private val state: S,
@@ -96,7 +98,7 @@ public class ConstantChain(public val value: T) : Chain {
/**
* Map the chain result using suspended transformation. Initial chain result can no longer be safely consumed
- * since mapped chain consumes tokens. Accepts regular transformation function
+ * since mapped chain consumes tokens. Accepts regular transformation function.
*/
public fun Chain.map(func: suspend (T) -> R): Chain = object : Chain {
override suspend fun next(): R = func(this@map.next())
diff --git a/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/streaming/BufferFlow.kt b/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/streaming/BufferFlow.kt
index 0d6a1178a..4d4493aa4 100644
--- a/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/streaming/BufferFlow.kt
+++ b/kmath-coroutines/src/commonMain/kotlin/space/kscience/kmath/streaming/BufferFlow.kt
@@ -76,7 +76,7 @@ public fun Flow.chunked(bufferSize: Int): Flow = flow {
/**
* Map a flow to a moving window buffer. The window step is one.
- * In order to get different steps, one could use skip operation.
+ * To get different steps, one could use skip operation.
*/
public fun Flow.windowed(window: Int): Flow> = flow {
require(window > 1) { "Window size must be more than one" }
diff --git a/kmath-dimensions/src/commonMain/kotlin/space/kscience/kmath/dimensions/Wrappers.kt b/kmath-dimensions/src/commonMain/kotlin/space/kscience/kmath/dimensions/Wrappers.kt
index deb297913..eb099bd79 100644
--- a/kmath-dimensions/src/commonMain/kotlin/space/kscience/kmath/dimensions/Wrappers.kt
+++ b/kmath-dimensions/src/commonMain/kotlin/space/kscience/kmath/dimensions/Wrappers.kt
@@ -20,7 +20,7 @@ import kotlin.jvm.JvmInline
public interface DMatrix : Structure2D {
public companion object {
/**
- * Coerces a regular matrix to a matrix with type-safe dimensions and throws a error if coercion failed
+ * Coerces a regular matrix to a matrix with type-safe dimensions and throws an error if coercion failed
*/
public inline fun coerce(structure: Structure2D): DMatrix {
require(structure.rowNum == Dimension.dim()) {
@@ -35,7 +35,7 @@ public interface DMatrix : Structure2D {
}
/**
- * The same as [DMatrix.coerce] but without dimension checks. Use with caution
+ * The same as [DMatrix.coerce] but without dimension checks. Use with caution.
*/
public fun coerceUnsafe(structure: Structure2D): DMatrix =
DMatrixWrapper(structure)
diff --git a/kmath-for-real/build.gradle.kts b/kmath-for-real/build.gradle.kts
index 25fdefaba..4cccaef5c 100644
--- a/kmath-for-real/build.gradle.kts
+++ b/kmath-for-real/build.gradle.kts
@@ -12,7 +12,7 @@ kotlin.sourceSets.commonMain {
readme {
description = """
- Extension module that should be used to achieve numpy-like behavior.
+ Extension module that should be used to achieve numpy-like behavior.
All operations are specialized to work with `Double` numbers without declaring algebraic contexts.
One can still use generic algebras though.
""".trimIndent()
diff --git a/kmath-for-real/src/commonMain/kotlin/space/kscience/kmath/real/RealVector.kt b/kmath-for-real/src/commonMain/kotlin/space/kscience/kmath/real/RealVector.kt
index d3867ea89..0508e9ca3 100644
--- a/kmath-for-real/src/commonMain/kotlin/space/kscience/kmath/real/RealVector.kt
+++ b/kmath-for-real/src/commonMain/kotlin/space/kscience/kmath/real/RealVector.kt
@@ -22,7 +22,7 @@ public typealias DoubleVector = Point
public fun DoubleVector(vararg doubles: Double): DoubleVector = doubles.asBuffer()
/**
- * Fill the vector of given [size] with given [value]
+ * Fill the vector with given [size] with given [value]
*/
@UnstableKMathAPI
public fun Buffer.Companion.same(size: Int, value: Number): DoubleVector = double(size) { value.toDouble() }
diff --git a/kmath-for-real/src/commonMain/kotlin/space/kscience/kmath/real/grids.kt b/kmath-for-real/src/commonMain/kotlin/space/kscience/kmath/real/grids.kt
index c3556216d..1926ef02c 100644
--- a/kmath-for-real/src/commonMain/kotlin/space/kscience/kmath/real/grids.kt
+++ b/kmath-for-real/src/commonMain/kotlin/space/kscience/kmath/real/grids.kt
@@ -45,8 +45,8 @@ public fun Buffer.Companion.withFixedStep(range: ClosedFloatingPointRange> PiecewisePolynomial(
}
/**
- * An optimized piecewise which uses not separate pieces, but a range separated by delimiters.
- * The pieces search is logarithmic
+ * An optimized piecewise that uses not separate pieces, but a range separated by delimiters.
+ * The pieces search is logarithmic.
*/
private class OrderedPiecewisePolynomial>(
override val pieces: List, Polynomial>>,
@@ -79,7 +79,7 @@ public class PiecewiseBuilder>(delimiter: T) {
/**
* Dynamically adds a piece to the right side (beyond maximum argument value of previous piece)
*
- * @param right new rightmost position. If is less then current rightmost position, an error is thrown.
+ * @param right new rightmost position. If is less than current rightmost position, an error is thrown.
* @param piece the sub-function.
*/
public fun putRight(right: T, piece: Polynomial) {
@@ -91,7 +91,7 @@ public class PiecewiseBuilder>(delimiter: T) {
/**
* Dynamically adds a piece to the left side (beyond maximum argument value of previous piece)
*
- * @param left the new leftmost position. If is less then current rightmost position, an error is thrown.
+ * @param left the new leftmost position. If is less than current rightmost position, an error is thrown.
* @param piece the sub-function.
*/
public fun putLeft(left: T, piece: Polynomial) {
@@ -114,7 +114,7 @@ public fun > PiecewisePolynomial(
): PiecewisePolynomial = PiecewiseBuilder(startingPoint).apply(builder).build()
/**
- * Return a value of polynomial function with given [ring] an given [arg] or null if argument is outside of piecewise
+ * Return a value of polynomial function with given [ring] a given [arg] or null if argument is outside piecewise
* definition.
*/
public fun , C : Ring> PiecewisePolynomial.value(ring: C, arg: T): T? =
diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/GaussIntegrator.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/GaussIntegrator.kt
index 283f97557..278ef6abe 100644
--- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/GaussIntegrator.kt
+++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/GaussIntegrator.kt
@@ -10,15 +10,17 @@ import space.kscience.kmath.structures.Buffer
import space.kscience.kmath.structures.asBuffer
import space.kscience.kmath.structures.indices
-
-
/**
* A simple one-pass integrator based on Gauss rule
* Following integrand features are accepted:
- * [GaussIntegratorRuleFactory] - A factory for computing the Gauss integration rule. By default uses [GaussLegendreRuleFactory]
- * [IntegrationRange] - the univariate range of integration. By default uses 0..1 interval.
- * [IntegrandMaxCalls] - the maximum number of function calls during integration. For non-iterative rules, always uses the maximum number of points. By default uses 10 points.
- * [UnivariateIntegrandRanges] - Set of ranges and number of points per range. Defaults to given [IntegrationRange] and [IntegrandMaxCalls]
+ *
+ * * [GaussIntegratorRuleFactory]—a factory for computing the Gauss integration rule. By default, uses
+ * [GaussLegendreRuleFactory].
+ * * [IntegrationRange]—the univariate range of integration. By default, uses `0..1` interval.
+ * * [IntegrandMaxCalls]—the maximum number of function calls during integration. For non-iterative rules, always
+ * uses the maximum number of points. By default, uses 10 points.
+ * * [UnivariateIntegrandRanges]—set of ranges and number of points per range. Defaults to given
+ * [IntegrationRange] and [IntegrandMaxCalls].
*/
public class GaussIntegrator(
public val algebra: Field,
@@ -71,14 +73,14 @@ public class GaussIntegrator(
}
/**
- * Create a Gauss-Legendre integrator for this field
+ * Create a Gauss-Legendre integrator for this field.
* @see [GaussIntegrator]
*/
-public val Field.gaussIntegrator: GaussIntegrator get() = GaussIntegrator(this)
+public val Field.gaussIntegrator: GaussIntegrator get() = GaussIntegrator(this)
/**
- * Integrate using [intervals] segments with Gauss-Legendre rule of [order] order
+ * Integrate using [intervals] segments with Gauss-Legendre rule of [order] order.
*/
@UnstableKMathAPI
public fun GaussIntegrator.integrate(
diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/GaussIntegratorRuleFactory.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/GaussIntegratorRuleFactory.kt
index 594ca9940..2eceec135 100644
--- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/GaussIntegratorRuleFactory.kt
+++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/GaussIntegratorRuleFactory.kt
@@ -72,7 +72,7 @@ public object GaussLegendreRuleFactory : GaussIntegratorRuleFactory {
}
// Get previous rule.
- // If it has not been computed yet it will trigger a recursive call
+ // If it has not been computed, yet it will trigger a recursive call
// to this method.
val previousPoints: Buffer = getOrBuildRule(numPoints - 1).first
@@ -146,7 +146,7 @@ public object GaussLegendreRuleFactory : GaussIntegratorRuleFactory {
}
// If "numPoints" is odd, 0 is a root.
// Note: as written, the test for oddness will work for negative
- // integers too (although it is not necessary here), preventing
+ // integers too (although it is unnecessary here), preventing
// a FindBugs warning.
if (numPoints % 2 != 0) {
var pmc = 1.0
diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/SimpsonIntegrator.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/SimpsonIntegrator.kt
index baa9d4af8..c01c30ec2 100644
--- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/SimpsonIntegrator.kt
+++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/SimpsonIntegrator.kt
@@ -13,9 +13,10 @@ import space.kscience.kmath.operations.sum
/**
* Use double pass Simpson rule integration with a fixed number of points.
- * Requires [UnivariateIntegrandRanges] or [IntegrationRange] and [IntegrandMaxCalls]
- * [IntegrationRange] - the univariate range of integration. By default uses 0..1 interval.
- * [IntegrandMaxCalls] - the maximum number of function calls during integration. For non-iterative rules, always uses the maximum number of points. By default uses 10 points.
+ * Requires [UnivariateIntegrandRanges] or [IntegrationRange] and [IntegrandMaxCalls].
+ * * [IntegrationRange]—the univariate range of integration. By default, uses `0..1` interval.
+ * * [IntegrandMaxCalls]—the maximum number of function calls during integration. For non-iterative rules, always
+ * uses the maximum number of points. By default, uses 10 points.
*/
@UnstableKMathAPI
public class SimpsonIntegrator(
@@ -63,12 +64,12 @@ public val Field.simpsonIntegrator: SimpsonIntegrator get() = Si
/**
* Use double pass Simpson rule integration with a fixed number of points.
- * Requires [UnivariateIntegrandRanges] or [IntegrationRange] and [IntegrandMaxCalls]
- * [IntegrationRange] - the univariate range of integration. By default uses 0..1 interval.
- * [IntegrandMaxCalls] - the maximum number of function calls during integration. For non-iterative rules, always uses the maximum number of points. By default uses 10 points.
+ * Requires [UnivariateIntegrandRanges] or [IntegrationRange] and [IntegrandMaxCalls].
+ * * [IntegrationRange]—the univariate range of integration. By default, uses `0.0..1.0` interval.
+ * * [IntegrandMaxCalls]—the maximum number of function calls during integration. For non-iterative rules, always uses
+ * the maximum number of points. By default, uses 10 points.
*/
public object DoubleSimpsonIntegrator : UnivariateIntegrator {
-
private fun integrateRange(
integrand: UnivariateIntegrand, range: ClosedRange, numPoints: Int,
): Double {
diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/SplineIntegrator.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/SplineIntegrator.kt
index 23d7bdd8d..07b37bd6a 100644
--- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/SplineIntegrator.kt
+++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/SplineIntegrator.kt
@@ -45,8 +45,9 @@ public fun > PiecewisePolynomial.integrate(
/**
* A generic spline-interpolation-based analytic integration
- * [IntegrationRange] - the univariate range of integration. By default uses 0..1 interval.
- * [IntegrandMaxCalls] - the maximum number of function calls during integration. For non-iterative rules, always uses the maximum number of points. By default uses 10 points.
+ * * [IntegrationRange]—the univariate range of integration. By default, uses `0..1` interval.
+ * * [IntegrandMaxCalls]—the maximum number of function calls during integration. For non-iterative rules, always uses
+ * the maximum number of points. By default, uses 10 points.
*/
@UnstableKMathAPI
public class SplineIntegrator>(
@@ -57,6 +58,7 @@ public class SplineIntegrator>(
val range = integrand.getFeature()?.range ?: 0.0..1.0
val interpolator: PolynomialInterpolator = SplineInterpolator(algebra, bufferFactory)
+
val nodes: Buffer = integrand.getFeature()?.nodes ?: run {
val numPoints = integrand.getFeature()?.maxCalls ?: 100
val step = (range.endInclusive - range.start) / (numPoints - 1)
@@ -75,15 +77,16 @@ public class SplineIntegrator>(
/**
* A simplified double-based spline-interpolation-based analytic integration
- * [IntegrationRange] - the univariate range of integration. By default uses 0..1 interval.
- * [IntegrandMaxCalls] - the maximum number of function calls during integration. For non-iterative rules, always uses the maximum number of points. By default uses 10 points.
+ * * [IntegrationRange]—the univariate range of integration. By default, uses `0.0..1.0` interval.
+ * * [IntegrandMaxCalls]—the maximum number of function calls during integration. For non-iterative rules, always
+ * uses the maximum number of points. By default, uses 10 points.
*/
@UnstableKMathAPI
public object DoubleSplineIntegrator : UnivariateIntegrator {
override fun integrate(integrand: UnivariateIntegrand): UnivariateIntegrand {
val range = integrand.getFeature()?.range ?: 0.0..1.0
-
val interpolator: PolynomialInterpolator = SplineInterpolator(DoubleField, ::DoubleBuffer)
+
val nodes: Buffer = integrand.getFeature()?.nodes ?: run {
val numPoints = integrand.getFeature()?.maxCalls ?: 100
val step = (range.endInclusive - range.start) / (numPoints - 1)
diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/UnivariateIntegrand.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/UnivariateIntegrand.kt
index 7f68284a7..9c8aeef1b 100644
--- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/UnivariateIntegrand.kt
+++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/integration/UnivariateIntegrand.kt
@@ -40,8 +40,8 @@ public class IntegrationRange(public val range: ClosedRange) : Integrand
}
/**
- * Set of univariate integration ranges. First components correspond to ranges themselves, second components to number of
- * integration nodes per range
+ * Set of univariate integration ranges. First components correspond to the ranges themselves, second components to
+ * number of integration nodes per range.
*/
public class UnivariateIntegrandRanges(public val ranges: List, Int>>) : IntegrandFeature {
public constructor(vararg pairs: Pair, Int>) : this(pairs.toList())
diff --git a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram.kt b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram.kt
index 31da4f392..4e803fc63 100644
--- a/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram.kt
+++ b/kmath-histograms/src/commonMain/kotlin/space/kscience/kmath/histogram/Histogram.kt
@@ -11,7 +11,7 @@ import space.kscience.kmath.structures.DoubleBuffer
import space.kscience.kmath.structures.asBuffer
/**
- * The binned data element. Could be a histogram bin with a number of counts or an artificial construct
+ * The binned data element. Could be a histogram bin with a number of counts or an artificial construct.
*/
public interface Bin : Domain {
/**
diff --git a/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/UnivariateHistogram.kt b/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/UnivariateHistogram.kt
index f461ee4fa..ca37279c3 100644
--- a/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/UnivariateHistogram.kt
+++ b/kmath-histograms/src/jvmMain/kotlin/space/kscience/kmath/histogram/UnivariateHistogram.kt
@@ -16,9 +16,10 @@ public val UnivariateDomain.center: Double
get() = (range.endInclusive + range.start) / 2
/**
- * A univariate bin based an a range
- * @param value The value of histogram including weighting
- * @param standardDeviation Standard deviation of the bin value. Zero or negative if not applicable
+ * A univariate bin based on a range
+ *
+ * @property value The value of histogram including weighting
+ * @property standardDeviation Standard deviation of the bin value. Zero or negative if not applicable
*/
@UnstableKMathAPI
public class UnivariateBin(
diff --git a/kmath-jafama/README.md b/kmath-jafama/README.md
index 71097771d..3c5d4e19d 100644
--- a/kmath-jafama/README.md
+++ b/kmath-jafama/README.md
@@ -52,22 +52,4 @@ fun main() {
According to KMath benchmarks on GraalVM, Jafama functions are slower than JDK math; however, there are indications that on Hotspot Jafama is a bit faster.
-
-
-Report for benchmark configuration jafamaDouble
-
-
-* Run on OpenJDK 64-Bit Server VM (build 11.0.11+8-jvmci-21.1-b05) with Java process:
-
-```
-/home/commandertvis/graalvm-ce-java11/bin/java -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCIProduct -XX:-UnlockExperimentalVMOptions -XX:ThreadPriorityPolicy=1 -javaagent:/home/commandertvis/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlinx/kotlinx-coroutines-core-jvm/1.5.0/d8cebccdcddd029022aa8646a5a953ff88b13ac8/kotlinx-coroutines-core-jvm-1.5.0.jar -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -ea
-```
-* JMH 1.21 was used in `thrpt` mode with 1 warmup iteration by 1000 ms and 5 measurement iterations by 1000 ms.
-
-| Benchmark | Score |
-|:---------:|:-----:|
-|`space.kscience.kmath.benchmarks.JafamaBenchmark.core`|14.35014650168397 ± 0.9200669832937576 ops/s|
-|`space.kscience.kmath.benchmarks.JafamaBenchmark.jafama`|12.048429204455887 ± 1.2882929181842269 ops/s|
-|`space.kscience.kmath.benchmarks.JafamaBenchmark.strictJafama`|12.977653357239152 ± 1.4122819627470866 ops/s|
-
-
+> **Can't find appropriate benchmark data. Try generating readme files after running benchmarks**.
diff --git a/kmath-kotlingrad/README.md b/kmath-kotlingrad/README.md
index 3b337460f..aeb44ea13 100644
--- a/kmath-kotlingrad/README.md
+++ b/kmath-kotlingrad/README.md
@@ -1,6 +1,6 @@
# Module kmath-kotlingrad
-[Kotlin∇](https://www.htmlsymbols.xyz/unicode/U+2207) integration module.
+[Kotlin∇](https://github.com/breandan/kotlingrad) integration module.
- [differentiable-mst-expression](src/main/kotlin/space/kscience/kmath/kotlingrad/KotlingradExpression.kt) : MST based DifferentiableExpression.
- [scalars-adapters](src/main/kotlin/space/kscience/kmath/kotlingrad/scalarsAdapters.kt) : Conversions between Kotlin∇'s SFun and MST
diff --git a/kmath-kotlingrad/docs/README-TEMPLATE.md b/kmath-kotlingrad/docs/README-TEMPLATE.md
index ac38c849b..bc99bdf5f 100644
--- a/kmath-kotlingrad/docs/README-TEMPLATE.md
+++ b/kmath-kotlingrad/docs/README-TEMPLATE.md
@@ -1,6 +1,6 @@
# Module kmath-kotlingrad
-[Kotlin∇](https://www.htmlsymbols.xyz/unicode/U+2207) integration module.
+[Kotlin∇](https://github.com/breandan/kotlingrad) integration module.
${features}
diff --git a/kmath-memory/src/commonMain/kotlin/space/kscience/kmath/memory/Memory.kt b/kmath-memory/src/commonMain/kotlin/space/kscience/kmath/memory/Memory.kt
index 930b21095..e8e51e9e2 100644
--- a/kmath-memory/src/commonMain/kotlin/space/kscience/kmath/memory/Memory.kt
+++ b/kmath-memory/src/commonMain/kotlin/space/kscience/kmath/memory/Memory.kt
@@ -156,6 +156,6 @@ public expect fun Memory.Companion.allocate(length: Int): Memory
/**
* Wraps a [Memory] around existing [ByteArray]. This operation is unsafe since the array is not copied
- * and could be mutated independently from the resulting [Memory].
+ * and could be mutated independently of the resulting [Memory].
*/
public expect fun Memory.Companion.wrap(array: ByteArray): Memory
diff --git a/kmath-memory/src/jsMain/kotlin/space/kscience/kmath/memory/DataViewMemory.kt b/kmath-memory/src/jsMain/kotlin/space/kscience/kmath/memory/DataViewMemory.kt
index 9a622ea36..6153743fc 100644
--- a/kmath-memory/src/jsMain/kotlin/space/kscience/kmath/memory/DataViewMemory.kt
+++ b/kmath-memory/src/jsMain/kotlin/space/kscience/kmath/memory/DataViewMemory.kt
@@ -95,7 +95,7 @@ public actual fun Memory.Companion.allocate(length: Int): Memory {
/**
* Wraps a [Memory] around existing [ByteArray]. This operation is unsafe since the array is not copied
- * and could be mutated independently from the resulting [Memory].
+ * and could be mutated independently of the resulting [Memory].
*/
public actual fun Memory.Companion.wrap(array: ByteArray): Memory {
@Suppress("CAST_NEVER_SUCCEEDS") val int8Array = array as Int8Array
diff --git a/kmath-memory/src/jvmMain/kotlin/space/kscience/kmath/memory/ByteBufferMemory.kt b/kmath-memory/src/jvmMain/kotlin/space/kscience/kmath/memory/ByteBufferMemory.kt
index 944e8455b..aef68fd80 100644
--- a/kmath-memory/src/jvmMain/kotlin/space/kscience/kmath/memory/ByteBufferMemory.kt
+++ b/kmath-memory/src/jvmMain/kotlin/space/kscience/kmath/memory/ByteBufferMemory.kt
@@ -103,7 +103,7 @@ public actual fun Memory.Companion.allocate(length: Int): Memory =
/**
* Wraps a [Memory] around existing [ByteArray]. This operation is unsafe since the array is not copied
- * and could be mutated independently from the resulting [Memory].
+ * and could be mutated independently of the resulting [Memory].
*/
public actual fun Memory.Companion.wrap(array: ByteArray): Memory =
ByteBufferMemory(checkNotNull(ByteBuffer.wrap(array)))
diff --git a/kmath-memory/src/nativeMain/kotlin/space/kscience/kmath/memory/NativeMemory.kt b/kmath-memory/src/nativeMain/kotlin/space/kscience/kmath/memory/NativeMemory.kt
index d31c9e8f4..5146d9689 100644
--- a/kmath-memory/src/nativeMain/kotlin/space/kscience/kmath/memory/NativeMemory.kt
+++ b/kmath-memory/src/nativeMain/kotlin/space/kscience/kmath/memory/NativeMemory.kt
@@ -60,7 +60,7 @@ internal class NativeMemory(
}
override fun writeByte(offset: Int, value: Byte) {
- array.set(position(offset), value)
+ array[position(offset)] = value
}
override fun writeShort(offset: Int, value: Short) {
@@ -85,7 +85,7 @@ internal class NativeMemory(
/**
* Wraps a [Memory] around existing [ByteArray]. This operation is unsafe since the array is not copied
- * and could be mutated independently from the resulting [Memory].
+ * and could be mutated independently of the resulting [Memory].
*/
public actual fun Memory.Companion.wrap(array: ByteArray): Memory = NativeMemory(array)
diff --git a/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebra.kt b/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebra.kt
index 7a650df3c..f69f831e8 100644
--- a/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebra.kt
+++ b/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayAlgebra.kt
@@ -35,7 +35,7 @@ public sealed interface Nd4jArrayAlgebra> : AlgebraND
/**
- * Unwraps to or acquires [INDArray] from [StructureND].
+ * Unwraps to or get [INDArray] from [StructureND].
*/
public val StructureND.ndArray: INDArray
diff --git a/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayStructure.kt b/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayStructure.kt
index 97427d5c6..2a0fdc86c 100644
--- a/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayStructure.kt
+++ b/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jArrayStructure.kt
@@ -17,7 +17,7 @@ import space.kscience.kmath.nd.StructureND
*/
public sealed class Nd4jArrayStructure : MutableStructureND {
/**
- * The wrapped [INDArray]. Since KMath uses [Int] indexes, assuming that the size of [INDArray] is less or equal to
+ * The wrapped [INDArray]. Since KMath uses [Int] indexes, assuming the size of [INDArray] is less or equal to
* [Int.MAX_VALUE].
*/
public abstract val ndArray: INDArray
diff --git a/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jTensorAlgebra.kt b/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jTensorAlgebra.kt
index 0674c565e..1fdf845a6 100644
--- a/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jTensorAlgebra.kt
+++ b/kmath-nd4j/src/main/kotlin/space/kscience/kmath/nd4j/Nd4jTensorAlgebra.kt
@@ -29,7 +29,7 @@ public sealed interface Nd4jTensorAlgebra : AnalyticTensorAlgebra
public fun INDArray.wrap(): Nd4jArrayStructure
/**
- * Unwraps to or acquires [INDArray] from [StructureND].
+ * Unwraps to or gets [INDArray] from [StructureND].
*/
public val StructureND.ndArray: INDArray
diff --git a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/distributions/Distribution.kt b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/distributions/Distribution.kt
index 5a74a9a18..3d3f95f8f 100644
--- a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/distributions/Distribution.kt
+++ b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/distributions/Distribution.kt
@@ -22,7 +22,7 @@ public interface Distribution : Sampler {
override fun sample(generator: RandomGenerator): Chain
/**
- * An empty companion. Distribution factories should be written as its extensions
+ * An empty companion. Distribution factories should be written as its extensions.
*/
public companion object
}
diff --git a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/distributions/FactorizedDistribution.kt b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/distributions/FactorizedDistribution.kt
index dde429244..1218f13c5 100644
--- a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/distributions/FactorizedDistribution.kt
+++ b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/distributions/FactorizedDistribution.kt
@@ -10,12 +10,12 @@ import space.kscience.kmath.chains.SimpleChain
import space.kscience.kmath.stat.RandomGenerator
/**
- * A multivariate distribution which takes a map of parameters
+ * A multivariate distribution that takes a map of parameters.
*/
public interface NamedDistribution : Distribution