0

This function is pretty useful and is supported in Matlab and Numpy, but I didn't find this function in DolphinDB help page. Is there any equivalent function in DolphinDB?

Ju Piece
  • 249
  • 3
  • 9

1 Answers1

1
def repmatrix(m, rowRep, colRep){
    rows = m.rows()
    cols = m.columns()
    newM = matrix(m.type(), rows*rowRep, cols*colRep)
    for(i in 0 : rowRep){
        for(j in 0 : colRep)
            newM[(i*rows) : ((i+1)*rows), (j*cols) : ((j+1)*cols)] = m
    }
    return newM
}

a = matrix(1 2, 3 4)
m = repmatrix(a, 2, 3)
Davis Zhou
  • 353
  • 4
  • 6