BIDData/BIDMat

GSMat contains no transpose method

Opened this issue · 2 comments

The GSMat class contains no transpose method. Something like this might work:

override def t = {
  val out = GSMat.newOrCheckGSMat(ncols, nrows, nnz0, null, GUID, "t".##)
  CUMATD.transpose(this.data, nrows, out.data, ncols, nrows, ncols)
  cudaDeviceSynchronize()
  out
}

(Note the extra nnz0 term to include when checking the cache for GSMats).

However, I did a few tests and got some weird behavior when multiplying GSMats with other matrices (e.g., GSMat(a) * GMat(mkdiag(ones(3,1)))), so I just wanted to check in and see if GSMats were really supposed to have transposes. It seems like they should because SMats have transposes.

The above won't quite work. A lame shortcut for now, since I'm not completely sure how to implement it in GSMats, is to use GSMat(SMat(a).t). For now, I'll leave this open in case we want to fix this later.

Transposing sparse matrices into a valid representation (CSC +COO in BIDMat) is very expensive because it requires a resort of indices. On the other hand, transpose of dense matrices is fast. Its often possible to get the result you want without sparse transpose. e.g. for a sparse S and dense M,

M * S^T = M ^ S (^ is directly implemented)
S^T * M = (M^T * S)^T (two dense transposes)

We should probably implement this some time, but we need to find a way to discourage people from using it.