Displaying 11 results from an estimated 11 matches for "get_dim".
Did you mean:
net_dim
2012 Dec 06
1
Use .Call interface
...OTECT(W=AS_NUMERIC(W));nprot++;
PROTECT(xymod=AS_INTEGER(xymod));nprot++;
PROTECT(modif=AS_NUMERIC(modif));nprot++;
double *lptr; lptr=REAL(L);
double *gptr; gptr=REAL(G);
double *wptr; wptr=REAL(W);
int *xyptr; xyptr=INTEGER(xymod);
double *ifptr; ifptr=REAL(modif);
int *dimL; dimL=INTEGER(GET_DIM(L));
int *dimG; dimG=INTEGER(GET_DIM(G));
int *dimW; dimW=INTEGER(GET_DIM(W));
int *dimxy; dimxy=INTEGER(GET_DIM(xymod));
int *dimif; dimif=INTEGER(GET_DIM(modif));
SEXP ans;
PROTECT(ans=allocMatrix(REALSXP, dimG[0], dimL[1])); nprot++;
double *ansptr; ansptr=REAL(ans);
Projector(lptr, dimL...
2004 Jun 22
3
[Q] GET_DIM() crash on Windows only
...R.h>
#include <Rdefines.h>
#include <R_ext/PrtUtil.h>
int GetMatrixDimen(SEXP vntX, int *nrow, int *ncol)
{
SEXP vntXdim;
int nX;
#ifdef DEBUG_GETDIM
REprintf("In GetMatrixDimen()...\n");
#endif
/**** Code crashes here on Windoze ******/
PROTECT(vntXdim = GET_DIM(vntX));
#ifdef DEBUG_GETDIM
REprintf("\tgot dimension object\n");
#endif
nX = GET_LENGTH(vntXdim);
#ifdef DEBUG_GETDIM
REprintf("\tgot length from dimension object\n");
#endif
if (nX == 2)
{
int *piXdim = INTEGER_POINTER(vntXdim);
*nrow = p...
2004 Jun 24
0
[SOLVED] GET_DIM() crash on Windows only
Paul Roebuck wrote:
>I have the following contrived code in package format.
>On Solaris and Mac OS X, code runs just fine. On Windows,
>it crashes the R environment with the "Send Bug Report"
>dialog. I tried R 1.8.1 (Win2K) and R 1.9 (WinXP) binaries
>with the same result. PCs otherwise appear properly
>configured for creating R packages. Anything blatantly
>wrong?
2007 May 22
2
inline C/C++ in R: question and suggestion
...uld just work by copy-pasting.
Best and thanks in advance,
Oleg
code <- character(17)
code[1] <- " SEXP res;"
code[2] <- " int nprotect = 0, nx, ny, nz, x, y;"
code[3] <- " PROTECT(res = Rf_duplicate(a)); nprotect++;"
code[4] <- " nx = INTEGER(GET_DIM(a))[0];"
code[5] <- " ny = INTEGER(GET_DIM(a))[1];"
code[6] <- " nz = INTEGER(GET_DIM(a))[2];"
code[7] <- " double sigma2 = REAL(s)[0] * REAL(s)[0], d2 ;"
code[8] <- " double cx = REAL(centre)[0], cy = REAL(centre)[1], *data,
*rdata;"
cod...
2007 Feb 13
2
anyone has C++ STL classes stability issue if used with R
...al) {};
};
bool operator < (const Pixel & a, const Pixel & b) {
return a.intens < b.intens;
};
typedef priority_queue<Pixel> PixelPrQueue;
SEXP
lib_filterInvWS (SEXP x) {
SEXP res;
int i, j, index;
double val;
PixelPrQueue pq;
int nx = INTEGER ( GET_DIM(x) )[0];
int ny = INTEGER ( GET_DIM(x) )[1];
int nz = INTEGER ( GET_DIM(x) )[2];
int nprotect = 0;
PROTECT ( res = Rf_duplicate(x) );
nprotect++;
// Pixel px;
for (int im = 0; im < nz; im++ ) {
double * src = &( REAL(x)[ im * nx * ny ] );...
2007 Oct 05
1
Sklyar's inline package: how to return a list?
...-----------------------------------------------------------------------------------------------------------------------
library( inline )
c.code <- "
SEXP res;
int nprotect = 0, nx, ny, x, y;
double *dptr, *resptr, sum;
PROTECT(res = Rf_duplicate(a)); nprotect++;
nx = INTEGER(GET_DIM(a))[0];
ny = INTEGER(GET_DIM(a))[1];
dptr = REAL(a);
resptr = REAL( res );
sum = 0.0;
for (x = 0; x < nx; x++)
for (y = 0; y < ny; y++)
{
resptr[ x + y*nx ] = -dptr[ x + y*nx ];
sum += -dptr[ x + y*nx ];
}
UNPROTECT(nprotect);
return res;
"
funx &l...
2003 May 21
2
moving onto returning a data.frame?
...ment and returns a data.frame (post-hocus-pocus).
Here's my function so far...
SEXP testfunction3(
SEXP m_in )
{
int *mdims, n, p, i;
double *mm;
SEXP m_out;
SEXP nms;
if( !isMatrix( m_in ) )
{
error("m_in must be a matrix");
}
mdims = INTEGER( GET_DIM( m_in ) );
n = mdims[0];
p = mdims[1];
PROTECT( m_out = NEW_NUMERIC( p ) );
PROTECT( m_in = AS_NUMERIC( m_in ) );
PROTECT( nms = GET_COLNAMES( GET_DIMNAMES( m_in ) ) );
/* here you'll disect the incoming data.frame into the vectors you'll
pass into your simulation code *...
2016 Jan 10
3
coerce SEXP type to C++ matrix class and back
...e:
#include <R.h>
#include <Rdefines.h>
#include <Rinternals.h>
#include <Rmath.h>
#include <R_ext/BLAS.h>
#include <R_ext/Lapack.h>
#include <armadillo>
#define IDX(i,j,dim0) (i) + (j) * (dim0)
extern "C" SEXP Symm(SEXP RA)
{
int m = INTEGER(GET_DIM(RA))[0];
int n = INTEGER(GET_DIM(RA))[1];
double *A;
A = REAL(RA);
arma::mat C(m, n), D(m, n);
for (int i = 0; i < m; i++)
for (int j = 0; j < n; j++)
C[IDX(i, j, m)] = A[IDX(i, j, m)];
D = arma::symmatu(C);
SEXP B = PROTECT(allocMatrix(REALSXP, m, n));
for (int...
2003 Jun 23
3
FW: S4 classes, creating in C
...pdf
e.g.
SEXP La_DGE_dc(SEXP A)
{
SEXP aa = PROTECT(duplicate(A));
SEXP adims, pivot, val;
int m, n, info;
if (!isMatrix(aa) || !isReal(aa)) {
error("A must be a double precision matrix");
}
adims = GET_DIM(aa); m = INTEGER(adims)[0]; n = INTEGER(adims)[1];
pivot = PROTECT(NEW_INTEGER(m < n ? m : n));
F77_CALL(dgetrf)(&m, &n, REAL(aa), &m, INTEGER(pivot), &info);
check_Lapack_error(info, "dtrtrf");
val = PROTECT(NEW_OBJECT(M...
2001 Dec 14
2
colSums in C
Hi, all!
My project today is to write a speedy colSums(), which is a function
available in S-Plus to add the columns of a matrix. Here are 4 ways to do it,
with the time it took (elapsed, best of 3 trials) in both R and S-Plus:
m <- matrix(1, 400, 40000)
x1 <- apply(m, 2, sum) ## R=16.55 S=52.39
x2 <- as.vector(rep(1,nrow(m)) %*% m) ## R= 2.39 S= 8.52
x3 <-
2010 Feb 18
3
R CMD check: OK in LINUX. Crashes in Windows!
Hi,
I have followed the recommended steps for creating a package (rctest). As of
now, my goal is simply to understand how various pieces fit together. The
package includes:
(1) C code with source in sub-directories, compiled to create a static
library.
(a) There is a single C-struct (dns) a simple 'matrix': {int m; int n;
double *d;}
(b) C code to create random matrix of a certain size.