Matrix-exponentiation operator: Difference between revisions
Content added Content deleted
ReeceGoding (talk | contribs) m (→Infix operator: Improved syntax.) |
ReeceGoding (talk | contribs) m (→Infix operator) |
||
Line 2,889: | Line 2,889: | ||
if(n==0) diag(nrow = nrow(mat))#Identity matrix of mat's dimensions |
if(n==0) diag(nrow = nrow(mat))#Identity matrix of mat's dimensions |
||
else if(n == 1) mat |
else if(n == 1) mat |
||
else if(n > 1) mat %*% (mat%^%(n - 1)) |
else if(n > 1) mat %*% (mat %^% (n - 1)) |
||
else stop("Invalid n.") |
else stop("Invalid n.") |
||
} |
} |