-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Potential bug with diag #216
Comments
Yeah, I think this is a duplicate of #108, but this has more info. So I'll close that one. Thanks! |
I have a branch on my fork which fixes this. I insert:
into the |
Nice, thanks! I'm hoping to cover all of the different ways of constructing a diagonal matrix with diag, which, from memory, also includes creating non-square diagonal matrices. When I get to that I'll try to include your fork though. Could you please point me to it? |
My fork is Voltemand/greta/issue216 (I have now stopped naming my branches after issues as I forget what they are all about!) I basically insert the following code into # try to construct a greta array if either nrow or ncol are specified
if (!missing(nrow) | !missing(ncol)) {
if (dim[2] != 1) {
stop("'nrow' or 'ncol' cannot be specified when 'x' is not a vector",
" like greta_array")
} else {
vec <- as.vector(get_node(x)$value())
out <- diag(vec, nrow, ncol)
return(as.greta_array(out))
}
} I think (hope?) that the use of All the best! |
Great, thanks! I'll write up some tests to cover all the documented behaviours and give this a go. |
diag function does not seem to be working with greta arrays, e.g.:
N=100
xx=as_data(1)
dim(diag(xx,N,N))
produces
[1] 1 1
but should be
[1] 100 100
The text was updated successfully, but these errors were encountered: