Description Usage Arguments Details Value Note See Also Examples
Transform a triangular matrix x
, i.e., of class
"triangularMatrix"
,
from (internally!) unit triangular (“unitriangular”) to
“general” triangular (diagU2N(x)
) or back (diagN2U(x)
).
Note that the latter, diagN2U(x)
, also sets the diagonal to one
in cases where diag(x)
was not all one.
.diagU2N(x)
assumes but does not check that x
is
a triangularMatrix
with diag
slot
"U"
, and should hence be used with care.
1 2 3 4 | diagN2U(x, cl = getClassDef(class(x)), checkDense = FALSE)
diagU2N(x, cl = getClassDef(class(x)), checkDense = FALSE)
.diagU2N(x, cl, checkDense = FALSE)
|
x |
a |
cl |
(optional, for speedup only:) class (definition) of |
checkDense |
logical indicating if dense (see
|
The concept of unit triangular matrices with a diag
slot of
"U"
stems from LAPACK.
a triangular matrix of the same class
but with a
different diag
slot. For diagU2N
(semantically) with
identical entries as x
, whereas in diagN2U(x)
, the
off-diagonal entries are unchanged and the diagonal is set to all
1
even if it was not previously.
Such internal storage details should rarely be of relevance to the user. Hence, these functions really are rather internal utilities.
"triangularMatrix"
,
"dtCMatrix"
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | (T <- Diagonal(7) + triu(Matrix(rpois(49, 1/4), 7,7), k = 1))
(uT <- diagN2U(T)) # "unitriangular"
(t.u <- diagN2U(10*T))# changes the diagonal!
stopifnot(all(T == uT), diag(t.u) == 1,
identical(T, diagU2N(uT)))
T[upper.tri(T)] <- 5
T <- diagN2U(as(T,"triangularMatrix"))
stopifnot(T@diag == "U")
dT <- as(T, "denseMatrix")
dt. <- diagN2U(dT)
dtU <- diagN2U(dT, checkDense=TRUE)
stopifnot(is(dtU, "denseMatrix"), is(dt., "sparseMatrix"),
all(dT == dt.), all(dT == dtU),
dt.@diag == "U", dtU@diag == "U")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.