diff --git a/kmath-functions/build.gradle.kts b/kmath-functions/build.gradle.kts index 0a8e8a1be..149a8f277 100644 --- a/kmath-functions/build.gradle.kts +++ b/kmath-functions/build.gradle.kts @@ -19,6 +19,10 @@ kotlin.sourceSets { } } +dependencies { + dokkaPlugin("org.jetbrains.dokka:mathjax-plugin:${versionCatalogs.named("npmlibs").findVersion("dokka").get().requiredVersion}") +} + readme { maturity = ru.mipt.npm.gradle.Maturity.EXPERIMENTAL propertyByTemplate("artifact", rootProject.file("docs/templates/ARTIFACT-TEMPLATE.md")) diff --git a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/Polynomial.kt b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/Polynomial.kt index bfb378cce..1e811d3ba 100644 --- a/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/Polynomial.kt +++ b/kmath-functions/src/commonMain/kotlin/space/kscience/kmath/functions/Polynomial.kt @@ -23,8 +23,10 @@ import kotlin.math.min @JvmInline public value class Polynomial( /** - * List that contains coefficients of the polynomial. Every monomial `a x^d` is stored as a coefficient `a` placed - * into the list at index `d`. For example, coefficients of a polynomial `5 x^2 - 6` can be represented as + * List that contains coefficients of the polynomial. + * + * Every monomial \(a x^d\) is stored as a coefficient \(a\) placed + * into the list at index \(d\). For example, coefficients of a polynomial \(5 x^2 - 6\) can be represented as * ``` * listOf( * -6, // -6 + @@ -42,9 +44,11 @@ public value class Polynomial( * 0, // 0 x^4 * ) * ``` - * It is not prohibited to put extra zeros at end of the list (as for `0x^3` and `0x^4` in the example). But the + * It is not prohibited to put extra zeros at end of the list (as for \(0x^3\) and \(0x^4\) in the example). But the * longer the coefficients list the worse performance of arithmetical operations performed on it. Thus, it is * recommended not to put (or even to remove) extra (or useless) coefficients at the end of the coefficients list. + * + * @usesMathJax */ public val coefficients: List ) { diff --git a/kmath-polynomial/build.gradle.kts b/kmath-polynomial/build.gradle.kts index dcfcb1b46..b0f4a095c 100644 --- a/kmath-polynomial/build.gradle.kts +++ b/kmath-polynomial/build.gradle.kts @@ -20,6 +20,10 @@ kotlin.sourceSets { } } +dependencies { + dokkaPlugin("org.jetbrains.dokka:mathjax-plugin:${versionCatalogs.named("npmlibs").findVersion("dokka").get().requiredVersion}") +} + readme { maturity = ru.mipt.npm.gradle.Maturity.PROTOTYPE propertyByTemplate("artifact", rootProject.file("docs/templates/ARTIFACT-TEMPLATE.md")) diff --git a/kmath-polynomial/src/commonMain/kotlin/space.kscience.kmath.functions/LabeledPolynomial.kt b/kmath-polynomial/src/commonMain/kotlin/space.kscience.kmath.functions/LabeledPolynomial.kt index 7f107a87f..12bf9f839 100644 --- a/kmath-polynomial/src/commonMain/kotlin/space.kscience.kmath.functions/LabeledPolynomial.kt +++ b/kmath-polynomial/src/commonMain/kotlin/space.kscience.kmath.functions/LabeledPolynomial.kt @@ -25,9 +25,9 @@ internal constructor( /** * Map that contains coefficients of the polynomial. * - * Every monomial `a x_1^{d_1} ... x_n^{d_n}` is stored as a pair "key-value" in the map, where the value is the - * coefficient `a` and the key is a map that associates variables in the monomial with their degree in the monomial. - * For example, coefficients of a polynomial `5 a^2 c^3 - 6 b` can be represented as + * Every monomial \(a x_1^{d_1} ... x_n^{d_n}\) is stored as a pair "key-value" in the map, where the value is the + * coefficient \(a\) and the key is a map that associates variables in the monomial with their degree in the monomial. + * For example, coefficients of a polynomial \(5 a^2 c^3 - 6 b\) can be represented as * ``` * mapOf( * mapOf( @@ -55,7 +55,12 @@ internal constructor( * ) to 0 * ) * ``` - * where `a`, `b` and `c` are corresponding [Symbol] objects. + * where \(a\), \(b\) and \(c\) are corresponding [Symbol] objects. + * + * It is not prohibited to put extra zero monomials into the map (as for \(0 b c\) in the example). But the + * bigger the coefficients map the worse performance of arithmetical operations performed on it. Thus, it is + * recommended not to put (or even to remove) extra (or useless) monomials in the coefficients map. + * @usesMathJax */ public val coefficients: Map, C> ) : Polynomial { diff --git a/kmath-polynomial/src/commonMain/kotlin/space.kscience.kmath.functions/ListPolynomial.kt b/kmath-polynomial/src/commonMain/kotlin/space.kscience.kmath.functions/ListPolynomial.kt index 76e1a6bb6..91b9c7658 100644 --- a/kmath-polynomial/src/commonMain/kotlin/space.kscience.kmath.functions/ListPolynomial.kt +++ b/kmath-polynomial/src/commonMain/kotlin/space.kscience.kmath.functions/ListPolynomial.kt @@ -21,8 +21,10 @@ import kotlin.math.min */ public data class ListPolynomial( /** - * List that contains coefficients of the polynomial. Every monomial `a x^d` is stored as a coefficient `a` placed - * into the list at index `d`. For example, coefficients of a polynomial `5 x^2 - 6` can be represented as + * List that contains coefficients of the polynomial. + * + * Every monomial \(a x^d\) is stored as a coefficient \(a\) placed + * into the list at index \(d\). For example, coefficients of a polynomial \(5 x^2 - 6\) can be represented as * ``` * listOf( * -6, // -6 + @@ -40,9 +42,10 @@ public data class ListPolynomial( * 0, // 0 x^4 * ) * ``` - * It is not prohibited to put extra zeros at end of the list (as for `0x^3` and `0x^4` in the example). But the + * It is not prohibited to put extra zeros at end of the list (as for \(0x^3\) and \(0x^4\) in the example). But the * longer the coefficients list the worse performance of arithmetical operations performed on it. Thus, it is * recommended not to put (or even to remove) extra (or useless) coefficients at the end of the coefficients list. + * @usesMathJax */ public val coefficients: List ) : Polynomial { diff --git a/kmath-polynomial/src/commonMain/kotlin/space.kscience.kmath.functions/NumberedPolynomial.kt b/kmath-polynomial/src/commonMain/kotlin/space.kscience.kmath.functions/NumberedPolynomial.kt index f7dd9d8de..96c96e555 100644 --- a/kmath-polynomial/src/commonMain/kotlin/space.kscience.kmath.functions/NumberedPolynomial.kt +++ b/kmath-polynomial/src/commonMain/kotlin/space.kscience.kmath.functions/NumberedPolynomial.kt @@ -24,9 +24,9 @@ internal constructor( /** * Map that contains coefficients of the polynomial. * - * Every monomial `a x_1^{d_1} ... x_n^{d_n}` is stored as a pair "key-value" in the map, where the value is the - * coefficient `a` and the key is a list that associates index of every variable in the monomial with their degree - * in the monomial. For example, coefficients of a polynomial `5 x_1^2 x_3^3 - 6 x_2` can be represented as + * Every monomial \(a x_1^{d_1} ... x_n^{d_n}\) is stored as a pair "key-value" in the map, where the value is the + * coefficient \(a\) and the key is a list that associates index of every variable in the monomial with their degree + * in the monomial. For example, coefficients of a polynomial \(5 x_1^2 x_3^3 - 6 x_2\) can be represented as * ``` * mapOf( * listOf(2, 0, 3) to 5, // 5 x_1^2 x_3^3 + @@ -41,9 +41,10 @@ internal constructor( * listOf(0, 1, 1) to 0, // 0 x_2^1 x_3^1 * ) * ``` - * It is not prohibited to put extra zero monomials into the map (as for `0 x_2 x_3` in the example). But the + * It is not prohibited to put extra zero monomials into the map (as for \(0 x_2 x_3\) in the example). But the * bigger the coefficients map the worse performance of arithmetical operations performed on it. Thus, it is * recommended not to put (or even to remove) extra (or useless) monomials in the coefficients map. + * @usesMathJax */ public val coefficients: Map, C> ) : Polynomial { @@ -325,7 +326,7 @@ public class NumberedPolynomialSpace>( /** * Maximal index (ID) of variable occurring in the polynomial with positive power. If there is no such variable, - * the result is `-1`. + * the result is -1. */ public val NumberedPolynomial.lastVariable: Int get() = coefficients.keys.maxOfOrNull { degs -> degs.lastIndex } ?: -1 @@ -365,7 +366,7 @@ public class NumberedPolynomialSpace>( } ?: 0u /** * Count of variables occurring in the polynomial with positive power. If there is no such variable, - * the result is `0`. + * the result is 0. */ public val NumberedPolynomial.countOfVariables: Int get() = diff --git a/kmath-polynomial/src/commonMain/kotlin/space.kscience.kmath.functions/labeledConstructors.kt b/kmath-polynomial/src/commonMain/kotlin/space.kscience.kmath.functions/labeledConstructors.kt index 819a36449..d23efc5c2 100644 --- a/kmath-polynomial/src/commonMain/kotlin/space.kscience.kmath.functions/labeledConstructors.kt +++ b/kmath-polynomial/src/commonMain/kotlin/space.kscience.kmath.functions/labeledConstructors.kt @@ -262,7 +262,7 @@ public inline fun C.asLabeledPolynomial() : LabeledPolynomial = LabeledPo /** * Marks DSL that allows to more simply create [LabeledPolynomial]s with good performance. * - * For example, polynomial `5 a^2 c^3 - 6 b` can be described as + * For example, polynomial \(5 a^2 c^3 - 6 b\) can be described as * ``` * Int.algebra { * val numberedPolynomial : NumberedPolynomial = NumberedPolynomial { @@ -271,6 +271,7 @@ public inline fun C.asLabeledPolynomial() : LabeledPolynomial = LabeledPo * } * } * ``` + * @usesMathJax */ @DslMarker @UnstableKMathAPI @@ -385,7 +386,7 @@ public class DSL1LabeledPolynomialBuilder( ///** // * Creates [LabeledPolynomial] with lambda [block] in context of [this] ring of constants. // * -// * For example, polynomial `5 x_1^2 x_3^3 - 6 x_2` can be described as +// * For example, polynomial \(5 x_1^2 x_3^3 - 6 x_2\) can be described as // * ``` // * Int.algebra { // * val LabeledPolynomial : LabeledPolynomial = LabeledPolynomial { @@ -394,6 +395,7 @@ public class DSL1LabeledPolynomialBuilder( // * } // * } // * ``` +// * @usesMathJax // */ // FIXME: For now this fabric does not let next two fabrics work. (See KT-52803.) Possible feature solutions: // 1. `LowPriorityInOverloadResolution` becomes public. Then it should be applied to this function. @@ -404,7 +406,7 @@ public class DSL1LabeledPolynomialBuilder( /** * Creates [LabeledPolynomial] with lambda [block] in context of [this] ring of [LabeledPolynomial]s. * - * For example, polynomial `5 x_1^2 x_3^3 - 6 x_2` can be described as + * For example, polynomial \(5 x_1^2 x_3^3 - 6 x_2\) can be described as * ``` * Int.algebra { * val LabeledPolynomial : LabeledPolynomial = LabeledPolynomial { @@ -413,14 +415,15 @@ public class DSL1LabeledPolynomialBuilder( * } * } * ``` + * @usesMathJax */ @UnstableKMathAPI public inline fun > LabeledPolynomialSpace.LabeledPolynomialDSL1(initialCapacity: Int = 0, block: DSL1LabeledPolynomialBuilder.() -> Unit) : LabeledPolynomial = DSL1LabeledPolynomialBuilder({ left: C, right: C -> left + right }, initialCapacity).apply(block).build() /** * Creates [LabeledPolynomial] with lambda [block] in context of [this] field of [LabeledRationalFunction]s. * - * For example, polynomial `5 x_1^2 x_3^3 - 6 x_2` can be described as - * ``` + * For example, polynomial \(5 x_1^2 x_3^3 - 6 x_2\) can be described as + * `` * Int.algebra { * val LabeledPolynomial : LabeledPolynomial = LabeledPolynomial { * 5 { 1 inPowerOf 2u; 3 inPowerOf 3u } // 5 x_1^2 x_3^3 + @@ -428,6 +431,7 @@ public inline fun > LabeledPolynomialSpace.LabeledPolynomial * } * } * ``` + * @usesMathJax */ @UnstableKMathAPI public inline fun > LabeledRationalFunctionSpace.LabeledPolynomialDSL1(initialCapacity: Int = 0, block: DSL1LabeledPolynomialBuilder.() -> Unit) : LabeledPolynomial = DSL1LabeledPolynomialBuilder({ left: C, right: C -> left + right }, initialCapacity).apply(block).build() diff --git a/kmath-polynomial/src/commonMain/kotlin/space.kscience.kmath.functions/numberedConstructors.kt b/kmath-polynomial/src/commonMain/kotlin/space.kscience.kmath.functions/numberedConstructors.kt index 8d2c9e617..051019159 100644 --- a/kmath-polynomial/src/commonMain/kotlin/space.kscience.kmath.functions/numberedConstructors.kt +++ b/kmath-polynomial/src/commonMain/kotlin/space.kscience.kmath.functions/numberedConstructors.kt @@ -243,7 +243,7 @@ public inline fun C.asNumberedPolynomial() : NumberedPolynomial = Numbere /** * Marks DSL that allows to more simply create [NumberedPolynomial]s with good performance. * - * For example, polynomial `5 x_1^2 x_3^3 - 6 x_2` can be described as + * For example, polynomial \(5 x_1^2 x_3^3 - 6 x_2\) can be described as * ``` * Int.algebra { * val numberedPolynomial : NumberedPolynomial = NumberedPolynomial { @@ -252,6 +252,7 @@ public inline fun C.asNumberedPolynomial() : NumberedPolynomial = Numbere * } * } * ``` + * @usesMathJax */ @DslMarker @UnstableKMathAPI @@ -372,7 +373,7 @@ public class DSL1NumberedPolynomialBuilder( ///** // * Creates [NumberedPolynomial] with lambda [block] in context of [this] ring of constants. // * -// * For example, polynomial `5 x_1^2 x_3^3 - 6 x_2` can be described as +// * For example, polynomial \(5 x_1^2 x_3^3 - 6 x_2\) can be described as // * ``` // * Int.algebra { // * val numberedPolynomial : NumberedPolynomial = NumberedPolynomial { @@ -381,6 +382,7 @@ public class DSL1NumberedPolynomialBuilder( // * } // * } // * ``` +// * @usesMathJax // */ // FIXME: For now this fabric does not let next two fabrics work. (See KT-52803.) Possible feature solutions: // 1. `LowPriorityInOverloadResolution` becomes public. Then it should be applied to this function. @@ -391,7 +393,7 @@ public class DSL1NumberedPolynomialBuilder( /** * Creates [NumberedPolynomial] with lambda [block] in context of [this] ring of [NumberedPolynomial]s. * - * For example, polynomial `5 x_1^2 x_3^3 - 6 x_2` can be described as + * For example, polynomial \(5 x_1^2 x_3^3 - 6 x_2\) can be described as * ``` * Int.algebra { * val numberedPolynomial : NumberedPolynomial = NumberedPolynomial { @@ -400,13 +402,14 @@ public class DSL1NumberedPolynomialBuilder( * } * } * ``` + * @usesMathJax */ @UnstableKMathAPI public inline fun > NumberedPolynomialSpace.NumberedPolynomialDSL1(initialCapacity: Int = 0, block: DSL1NumberedPolynomialBuilder.() -> Unit) : NumberedPolynomial = DSL1NumberedPolynomialBuilder({ left: C, right: C -> left + right }, initialCapacity).apply(block).build() /** * Creates [NumberedPolynomial] with lambda [block] in context of [this] field of [NumberedRationalFunction]s. * - * For example, polynomial `5 x_1^2 x_3^3 - 6 x_2` can be described as + * For example, polynomial \(5 x_1^2 x_3^3 - 6 x_2\) can be described as * ``` * Int.algebra { * val numberedPolynomial : NumberedPolynomial = NumberedPolynomial { @@ -415,6 +418,7 @@ public inline fun > NumberedPolynomialSpace.NumberedPolynomi * } * } * ``` + * @usesMathJax */ @UnstableKMathAPI public inline fun > NumberedRationalFunctionSpace.NumberedPolynomialDSL1(initialCapacity: Int = 0, block: DSL1NumberedPolynomialBuilder.() -> Unit) : NumberedPolynomial = DSL1NumberedPolynomialBuilder({ left: C, right: C -> left + right }, initialCapacity).apply(block).build()