Skip to content

Commit

Permalink
fix for #850: transpose-slice-multiply crash
Browse files Browse the repository at this point in the history
  • Loading branch information
philwalk committed Aug 28, 2024
1 parent 39542c3 commit 132e433
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,9 @@ trait DenseMatrixMultiplyOps extends DenseMatrixExpandedOps with DenseMatrixMult

// if we have a weird stride...
val a: DenseMatrix[Double] =
if (_a.majorStride < math.max(if (_a.isTranspose) _a.cols else _a.rows, 1)) _a.copy else _a
if (_a.majorStride > math.max(if (_a.isTranspose) _a.cols else _a.rows, 1)) _a.copy else _a
val b: DenseMatrix[Double] =
if (_b.majorStride < math.max(if (_b.isTranspose) _b.cols else _b.rows, 1)) _b.copy else _b
if (_b.majorStride > math.max(if (_b.isTranspose) _b.cols else _b.rows, 1)) _b.copy else _b

blas.dgemm(
transposeString(a),
Expand Down
11 changes: 11 additions & 0 deletions math/src/test/scala/breeze/linalg/DenseMatrixTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,17 @@ class DenseMatrixTest extends AnyFunSuite with Checkers with DoubleImplicits wit
assert(sm == sm.copy)
}

test("#850 - transpose slice multiply bug") {
val = DenseMatrix( (0.75, -0.25), (-0.25, 0.75))
val matB = DenseMatrix(
(67.0, 33.0),
(69.0, 78.0),
(93.0, 57.0)
).t
val B = matB(::, 1 until matB.cols)
Jɴ * B // should not crash
}

}

trait MatrixTestUtils {
Expand Down
3 changes: 2 additions & 1 deletion math/src/test/scala/breeze/linalg/TextOperationsTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import org.scalatest.funsuite.AnyFunSuite
* Created by Luca Puggini: [email protected] on 19/02/16.
*/
class TextOperationsTest extends AnyFunSuite {
System.err.println(new File(".").getAbsolutePath)
test("csvread and String2File methods") {
// A csv file can be read both using the java File function and the toFile method of the string class
val file_path = if (new File(".").getAbsolutePath.endsWith("math/.")) {
val file_path = if (new File(".").getAbsolutePath.replace('\\', '/').endsWith("math/.")) {
"src/test/resources/glass_data.txt"
} else {
"./math/src/test/resources/glass_data.txt"
Expand Down
2 changes: 1 addition & 1 deletion project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ object Common {
}
}

val buildCrossScalaVersions = Seq("3.1.3", "2.12.15", "2.13.8")
val buildCrossScalaVersions = Seq("3.4.2", "2.12.19", "2.13.14")

lazy val buildScalaVersion = buildCrossScalaVersions.head

Expand Down

0 comments on commit 132e433

Please sign in to comment.