API cleanup

This commit is contained in:
Alexander Nozik 2021-10-02 15:56:57 +03:00
parent 01bbb4bb13
commit 0f634688cc
5 changed files with 37 additions and 32 deletions

View File

@ -4,9 +4,11 @@
#
kotlin.code.style=official
kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.mpp.stability.nowarn=true
kotlin.native.enableDependencyPropagation=false
#kotlin.mpp.enableGranularSourceSetsMetadata=true
#kotlin.native.enableDependencyPropagation=false
kotlin.jupyter.add.scanner=false
org.gradle.configureondemand=true

View File

@ -3,18 +3,18 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
*/
package space.kscience.kmath.structures
package space.kscience.kmath.operations
import space.kscience.kmath.linear.Point
import space.kscience.kmath.misc.UnstableKMathAPI
import space.kscience.kmath.operations.*
import space.kscience.kmath.structures.Buffer
import space.kscience.kmath.structures.DoubleBuffer
import space.kscience.kmath.structures.fold
import kotlin.math.*
/**
* [ExtendedFieldOperations] over [DoubleBuffer].
*/
@Deprecated("To be replaced by generic BufferAlgebra")
public object DoubleBufferFieldOperations : ExtendedFieldOperations<Buffer<Double>> {
public object DoubleBufferOperations : ExtendedFieldOperations<Buffer<Double>> {
override fun Buffer<Double>.unaryMinus(): DoubleBuffer = if (this is DoubleBuffer) {
DoubleBuffer(size) { -array[it] }
} else {
@ -179,13 +179,13 @@ public class DoubleBufferField(public val size: Int) : ExtendedField<Buffer<Doub
override fun number(value: Number): Buffer<Double> = DoubleBuffer(size) { value.toDouble() }
override fun Buffer<Double>.unaryMinus(): Buffer<Double> = DoubleBufferFieldOperations.run {
override fun Buffer<Double>.unaryMinus(): Buffer<Double> = DoubleBufferOperations.run {
-this@unaryMinus
}
override fun add(a: Buffer<Double>, b: Buffer<Double>): DoubleBuffer {
require(a.size == size) { "The buffer size ${a.size} does not match context size $size" }
return DoubleBufferFieldOperations.add(a, b)
return DoubleBufferOperations.add(a, b)
}
override fun scale(a: Buffer<Double>, value: Double): DoubleBuffer {
@ -199,87 +199,87 @@ public class DoubleBufferField(public val size: Int) : ExtendedField<Buffer<Doub
override fun multiply(a: Buffer<Double>, b: Buffer<Double>): DoubleBuffer {
require(a.size == size) { "The buffer size ${a.size} does not match context size $size" }
return DoubleBufferFieldOperations.multiply(a, b)
return DoubleBufferOperations.multiply(a, b)
}
override fun divide(a: Buffer<Double>, b: Buffer<Double>): DoubleBuffer {
require(a.size == size) { "The buffer size ${a.size} does not match context size $size" }
return DoubleBufferFieldOperations.divide(a, b)
return DoubleBufferOperations.divide(a, b)
}
override fun sin(arg: Buffer<Double>): DoubleBuffer {
require(arg.size == size) { "The buffer size ${arg.size} does not match context size $size" }
return DoubleBufferFieldOperations.sin(arg)
return DoubleBufferOperations.sin(arg)
}
override fun cos(arg: Buffer<Double>): DoubleBuffer {
require(arg.size == size) { "The buffer size ${arg.size} does not match context size $size" }
return DoubleBufferFieldOperations.cos(arg)
return DoubleBufferOperations.cos(arg)
}
override fun tan(arg: Buffer<Double>): DoubleBuffer {
require(arg.size == size) { "The buffer size ${arg.size} does not match context size $size" }
return DoubleBufferFieldOperations.tan(arg)
return DoubleBufferOperations.tan(arg)
}
override fun asin(arg: Buffer<Double>): DoubleBuffer {
require(arg.size == size) { "The buffer size ${arg.size} does not match context size $size" }
return DoubleBufferFieldOperations.asin(arg)
return DoubleBufferOperations.asin(arg)
}
override fun acos(arg: Buffer<Double>): DoubleBuffer {
require(arg.size == size) { "The buffer size ${arg.size} does not match context size $size" }
return DoubleBufferFieldOperations.acos(arg)
return DoubleBufferOperations.acos(arg)
}
override fun atan(arg: Buffer<Double>): DoubleBuffer {
require(arg.size == size) { "The buffer size ${arg.size} does not match context size $size" }
return DoubleBufferFieldOperations.atan(arg)
return DoubleBufferOperations.atan(arg)
}
override fun sinh(arg: Buffer<Double>): DoubleBuffer {
require(arg.size == size) { "The buffer size ${arg.size} does not match context size $size" }
return DoubleBufferFieldOperations.sinh(arg)
return DoubleBufferOperations.sinh(arg)
}
override fun cosh(arg: Buffer<Double>): DoubleBuffer {
require(arg.size == size) { "The buffer size ${arg.size} does not match context size $size" }
return DoubleBufferFieldOperations.cosh(arg)
return DoubleBufferOperations.cosh(arg)
}
override fun tanh(arg: Buffer<Double>): DoubleBuffer {
require(arg.size == size) { "The buffer size ${arg.size} does not match context size $size" }
return DoubleBufferFieldOperations.tanh(arg)
return DoubleBufferOperations.tanh(arg)
}
override fun asinh(arg: Buffer<Double>): DoubleBuffer {
require(arg.size == size) { "The buffer size ${arg.size} does not match context size $size" }
return DoubleBufferFieldOperations.asinh(arg)
return DoubleBufferOperations.asinh(arg)
}
override fun acosh(arg: Buffer<Double>): DoubleBuffer {
require(arg.size == size) { "The buffer size ${arg.size} does not match context size $size" }
return DoubleBufferFieldOperations.acosh(arg)
return DoubleBufferOperations.acosh(arg)
}
override fun atanh(arg: Buffer<Double>): DoubleBuffer {
require(arg.size == size) { "The buffer size ${arg.size} does not match context size $size" }
return DoubleBufferFieldOperations.atanh(arg)
return DoubleBufferOperations.atanh(arg)
}
override fun power(arg: Buffer<Double>, pow: Number): DoubleBuffer {
require(arg.size == size) { "The buffer size ${arg.size} does not match context size $size" }
return DoubleBufferFieldOperations.power(arg, pow)
return DoubleBufferOperations.power(arg, pow)
}
override fun exp(arg: Buffer<Double>): DoubleBuffer {
require(arg.size == size) { "The buffer size ${arg.size} does not match context size $size" }
return DoubleBufferFieldOperations.exp(arg)
return DoubleBufferOperations.exp(arg)
}
override fun ln(arg: Buffer<Double>): DoubleBuffer {
require(arg.size == size) { "The buffer size ${arg.size} does not match context size $size" }
return DoubleBufferFieldOperations.ln(arg)
return DoubleBufferOperations.ln(arg)
}
override fun norm(arg: Buffer<Double>): Double = DoubleL2Norm.norm(arg)

View File

@ -306,14 +306,14 @@ public fun <T : AlgebraElement<T, out ExponentialOperations<T>>> tanh(arg: T): T
*/
@UnstableKMathAPI
@Deprecated("AlgebraElements are considered odd and will be removed in future releases.")
public fun <T : AlgebraElement<T, out ExponentialOperations<T>>> asinh(arg: T): T = arg.context.asinh(arg)
public fun <T : AlgebraElement<T, ExponentialOperations<T>>> asinh(arg: T): T = arg.context.asinh(arg)
/**
* Computes the inverse hyperbolic cosine of [arg].
*/
@UnstableKMathAPI
@Deprecated("AlgebraElements are considered odd and will be removed in future releases.")
public fun <T : AlgebraElement<T, out ExponentialOperations<T>>> acosh(arg: T): T = arg.context.acosh(arg)
public fun <T : AlgebraElement<T, ExponentialOperations<T>>> acosh(arg: T): T = arg.context.acosh(arg)
/**
* Computes the inverse hyperbolic tangent of [arg].

View File

@ -40,6 +40,8 @@ public abstract class EjmlLinearSpace<T : Any, out A : Ring<T>, out M : org.ejml
public abstract override fun buildVector(size: Int, initializer: A.(Int) -> T): EjmlVector<T, M>
@Suppress("UNCHECKED_CAST")
@UnstableKMathAPI
public fun EjmlMatrix<T, *>.inverse(): Structure2D<Double> = computeFeature(this, InverseMatrixFeature::class)?.inverse as Structure2D<Double>
public fun EjmlMatrix<T, *>.inverse(): Structure2D<Double> =
computeFeature(this, InverseMatrixFeature::class)?.inverse as Structure2D<Double>
}

View File

@ -7,11 +7,12 @@ package space.kscience.kmath.real
import space.kscience.kmath.linear.Point
import space.kscience.kmath.misc.UnstableKMathAPI
import space.kscience.kmath.operations.Norm
import space.kscience.kmath.structures.*
import space.kscience.kmath.operations.DoubleL2Norm
import space.kscience.kmath.structures.Buffer
import space.kscience.kmath.structures.MutableBuffer.Companion.double
import space.kscience.kmath.structures.asBuffer
import space.kscience.kmath.structures.indices
import kotlin.math.pow
import kotlin.math.sqrt
public typealias DoubleVector = Point<Double>