Kone (pronounced the same way as "cone") is a library that implements common algorithms to simplify your experience of mathematical experiments.
Visit Kone's docs and API reference sites.
[WIP] Kotlin library for pure mathematics computational experiments
Home Page: https://lounres.github.io/Kone
License: Apache License 2.0
Kone (pronounced the same way as "cone") is a library that implements common algorithms to simplify your experience of mathematical experiments.
Visit Kone's docs and API reference sites.
Implement API for retrieving coefficients of multivariate polynomials like:
val polynomial: LabelledPolynomial<C> = ...
val coefficient1 = polynomial[{ x pow 3u; y pow 1u; z pow 15u }] // Signature description as in DSL1
val coefficient2 = polynomial[mapOf(x to 3u, y to 1u, z to 15u)] // Just a `get` function delegated by `polynomial` to `polynomial.coefficients`
public fun <T: Comparable<T>> List<T>.maxes(count: Int): List<T> = buildList(count) {
val iterator = iterator()
repeat(count) {
if (!iterator.hasNext()) throw NoSuchElementException()
this.add(iterator.next())
}
while (iterator.hasNext()) {
val e = iterator.next()
var index = count - 1
this[index] = e
while (index >= 1) {
if (this[index-1] >= e) break
this[index] = this[index-1]
this[index-1] = e
index--
}
}
}
Make a framework that will provide out of the box such features:
Pause and resume computation serialising interim computation state
Framework should be able to pause and resume end user's computation regardless of whether program will be stopped or not. Paused computation must be able to be resumed without (or with minimal) change of program source code. Interim computation state must be able to be serialised in a file. The file may (and apparently will) be used to serialise and deserialise the computational state. The serialisation may be delegated to end user. But it will awesome to come up with API to minimise user work. Also interim partial output data must be able to be serialised and returned.
Compute parallelly
The framework must provide API for parallelising end user's computation.
UI
The framework must provide ability to plug in CLI, web UI or any other UI. UI must contain elements for:
The default web UI backend must just serve interim data. The default web UI frontend must be very simple. Web UI must be able to be changed (with inheritance or whatever) by end user including frontend replacement.
There is need in:
Assume polynomial conditions. The feature provides functionality to assume some polynomial conditions and check other statements under them. Also, it provides context for containing such conditions, enhanced manipulating with polynomial statements in the contexts, and ability to inherit such context to structure computation. Syntax illustration:
Rational.field.planimetricProblem { // It's a Planimetric Problem Context equipped with Planimetrics Computation Context.
val A by Point
val B by Point
val C by Point
val l by Line
assume(A liesOn l)
assume { B liesOn l }
println(C isLyingOn l)
// >>> false
subproblem {
assume(collinearityCondition(A, B, C))
println(C isLyingOn l)
// >>> true
}
println(C isLyingOn l)
// >>> false
}
Needs:
Implement test for polynomial lying in radical of ideal generated by assumed polynomials. Found articles:
Computation of radical ideal:
Computation on containing in an polynomial ideal:
Fix temporary collections API and come up with a new one (like from Java API but better?).
Hooks. A part of abstract algorithms works like (or precisely are) dynamic algorithms. It means there is an input data that is changing and the output should be changed along. It also means that there should be an API to simplify representation of such relationship.
Suggestion is that there should be a Hook
interface which declares API for hooking on changes viewers. In that case all the algorithms can be represented as a simple object which state depends on its arguments and, hence, can be called "views". For example,
/**
* @param C type that is representing data change
* @param I type of intermediate data representation
*/
interface Hook<C, I> {
fun hookOn(callback: I.(change: C) -> Unit)
}
interface View<E> {
val value: E
}
// ...
sealed interface ListChange<E> {
data class Assign<E>(val index: Int, val oldElement: E, val newElement: E): ListChange<E>
data class Insert<E>(val index: Int, val newElement: E): ListChange<E>
data class Remove<E>(val index: Int, val oldElement: E): ListChange<E>
}
interface MutableListHook<E>: MutableList<E>, Hook<ListChange<E>, List<E>>
class MutableListHookImpl<E>(private val list: MutableList<E>): MutableList<E> by list, MutableListHook<E> {
private val hooks = mutableListOf<List<E>.(ListChange<E>) -> Unit>()
override fun hookOn(callback: List<E>.(change: ListChange<E>) -> Unit) { hooks.add(callback) }
private fun trigger(change: ListChange<E>) { hooks.forEach { list.it(change) } }
override fun add(element: E): Boolean {
trigger(ListChange.Insert(list.size, element))
return list.add(element)
}
// ...
}
// ...
class DynamicMaximumValueView<E>(hook: MutableListHook<E>, comparator: Comparator<E>): View<E> {
private val heap = MaxHeap(hook, comparator)
init {
hook.hookOn {
when (it) {
is ListChange.Assign -> {
heap.remove(it.oldElement)
heap.add(it.newElement)
}
is ListChange.Insert -> {
heap.add(it.newElement)
}
is ListChange.Remove -> {
heap.remove(it.oldElement)
}
}
}
}
override val value: E get() = heap.head
}
Looks like feature-gradle-plugin has to provide ability to get list of projects with specified tag(s).
There may be a use case (in equality of labelled or numbered polynomials) for operator like
fun <K, V1, V2> checkOnMerge(
map1: Map<K, V1>,
map2: Map<K, V2>,
check1: (key: K, value: V1) -> Boolean,
check2: (key: K, value: V2) -> Boolean,
checkUnion: (key: K, value1: V1, value2: V2) -> Boolean,
) : Boolean
that checks if check1
is true on all unique keys from map1
, check2
is true on all unique keys from map2
, and checkUnion
is true on all common keys from map1
and map2
.
Also, there could be operator:
fun <K, V1, V2, R> foldOnMerge(
map1: Map<K, V1>,
map2: Map<K, V2>,
acc: R,
change1: (acc: R, key: K, value: V1) -> R,
change2: (acc: R, key: K, value: V2) -> R,
changeUnion: (acc: R, key: K, value1: V1, value2: V2) -> R,
) : R
that is mix of previous function and fold
: for each key of any of map1
or map2
it changes accumulator acc
with either change1
, change2
, or changeUnion
depending on whether the key is unique for any of the maps or their common key.
Make main
branch just a Kotlin multiplatform branch and copy and modify environment and implementations for the features in their own branches
Features:
1.7.20-Beta
1.7.20-Beta
+ K2 compiler1.7.20-Beta
+ rangeUntil
operatormain
branch protection (ref)P.S. Also, see: https://habr.com/ru/company/inDrive/blog/706662/
And replace legacy implementation.
Implement ExpressionPolynomial
class that just represents arithmetic circuit and a polynomial space for it (over field or ring?).
kone-
modules to kone
directory.util
directory.Sometimes there is need in comparing numeric values (that obviously must depend not on type of the numeric values but on algebraic context of the values).
Add ability to declare different brute force strategies on different structures.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.