SCM Repository

[matrix] View of /pkg/TODO
ViewVC logotype

View of /pkg/TODO

Parent Directory Parent Directory | Revision Log Revision Log

Revision 2223 - (download) (annotate)
Fri Jul 18 23:04:48 2008 UTC (10 years, 7 months ago) by mmaechler
File size: 9367 byte(s)
build sparse_diagU2N() into functions underlying AS_CHM_*()
- Check for DimNames propagation in coercion and other operations.

- Report the problem in the Linux ldexp manual page.  The second and
  third calls in the Synopsis should be to ldexpf and ldexpl.

- provide methods for "dspMatrix" and "dppMatrix"!

- implement (more) methods for supporting "packed" (symmetric / triangular)
  matrices; particularly something like pack() and unpack()  [to/from our
  classes from/to "numeric"] --- have already man/unpack.Rd but no method yet!

  (have some dtr* <-> dtp*)

- combine the C functions for multiplication by special forms and
  solution wrt special forms by using a 'right' argument and a
  'classed' argument.
   [done with dgeMatrix_matrix_mm();  not yet for other classes;
    and for _crossprod()]


- "Math2" , "Math", "Arith":
   keep triangular and symmetric Matrices when appropriate:
   particularly desirable for  "Math2": round(), signif()

  For triangular matrices, more specifically make sure the four rules of
  "triangular matrix algebra" (Golub+Van Loan 1996, 3.1.8, p.93) are
  fulfilled; now(2008-03-06) ok for Csparse; not yet for <dtr> %*% <dtr>

- "d" <-> "l" coercion for all "[TCR]" sparse matrices is really trivial:
  "d" -> "l" : drops the 'x' slot
  "l" -> "d" : construct an 'x' slot of all '1'
  We currently have many of these conversions explicitly, e.g.
   setAs("dsTMatrix", "lsTMatrix",
      function(from) new("lsTMatrix", i = from@i, j = from@j, uplo = from@uplo,
                         Dim = from@Dim, Dimnames = from@Dimnames))
  but I would rather want to automatically construct all these coercion
  methods at once by a ``method constructor'', i.e.,
  for all  "dsparse*" -> "lsparse*" and vice versa.
  How can one do this {in a documented way} ?

- Think of constructing  setAs(...) calls automatically in order to
  basically enable all ``sensible'' as(fromMatrix, toMatrix)  calls,
  possibly using canCoerce(.)

- setAs(<Mcl>,  "[dln]Matrix") for <Mcl> in {Matrix or denseMatrix + sparseMatrix}

- When we have a packed matrix, it's a waste to go through "full" to "sparse":
  ==> implement
	setAs("dspMatrix", "sparseMatrix")
	setAs("dppMatrix", "sparseMatrix")
	setAs("dtpMatrix", "sparseMatrix")
  and the same for "lsp" , "ltp"  and  "nsp" , "ntp" !

- tcrossprod(x, y) : do provide methods for y != NULL
  calling Lapack's DGEMM for "dense"
  [2005-12-xx: done for dgeMatrix at least]

- BUGlet:  Shouldn't lose factorization here:
  h6 <- Hilbert(6); chol(h6) ; str(h6) # has factor
  str(H6 <- as(h6, "dspMatrix"))       # has lost factor
  ## and the same in a similar situation involving  "dpo", "dpp"

- Factorizations: LU done; also Schur()  for  *sparse*  Matrices.

- method for all our matrices [ ==> which(*, arr.ind=TRUE) might work ]

- use  .Call(Csparse_drop, M, tol) in more places,
  both with 'tol = 0.' to drop "values that happen to be 0" and for
  zapsmall() methods for Csparse*

- implement .Call(Csparse_scale, ....) interfacing to cholmod_scale()
  in src/CHOLMOD/Include/cholmod_matrixops.h : for another function
  specifically for multiplying a cholmod_sparse object by a diagonal matrix.
  Use it in %*% and [t]crossprod methods.

- chol() should ``work'': proper result or "good" error message.

- make sure *all* group methods have (maybe "bail-out") setMethod for "Matrix".
  e.g. zapsmall(<pMatrix>) fails "badly"

- Implement  expand(.) for the Cholesky() results
  "dCHMsimpl" and  "dCHMsuper"  -- currently have no *decent* way to get at
  the matrix factors of the corresponding matrix factorization !!

- rbind2(<sparse>, <dense>) does not work  (e.g. <dgC>, <dge>)

- <sparse> %*% <dense>  {also in crossprod/tcrossprod}  currently always
  returns <dense>, since --> Csparse_dense_prod --> cholmod_sdmult
  and that does only return dense.
  When the sparse matrix is very sparse, i.e. has many rows with only zero
  entries, it would make much sense to return sparse.

- sparse-symmetric + diagonal should stay sparse-symmetric
  (only stays sparse): Matrix(0, 4, 4) + Diagonal(4, 1:4)
  --> R/diagMatrix.R ('FIXME')
  but also R/Ops.R  to ensure  sp-sym. + sp-sym. |-> sp-sym.  etc

- ! <symmetricMatrix>  loses symmetry, both for dense and sparse matrices.
  !M  where M is "sparseMatrix", currently always gives dense. This only
  makes sense when M is ``really sparse''.

- example(Cholesky, echo=FALSE) ; cm <- chol(mtm); str(cm); str(mtm)

  shows that chol() does not seems to make use of an already
  present factorization and rather uses one with more '0' in x slot.

