Skip to content
Prev 258145 / 398502 Next

sub-matrix block size

On Apr 27, 2011, at 12:07 AM, Dennis Murphy wrote:

            
If we are in the stage of providing potentially useful but incomplete  
ideas, this would be my notion. Use the row and col functions with "["  
to locate non-zero elements in the diagonal and subdiagonal:

Diagonal:  (My matrix was named `mm`)
 > mm[row(mm)==col(mm)]
  [1] 1 1 1 0 1 1 1 1 1 1 0
First subdiagonal:
 > mm[row(mm)==col(mm)+1]
  [1] 0 0 0 0 0 0 0 0 0 0
First superdiagonal:
 > mm[row(mm)==col(mm)-1]
  [1] 1 0 0 0 1 1 0 1 1 0

Perhaps a combination of the two? It seems as though the rowSums/ 
colSums approach might be insensitive to whether triangular blocks  
were sub or super diagonal:

 > rowSums(mm) + colSums(mm) - 1
  [1]  2  2  1 -1  3  3  3  3  3  3 -1
 > mm[1,2]<-0
 > mm[2,1]<-1
 > rowSums(mm) + colSums(mm) - 1
  [1]  2  2  1 -1  3  3  3  3  3  3 -1
David Winsemius, MD
West Hartford, CT