The R Project SVN R-packages

Rev

Rev 4953 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4953 Rev 4984
Line 9... Line 9...
9
    dd <- dim(x)
9
    dd <- dim(x)
10
    stopifnot(-dd[1] <= k, k <= dd[1])  # had k <= 0
10
    stopifnot(-dd[1] <= k, k <= dd[1])  # had k <= 0
11
    if(k <= 0 && x@uplo == "L")
11
    if(k <= 0 && x@uplo == "L")
12
        x
12
        x
13
    else { ## more to do
13
    else { ## more to do
14
        x <- .diagU2N(x, class(x))
14
        if(x@diag == "U") x <- .diagU2N(x, class(x), checkDense = TRUE)
15
        callNextMethod()
15
        callNextMethod()
16
    }
16
    }
17
}
17
}
18
 
18
 
19
.triu.tr <- function(x, k = 0, ...) {  # are always square
19
.triu.tr <- function(x, k = 0, ...) {  # are always square
Line 21... Line 21...
21
    dd <- dim(x)
21
    dd <- dim(x)
22
    stopifnot(-dd[1] <= k, k <= dd[1])  # had k >= 0
22
    stopifnot(-dd[1] <= k, k <= dd[1])  # had k >= 0
23
    if(k >= 0 && x@uplo == "U")
23
    if(k >= 0 && x@uplo == "U")
24
        x
24
        x
25
    else { ## more to do
25
    else { ## more to do
26
        x <- .diagU2N(x, class(x))
26
        if(x@diag == "U") x <- .diagU2N(x, class(x), checkDense = TRUE)
27
        callNextMethod()
27
        callNextMethod()
28
    }
28
    }
29
}
29
}
30
 
30
 
31
## In order to evade method dispatch ambiguity (with [CTR]sparse* and ddense*),
31
## In order to evade method dispatch ambiguity (with [CTR]sparse* and ddense*),
32
## but still remain "general"
32
## but still remain "general"
33
## we use this hack instead of signature  x = "triagonalMatrix" :
33
## we use this hack instead of signature  x = "triangularMatrix" :
34
 
34
 
35
trCls <- names(getClass("triangularMatrix")@subclasses)
35
trCls <- names(getClass("triangularMatrix")@subclasses)
36
trCls. <- trCls[grep(".t.Matrix", trCls)]  # not "*Cholesky", "*Kaufman" ..
36
trCls. <- trCls[grep(".t.Matrix", trCls)]  # not "*Cholesky", "*Kaufman" ..
37
for(cls in trCls.) {
37
for(cls in trCls.) {
38
    setMethod("tril", cls, .tril.tr)
38
    setMethod("tril", cls, .tril.tr)