Published on *OpenMx* (http://openmx.psyc.virginia.edu)

By *tbates*

Created *09/21/2013 - 07:08*

Sat, 09/21/2013 - 07:08 — tbates [1]

I'd really like diag implemented in Openmx - just so that the same code works inside and outside of OpenMx and to ease the learning transition. But, If we aren’t going to support the standard r implementation of diag(), can we implement

diag <- function(x=1, nrow, ncol) { message("We’re a bit worried that diag can be ambiguous, so we’ve broken it into multiple new functions...") # then either say stop("You need to choose among list up our replacement functions to handle everything that diag() does...") # or, more helpfully, tell people how to implement the diag functionality that they have requested if(is.matrix(x)){ message("You input x as a matrix: to get the diagonal of a matrix call WHATEVER WE HAVE DONE") } else if(x==1 & !missing(nrow))){ message("you asked for an nrow identity amtrix: please use WHATEVER WE HAVE DONE...") } else if(length(x) == 1 & missing(nrow) & missing(ncol))){ message("you asked for an ", x, " row Identity matrix: please use WHATEVER WE HAVE DONE...") } else if(length(x) > 1) { message("you asked for an ", x, " row Identity matrix: please use WHATEVER WE HAVE DONE...") } if !missing(nrow) | ! missing(ncol))){ message("you asked for an ", x, " row Identity matrix: please use WHATEVER WE HAVE DONE...") } } x = matrix(1:9,3) diag(x)

**Links:**

[1] http://openmx.psyc.virginia.edu/users/tbates

[2] http://openmx.psyc.virginia.edu/thread/1001

[3] http://openmx.psyc.virginia.edu/thread/2014

[4] http://openmx.psyc.virginia.edu/forums/openmx-developer-forums/new-feature-proposals