I plan on moving CSCMatrix.transpose to a CSRMatrix type at some point, so
there's one case...

And there won't be conflicts. Inside the algorithm, they're different
types. Outside, Scala will see that it can use the same implicit in both
places, and it will happily do so.

-- David


On Tue, May 6, 2014 at 12:13 AM, Li Pu <notifications@github.com> wrote:

> In math/src/main/scala/breeze/linalg/svd.scala:
>
> > +  trait OpMulMatrixDenseVector[Mat] extends
> > +    OpMulMatrix.Impl3[Mat, DenseVector[Double], Boolean, DenseVector[Double]]
> > +
> > +  /**
> > +   * Implementation of svds for a sparse matrix. The caller provides two operations: mul - matrix
> > +   * multiplies a DenseVector, and mulTranspose - the transpose of matrix multiplies a DenseVector.
> > +   *
> > +   * @param mul operation that multiples a matrix with a DenseVector with a boolean parameter
> > +   *            indicating if the matrix should be transposed.
> > +   * @tparam Mat type of the input matrix of size n*m.
> > +   * @return left singular vectors matrix of size n*k, singular value vector of length k, and
> > +   *         transpose of right singular vectors matrix of size k*m.
> > +   */
> > +  implicit def Svd_Sparse_Impl[Mat](implicit mul: OpMulMatrix.Impl3[Mat, DenseVector[Double],
> > +      Boolean, DenseVector[Double]]):Impl4[Mat, Int, Int, Double, (DenseMatrix[Double],
> > +      DenseVector[Double], DenseMatrix[Double])] = {
>
> @dlwh <https://github.com/dlwh> Thank you for the comments! I think it is
> better to have mul and trans. This would make the user less likely using
> inconsistent matrix and transpose. Svd_Sparse_Impl will hold the transposed
> matrix, and the user still has the choice on trans implementation. If we
> have mul and trans, there no need for mulTrans? If Mat and MatTranspose is
> the same, which is the usual case, there would be a conflict of implicits?
> How about a simplified version like this:
>
> implicit def Svd_Sparse_Impl[Mat](implicit mul: OpMulMatrix.Impl2[Mat, DenseVector[Double], DenseVector[Double]], trans: CanTranspose[Mat, Mat])
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/scalanlp/breeze/pull/240/files#r12312817>
> .
>