Fill in the lack of documentation of kmath-ast module for adv-expr #109
@ -73,7 +73,7 @@ fun <T : Any> MST.compileWith(type: KClass<T>, algebra: Algebra<T>): Expression<
|
|||||||
/**
|
/**
|
||||||
* Compile an [MST] to ASM using given algebra
|
* Compile an [MST] to ASM using given algebra
|
||||||
*/
|
*/
|
||||||
inline fun <reified T : Any> Algebra<T>.expresion(mst: MST): Expression<T> = mst.compileWith(T::class, this)
|
inline fun <reified T : Any> Algebra<T>.expression(mst: MST): Expression<T> = mst.compileWith(T::class, this)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Optimize performance of an [MSTExpression] using ASM codegen
|
* Optimize performance of an [MSTExpression] using ASM codegen
|
||||||
|
@ -5,6 +5,11 @@ import scientifik.kmath.operations.Algebra
|
|||||||
|
|
||||||
private val methodNameAdapters: Map<String, String> = mapOf("+" to "add", "*" to "multiply", "/" to "divide")
|
private val methodNameAdapters: Map<String, String> = mapOf("+" to "add", "*" to "multiply", "/" to "divide")
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the target [context] for code generation contains a method with needed [name] and [arity].
|
||||||
|
*
|
||||||
|
* @return `true` if contains, else `false`.
|
||||||
|
*/
|
||||||
internal fun <T> hasSpecific(context: Algebra<T>, name: String, arity: Int): Boolean {
|
internal fun <T> hasSpecific(context: Algebra<T>, name: String, arity: Int): Boolean {
|
||||||
val aName = methodNameAdapters[name] ?: name
|
val aName = methodNameAdapters[name] ?: name
|
||||||
|
|
||||||
@ -14,6 +19,12 @@ internal fun <T> hasSpecific(context: Algebra<T>, name: String, arity: Int): Boo
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the target [context] for code generation contains a method with needed [name] and [arity] and inserts
|
||||||
|
* [AsmBuilder.invokeAlgebraOperation] of this method.
|
||||||
|
*
|
||||||
|
* @return `true` if contains, else `false`.
|
||||||
|
*/
|
||||||
internal fun <T> AsmBuilder<T>.tryInvokeSpecific(context: Algebra<T>, name: String, arity: Int): Boolean {
|
internal fun <T> AsmBuilder<T>.tryInvokeSpecific(context: Algebra<T>, name: String, arity: Int): Boolean {
|
||||||
val aName = methodNameAdapters[name] ?: name
|
val aName = methodNameAdapters[name] ?: name
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user