Skip to content

Commit bce205d

Browse files
committed
⬆️ kotlin 1.2.21
- ldexp + coverage
1 parent 5a052e6 commit bce205d

File tree

7 files changed

+100
-7
lines changed

7 files changed

+100
-7
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ apply plugin: 'com.github.johnrengelman.shadow'
99

1010
buildscript {
1111

12-
ext.kotlinVersion = '1.2.20'
12+
ext.kotlinVersion = '1.2.21'
1313

1414
repositories {
1515
jcenter() // shadow
@@ -26,7 +26,7 @@ dependencies {
2626

2727
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
2828

29-
compile 'com.github.kotlin-graphics:kotlin-unsigned:v3.0.5'
29+
compile 'com.github.kotlin-graphics:kotlin-unsigned:9f1103b13fa5840bafff72a6d40a2d3c9aea5e58'
3030

3131
testCompile 'io.kotlintest:kotlintest:2.0.7'
3232
}

src/main/kotlin/glm_/func/common/func_common.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import glm_.glm.trunc
1818
import unsigned.Uint
1919
import unsigned.Ulong
2020
import kotlin.math.absoluteValue
21+
import kotlin.math.pow
2122
import kotlin.math.sign
2223
import kotlin.reflect.KMutableProperty0
2324
import kotlin.math.ceil as _ceil
@@ -256,7 +257,8 @@ interface func_common {
256257
}
257258

258259

259-
// TODO ldexp
260+
fun ldexp(a: Float, exp: Int) = a * 2f.pow(exp)
261+
fun ldexp(a: Double, exp: Int) = a * 2.0.pow(exp)
260262
}
261263

262264

src/main/kotlin/glm_/func/common/func_vector1_common.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import glm_.glm.frexp
1212
import glm_.glm.intBitsToFloat
1313
import glm_.glm.isInf
1414
import glm_.glm.isNan
15+
import glm_.glm.ldexp
1516
import glm_.glm.max
1617
import glm_.glm.min
1718
import glm_.glm.mix
@@ -510,7 +511,18 @@ interface func_vector1_common {
510511
}
511512

512513

513-
// TODO ldexp
514+
fun ldexp(a: Vec1, exp: Vec1i) = ldexp(a, exp, Vec1())
515+
fun ldexp(a: Vec1, exp: Vec1i, res: Vec1): Vec1 {
516+
res.x = ldexp(a.x, exp.x)
517+
return res
518+
}
519+
520+
fun ldexp(a: Vec1d, exp: Vec1i) = ldexp(a, exp, Vec1d())
521+
fun ldexp(a: Vec1d, exp: Vec1i, res: Vec1d): Vec1d {
522+
res.x = ldexp(a.x, exp.x)
523+
return res
524+
}
525+
514526

515527
companion object {
516528
var _i = 0 // TODO mention potential multithread issues

src/main/kotlin/glm_/func/common/func_vector2_common.kt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import glm_.glm.frexp
1212
import glm_.glm.intBitsToFloat
1313
import glm_.glm.isInf
1414
import glm_.glm.isNan
15+
import glm_.glm.ldexp
1516
import glm_.glm.max
1617
import glm_.glm.min
1718
import glm_.glm.mix
@@ -585,7 +586,20 @@ interface func_vector2_common {
585586
}
586587

587588

588-
// TODO ldexp
589+
fun ldexp(a: Vec2, exp: Vec2i) = ldexp(a, exp, Vec2())
590+
fun ldexp(a: Vec2, exp: Vec2i, res: Vec2): Vec2 {
591+
res.x = ldexp(a.x, exp.x)
592+
res.y = ldexp(a.y, exp.y)
593+
return res
594+
}
595+
596+
fun ldexp(a: Vec2d, exp: Vec2i) = ldexp(a, exp, Vec2d())
597+
fun ldexp(a: Vec2d, exp: Vec2i, res: Vec2d): Vec2d {
598+
res.x = ldexp(a.x, exp.x)
599+
res.y = ldexp(a.y, exp.y)
600+
return res
601+
}
602+
589603

590604
companion object {
591605
var _i = 0 // TODO mention potential multithread issues

src/main/kotlin/glm_/func/common/func_vector3_common.kt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import glm_.glm.fract
1212
import glm_.glm.intBitsToFloat
1313
import glm_.glm.isInf
1414
import glm_.glm.isNan
15+
import glm_.glm.ldexp
1516
import glm_.glm.max
1617
import glm_.glm.min
1718
import glm_.glm.mix
@@ -625,7 +626,22 @@ interface func_vector3_common {
625626
}
626627

627628

628-
// TODO ldexp
629+
fun ldexp(a: Vec3, exp: Vec3i) = ldexp(a, exp, Vec3())
630+
fun ldexp(a: Vec3, exp: Vec3i, res: Vec3): Vec3 {
631+
res.x = ldexp(a.x, exp.x)
632+
res.y = ldexp(a.y, exp.y)
633+
res.z = ldexp(a.z, exp.z)
634+
return res
635+
}
636+
637+
fun ldexp(a: Vec3d, exp: Vec3i) = ldexp(a, exp, Vec3d())
638+
fun ldexp(a: Vec3d, exp: Vec3i, res: Vec3d): Vec3d {
639+
res.x = ldexp(a.x, exp.x)
640+
res.y = ldexp(a.y, exp.y)
641+
res.z = ldexp(a.z, exp.z)
642+
return res
643+
}
644+
629645

630646
companion object {
631647
var _i = 0 // TODO mention potential multithread issues

src/main/kotlin/glm_/func/common/func_vector4_common.kt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import glm_.glm.fract
1212
import glm_.glm.intBitsToFloat
1313
import glm_.glm.isInf
1414
import glm_.glm.isNan
15+
import glm_.glm.ldexp
1516
import glm_.glm.max
1617
import glm_.glm.min
1718
import glm_.glm.mix
@@ -726,7 +727,24 @@ interface func_vector4_common {
726727
}
727728

728729

729-
// TODO ldexp
730+
fun ldexp(a: Vec4, exp: Vec4i) = ldexp(a, exp, Vec4())
731+
fun ldexp(a: Vec4, exp: Vec4i, res: Vec4): Vec4 {
732+
res.x = ldexp(a.x, exp.x)
733+
res.y = ldexp(a.y, exp.y)
734+
res.z = ldexp(a.z, exp.z)
735+
res.w = ldexp(a.w, exp.w)
736+
return res
737+
}
738+
739+
fun ldexp(a: Vec4d, exp: Vec4i) = ldexp(a, exp, Vec4d())
740+
fun ldexp(a: Vec4d, exp: Vec4i, res: Vec4d): Vec4d {
741+
res.x = ldexp(a.x, exp.x)
742+
res.y = ldexp(a.y, exp.y)
743+
res.z = ldexp(a.z, exp.z)
744+
res.w = ldexp(a.w, exp.w)
745+
return res
746+
}
747+
730748

731749
companion object {
732750
var _i = 0 // TODO mention potential multithread issues

src/test/kotlin/glm_/testCoreFunCommon.kt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,37 @@ class testCoreFunCommon : StringSpec() {
731731
glm.all(glm.equal(exp, Vec4i(10, -2, 0, 1))) shouldBe true
732732
}
733733
}
734+
735+
"ldexp" {
736+
737+
run {
738+
val a = Vec1(1)
739+
val exp = Vec1i(10)
740+
val x = glm.ldexp(a, exp)
741+
glm.all(glm.epsilonEqual(x, Vec1(1024),0.00001f)) shouldBe true
742+
}
743+
744+
run {
745+
val a = Vec2(1, 0.96)
746+
val exp = Vec2i(10, -2)
747+
val x = glm.ldexp(a, exp)
748+
glm.all(glm.epsilonEqual(x, Vec2(1024, .24),0.00001f)) shouldBe true
749+
}
750+
751+
run {
752+
val a = Vec3(1, 0.96, 0.0)
753+
val exp = Vec3i(10, -2, 0)
754+
val x = glm.ldexp(a, exp)
755+
glm.all(glm.epsilonEqual(x, Vec3(1024, .24, 0),0.00001f)) shouldBe true
756+
}
757+
758+
run {
759+
val a = Vec4(1, 0.96, 0.0, -0.665)
760+
val exp = Vec4i(10, -2, 0, 1)
761+
val x = glm.ldexp(a, exp)
762+
glm.all(glm.epsilonEqual(x, Vec4(1024, .24, 0, -1.33),0.00001f)) shouldBe true
763+
}
764+
}
734765
}
735766

736767
companion object {

0 commit comments

Comments
 (0)