Skip to content

Commit d2156d5

Browse files
committed
format linalg module
Signed-off-by: Zach Harel <zach@zharel.me>
1 parent 3d14039 commit d2156d5

8 files changed

Lines changed: 1111 additions & 1038 deletions

File tree

linalg/src/main/kotlin/dev/nextftc/linalg/Builders.kt

Lines changed: 56 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
*/
88

99
@file:JvmName("VectorBuilder")
10+
@file:Suppress("ktlint:standard:parameter-list-wrapping")
11+
1012
package dev.nextftc.linalg
1113

1214
import org.ejml.simple.SimpleMatrix
@@ -32,24 +34,68 @@ fun makeVector(x1: Double, x2: Double, x3: Double, x4: Double, x5: Double): Size
3234
SizedVector(SimpleMatrix(5, 1, false, doubleArrayOf(x1, x2, x3, x4, x5)), N5)
3335

3436
/** Creates a 6-dimensional vector. */
35-
fun makeVector(x1: Double, x2: Double, x3: Double, x4: Double, x5: Double, x6: Double): SizedVector<N6> =
37+
fun makeVector(
38+
x1: Double,
39+
x2: Double,
40+
x3: Double,
41+
x4: Double,
42+
x5: Double,
43+
x6: Double,
44+
): SizedVector<N6> =
3645
SizedVector(SimpleMatrix(6, 1, false, doubleArrayOf(x1, x2, x3, x4, x5, x6)), N6)
3746

3847
/** Creates a 7-dimensional vector. */
39-
fun makeVector(x1: Double, x2: Double, x3: Double, x4: Double, x5: Double, x6: Double, x7: Double): SizedVector<N7> =
48+
fun makeVector(
49+
x1: Double,
50+
x2: Double,
51+
x3: Double,
52+
x4: Double,
53+
x5: Double,
54+
x6: Double,
55+
x7: Double,
56+
): SizedVector<N7> =
4057
SizedVector(SimpleMatrix(7, 1, false, doubleArrayOf(x1, x2, x3, x4, x5, x6, x7)), N7)
4158

4259
/** Creates an 8-dimensional vector. */
43-
fun makeVector(x1: Double, x2: Double, x3: Double, x4: Double, x5: Double, x6: Double, x7: Double, x8: Double): SizedVector<N8> =
44-
SizedVector(SimpleMatrix(8, 1, false, doubleArrayOf(x1, x2, x3, x4, x5, x6, x7, x8)), N8,)
60+
fun makeVector(
61+
x1: Double,
62+
x2: Double,
63+
x3: Double,
64+
x4: Double,
65+
x5: Double,
66+
x6: Double,
67+
x7: Double,
68+
x8: Double,
69+
): SizedVector<N8> =
70+
SizedVector(SimpleMatrix(8, 1, false, doubleArrayOf(x1, x2, x3, x4, x5, x6, x7, x8)), N8)
4571

4672
/** Creates a 9-dimensional vector. */
47-
fun makeVector(x1: Double, x2: Double, x3: Double, x4: Double, x5: Double, x6: Double, x7: Double, x8: Double, x9: Double): SizedVector<N9> =
73+
fun makeVector(
74+
x1: Double,
75+
x2: Double,
76+
x3: Double,
77+
x4: Double,
78+
x5: Double,
79+
x6: Double,
80+
x7: Double,
81+
x8: Double,
82+
x9: Double,
83+
): SizedVector<N9> =
4884
SizedVector(SimpleMatrix(9, 1, false, doubleArrayOf(x1, x2, x3, x4, x5, x6, x7, x8, x9)), N9)
4985

5086
/** Creates a 10-dimensional vector. */
51-
fun makeVector(x1: Double, x2: Double, x3: Double, x4: Double, x5: Double, x6: Double, x7: Double, x8: Double, x9: Double, x10: Double): SizedVector<N10> =
52-
SizedVector(SimpleMatrix(10, 1, false, doubleArrayOf(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)), N10)
53-
54-
class MatrixBuilder internal constructor(rows: Int, cols: Int, data: DoubleArray) :
55-
SizedMatrix<N1, N1>(SimpleMatrix(rows, cols, false, data), N1, N1)
87+
fun makeVector(
88+
x1: Double,
89+
x2: Double,
90+
x3: Double,
91+
x4: Double,
92+
x5: Double,
93+
x6: Double,
94+
x7: Double,
95+
x8: Double,
96+
x9: Double,
97+
x10: Double,
98+
): SizedVector<N10> = SizedVector(
99+
SimpleMatrix(10, 1, false, doubleArrayOf(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)),
100+
N10,
101+
)

linalg/src/main/kotlin/dev/nextftc/linalg/Nat.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
*/
88

99
@file:JvmName("Naturals")
10+
1011
package dev.nextftc.linalg
1112

1213
/**
1314
* Type-level natural numbers for compile-time matrix dimension checking.
14-
* Use these as generic bounds on [Matrix] to ensure dimensional correctness at compile time.
15+
* Use these as generic bounds on [SizedMatrix] to ensure dimensional correctness at compile time.
1516
*/
1617
sealed interface Nat {
1718
val num: Int

linalg/src/main/kotlin/dev/nextftc/linalg/SizedMatrix.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ open class SizedMatrix<R : Nat, C : Nat> internal constructor(
3737
) {
3838
@Suppress("UNCHECKED_CAST")
3939
constructor(data: Array<DoubleArray>) :
40-
this(SimpleMatrix(data), natOf(data.size) as R, natOf(data.first().size) as C)
40+
this(SimpleMatrix(data), natOf(data.size) as R, natOf(data.first().size) as C)
4141

4242
companion object {
4343
/**
@@ -52,7 +52,7 @@ open class SizedMatrix<R : Nat, C : Nat> internal constructor(
5252
*/
5353
@JvmStatic
5454
@Suppress("UNCHECKED_CAST")
55-
fun <R: Nat, C: Nat> zero(rows: Int, cols: Int) : SizedMatrix<R, C> {
55+
fun <R : Nat, C : Nat> zero(rows: Int, cols: Int): SizedMatrix<R, C> {
5656
val rNat = natOf(rows)
5757
val cNat = natOf(cols)
5858
return zero(rNat, cNat) as SizedMatrix<R, C>

0 commit comments

Comments
 (0)