Difference between revisions of "Kotlin"

From Efficient Java Matrix Library
Jump to navigation Jump to search
(Created page with "= EJML in Kotlin! = EJML works just fine when used in the Kotlin JVM environment. EJML also provides specialized Kotlin support in the form of Kotlin extensions.")
 
 
Line 1: Line 1:
 
= EJML in Kotlin! =
 
= EJML in Kotlin! =
  
EJML works just fine when used in the Kotlin JVM environment. EJML also provides specialized Kotlin support in the form of Kotlin extensions.
+
EJML works just fine when used in the Kotlin JVM environment. EJML also provides specialized Kotlin support in the form of Kotlin extensions. A complete list of extensions can be found on [https://github.com/lessthanoptimal/ejml/blob/SNAPSHOT/main/ejml-kotlin/src/Extensions_F64.kt Github]. This is still considered a preview feature. Suggestions and pull requests to improve the Kotlin support are most welcomed!
 +
 
 +
Kotlin
 +
<syntaxhighlight lang="kotlin">
 +
val c = H*P
 +
val S = multTransB(c,H,null)
 +
S += R
 +
S_inv = S.invert()
 +
multTransA(H,S_inv,d);
 +
K = P*D
 +
</syntaxhighlight>
 +
 
 +
 
 +
Java
 +
<syntaxhighlight lang="java">
 +
mult(H,P,c);
 +
multTransB(c,H,S);
 +
addEquals(S,R);
 +
if( !invert(S,S_inv) )
 +
    throw new RuntimeException("Invert failed");
 +
multTransA(H,S_inv,d);
 +
mult(P,d,K);
 +
</syntaxhighlight>

Latest revision as of 05:47, 29 October 2020

EJML in Kotlin!

EJML works just fine when used in the Kotlin JVM environment. EJML also provides specialized Kotlin support in the form of Kotlin extensions. A complete list of extensions can be found on Github. This is still considered a preview feature. Suggestions and pull requests to improve the Kotlin support are most welcomed!

Kotlin

val c = H*P
val S = multTransB(c,H,null)
S += R
S_inv = S.invert()
multTransA(H,S_inv,d);
K = P*D


Java

mult(H,P,c);
multTransB(c,H,S);
addEquals(S,R);
if( !invert(S,S_inv) ) 
    throw new RuntimeException("Invert failed");
multTransA(H,S_inv,d);
mult(P,d,K);