A way to assign the diagonals of a matrix that can handle input having no dimensions. Ordinarily, x is square matrix and newdiag is a vector equal in length to x's diagonal.
A new x is returned having the newdiag on its diagonal. In that usage, it matches the assign option for R's function diag.
This improves diag by handling x with no dimensions, ie a scalar, or just one dimension. Then newdiag is simply returned.
1 | AssignDiag(x, newdiag)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.