could not find implicit value for parameter impl: breeze.linalg.norm.Impl[breeze.linalg.DenseMatrix[Double],VR]

16 views
Skip to first unread message

Jim Newton

unread,
Apr 6, 2021, 10:48:51 AM4/6/21
to Scala Breeze
I'm trying to call the norm function, as documented in the cheat sheet.

Here is the code I'm trying to compile, and the compilation error is shown below.
What is the correct way to find out if two matrices of the same dimensions are equal within a given epsilon?  Am I doing it wrong?

test("breeze"){
  import breeze.linalg._
  import scala.util.Random
  for{dim <- 1 to 4} {
    val dm1 = DenseMatrix.tabulate(dim, dim)((_,_)=>Random.between(-10.0,10.0))
    val svd.SVD(u, s, vt) = svd(dm1)
    val dm2 = u * diag(s) * vt.t
    val dist:Double = norm(dm2 - dm1) /// <--- this fails to compile
    assert(dist < 0.001, s"dist=$dist dm1=[$dm1] dm2=[$dm2]")
  }
}


But I get a compilation error about a missing implicit.  I don't see information in the cheat sheet about how to get the implicits.

/Users/jnewton/Repos/scalain_e/scalain-e-course-code/src/test/scala/TranscendentalsTestSuite.scala:493:29
could not find implicit value for parameter impl: breeze.linalg.norm.Impl[breeze.linalg.DenseMatrix[Double],VR]
      val dist:Double = norm(dm2 - dm1)
Reply all
Reply to author
Forward
0 new messages