Dev #194
@ -6,8 +6,8 @@ import kscience.kmath.structures.complex
|
||||
|
||||
fun main() {
|
||||
// 2d element
|
||||
val element = NDElement.complex(2, 2) { index: IntArray ->
|
||||
Complex(index[0].toDouble() - index[1].toDouble(), index[0].toDouble() + index[1].toDouble())
|
||||
val element = NDElement.complex(2, 2) { (i,j) ->
|
||||
Complex(i.toDouble() - j.toDouble(), i.toDouble() + j.toDouble())
|
||||
}
|
||||
println(element)
|
||||
|
||||
|
@ -16,7 +16,7 @@ import kotlin.properties.ReadOnlyProperty
|
||||
*/
|
||||
public class DerivativeStructureField(
|
||||
public val order: Int,
|
||||
public val parameters: Map<String, Double>
|
||||
public val parameters: Map<String, Double>,
|
||||
) : ExtendedField<DerivativeStructure> {
|
||||
public override val zero: DerivativeStructure by lazy { DerivativeStructure(parameters.size, order) }
|
||||
public override val one: DerivativeStructure by lazy { DerivativeStructure(parameters.size, order, 1.0) }
|
||||
@ -85,8 +85,9 @@ public class DerivativeStructureField(
|
||||
/**
|
||||
* A constructs that creates a derivative structure with required order on-demand
|
||||
*/
|
||||
public class DiffExpression(public val function: DerivativeStructureField.() -> DerivativeStructure) :
|
||||
Expression<Double> {
|
||||
public class DiffExpression(
|
||||
public val function: DerivativeStructureField.() -> DerivativeStructure,
|
||||
) : Expression<Double> {
|
||||
public override operator fun invoke(arguments: Map<String, Double>): Double = DerivativeStructureField(
|
||||
0,
|
||||
arguments
|
||||
|
@ -18,7 +18,7 @@ internal inline fun <R> diff(
|
||||
internal class AutoDiffTest {
|
||||
@Test
|
||||
fun derivativeStructureFieldTest() {
|
||||
val res = diff(3, "x" to 1.0, "y" to 1.0) {
|
||||
val res: Double = diff(3, "x" to 1.0, "y" to 1.0) {
|
||||
val x by variable
|
||||
val y = variable("y")
|
||||
val z = x * (-sin(x * y) + y)
|
||||
|
@ -195,6 +195,7 @@ public data class Complex(val re: Double, val im: Double) : FieldElement<Complex
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a complex number with real part equal to this real.
|
||||
*
|
||||
|
@ -10,7 +10,7 @@ pluginManagement {
|
||||
maven("https://dl.bintray.com/kotlin/kotlin-dev/")
|
||||
}
|
||||
|
||||
val toolsVersion = "0.6.1-dev-1.4.20-M1"
|
||||
val toolsVersion = "0.6.3-dev-1.4.20-M1"
|
||||
val kotlinVersion = "1.4.20-M1"
|
||||
|
||||
plugins {
|
||||
|
Loading…
Reference in New Issue
Block a user