eethos.neureka.0.5.0-pre.source-code.scripting_setup.groovy Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of neureka Show documentation
Show all versions of neureka Show documentation
A platform independent tensor library written in Java.
import neureka.Tsr
import neureka.calculus.Function
/**
* Operator overloading for native classes:
*/
//PLUS
Integer.metaClass.plus = { Tsr t -> new Tsr(delegate.toString(),"+", t ) }
Double.metaClass.plus = { Tsr t -> new Tsr(delegate.toString(),"+", t ) }
BigDecimal.metaClass.plus = { Tsr t -> new Tsr(delegate.toString(),"+", t ) }
//MINUS
Integer.metaClass.minus = { Tsr t -> new Tsr(delegate.toString(),"-", t ) }
Double.metaClass.minus = { Tsr t -> new Tsr(delegate.toString(),"-", t ) }
BigDecimal.metaClass.minus = { Tsr t -> new Tsr(delegate.toString(),"-", t ) }
//DIVIDE
Integer.metaClass.div = { Tsr t -> new Tsr(delegate.toString(),"/", t ) }
Double.metaClass.div = { Tsr t -> new Tsr(delegate.toString(),"/", t ) }
BigDecimal.metaClass.div = { Tsr t -> new Tsr(delegate.toString(),"/", t ) }
//POWER
Integer.metaClass.power = { Tsr t -> new Tsr(delegate.toString(),"^", t ) }
Double.metaClass.power = { Tsr t -> new Tsr(delegate.toString(),"^", t ) }
BigDecimal.metaClass.power = { Tsr t -> new Tsr(delegate.toString(),"^", t ) }
//XOR (POWER)
Integer.metaClass.xor = { Tsr t -> new Tsr(delegate.toString(),"^", t ) }
Double.metaClass.xor = { Tsr t -> new Tsr(delegate.toString(),"^", t ) }
BigDecimal.metaClass.xor = { Tsr t -> new Tsr(delegate.toString(),"^", t ) }
//MULTIPLY
Integer.metaClass.multiply = { Tsr t -> new Tsr(delegate.toString(),"*", t ) }
Double.metaClass.multiply = { Tsr t -> new Tsr(delegate.toString(),"*", t ) }
BigDecimal.metaClass.multiply = { Tsr t -> new Tsr(delegate.toString(),"*", t ) }
// String to Function
String.metaClass.asFunction = { boolean doAD -> Function.create(delegate, doAD) }
String.metaClass.asFunction = { delegate.asFunction( true ) }
String.metaClass.getAt = { List inputs -> delegate.asFunction()(inputs.toArray(new Tsr[ 0 ])) }
String.metaClass.mod = { List inputs -> delegate.asFunction()(inputs.toArray(new Tsr[ 0 ])) }
String.metaClass.mod = { Tsr t -> delegate.asFunction()( t ) }
© 2015 - 2025 Weber Informatics LLC | Privacy Policy