SM2A: SM2A: Convert a sparse matrix object ASM into a matrix A

View source: R/qDEA.R

SM2AR Documentation

SM2A: Convert a sparse matrix object ASM into a matrix A

Description

ASM is a sparse matrix object containing: nr = number of rows, nc = number of columns, ra = nonzero coeff, ia = row indices, ja = col indices, rnames = row names,cnames = column names # Note these may be missing or "" SMM = space matrix method, and ZINDEX = use 0-indexing

Usage

SM2A(ASM, NA_flag = (-1e+12))

Arguments

ASM

A sparse matrix object

NA_flag

Number to uses as NA flag

Value

The matrix A.

Examples

(A = matrix(c(1,0,0,2,0,3,1,0,0,5,0,6),3,4,byrow=TRUE))
(ASM1 = A2SM(A,SMM='CMO',ZINDEX=TRUE))
(ASM2=SM2SM(ASM1,SMM2='CRI',ZINDEX2=FALSE))
SM2A(ASM1)
SM2A(ASM2)

(A = matrix(c(1,0,0,2,0,3,1,0,0,5,0,6),3,4,byrow=TRUE)); A[2,3]=NA; A
(ASM1 = A2SM(A,SMM='CMO',ZINDEX=TRUE)); A; SM2A(ASM1)
(ASM2 = SM2SM(ASM1,SMM2='CRI',ZINDEX2=TRUE)); A ; SM2A(ASM2)

#CMO  documentation example
nr=5
nc=8
ra=c(3.0,5.6,1.0,2.0,1.1,1.0,-2.0,2.8,-1.0,1.0,1.0,-1.2,-1.0,1.9)
ia=c(0,4,0,1,1,2,0,3,0,4,2,3,0,4)
ja=c(0,2,4,6,8,10,11,12,14)
SMM='CMO'
ZINDEX=TRUE
ASM=list(nr=nr,nc=nc,ra=ra,ia=ia,ja=ja,SMM=SMM,ZINDEX=ZINDEX)
(A=SM2A(ASM))

qDEA documentation built on April 13, 2026, 5:07 p.m.