search for: ncx

Displaying 20 results from an estimated 24 matches for "ncx".

Did you mean: ecx
2013 Apr 25
1
lsfit: Error in formatting error message
...in the formatting of the error message (note that this was not happening in 2.15.3): > nobs <- 5; nvar <- 6; lsfit(matrix(runif(nobs*nvar), ncol=nvar), runif(nobs), intercept=FALSE) Error in sprintf(ngettext(nry, "%d response", "%d responses"), ", ", ngettext(ncx, : invalid format '%d'; use format %s for character objects > traceback() 3: sprintf(ngettext(nry, "%d response", "%d responses"), ", ", ngettext(ncx, "but only %d variable", "but only %d variables"), nry, ncx) 2: stop(sprintf(n...
2019 Apr 05
2
patch to improve matrix conformability error message
...etions(-) diff --git a/src/main/array.c b/src/main/array.c index 4b95e33..cedf627 100644 --- a/src/main/array.c +++ b/src/main/array.c @@ -1350,15 +1350,18 @@ SEXP attribute_hidden do_matprod(SEXP call, SEXP op, SEXP args, SEXP rho) if (PRIMVAL(op) == 0) { /* primitive, so use call */ if (ncx != nry) - errorcall(call, _("non-conformable arguments")); + errorcall(call, _("non-conformable arguments of dimension (%d, %d) and (%d, %d)"), + nrx, ncx, nry, ncy); } else if (PRIMVAL(op) == 1) { if (nrx != nry) - error(_("non-conformable argume...
2005 Oct 12
1
Using matprod from array.c
...unction from array.c in my own C routine. I tried the following as a test /* my_matprod.c */ # include <Rinternals.h> /* for REAL, SEXP etc */ # include <R_ext/Applic.h> /* array.c says need for dgemm */ /* following copied from array.c */ static void matprod(double *x, int nrx, int ncx, double *y, int nry, int ncy, double *z) { char *transa = "N", *transb = "N"; int i, j, k; double one = 1.0, zero = 0.0, sum; Rboolean have_na = FALSE; if (nrx > 0 && ncx > 0 && nry > 0 && ncy > 0) { /* Don't t...
2006 Aug 03
1
question about dll crashing R
...ect answer. If I put a loop inside foobar and run the main code routine more than 100 times, it crashes R. Or if I call .Call("foobar"....) seperately more than two tims it crashes R. For the most part I am doing matirx multiplies using EXP matrixprod (SEXP x , SEXP y ) { int nrx , ncx , nry , ncy , mode; SEXP xdims , ydims , ans ; char *transa = "N" , *transb = "N" ; double one = 1.0 , zero = 0.0 ; xdims = getAttrib (x , R_DimSymbol ) ; ydims = getAttrib (y , R_DimSymbol ) ; mode = REALSXP; nrx = INTEGER( xdims ) [ 0 ] ; ncx = INTEGER( xdims ) [ 1 ] ; nry = I...
2010 Aug 23
1
Internal state indicating if a data object has NAs/no NAs/not sure (Was: Re: Speeding up matrix multiplies)
...ge any R configuration options regarding compilation. > > Below is my modified version of the matprod function in src/main/array.c. > > ? Radford Neal > > ------------------------------------------------------------------------ > > static void matprod(double *x, int nrx, int ncx, > ? ? ? ? ? ? ? ? ? ?double *y, int nry, int ncy, double *z) > { > ? ?char *transa = "N", *transb = "N"; > ? ?int i, ?j, k; > ? ?double one = 1.0, zero = 0.0; > ? ?LDOUBLE sum; > ? ?Rboolean do_it_here; > > ? ?/* NOTE: ncx must be equal to nry. */ &gt...
2019 Apr 30
0
patch to improve matrix conformability error message
...main/array.c b/src/main/array.c >index 4b95e33..cedf627 100644 >--- a/src/main/array.c >+++ b/src/main/array.c >@@ -1350,15 +1350,18 @@ SEXP attribute_hidden do_matprod(SEXP call, SEXP op, SEXP args, SEXP rho) > if (PRIMVAL(op) == 0) { > /* primitive, so use call */ > if (ncx != nry) >- errorcall(call, _("non-conformable arguments")); >+ errorcall(call, _("non-conformable arguments of dimension (%d, %d) and (%d, %d)"), >+ nrx, ncx, nry, ncy); > } > else if (PRIMVAL(op) == 1) { > if (nrx != nry) >- error(_(...
2006 Mar 09
0
When calling external C-function repeatedly I get different results; can't figure out why..
...by the R-source code, I've created the following functions (I am *new* to writing external C-functions, so feel free to laugh at my code - or, perhaps, suggest changes): #include <Rinternals.h> #include <R_ext/Applic.h> /* for dgemm */ static void matprod(double *x, int nrx, int ncx, double *y, int nry, int ncy, double *z) { char *transa = "N", *transb = "N"; double one = 1.0, zero = 0.0; F77_CALL(dgemm)(transa, transb, &nrx, &ncy, &ncx, &one, x, &nrx, y, &nry, &zero, z, &nrx); } SEXP trProd2(SEXP x,...
2006 Mar 09
0
When calling external C-function repeatedly I get differentresults; can't figure out why..
...ed the following > functions (I am *new* to writing external C-functions, so > feel free to laugh at my code - or, perhaps, suggest changes): > > #include <Rinternals.h> > #include <R_ext/Applic.h> /* for dgemm */ > > static void matprod(double *x, int nrx, int ncx, > double *y, int nry, int ncy, double *z) { > char *transa = "N", *transb = "N"; > double one = 1.0, zero = 0.0; > F77_CALL(dgemm)(transa, transb, &nrx, &ncy, &ncx, &one, > x, &nrx, y, &nry, &zero, z, &nrx);...
2010 Aug 23
1
Speeding up matrix multiplies
...4.2.4-1ubuntu4) I didn't change any R configuration options regarding compilation. Below is my modified version of the matprod function in src/main/array.c. Radford Neal ------------------------------------------------------------------------ static void matprod(double *x, int nrx, int ncx, double *y, int nry, int ncy, double *z) { char *transa = "N", *transb = "N"; int i, j, k; double one = 1.0, zero = 0.0; LDOUBLE sum; Rboolean do_it_here; /* NOTE: ncx must be equal to nry. */ if (nrx==1 && ncy==1) { /* Do do...
2004 Nov 02
0
how to call function in ../src/main
...result: $temp \n"; } test(); It works fine. But it looks not for calling functions in R/R-1.9.1/src/main We want to correlation only, so we copy cov.c to cor.c where use cor ( int n, double *x, double *y, double *ans ) { Rboolean cor, kendall, pair, na_fail, sd_0; int ansmat, method, ncx, ncy; /* compute correlations if PRIMVAL(op) == 0, covariances if PRIMVAL(op) != 0 */ cor = 0; ansmat = 0; ncx = 1; ncy = 1; pair = TRUE; kendall = FALSE; cov_pairwise2(n, ncx, ncy, x, y, ans, &sd_0, cor, kendall); } replace SE...
2006 Feb 22
2
How can I see how %*% is implemented?
I would like to see how the matrix multiplication operator %*% is implemented (because I want to see which external Fortran/C routines are used). How can I do so? Best S??ren
2017 Jan 07
2
accelerating matrix multiply
...e 58.351572s ??? user?? system? elapsed 2710.154?? 20.999?? 58.398 The NaN checking code is not being vectorized because of the early exit when NaN is detected: /* Don't trust the BLAS to handle NA/NaNs correctly: PR#4582 * The test is only O(n) here. */ for (R_xlen_t i = 0; i < NRX*ncx; i++) if (ISNAN(x[i])) {have_na = TRUE; break;} if (!have_na) for (R_xlen_t i = 0; i < NRY*ncy; i++) if (ISNAN(y[i])) {have_na = TRUE; break;} I tried deleting the 'break'. By inspecting the asm code, I verified that the loop was not being vectorized before, but now is vect...
2017 Oct 09
1
Using response variable in interaction as explanatory variable in glm crashes R
...ws(contrast), ncols(contrast), INTEGER(var_i)+adj); then in firstfactor(), we see the segfault (when running R with '-d gdb') : > model.matrix(dob_mon ~ dob_day*dob_mon, data = tab) Program received signal SIGSEGV, Segmentation fault. 0x00007fffeafa76b5 in firstfactor (ncx=0, v=0x5c3b37c, ncc=1, nrc=2, c=0x5c90008, nrx=8, x=0x5cbf150) at ../../../../../R/src/library/stats/src/model.c:252 252 else xj[i] = cj[v[i]-1]; Missing separate debuginfos, ................. (gdb) list 247 for (int j = 0; j < ncc; j++) { 248 xj = &x[j * (R...
1997 Nov 28
3
R-alpha: Problems with dimnames and names
.../src/main/cov.c R-0.50-a4.patched/src/main/cov.c --- R-0.50-a4/src/main/cov.c Sun Nov 24 23:43:05 1996 +++ R-0.50-a4.patched/src/main/cov.c Fri Nov 28 11:21:23 1997 @@ -390,7 +390,7 @@ } if(isNull(y)) { x = getAttrib(x, R_DimNamesSymbol); - if(!isNull(x) && !isNull(CADR(x))) { + if(ncx > 1 && !isNull(x) && !isNull(CADR(x))) { PROTECT(ind = allocList(2)); CAR(ind) = CADR(x); CADR(ind) = CADR(x); @@ -401,7 +401,7 @@ else { x = getAttrib(x, R_DimNamesSymbol); y = getAttrib(y, R_DimNamesSymbol); - if((!isNull(x) && !isNull(CADR(x))) ||...
2012 Jan 15
0
patching ?merge to allow the user to keep the order of one of the two data.frame objects merged
...m <- .Internal(merge(xinds, yinds, all.x, all.y)) else m <- list(xi = integer(), yi = integer(), x.alone = seq_len(nx), y.alone = seq_len(ny)) nm <- nm.x <- names(x)[-by.x] nm.by <- names(x)[by.x] nm.y <- names(y)[-by.y] ncx <- ncol(x) if (all.x) all.x <- (nxx <- length(m$x.alone)) > 0L if (all.y) all.y <- (nyy <- length(m$y.alone)) > 0L lxy <- length(m$xi) has.common.nms <- any(cnm <- nm.x %in% nm.y) if (has.common.nms)...
2017 Jan 11
2
accelerating matrix multiply
...2710.154 20.999 58.398 > > The NaN checking code is not being vectorized because of the early > exit when NaN is detected: > > /* Don't trust the BLAS to handle NA/NaNs correctly: PR#4582 > * The test is only O(n) here. > */ > for (R_xlen_t i = 0; i < NRX*ncx; i++) > if (ISNAN(x[i])) {have_na = TRUE; break;} > if (!have_na) > for (R_xlen_t i = 0; i < NRY*ncy; i++) > if (ISNAN(y[i])) {have_na = TRUE; break;} > > I tried deleting the 'break'. By inspecting the asm code, I verified > that the loop was not bein...
2017 Jan 10
0
accelerating matrix multiply
...2710.154 20.999 58.398 > > The NaN checking code is not being vectorized because of the > early exit when NaN is detected: > > /* Don't trust the BLAS to handle NA/NaNs correctly: PR#4582 > * The test is only O(n) here. > */ > for (R_xlen_t i = 0; i < NRX*ncx; i++) > if (ISNAN(x[i])) {have_na = TRUE; break;} > if (!have_na) > for (R_xlen_t i = 0; i < NRY*ncy; i++) > if (ISNAN(y[i])) {have_na = TRUE; break;} > > I tried deleting the 'break'. By inspecting the asm code, I > verified that the loop was not being...
2017 Jan 16
1
accelerating matrix multiply
...;> >> The NaN checking code is not being vectorized because of the early >> exit when NaN is detected: >> >> /* Don't trust the BLAS to handle NA/NaNs correctly: PR#4582 >> * The test is only O(n) here. >> */ >> for (R_xlen_t i = 0; i < NRX*ncx; i++) >> if (ISNAN(x[i])) {have_na = TRUE; break;} >> if (!have_na) >> for (R_xlen_t i = 0; i < NRY*ncy; i++) >> if (ISNAN(y[i])) {have_na = TRUE; break;} >> >> I tried deleting the 'break'. By inspecting the asm code, I verified >>...
2017 Jan 16
0
accelerating matrix multiply
...t;> >> The NaN checking code is not being vectorized because of the early >> exit when NaN is detected: >> >> /* Don't trust the BLAS to handle NA/NaNs correctly: PR#4582 >> * The test is only O(n) here. >> */ >> for (R_xlen_t i = 0; i < NRX*ncx; i++) >> if (ISNAN(x[i])) {have_na = TRUE; break;} >> if (!have_na) >> for (R_xlen_t i = 0; i < NRY*ncy; i++) >> if (ISNAN(y[i])) {have_na = TRUE; break;} >> >> I tried deleting the 'break'. By inspecting the asm code, I verified >>...
2017 Oct 06
2
Using response variable in interaction as explanatory variable in glm crashes R
The following code crashes R (I know I shouldn't try to estimate such a model; this was a bug in some code of mine). I also tried with R-devel; same result. tab <- structure(list(dob_day = c(FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE), dob_mon = c(FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE), dob_year = c(FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE), n =