v0.3.0-dev-9 #324
@ -71,8 +71,8 @@ internal inline fun format(value: Double, digits: Int = 4): String {
|
|||||||
|
|
||||||
val lead = value / ten.pow(order)
|
val lead = value / ten.pow(order)
|
||||||
val leadDisplay = round(lead*ten.pow(digits)) / ten.pow(digits)
|
val leadDisplay = round(lead*ten.pow(digits)) / ten.pow(digits)
|
||||||
val orderDisplay = if(order >= 0) "+$order" else "$order"
|
val orderDisplay = if(order == 0) "" else if(order > 0) "E+$order" else "E$order"
|
||||||
val valueDisplay = "${leadDisplay}E$orderDisplay"
|
val valueDisplay = "${leadDisplay}$orderDisplay"
|
||||||
val res = if(value < 0.0) valueDisplay else " $valueDisplay"
|
val res = if(value < 0.0) valueDisplay else " $valueDisplay"
|
||||||
val fLength = digits + 6
|
val fLength = digits + 6
|
||||||
val endSpace = " ".repeat(fLength - res.length)
|
val endSpace = " ".repeat(fLength - res.length)
|
||||||
@ -83,7 +83,7 @@ internal inline fun DoubleTensor.toPrettyString(): String = buildString {
|
|||||||
var offset = 0
|
var offset = 0
|
||||||
val shape = this@toPrettyString.shape
|
val shape = this@toPrettyString.shape
|
||||||
val linearStructure = this@toPrettyString.linearStructure
|
val linearStructure = this@toPrettyString.linearStructure
|
||||||
var vectorSize = shape.last()
|
val vectorSize = shape.last()
|
||||||
val initString = "DoubleTensor(\n"
|
val initString = "DoubleTensor(\n"
|
||||||
append(initString)
|
append(initString)
|
||||||
var charOffset = 3
|
var charOffset = 3
|
||||||
|
@ -46,4 +46,10 @@ class TestDoubleTensor {
|
|||||||
assertEquals(secondRow[1], secondColumn[1])
|
assertEquals(secondRow[1], secondColumn[1])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun toStringTest() = DoubleTensorAlgebra {
|
||||||
|
val tensor = randNormal(intArrayOf(2,3))
|
||||||
|
println(tensor)
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user