diag: Matrix Diagonals

Description Usage Arguments Details Value See Also Examples

Description

Extract or replace the diagonal of a matrix, or construct a diagonal matrix.

Usage

1
diag(x, ...)

Arguments

x

is an object of class FLMatrix or FLVector

Details

diag has three distinct usages: x is a FLMatrix, when it extracts the diagonal. x is a scalar (length-one FLVector) and the only argument, it returns a square identity matrix of size given by the scalar. x is a FLVector, either of length at least 2. This returns a square matrix with the given diagonal entries.

Value

If x is a FLMatrix then diag(x) returns the diagonal of x as FLVector object. If x is FLVector, the value is a diagonal square FLMatrix with diagonal elements as given in FLVector.

See Also

diag for corresponding R function reference.

Examples

1
2
3
4
5
6
flmatrix <- FLMatrix(getTestTableName("tblMatrixMulti"), 5,"MATRIX_ID",
                     "ROW_ID","COL_ID","CELL_VAL", dims= c(5,5))
resultFLVector <- diag(flmatrix)
WideTable <- FLTable(getTestTableName("tblUSArrests"),"ObsID","VarId","Num_Val")
flvectorDeep <- WideTable[1:5,1]
resultFLMatrix <- diag(flvectorDeep)

Fuzzy-Logix/AdapteR documentation built on May 6, 2019, 5:07 p.m.