Hi

My code is as following:

#include <R.h>
#include <Rinternals.h>

//* the Projector part  *//
void Projector(double *L, int *dimL, double *G, int *dimG, double *W, int
*dimW, int *xymod, int *dimxy, double *modif, int *dimif, double *Lsum)
{ ...}

//* the interface part *//
#define getDim(A) INTEGER(coerceVector(getAttrib(A,R_DimSymbol), INTSXP))

SEXP Projector5(SEXP L, SEXP G, SEXP W, SEXP xymod, SEXP modif)
{
    //* digest SEXPs from R *//
    int *dimL, *dimG, *dimW, *dimxy, *dimif;
    double *lptr, *gptr, *wptr, *ifptr;
    int *xyptr;
    dimL=getDim(L);
    PROTECT(L=coerceVector(L, REALSXP));
    lptr=REAL(L);
    dimG=getDim(G);
    PROTECT(G=coerceVector(G, REALSXP));
    gptr=REAL(G);
    dimW=getDim(W);
    PROTECT(W=coerceVector(W, REALSXP));
    wptr=REAL(W);
    dimxy=getDim(xymod);
    PROTECT(xymod=coerceVector(xymod, INTSXP));
    xyptr=INTEGER(xymod);
    dimif=getDim(modif);
    PROTECT(modif=coerceVector(modif, REALSXP));
    ifptr=REAL(modif);

    //* create SEXP to hold the answer *//
    SEXP ans;
    double *ansptr;
    PROTECT(ans=allocMatrix(REALSXP, dimG[1], dimG[0]));
    ansptr=REAL(ans);

    //* calculate the result *//
    Projector(lptr, dimL, gptr, dimG, wptr, dimW, xyptr, dimxy, ifptr,
dimif, ansptr);

    //* wrap up and return the result to R *//
    UNPROTECT(6);
    return(ans);
}

The function "Projector" works well and actually the interface with .C
works OK.
The question is that I can compile it in R, but ".Call" returns different
result each time with same inputs. Could anybody tell me why? Thanks!

Regards
Shangru

-- 
Department of Mathematics,
National University of Singapore,
Blk S17, 10 Lower Kent Ridge Road,
119076





-- 
Department of Mathematics,
National University of Singapore,
Blk S17, 10 Lower Kent Ridge Road,
119076

	[[alternative HTML version deleted]]


