@@ -56,6 +56,10 @@ is.SparseBlockMatrixR <- function(x){
5656 inherits(x , " SparseBlockMatrixR" )
5757} # END IS.SPARSEBLOCKMATRIXR
5858
59+ as.SparseBlockMatrixR <- function (x ){
60+ SparseBlockMatrixR(x ) # NOTE: S3 delegation is implicitly handled by the constructor here
61+ }
62+
5963# ------------------------------------------------------------------------------#
6064# reIndexC.SparseBlockMatrixR
6165# Re-indexing TO C for SparseBlockMatrixR objects
@@ -201,30 +205,6 @@ SparseBlockMatrixR.matrix <- function(x, sigmas, ...){
201205 SparseBlockMatrixR(sparsebnUtils :: as.sparse(x ), sigmas , ... )
202206} # END SPARSEBLOCKMATRIXR.MATRIX
203207
204- # ------------------------------------------------------------------------------#
205- # as.SparseBlockMatrixR.list
206- # Convert FROM list TO SparseBlockMatrixR
207- #
208- as.SparseBlockMatrixR.list <- function (x ){
209- SparseBlockMatrixR(x )
210- } # END AS.SPARSEBLOCKMATRIXR.LIST
211-
212- # ------------------------------------------------------------------------------#
213- # as.SparseBlockMatrixR.sparse
214- # Convert FROM sparse TO SparseBlockMatrixR
215- #
216- as.SparseBlockMatrixR.sparse <- function (x ){
217- SparseBlockMatrixR(x )
218- } # END AS.SPARSEBLOCKMATRIXR.SPARSE
219-
220- # ------------------------------------------------------------------------------#
221- # as.SparseBlockMatrixR.matrix
222- # Convert FROM matrix TO SparseBlockMatrixR
223- #
224- as.SparseBlockMatrixR.matrix <- function (x ){
225- SparseBlockMatrixR(x )
226- } # END AS.SPARSEBLOCKMATRIXR.MATRIX
227-
228208# ------------------------------------------------------------------------------#
229209# as.list.SparseBlockMatrixR
230210# Convert FROM SparseBlockMatrixR TO list
@@ -261,10 +241,11 @@ as.matrix.SparseBlockMatrixR <- function(x){
261241} # END AS.MATRIX.SPARSEBLOCKMATRIXR
262242
263243# ------------------------------------------------------------------------------#
264- # as. edgeList.SparseBlockMatrixR
244+ # edgeList.SparseBlockMatrixR
265245# Coerce SBM to edge list
266246#
267- as.edgeList.SparseBlockMatrixR <- function (x ){
247+ # ' @export
248+ edgeList.SparseBlockMatrixR <- function (x ){
268249 #
269250 # We have to be careful in obtaining the edge list of a SparseBlockMatrixR object:
270251 # It is NOT the same as the rows slot since some of these components may have
@@ -278,12 +259,13 @@ as.edgeList.SparseBlockMatrixR <- function(x){
278259 el <- mapply(function (x , y ){ y [which(abs(x ) > sparsebnUtils :: zero_threshold())]}, x $ vals , x $ rows )
279260
280261 sparsebnUtils :: edgeList(el )
281- } # AS. EDGELIST.SPARSEBLOCKMATRIXR
262+ } # EDGELIST.SPARSEBLOCKMATRIXR
282263
283264# ------------------------------------------------------------------------------#
284265# sparse.SparseBlockMatrixR
285266# 2016-01-22: Migrated to this file from s3-sparse.R
286267#
268+ # ' @export
287269sparse.SparseBlockMatrixR <- function (x , index = " R" , ... ){
288270
289271 if (index != " R" && index != " C" ) stop(" Invalid entry for index parameter: Must be either 'R' or 'C'!" )
@@ -321,16 +303,16 @@ sparse.SparseBlockMatrixR <- function(x, index = "R", ...){
321303 }
322304} # END SPARSE.SPARSEBLOCKMATRIXR
323305
324- # ------------------------------------------------------------------------------#
325- # as.sparse.SparseBlockMatrixR
326- # Convert FROM SparseBlockMatrixR TO sparse
327- # By default, return the object using R indexing. If desired, the method can return C-style indexing by setting
328- # index = "C".
329- # 2016-01-22: Migrated to this file from s3-sparse.R
330- #
331- as.sparse.SparseBlockMatrixR <- function (x , index = " R" , ... ){
332- sparse.SparseBlockMatrixR(x , index )
333- } # END AS.SPARSE.SPARSEBLOCKMATRIXR
306+ # # ------------------------------------------------------------------------------#
307+ # # as.sparse.SparseBlockMatrixR
308+ # # Convert FROM SparseBlockMatrixR TO sparse
309+ # # By default, return the object using R indexing. If desired, the method can return C-style indexing by setting
310+ # # index = "C".
311+ # # 2016-01-22: Migrated to this file from s3-sparse.R
312+ # #
313+ # as.sparse.SparseBlockMatrixR <- function(x, index = "R", ...){
314+ # sparse.SparseBlockMatrixR(x, index)
315+ # } # END AS.SPARSE.SPARSEBLOCKMATRIXR
334316
335317# to_graphNEL.SparseBlockMatrixR
336318# Convert SBM object to graphNEL object
@@ -347,7 +329,7 @@ to_graphNEL.SparseBlockMatrixR <- function(x){
347329} # END TO_GRAPHNEL.SPARSEBLOCKMATRIXR
348330
349331get.adjacency.matrix.SparseBlockMatrixR <- function (x ){
350- sparsebnUtils :: get.adjacency.matrix(as.edgeList.SparseBlockMatrixR (x ))
332+ sparsebnUtils :: get.adjacency.matrix(as.edgeList(x ))
351333} # END GET.ADJACENCY.MATRIX.SPARSEBLOCKMATRIXR
352334
353335num.nodes.SparseBlockMatrixR <- function (x ){
@@ -357,7 +339,7 @@ num.nodes.SparseBlockMatrixR <- function(x){
357339
358340num.edges.SparseBlockMatrixR <- function (x ){
359341 # ## The number of nodes should be exactly the same as the length of the rows list
360- sparsebnUtils :: num.edges(as.edgeList.SparseBlockMatrixR (x ))
342+ sparsebnUtils :: num.edges(as.edgeList(x ))
361343} # END NUM.EDGES.SPARSEBLOCKMATRIXR
362344
363345# This function is (so far) only used in unit tests
0 commit comments