Dev #194

Merged
altavir merged 266 commits from dev into master 2021-01-20 17:32:32 +03:00
6 changed files with 10 additions and 8 deletions
Showing only changes of commit e44423192d - Show all commits

View File

@ -24,4 +24,4 @@ subprojects {
readme {
readmeTemplate = file("docs/templates/README-TEMPLATE.md")
}
}

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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.
*

View File

@ -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 {