Skip to content

Commit 9d8566f

Browse files
Develop v1.1.1 (#32)
* Matrix [+] Добавил матричный размер и инициализацию матрицы с использованием размера. [+] Написал для них тесты. * Factorial [+] Добавил expect/actual для реализации BigInteger в android на платформах IOS, android, JVM, LinuxX64 * Test [~] Исправил тест * Matrix, Readme, tests [+] Добавил оператор compateTo для матриц. [+] Добавил тесты. [+] Добавил в доку поиск минимального пути на графе, операторы для матриц, факториал. * expect/actual [+] Добавил BigFloat [+] Добавил bigTetraction гипер оператор. [+] Добавил тесты. * Readme [~] Обновил ридмишки * Readme [~] Обновил ридмишки * Update README.md * Matrix [+] Добавила метод для поиска в матрице. * Matrix [+] Добавила тест. * Native [+] Добавил нативный гипероператор. * Native [+] Обновил гит игнор. * Library [+] Перенёс нативную либу в library. [~] Сделал контекст выполнения юнит тестов в JVM. [+] Добавил контекст выполнения тестов в Android. * Library [+] merge * Library [-] Удалил запуск тестов для android. * Library [+] Добавил нативные функции. * Library [~] обновил версионный каталог. * Library [+] Добавил JNI кода! --------- Co-authored-by: Slava <[email protected]> Co-authored-by: Slava <[email protected]>
1 parent 0a73321 commit 9d8566f

File tree

21 files changed

+509
-22
lines changed

21 files changed

+509
-22
lines changed

.github/workflows/library unit test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77

88
jobs:
99
test:
10-
runs-on: ubuntu-latest
10+
runs-on: windows-latest
1111
steps:
1212
- uses: actions/checkout@v1
1313
- name: set up JDK
@@ -18,4 +18,4 @@ jobs:
1818
- name: Make gradlew executable
1919
run: chmod +x ./gradlew
2020
- name: Unit Test
21-
run: ./gradlew :library:testDebugUnitTest
21+
run: ./gradlew :library:JvmTest

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ Pods/
1717
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
1818
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
1919

20+
# Cpp
21+
.cxx
22+
2023
# User-specific stuff
2124
.idea/**/workspace.xml
2225
.idea/**/tasks.xml

.idea/kotlinc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ plugins {
22
alias(libs.plugins.androidLibrary).apply(false)
33
alias(libs.plugins.kotlinMultiplatform).apply(false)
44
alias(libs.plugins.vanniktech.mavenPublish).apply(false)
5+
alias(libs.plugins.kotlin.android) apply false
56
}

docs/images/telegram.svg

Lines changed: 5 additions & 0 deletions
Loading

docs/languages/README-en.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# More math
99

1010
Kotlin multiplatform library adding mathematical operations with matrices, vectors, combinatorics and much more.
11+
![Telegram](https://github.com/plumsoftware/more-math/blob/develop-v0.0.1/docs/images/telegram.svg) Telegram emoji are available below the link https://t.me/addemoji/RkIQSnNfAAA
1112

1213
![Telegram](https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white)
1314
<br>Telegram emoji are available below the link https://t.me/addemoji/RkIQSnNfAAA

gradle/libs.versions.toml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,35 @@
22
agp = "8.3.0"
33
kotlin = "2.0.0"
44
nexus-publish = "2.0.0"
5-
android-minSdk = "24"
6-
android-compileSdk = "34"
5+
android-minSdk = "21"
6+
android-compileSdk = "35"
77
mavenPublish = "0.29.0"
88

99
#Coroutines
1010
kotlin-coroutines = "1.9.0"
11+
kotlinVersion = "1.9.0"
12+
coreKtx = "1.15.0"
13+
junit = "4.13.2"
14+
junitVersion = "1.2.1"
15+
espressoCore = "3.6.1"
16+
appcompat = "1.7.0"
17+
material = "1.12.0"
1118

1219
[libraries]
1320
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
14-
nexus-publish = { module = "io.github.gradle-nexus.publish-plugin:io.github.gradle-nexus.publish-plugin.gradle.plugin", version.ref = "nexus-publish" }
1521

1622
#Coroutines
1723
kotlin-coroutines = {module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlin-coroutines"}
1824
kotlin-coroutines-test = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-test", version.ref = "kotlin-coroutines" }
25+
core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
26+
junit = { group = "junit", name = "junit", version.ref = "junit" }
27+
ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
28+
espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
29+
appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
30+
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
1931

2032
[plugins]
2133
androidLibrary = { id = "com.android.library", version.ref = "agp" }
2234
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
23-
vanniktech-mavenPublish = {id = "com.vanniktech.maven.publish", version.ref = "mavenPublish"}
35+
vanniktech-mavenPublish = {id = "com.vanniktech.maven.publish", version.ref = "mavenPublish"}
36+
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlinVersion" }

library/build.gradle.kts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,28 @@ android {
5151
compileSdk = libs.versions.android.compileSdk.get().toInt()
5252
defaultConfig {
5353
minSdk = libs.versions.android.minSdk.get().toInt()
54+
55+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
56+
}
57+
58+
externalNativeBuild {
59+
cmake {
60+
path("src/commonMain/cpp/CMakeLists.txt")
61+
version = "3.22.1"
62+
}
63+
}
64+
65+
dependencies {
66+
testImplementation(libs.junit)
67+
androidTestImplementation(libs.ext.junit)
68+
androidTestImplementation(libs.espresso.core)
5469
}
5570
}
5671

5772
mavenPublishing {
5873

5974
group = "io.github.plumsoftware"
60-
version = "1.1.0"
75+
version = "1.1.1"
6176

6277
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
6378

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package more.math.native.model
2+
3+
@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
4+
internal actual class NativeProvider actual constructor() {
5+
6+
companion object {
7+
init {
8+
System.loadLibrary("nativelib")
9+
}
10+
}
11+
12+
private external fun cppFactorial(number: Int) : Long
13+
14+
private external fun cppLongFactorial(number: Long) : Long
15+
16+
private external fun cppAverage(vararg number: Int) : Double
17+
18+
private external fun cppStandardDeviation(vararg numbers: Double) : Double
19+
20+
private external fun cppTetraction(number: Double, other: Int) : Double
21+
22+
private external fun cppGcd(a: Int, b: Int) : Int
23+
24+
actual fun nativeFactorial(number: Int): Long {
25+
return cppFactorial(number = number)
26+
}
27+
28+
actual fun nativeFactorial(number: Long): Long {
29+
return cppLongFactorial(number = number)
30+
}
31+
32+
actual fun nativeAverage(vararg numbers: Int) : Double {
33+
return cppAverage(*numbers)
34+
}
35+
36+
actual fun standardDeviation(vararg numbers: Double) : Double {
37+
return cppStandardDeviation(*numbers)
38+
}
39+
40+
actual fun tetraction(number: Double, other: Int) : Double {
41+
return cppTetraction(number = number, other = other)
42+
}
43+
44+
actual fun gcd(a: Int, b: Int): Int {
45+
return cppGcd(a, b)
46+
}
47+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package more.math.native.model
2+
3+
import androidx.test.ext.junit.runners.AndroidJUnit4
4+
import more.math.MoreMath
5+
import org.junit.Test
6+
import org.junit.runner.RunWith
7+
import org.junit.Assert.*
8+
9+
@RunWith(AndroidJUnit4::class)
10+
class NativeLibTest {
11+
12+
@Test
13+
fun nativeFactorial() {
14+
val actual = MoreMath.factorial(n = 3)
15+
val expected = 6L
16+
assertEquals(expected, actual)
17+
18+
val actual1 = MoreMath.factorial(n = 3L)
19+
val expected1 = 6L
20+
assertEquals(expected1, actual1)
21+
}
22+
23+
@Test
24+
fun average() {
25+
val exp: Double = 2.0
26+
val act: Double = MoreMath.average(1, 2, 3)
27+
assertEquals(exp.toString(), act.toString())
28+
}
29+
30+
@Test
31+
fun tetraction() {
32+
val result = MoreMath.tetraction(number = 2.0, other = 3)
33+
assertEquals(16.0.toString(), result.toString())
34+
}
35+
36+
@Test
37+
fun stdDev() {
38+
val exp: Double = 1.0
39+
val act: Double = MoreMath.standardDeviation(1.0, 2.0, 3.0)
40+
assertEquals(exp.toString(), act.toString())
41+
}
42+
43+
@Test
44+
fun gcd() {
45+
val exp: Int = 5
46+
val act: Int = MoreMath.gcd(10, 15)
47+
assertEquals(exp, act)
48+
}
49+
}

0 commit comments

Comments
 (0)