Added MathJax to docs.
This commit is contained in:
parent
f7d159bc03
commit
87aeda84d9
@ -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"))
|
||||
|
@ -23,8 +23,10 @@ import kotlin.math.min
|
||||
@JvmInline
|
||||
public value class Polynomial<C>(
|
||||
/**
|
||||
* 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<C>(
|
||||
* 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<C>
|
||||
) {
|
||||
|
@ -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"))
|
||||
|
@ -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<Map<Symbol, UInt>, C>
|
||||
) : Polynomial<C> {
|
||||
|
@ -21,8 +21,10 @@ import kotlin.math.min
|
||||
*/
|
||||
public data class ListPolynomial<C>(
|
||||
/**
|
||||
* 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<C>(
|
||||
* 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<C>
|
||||
) : Polynomial<C> {
|
||||
|
@ -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<List<UInt>, C>
|
||||
) : Polynomial<C> {
|
||||
@ -325,7 +326,7 @@ public class NumberedPolynomialSpace<C, A : Ring<C>>(
|
||||
|
||||
/**
|
||||
* 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<C>.lastVariable: Int
|
||||
get() = coefficients.keys.maxOfOrNull { degs -> degs.lastIndex } ?: -1
|
||||
@ -365,7 +366,7 @@ public class NumberedPolynomialSpace<C, A : Ring<C>>(
|
||||
} ?: 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<C>.countOfVariables: Int
|
||||
get() =
|
||||
|
@ -262,7 +262,7 @@ public inline fun <C> C.asLabeledPolynomial() : LabeledPolynomial<C> = 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<Int> = NumberedPolynomial {
|
||||
@ -271,6 +271,7 @@ public inline fun <C> C.asLabeledPolynomial() : LabeledPolynomial<C> = LabeledPo
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* @usesMathJax
|
||||
*/
|
||||
@DslMarker
|
||||
@UnstableKMathAPI
|
||||
@ -385,7 +386,7 @@ public class DSL1LabeledPolynomialBuilder<C>(
|
||||
///**
|
||||
// * 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<Int> = LabeledPolynomial {
|
||||
@ -394,6 +395,7 @@ public class DSL1LabeledPolynomialBuilder<C>(
|
||||
// * }
|
||||
// * }
|
||||
// * ```
|
||||
// * @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<C>(
|
||||
/**
|
||||
* 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<Int> = LabeledPolynomial {
|
||||
@ -413,14 +415,15 @@ public class DSL1LabeledPolynomialBuilder<C>(
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* @usesMathJax
|
||||
*/
|
||||
@UnstableKMathAPI
|
||||
public inline fun <C, A: Ring<C>> LabeledPolynomialSpace<C, A>.LabeledPolynomialDSL1(initialCapacity: Int = 0, block: DSL1LabeledPolynomialBuilder<C>.() -> Unit) : LabeledPolynomial<C> = 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<Int> = LabeledPolynomial {
|
||||
* 5 { 1 inPowerOf 2u; 3 inPowerOf 3u } // 5 x_1^2 x_3^3 +
|
||||
@ -428,6 +431,7 @@ public inline fun <C, A: Ring<C>> LabeledPolynomialSpace<C, A>.LabeledPolynomial
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* @usesMathJax
|
||||
*/
|
||||
@UnstableKMathAPI
|
||||
public inline fun <C, A: Ring<C>> LabeledRationalFunctionSpace<C, A>.LabeledPolynomialDSL1(initialCapacity: Int = 0, block: DSL1LabeledPolynomialBuilder<C>.() -> Unit) : LabeledPolynomial<C> = DSL1LabeledPolynomialBuilder({ left: C, right: C -> left + right }, initialCapacity).apply(block).build()
|
||||
|
@ -243,7 +243,7 @@ public inline fun <C> C.asNumberedPolynomial() : NumberedPolynomial<C> = 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<Int> = NumberedPolynomial {
|
||||
@ -252,6 +252,7 @@ public inline fun <C> C.asNumberedPolynomial() : NumberedPolynomial<C> = Numbere
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* @usesMathJax
|
||||
*/
|
||||
@DslMarker
|
||||
@UnstableKMathAPI
|
||||
@ -372,7 +373,7 @@ public class DSL1NumberedPolynomialBuilder<C>(
|
||||
///**
|
||||
// * 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<Int> = NumberedPolynomial {
|
||||
@ -381,6 +382,7 @@ public class DSL1NumberedPolynomialBuilder<C>(
|
||||
// * }
|
||||
// * }
|
||||
// * ```
|
||||
// * @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<C>(
|
||||
/**
|
||||
* 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<Int> = NumberedPolynomial {
|
||||
@ -400,13 +402,14 @@ public class DSL1NumberedPolynomialBuilder<C>(
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* @usesMathJax
|
||||
*/
|
||||
@UnstableKMathAPI
|
||||
public inline fun <C, A: Ring<C>> NumberedPolynomialSpace<C, A>.NumberedPolynomialDSL1(initialCapacity: Int = 0, block: DSL1NumberedPolynomialBuilder<C>.() -> Unit) : NumberedPolynomial<C> = 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<Int> = NumberedPolynomial {
|
||||
@ -415,6 +418,7 @@ public inline fun <C, A: Ring<C>> NumberedPolynomialSpace<C, A>.NumberedPolynomi
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
* @usesMathJax
|
||||
*/
|
||||
@UnstableKMathAPI
|
||||
public inline fun <C, A: Ring<C>> NumberedRationalFunctionSpace<C, A>.NumberedPolynomialDSL1(initialCapacity: Int = 0, block: DSL1NumberedPolynomialBuilder<C>.() -> Unit) : NumberedPolynomial<C> = DSL1NumberedPolynomialBuilder({ left: C, right: C -> left + right }, initialCapacity).apply(block).build()
|
||||
|
Loading…
Reference in New Issue
Block a user