Skip to content

Commit 67dbb7b

Browse files
committed
.
1 parent fc7903b commit 67dbb7b

3 files changed

Lines changed: 22 additions & 29 deletions

File tree

vecxt/jvm/src/doublematrix.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ object JvmDoubleMatrix:
1414
final val sp_int_doubleLanes =
1515
VectorSpecies.of(java.lang.Integer.TYPE, VectorShape.forBitSize(vecxt.arrays.spdl * Integer.SIZE));
1616

17-
extension (m: Matrix[Double]) // inline def /(n: Double): Matrix[Double] =
17+
extension (m: Matrix[Double]) // inline def /(n: Double): Matrix[Double] =
1818
// Matrix(vecxt.arrays./(m.raw)(n), m.shape)(using BoundsCheck.DoBoundsCheck.no)
1919

2020
// TODO check whether this work with flexible memory layout patterns
@@ -44,8 +44,8 @@ object JvmDoubleMatrix:
4444
)
4545
Matrix(newArr, m.rows, b.cols)
4646
else ???
47+
end if
4748

48-
4949
end matmul
5050

5151
// TODO: SIMD

vecxt/src/doublematrix.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ object DoubleMatrix:
3636
extension (m: Matrix[Double])
3737

3838
inline def @@(b: Matrix[Double])(using inline boundsCheck: BoundsCheck): Matrix[Double] =
39-
m.matmul(b)
39+
m.matmul(b)
4040

4141
inline def *=(d: Double): Unit =
4242
if m.hasSimpleContiguousMemoryLayout then m.raw.multInPlace(d)

vecxt/test/src/matMulLayoutChecks.test.scala

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ import vecxt.BoundsCheck.DoBoundsCheck.yes
77

88
class DifferentMemoryLayoutTests extends FunSuite:
99