- diag(m) <- val    currently automatically works via  m[cbind(i,i)] <- val
  This (`[<-` method) is now "smart" for diagonalMatrix, but needs also to
  be for triangularMatrix, and probably also "dense*general*Matrix" since the
  above currently goes via "matrix" and back instead of using the 'x' slot
  directly; in particular, the triangular* "class property" is lost!

  Note that 'diag(M[,-1]) <- val' is deadly slow for large sparse M,
  but that's because of the "outer" assignment in the equivalent
  M[,-1] <- `diag<-`(M[,-1], val).

- examples for solve( Cholesky(.), b, system = c("A", "LDLt"....))
  probably rather in man/CHMfactor-class.Rd than man/Cholesky.Rd

- LDL(<CHMsimpl>) looks relatively easy; via  "tCsparse_diag()"
   {diagonal entries of *triangular* Csparse}
  --> see comment in determinant(<dsC>) in R/dsCMatrix.R, will give
  faster determinant

- tr(A %*% B) {and even  tr(A %*% B %*% C) ...} are also needed
  frequently in some computations {conditional normal distr. ...}.
  Since this can be done faster than by
    sum(diag(A %*% B))  even for traditional matrices, e.g.
    	       sum(A * t(B)) or {even faster for "full" mat}
	       crossprod(as.vector(A), as.vector(B))
  and even more so for, e.g.  <sparse> %*% <dense>
  {used in Soeren's 'gR' computations},
  we should also provide a generic and methods.

- qr.R(qr(x)) may differ for the "same" matrix, depending on it being
  sparse or dense:
    "qr.R(<sparse>) may differ from qr.R(<dense>) because of permutations"

  This is not really acceptable and currently influences  rcond() as well.

- eigen() should become generic, and get a method at least for diagonal,
  but also for symmetric -> dsyMatrix  [LAPACK dsyev() uses UPLO !],
  but also simply for dgeMatrix (without going via tradition matrices).
  What about Sparse?  There's fill-in, but it may still be sensible, e.g.
  mlist <- list(1, 2:3, diag(x=5:3), 27, cbind(1,3:6), 100:101)
  ee <- eigen(tcrossprod(bdiag(lapply(mlist, as.matrix))))
  Matrix( signif(ee$vectors, 3) )

- facmul() has no single method defined;  it looks like a good idea though
  (instead of the infamous qr.qy, qr.qty,.... functions)

- symmpart() and skewpart()  for *sparse* matrices still use (x +/- t(x))/2
  and could be made more efficient.
  Consider going via  asTuniq() or something very close to
  .Arith.Csparse() in R/Ops.R

- many setAs(*, "[dl]..Matrix") are still needed, as long as e.g.
  replCmat() uses as_CspClass() and drop0(.) which itself call
  as_CspClass() quite a bit.  --> try to replace these by
  as(*, "CsparseMatrix"); forceSymmetric, etc.

- implement fast diag(<triangularCsparse>) via calling new
  src/Csparse.c's diag_tC_ptr()

- add examples (and tests!) for update(<CHMfactor>, ..) and
  Cholesky(......, Imult), also tests for hidden {hence no examples}
  ldetL2up() { R/CHMfactor.R }

- chol(<nsCMatrix>)  gives "temporarily disabled"
  but should give the *symbolic* factorization;
  similarly Cholesky(.) is not enabled

- writeMM(obj, file=stdout()) creates file "1" since file is silently
  assumed to be a string, i.e. cannot be a connection.
  An R (instead of C) version should be pretty simple, and would work with
  connections automatically ["lsparse" become either "real" or
  "pattern", "depending if they have NAs or not].

- <diagMatrix> o <ddenseMatrix> currently works via sparse, but
  should return <diagMatrix> in the same cases where
  <diagMatrix> o <numeric> does.

- look at solve.QP.compact() in \pkg{quadprog} and how to do that using
  our sparse matrices.  Maybe this needs to be re-implemented using CHOLMOD

- "sparseVector" : indices, i.e. @i and @length  should be changed
   		 from class "integer" to "numeric" (i.e. double prec),
  since we want to be able to coerce large sparse matrices to sparse
  vectors, where length maybe considerably larger than 2^32.

- src/Csparce.c etc:  grep 'AS_.*sparse_diagU2N' src/*.?
     o AS_CHM_SP(Csparse_diagU2N(.)) : as_cholmod_sparse(..)  \ src/chm_common.h
     o AS_CHM_TR(Tsparse_diagU2N(.)) : as_cholmod_triplet(..) /
     o AS_CSP   (Csparse_diagU2N(.)) : Matrix_as_cs(..)       > src/cs_utils.h

  all of which are "inefficient", because several "S4 <-> Cholmod" or
  "S4 <-> CS" coercions happen inside.

  Should make the "inner" Csparse_diagU2N()  part of the
    as_cholmod_sparse() or Matrix_as_cs() functions.
    Drawback: extraneous check even for all AS_*(x) calls where *sparse_diagU2N()
    is unneeded because x is known *not* to be triangular.

  To evade the drawback, do this by adding a new boolean argument
  'check_Udiag' to the C functions.
   --> This is an API change however, notably since we export as_cholmod_sparse
      ( in inst/include/Matrix.h )

[[ have done the as_cholmod_* ones, but not yet the Matrix_as_cs() one ]]
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business University of Wisconsin - Madison Powered By FusionForge