Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for #850: transpose-slice-multiply crash #862

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 Jɴ = 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