Update changelog

This commit is contained in:
Iaroslav Postovalov 2020-09-12 09:22:26 +07:00
parent 2b15d69f11
commit 8b171ac3a3
No known key found for this signature in database
GPG Key ID: 70D5F4DCB0972F1B
4 changed files with 17 additions and 17 deletions

View File

@ -27,7 +27,7 @@
- `power(T, Int)` extension function has preconditions and supports `Field<T>`
- Memory objects have more preconditions (overflow checking)
- `tg` function is renamed to `tan` (https://github.com/mipt-npm/kmath/pull/114)
- Gradle version: 6.3 -> 6.6
- Gradle version: 6.3 -> 6.6.1
- Moved probability distributions to commons-rng and to `kmath-prob`
### Fixed

View File

@ -255,9 +255,9 @@ public class BigInt internal constructor(
}
private fun addMagnitudes(mag1: Magnitude, mag2: Magnitude): Magnitude {
val resultLength: Int = max(mag1.size, mag2.size) + 1
val resultLength = max(mag1.size, mag2.size) + 1
val result = Magnitude(resultLength)
var carry: TBase = 0UL
var carry = 0uL
for (i in 0 until resultLength - 1) {
val res = when {
@ -265,20 +265,22 @@ public class BigInt internal constructor(
i >= mag2.size -> mag1[i].toULong() + carry
else -> mag1[i].toULong() + mag2[i].toULong() + carry
}
result[i] = (res and BASE).toUInt()
carry = (res shr BASE_SIZE)
}
result[resultLength - 1] = carry.toUInt()
return stripLeadingZeros(result)
}
private fun subtractMagnitudes(mag1: Magnitude, mag2: Magnitude): Magnitude {
val resultLength: Int = mag1.size
val resultLength = mag1.size
val result = Magnitude(resultLength)
var carry = 0L
for (i in 0 until resultLength) {
var res: Long =
var res =
if (i < mag2.size) mag1[i].toLong() - mag2[i].toLong() - carry
else mag1[i].toLong() - carry
@ -292,9 +294,9 @@ public class BigInt internal constructor(
}
private fun multiplyMagnitudeByUInt(mag: Magnitude, x: UInt): Magnitude {
val resultLength: Int = mag.size + 1
val resultLength = mag.size + 1
val result = Magnitude(resultLength)
var carry: ULong = 0UL
var carry = 0uL
for (i in mag.indices) {
val cur: ULong = carry + mag[i].toULong() * x.toULong()
@ -307,11 +309,11 @@ public class BigInt internal constructor(
}
private fun multiplyMagnitudes(mag1: Magnitude, mag2: Magnitude): Magnitude {
val resultLength: Int = mag1.size + mag2.size
val resultLength = mag1.size + mag2.size
val result = Magnitude(resultLength)
for (i in mag1.indices) {
var carry: ULong = 0UL
var carry = 0uL
for (j in mag2.indices) {
val cur: ULong = result[i + j].toULong() + mag1[i].toULong() * mag2[j].toULong() + carry
@ -338,9 +340,7 @@ public class BigInt internal constructor(
return stripLeadingZeros(result)
}
}
}
private fun stripLeadingZeros(mag: Magnitude): Magnitude {
@ -366,7 +366,8 @@ public fun Int.toBigInt(): BigInt = BigInt(sign.toByte(), uintArrayOf(kotlin.mat
* Convert this [Long] to [BigInt]
*/
public fun Long.toBigInt(): BigInt = BigInt(
sign.toByte(), stripLeadingZeros(
sign.toByte(),
stripLeadingZeros(
uintArrayOf(
(kotlin.math.abs(this).toULong() and BASE).toUInt(),
((kotlin.math.abs(this).toULong() shr BASE_SIZE) and BASE).toUInt()
@ -384,7 +385,6 @@ public fun UInt.toBigInt(): BigInt = BigInt(1, uintArrayOf(this))
*/
public fun ULong.toBigInt(): BigInt = BigInt(
1,
stripLeadingZeros(
uintArrayOf(
(this and BASE).toUInt(),

View File

@ -13,9 +13,9 @@ import kotlin.math.pow
* Polynomial coefficients without fixation on specific context they are applied to
* @param coefficients constant is the leftmost coefficient
*/
public /*inline*/ class Polynomial<T : Any>(public val coefficients: List<T>) {
public constructor(vararg coefficients: T) : this(coefficients.toList())
}
public inline class Polynomial<T : Any>(public val coefficients: List<T>)
public fun <T : Any> Polynomial(vararg coefficients: T): Polynomial<T> = Polynomial(coefficients.toList())
public fun Polynomial<Double>.value(): Double = coefficients.reduceIndexed { index, acc, d -> acc + d.pow(index) }

View File

@ -10,7 +10,7 @@ public inline class ViktorBuffer(public val flatArray: F64FlatArray) : MutableBu
public override inline fun get(index: Int): Double = flatArray[index]
override inline fun set(index: Int, value: Double) {
public override inline fun set(index: Int, value: Double) {
flatArray[index] = value
}