Hello all and Prof. Brian Ripley ,
Sorry about my incautiousness, I use the tips, but is happen same problems.
Below the R code.
rspcplot <- function(file1="dg_01.lab.txt"){
if(is.null(n))
stop("You need first run the function cluster")
file<-"dg_01.lab.txt"
aux<-file1
file1<-pmatch(file1,file)
if(is.na(file1)){
matrix=loadMatrix(file,n)
}
else{
matrix=loadMatrix(aux,n)
}
matrixc<-correct(matrix)
#merge2(matrixc)
nrow=nrow(matrixc)
ncol=ncol(matrixc)
ntemp=getTemp()
out <- .C("merge2",matrixc,nrow, ncol,ntemp,outMerge=as.integer
(0),outHeight=as.integer(0),PACKAGE="rspc")
##
Below the C code.
##
void merge2(int *nmat,int nrow,int ncol, int *ntemp,int ntam, int *out, int
*height){
int row,col,*temp,i,j,k,n3,tam,x,aux2,n1;
row = nrow;
col = ncol;
int *temp1,*temp2,*temp3,*temp4;
temp1 = (int*)Calloc(col,int);
printf("OK1 \n");
temp2 = (int*)Calloc(col,int);
printf("OK2 \n");
temp3 = (int *)Calloc(col,int);
printf("OK3 \n");
temp4 = (int *)Calloc(col,int);
if(temp4 == NULL){
printf("\n\n No Memory4!");
exit(1);
}
printf("OK4\n");
int *cvector;
cvector = (int *)Calloc(col,int);
if(cvector == NULL){
printf("\n\n No Memory5!");
exit(1);
}
printf("OK5\n");
tam=ntam;
###
Output of Work Space:
> rspcplot()
Read 525 items
Read 101 items
OK1
OK2
OK3
OK4
Error in rspcplot() : Calloc could not allocate (145869080 of 4) memory
>
Using the Ruspini data, the values of variables col = 2 and row = 75. I was
thinking that the number of pointers and space of memory are too big.
Thanks All !
On 12/29/05, Prof Brian Ripley <[EMAIL PROTECTED]> wrote:
>
> Rather than trying to reinvent the wheel, why not make use of the
> functions documented in Writing R Extensions, especially Calloc/Free?
>
> And definitely do not call exit() from code linked into R: it is
> antisocial behaviour to terminate your host's process.
>
> Your example is incomplete, and for some values of 'col' you will run out
> of memory. (It is also not legal C as written, since you mix code and
> declarations.)
>
> On Thu, 29 Dec 2005, Marcelo Damasceno wrote:
>
> > Hi all,
> >
> > I have a C code in Linux, it has 7 pointers and compile e run OK, but
> when I
> > run in R happens problems with calloc function, it returns NULL.
> > ###
> >> int *temp1,*temp2,*temp3,*temp4;
> >
> > temp1 = (int *)calloc(col,sizeof(int));
> > if(temp1 == NULL){
> > printf("\n\n No Memory1!");
> > exit(1);
> > }
> >
> > temp2 = (int *)calloc(col,sizeof(int));
> > if(temp2 == NULL){
> >>printf("\n\n No Memory2!");
> >>exit(1);
> >}
> >
> >temp3 = (int *)calloc(col,sizeof(int));
> >if(temp3 == NULL){
> >>printf("\n\n No Memory3!");
> >>exit(1);
> >}
> >
> >temp4 = (int *)calloc(col,sizeof(int));
> >if(temp4 == NULL){
> >printf("\n\n No Memory4!");
> >exit(1);
> >}
> >
> >int *cvector;
> >cvector = (int *)calloc(col,sizeof(int));
> >if(cvector == NULL){
> >printf("\n\n No Memory5!");
> >exit(1);
> >}
> >
> >tam=ntam;
> >
> >int **matrix;
> >matrix=(int**)calloc(row,sizeof(int*));
> >if(matrix == NULL){
> >printf("\n\n No Memory6!");
> >exit(1);
> >}
> >
> >temp=(int*)calloc(tam,sizeof(int));
> >if(temp == NULL){
> >printf("\n\n No Memory7!");
> >exit(1);
> >}
> >
> >iia = (int *)calloc(row-1,sizeof(int));
> >if(iia == NULL){
> >printf("\n\n No Memory8!");
> >exit(1);
> >}
> >
> >iib = (int *)calloc(row-1,sizeof(int));
> >if(iib == NULL){
> >printf("\n\n No Memory9!");
> >exit(1);
> >}
> >
> > In output !
> >> No Memory5!
> >> [EMAIL PROTECTED] home] $
> >
> > What's wrong?
> > Th