Skip to content

nodes.symDMatrix #5

Description

@gdlc

It may be good to have a nodes (or perhaps blocks) method for symDMatrix()--a template is given below.

With this we could also generate a new interface for getG which uses task, nBlocks and task, as opposed to i and i2.

Gustavo

nodes.symDMatrix<-function(nBlocks,n){
     chunkSize=ceiling(n/nBlocks)
     nTasks=nBlocks*(nBlocks+1)/2
     INDEX=matrix(nrow=nTasks,ncol=7,NA)
     colnames(INDEX)=c('task','rowBlock','colBlock','rowIni','rowEnd','colIni','colEnd')
     INDEX[,1]=1:nTasks
     counter=0
     for(i in 1:nBlocks){
          for(j in i:nBlocks){

               counter=counter+1
               INDEX[counter,2]=i
               INDEX[counter,3]=j

               INDEX[counter,4]=(i-1)*chunkSize+1
               INDEX[counter,5]=min(n,INDEX[counter,4]+chunkSize-1)

               INDEX[counter,6]=(j-1)*chunkSize+1
               INDEX[counter,7]=min(n,INDEX[counter,6]+chunkSize-1)
           }
      }
    return(INDEX)

 }
 nodes.symDMatrix(5,21)


# And if we have the task

task=13

nodes.symDMatrix(5,13)[13,]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions