--
You received this message because you are subscribed to the Google Groups "Scala Breeze" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-breeze+unsubscribe@googlegroups.com.
To post to this group, send email to scala-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-breeze/b6553c22-3079-45bb-a28e-dcb3cceeab72%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
In Breeze, operations are provided via an implicit parameter that provides the implementation. This allows for a lot more flexibility and extensibility in terms of how things are put together. This is provided via the UFunc abstraction (https://github.com/scalanlp/breeze/wiki/Universal-Functions)In particular see https://github.com/scalanlp/breeze/wiki/Universal-Functions#using-ufuncs-in-generic-functionsMore concretely, you need class MyClass[T](a: DenseMatrix[T], b: DenseMatrix[T])(implicit mul: OpMulMatrix.Impl2[DenseMatrix[T], DenseMatrix[T], DenseMatrix[T]])
On Thu, Sep 14, 2017 at 9:36 PM, Andrey Ilinykh <aili...@gmail.com> wrote:
Hello everybody!I have very simple problem. I want to create generic code which should operate with different matrix type - mostly DenseMatrix[Double] or DenseMatrix[Float]. Something like this:class MyClass[T](a: DenseMatrix[T], b: DenseMatrix[T]) {def myfunc = {a * b}//more methods here ...}and later use asnew MyClass[Float](a, b)ornew MyClass[Double](a, b)but it doesn't compile. The error I got isError:(87, 9) diverging implicit expansion for type breeze.linalg.operators.OpMulMatrix.Impl2[breeze.linalg.DenseMatrix[T],breeze.linalg.DenseMatrix[T],That]starting with method opMulMatrixFromSemiring in object OpMulMatrixa * bWhat would be the right way to do it?Thank you,Andrey
--
You received this message because you are subscribed to the Google Groups "Scala Breeze" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-breeze...@googlegroups.com.