diag(m)<-num function call added @vjovanov