10-
test("matmul col major * row major"){
10+
test("matmul col major * row major") {
1111
val matRow = Matrix[Double](NArray.tabulate[Double](9)(_.toDouble + 1), 3, 3, 3, 1, 0)
1212
val matCol = Matrix[Double](NArray.tabulate[Double](9)(_.toDouble + 1), 3, 3, 1, 3, 0)
1313

14-
15-
1614
// def assertMatMulResult(mat: Matrix[Double]): Unit =
1715
// assertEqualsDouble(mat(0,0), 1 * 1 + 2 * 2 + 3 * 3, 0.0001)
1816
// assertEqualsDouble(mat(0,2), 1 * 7 + 2 * 8 + 3 * 9, 0.0001)
@@ -25,43 +23,41 @@ class DifferentMemoryLayoutTests extends FunSuite:
2523
// println(matRow.printMat )
2624
// println(mat.printMat)
2725

28-
assertEqualsDouble(mat(0,0), 1 * 1 + 4 * 2 + 3 * 7, 0.0001)
29-
assertEqualsDouble(mat(0,2), 1 * 7 + 4 * 8 + 7 * 9, 0.0001)
30-
assertEqualsDouble(mat(1,1), 4 * 2 + 5 * 5 + 8 * 6, 0.0001)
31-
assertEqualsDouble(mat(2,0), 3 * 1 + 6 * 2 + 9 * 3, 0.0001)
26+
assertEqualsDouble(mat(0, 0), 1 * 1 + 4 * 2 + 3 * 7, 0.0001)
27+
assertEqualsDouble(mat(0, 2), 1 * 7 + 4 * 8 + 7 * 9, 0.0001)
28+
assertEqualsDouble(mat(1, 1), 4 * 2 + 5 * 5 + 8 * 6, 0.0001)
29+
assertEqualsDouble(mat(2, 0), 3 * 1 + 6 * 2 + 9 * 3, 0.0001)
3230

33-
34-
val mat2 = matCol @@ matRow
31+
val mat2 = matCol @@ matRow
3532
// println(matCol.printMat )
3633
// println("---")
3734
// println(matRow.printMat )
3835
// println("---")
3936
// println(mat.printMat)
40-
assertEqualsDouble(mat2(0,0), 1 * 1 + 4 * 4 + 7 * 7, 0.0001)
41-
assertEqualsDouble(mat2(0,2), 1 * 3 + 4 * 6 + 7 * 9, 0.0001)
42-
assertEqualsDouble(mat2(1,1), 2 * 2 + 5 * 5 + 8 * 8, 0.0001)
43-
assertEqualsDouble(mat2(2,0), 3 * 1 + 6 * 4 + 9 * 7, 0.0001)
37+
assertEqualsDouble(mat2(0, 0), 1 * 1 + 4 * 4 + 7 * 7, 0.0001)
38+
assertEqualsDouble(mat2(0, 2), 1 * 3 + 4 * 6 + 7 * 9, 0.0001)
39+
assertEqualsDouble(mat2(1, 1), 2 * 2 + 5 * 5 + 8 * 8, 0.0001)
40+
assertEqualsDouble(mat2(2, 0), 3 * 1 + 6 * 4 + 9 * 7, 0.0001)
4441

4542
val mat3 = matRow @@ matRow
4643
// println(matRow.printMat )
4744
// println("---")
4845
// println(mat3.printMat)
49-
assertEqualsDouble(mat3(0,0), 1 * 1 + 2 * 4 + 7 * 3, 0.0001)
50-
assertEqualsDouble(mat3(0,2), 1 * 3 + 2 * 6 + 3 * 9, 0.0001)
51-
assertEqualsDouble(mat3(1,1), 4 * 2 + 5 * 5 + 6 * 8, 0.0001)
52-
assertEqualsDouble(mat3(2,0), 7 * 1 + 8 * 4 + 9 * 7, 0.0001)
53-
46+
assertEqualsDouble(mat3(0, 0), 1 * 1 + 2 * 4 + 7 * 3, 0.0001)
47+
assertEqualsDouble(mat3(0, 2), 1 * 3 + 2 * 6 + 3 * 9, 0.0001)
48+
assertEqualsDouble(mat3(1, 1), 4 * 2 + 5 * 5 + 6 * 8, 0.0001)
49+
assertEqualsDouble(mat3(2, 0), 7 * 1 + 8 * 4 + 9 * 7, 0.0001)
5450

5551
val mat4 = matRow @@ matCol
5652
// println(matRow.printMat )
5753
// println("---")
5854
// println(matCol.printMat )
5955
// println("---")
6056
// println(mat4.printMat)
61-
assertEqualsDouble(mat4(0,0), 1 * 1 + 2 * 2 + 3 * 3, 0.0001)
62-
assertEqualsDouble(mat4(0,2), 1 * 7 + 2 * 8 + 3 * 9, 0.0001)
63-
assertEqualsDouble(mat4(1,1), 4 * 4 + 5 * 5 + 6 * 6, 0.0001)
64-
assertEqualsDouble(mat4(2,0), 7 * 1 + 8 * 2 + 9 * 3, 0.0001)
57+
assertEqualsDouble(mat4(0, 0), 1 * 1 + 2 * 2 + 3 * 3, 0.0001)
58+
assertEqualsDouble(mat4(0, 2), 1 * 7 + 2 * 8 + 3 * 9, 0.0001)
59+
assertEqualsDouble(mat4(1, 1), 4 * 4 + 5 * 5 + 6 * 6, 0.0001)
60+
assertEqualsDouble(mat4(2, 0), 7 * 1 + 8 * 2 + 9 * 3, 0.0001)
6561

6662
}
6763

@@ -78,10 +74,7 @@ class DifferentMemoryLayoutTests extends FunSuite:
7874
// assertEqualsDouble(matMul(0,0), 1 * 1 + 2 * 2 + 3 * 3, 0.0001)
7975
// assertEqualsDouble(matMul(0,2), 1 * 7 + 2 * 8 + 3 * 9, 0.0001)
8076
// assertEqualsDouble(matMul(1,1), 4 * 4 + 5 * 5 + 6 * 6, 0.0001)
81-
82-
// }
8377

78+
// }
8479

8580
end DifferentMemoryLayoutTests
86-
87-

0 commit comments

Comments
 (0)