Displaying 4 results from an estimated 4 matches for "set_dim".
Did you mean:
net_dim
2023 Oct 31
1
dim<-() changed in R-devel; no longer removing "dimnames" when doing dim(x) <- dim(x)
Hi Martin, Henrik,
I actually like this change.
Makes a lot of sense IMO that dim(x) <- dim(x) be a no-op, or, more
generally, that foo(x) <- foo(x) be a no-op for any setter/getter combo.
FWIW S4Arrays::set_dim() does that too. It also preserves the dimnames
if the right value is only adding or dropping outermost (ineffective)
dimensions:
??? > x <- array(1:6, dim=c(2,3,1), dimnames=list(c("A", "B"),
c("x","y", "z"), "T"))
??? > S4...
2023 Oct 30
2
dim<-() changed in R-devel; no longer removing "dimnames" when doing dim(x) <- dim(x)
>>>>> Henrik Bengtsson
>>>>> on Sun, 29 Oct 2023 10:42:19 -0700 writes:
> Hello,
> the fix of PR18612
> (https://bugs.r-project.org/show_bug.cgi?id=18612) in
> r85380
> (https://github.com/wch/r-source/commit/2653cc6203fce4c48874111c75bbccac3ac4e803)
> caused a change in `dim<-()`. Specifically, in the past,
2009 Mar 27
0
imporving performance of slicing on matrices and S4 their derivatives
...;/* test performance of getting A COPY of @.Data, keeping
dimnames */
int nrow = Rf_nrows(m);
int ncol = Rf_ncols(m);
SEXP res, dim;
PROTECT(res = allocVector(REALSXP, nrow*ncol));
PROTECT(dim = allocVector(INTSXP, 2));
INTEGER(dim)[0] = nrow;
INTEGER(dim)[1] = ncol;
SET_DIM(res, dim);
if (GET_DIMNAMES(m)!= R_NilValue)
SET_DIMNAMES(res, Rf_duplicate(GET_DIMNAMES(m)));
if (ncol>0 && nrow>0)
memcpy(REAL(res), REAL(m), nrow*ncol*sizeof(double));
UNPROTECT(2);
return res;"
mcols = cfunction(signature(m="matrix")...
2000 Apr 01
1
Bug ? mine or ? in R core
...maximum && j>maximum)
break;
}
/* transpose it */
DBG(1,"trimming");
SET_LENGTH(data,j*NCOLS); /* trim down buffer*/
INTEGER(stat)[0]=status;
PROTECT(dim=NEW_INTEGER(2));
INTEGER(dim)[1]=NCOLS;
INTEGER(dim)[0]=length(data)/NCOLS;
DBG(2,"writing dim to data");
SET_DIM(data,dim);
DBG(2,"writing to ans 0");
VECTOR(ans)[0]=data;
DBG(2,"writing to ans 1");
VECTOR(ans)[1]=stat;
DBG(3,"protecting names");
PROTECT(names=NEW_CHARACTER(2));
DBG(2,"writing to names 0");
STRING(names)[0]=COPY_TO_USER...