kmath/kmath-ast/index.html

136 lines
42 KiB
HTML
Raw Normal View History

<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" charset="UTF-8">
<title>kmath-ast</title>
</head><body><link href="../images/logo-icon.svg" rel="icon" type="image/svg"><script>var pathToRoot = "../";</script>
<script type="text/javascript" src="../scripts/sourceset_dependencies.js" async></script><link href="../styles/style.css" rel="Stylesheet"><link href="../styles/jetbrains-mono.css" rel="Stylesheet"><link href="../styles/main.css" rel="Stylesheet"><link href="../styles/prism.css" rel="Stylesheet"><link href="../styles/logo-styles.css" rel="Stylesheet"><script type="text/javascript" src="../scripts/clipboard.js" async></script><script type="text/javascript" src="../scripts/navigation-loader.js" async></script><script type="text/javascript" src="../scripts/platform-content-handler.js" async></script><script type="text/javascript" src="../scripts/main.js" defer></script><script type="text/javascript" src="../scripts/prism.js" async></script><script>const storage = localStorage.getItem("dokka-dark-mode")
const savedDarkMode = storage ? JSON.parse(storage) : false
if(savedDarkMode === true){
document.getElementsByTagName("html")[0].classList.add("theme-dark")
}</script>
<div class="navigation-wrapper" id="navigation-wrapper">
<div id="leftToggler"><span class="icon-toggler"></span></div>
<div class="library-name"><a href="../index.html"><span>kmath</span></a></div>
<div></div>
<div class="pull-right d-flex">
<div class="filter-section" id="filter-section"><button class="platform-tag platform-selector common-like" data-active="" data-filter=":kmath-ast:dokkaHtmlPartial/commonMain">common</button><button class="platform-tag platform-selector js-like" data-active="" data-filter=":kmath-ast:dokkaHtmlPartial/jsMain">js</button><button class="platform-tag platform-selector jvm-like" data-active="" data-filter=":kmath-ast:dokkaHtmlPartial/jvmMain">jvm</button></div>
<button id="theme-toggle-button"><span id="theme-toggle"></span></button>
<div id="searchBar"></div>
</div>
</div>
<div id="container">
<div id="leftColumn">
<div id="sideMenu"></div>
</div>
<div id="main">
<div class="main-content" id="content" pageids="kmath-ast::////PointingToDeclaration//-1763828843">
<div class="breadcrumbs"></div>
<div class="cover ">
<h1 class="cover"><span><span>kmath-ast</span></span></h1>
<div class="platform-hinted UnderCoverText with-platform-tabs" data-platform-hinted="data-platform-hinted">
<div class="platform-bookmarks-row" data-toggle-list="data-toggle-list"><button class="platform-bookmark common-like" data-filterable-current=":kmath-ast:dokkaHtmlPartial/commonMain" data-filterable-set=":kmath-ast:dokkaHtmlPartial/commonMain" data-active="" data-toggle=":kmath-ast:dokkaHtmlPartial/commonMain">common</button><button class="platform-bookmark js-like" data-filterable-current=":kmath-ast:dokkaHtmlPartial/jsMain" data-filterable-set=":kmath-ast:dokkaHtmlPartial/jsMain" data-toggle=":kmath-ast:dokkaHtmlPartial/jsMain">js</button><button class="platform-bookmark jvm-like" data-filterable-current=":kmath-ast:dokkaHtmlPartial/jvmMain" data-filterable-set=":kmath-ast:dokkaHtmlPartial/jvmMain" data-toggle=":kmath-ast:dokkaHtmlPartial/jvmMain">jvm</button></div>
<div class="content sourceset-depenent-content" data-active="" data-togglable=":kmath-ast:dokkaHtmlPartial/commonMain"><p class="paragraph">Extensions to MST API: transformations, dynamic compilation and visualization.</p><ul><li><p class="paragraph">src/commonMain/kotlin/space/kscience/kmath/ast/parser.kt : Expression language and its parser</p></li><li><p class="paragraph">src/jvmMain/kotlin/space/kscience/kmath/asm/asm.kt : Dynamic MST to JVM bytecode compiler</p></li><li><p class="paragraph">src/jsMain/kotlin/space/kscience/kmath/estree/estree.kt : Dynamic MST to JS compiler</p></li><li><p class="paragraph">src/commonMain/kotlin/space/kscience/kmath/ast/rendering/MathRenderer.kt : Extendable MST rendering</p></li></ul><h2 class=""> Artifact:</h2><p class="paragraph">The Maven coordinates of this project are <code class="lang-kotlin">space.kscience:kmath-ast:0.3.0</code>.</p><p class="paragraph"><strong>Gradle Groovy:</strong></p><div class="sample-container"><pre><code class="block lang-groovy" theme="idea">repositories {<br> maven { url 'https://repo.kotlin.link' }<br> mavenCentral()<br>}<br><br>dependencies {<br> implementation 'space.kscience:kmath-ast:0.3.0'<br>}</code></pre><span class="top-right-position"><span class="copy-icon"></span><div class="copy-popup-wrapper popup-to-left"><span class="copy-popup-icon"></span><span>Content copied to clipboard</span></div></span></div><p class="paragraph"><strong>Gradle Kotlin DSL:</strong></p><div class="sample-container"><pre><code class="block lang-kotlin" theme="idea">repositories {<br> maven("https://repo.kotlin.link")<br> mavenCentral()<br>}<br><br>dependencies {<br> implementation("space.kscience:kmath-ast:0.3.0")<br>}</code></pre><span class="top-right-position"><span class="copy-icon"></span><div class="copy-popup-wrapper popup-to-left"><span class="copy-popup-icon"></span><span>Content copied to clipboard</span></div></span></div><h2 class=""> Parsing expressions</h2><p class="paragraph">In this module there is a parser from human-readable strings like <code class="lang-kotlin">"x^3-x+3"</code> (in the more specific reference/ArithmeticsEvaluator.g4) to MST instances.</p><p class="paragraph">Supported literals:</p><ol><li><p class="paragraph">Constants and variables (consist of latin letters, digits and underscores, can't start with digit): <code class="lang-kotlin">x</code>, <code class="lang-kotlin">_Abc2</code>.</p></li><li><p class="paragraph">Numbers: <code class="lang-kotlin">123</code>, <code class="lang-kotlin">1.02</code>, <code class="lang-kotlin">1e10</code>, <code class="lang-kotlin">1e-10</code>, <code class="lang-kotlin">1.0e+3</code>—all parsed either as <code class="lang-kotlin">kotlin.Long</code> or <code class="lang-kotlin">kotlin.Double</code>.</p></li></ol><p class="paragraph">Supported binary operators (from the highest precedence to the lowest one):</p><ol><li><p class="paragraph"><code class="lang-kotlin">^</code></p></li><li><p class="paragraph"><code class="lang-kotlin">*</code>, <code class="lang-kotlin">/</code></p></li><li><p class="paragraph"><code class="lang-kotlin">+</code>, <code class="lang-kotlin">-</code></p></li></ol><p class="paragraph">Supported unary operator:</p><ol><li><p class="paragraph"><code class="lang-kotlin">-</code>, e.&nbsp;g. <code class="lang-kotlin">-x</code></p></li></ol><p class="paragraph">Arbitrary unary and binary functions are also supported: names consist of latin letters, digits and underscores, can't start with digit. Examples:</p><ol><li><p class="paragraph"><code class="lang-kotlin">sin(x)</code></p></li><li><p class="paragraph"><code class="lang-kotlin">add(x, y)</code></p></li></ol><h2 class=""> Dynamic expression code generation</h2><h3 class=""> On JVM</h3><p class="paragraph"><code class="lang-kotlin">kmath-ast</code> JVM module supports runtime code generation to eliminate overhead of tree traversal. Code generator builds a special implementation of <code class="lang-kotlin">Expression&lt;T&gt;</code> with implemented <code class="lang-kotlin">invoke</code> function.</p>
</div>
<h2 class="">Packages</h2>
<div class="table"><a data-name="1930886389%2FPackages%2F1542328537" anchor-label="space.kscience.kmath.asm" id="1930886389%2FPackages%2F1542328537" data-filterable-set=":kmath-ast:dokkaHtmlPartial/jvmMain"></a>
<div class="table-row" data-filterable-current=":kmath-ast:dokkaHtmlPartial/jvmMain" data-filterable-set=":kmath-ast:dokkaHtmlPartial/jvmMain">
<div>
<div class="main-subrow ">
<div class=""><span class="inline-flex">
<div><a href="space.kscience.kmath.asm/index.html">space.kscience.kmath.asm</a></div>
<span class="anchor-wrapper"><span class="anchor-icon" pointing-to="1930886389%2FPackages%2F1542328537"></span>
<div class="copy-popup-wrapper "><span class="copy-popup-icon"></span><span>Link copied to clipboard</span></div>
</span></span></div>
<div class="pull-right">
<div class="platform-tags no-gutters">
<div class="platform-tag jvm-like">jvm</div>
</div>
</div>
</div>
<div></div>
</div>
</div>
<a data-name="72249916%2FPackages%2F353974653" anchor-label="space.kscience.kmath.ast" id="72249916%2FPackages%2F353974653" data-filterable-set=":kmath-ast:dokkaHtmlPartial/commonMain"></a>
<div class="table-row" data-filterable-current=":kmath-ast:dokkaHtmlPartial/commonMain" data-filterable-set=":kmath-ast:dokkaHtmlPartial/commonMain">
<div>
<div class="main-subrow ">
<div class=""><span class="inline-flex">
<div><a href="space.kscience.kmath.ast/index.html">space.kscience.kmath.ast</a></div>
<span class="anchor-wrapper"><span class="anchor-icon" pointing-to="72249916%2FPackages%2F353974653"></span>
<div class="copy-popup-wrapper "><span class="copy-popup-icon"></span><span>Link copied to clipboard</span></div>
</span></span></div>
<div class="pull-right">
<div class="platform-tags no-gutters">
<div class="platform-tag common-like">common</div>
</div>
</div>
</div>
<div></div>
</div>
</div>
<a data-name="-622937510%2FPackages%2F353974653" anchor-label="space.kscience.kmath.ast.rendering" id="-622937510%2FPackages%2F353974653" data-filterable-set=":kmath-ast:dokkaHtmlPartial/commonMain"></a>
<div class="table-row" data-filterable-current=":kmath-ast:dokkaHtmlPartial/commonMain" data-filterable-set=":kmath-ast:dokkaHtmlPartial/commonMain">
<div>
<div class="main-subrow ">
<div class=""><span class="inline-flex">
<div><a href="space.kscience.kmath.ast.rendering/index.html">space.kscience.kmath.ast.rendering</a></div>
<span class="anchor-wrapper"><span class="anchor-icon" pointing-to="-622937510%2FPackages%2F353974653"></span>
<div class="copy-popup-wrapper "><span class="copy-popup-icon"></span><span>Link copied to clipboard</span></div>
</span></span></div>
<div class="pull-right">
<div class="platform-tags no-gutters">
<div class="platform-tag common-like">common</div>
</div>
</div>
</div>
<div></div>
</div>
</div>
<a data-name="-2000073002%2FPackages%2F-359754593" anchor-label="space.kscience.kmath.estree" id="-2000073002%2FPackages%2F-359754593" data-filterable-set=":kmath-ast:dokkaHtmlPartial/jsMain"></a>
<div class="table-row" data-filterable-current=":kmath-ast:dokkaHtmlPartial/jsMain" data-filterable-set=":kmath-ast:dokkaHtmlPartial/jsMain">
<div>
<div class="main-subrow ">
<div class=""><span class="inline-flex">
<div><a href="space.kscience.kmath.estree/index.html">space.kscience.kmath.estree</a></div>
<span class="anchor-wrapper"><span class="anchor-icon" pointing-to="-2000073002%2FPackages%2F-359754593"></span>
<div class="copy-popup-wrapper "><span class="copy-popup-icon"></span><span>Link copied to clipboard</span></div>
</span></span></div>
<div class="pull-right">
<div class="platform-tags no-gutters">
<div class="platform-tag js-like">js</div>
</div>
</div>
</div>
<div></div>
</div>
</div>
<a data-name="452572206%2FPackages%2F-359754593" anchor-label="space.kscience.kmath.wasm" id="452572206%2FPackages%2F-359754593" data-filterable-set=":kmath-ast:dokkaHtmlPartial/jsMain"></a>
<div class="table-row" data-filterable-current=":kmath-ast:dokkaHtmlPartial/jsMain" data-filterable-set=":kmath-ast:dokkaHtmlPartial/jsMain">
<div>
<div class="main-subrow ">
<div class=""><span class="inline-flex">
<div><a href="space.kscience.kmath.wasm/index.html">space.kscience.kmath.wasm</a></div>
<span class="anchor-wrapper"><span class="anchor-icon" pointing-to="452572206%2FPackages%2F-359754593"></span>
<div class="copy-popup-wrapper "><span class="copy-popup-icon"></span><span>Link copied to clipboard</span></div>
</span></span></div>
<div class="pull-right">
<div class="platform-tags no-gutters">
<div class="platform-tag js-like">js</div>
</div>
</div>
</div>
<div></div>
</div>
</div>
</div>
</div>
<div class="footer"><span class="go-to-top-icon"><a href="#content" id="go-to-top-link"></a></span><span>© 2022 Copyright</span><span class="pull-right"><span>Generated by </span><a href="https://github.com/Kotlin/dokka"><span>dokka</span><span class="padded-icon"></span></a></span></div>
</div>
</div>
</body></html>