Re: [R] replicating C example from the Extensions Manual problem

2012-03-14 Thread Peter Langfelder
Seems you're missing the required header(s). Can't find the example in
the extensions manual but you probably need

#include 

or

#include 


HTH,

Peter

On Wed, Mar 14, 2012 at 11:03 PM, Erin Hodgess  wrote:
> Dear R People:
>
> Here is something that I am sure is very simple.  I'm just trying to
> re-create the C convolution example in the Extensions manual.  Here is
> the subroutine:
>
> void convolve(double *a, int *na, double *b, int *nb, double *ab)
> {
> R_len_t i, j, nab = *na + *nb - 1;
> for(i = 0; i < nab; i++)
> ab[i] = 0.0;
> for(i = 0; i < *na; i++)
> for(j = 0; j < *nb; j++)
> ab[i + j] += a[i] * b[j];
> }
>
> And here are the results from trying to compile:
>
> erin@ubuntu:~$ R CMD SHLIB convolve.c
> gcc -std=gnu99 -I/usr/share/R/include      -fpic  -O3 -pipe  -g -c
> convolve.c -o convolve.o
> convolve.c: In function ‘convolve’:
> convolve.c:3:1: error: unknown type name ‘R_len_t’
> make: *** [convolve.o] Error 1
>
>
> What is wrong, please?
>
> This is on Ubuntu 11.10 with R-2.14.2.  I'm sure that it's totally goofy.
>
> Thanks,
> Erin
>
>
>
> --
> Erin Hodgess
> Associate Professor
> Department of Computer and Mathematical Sciences
> University of Houston - Downtown
> mailto: erinm.hodg...@gmail.com
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] replicating C example from the Extensions Manual problem

2012-03-14 Thread Jeff Newmiller
Do you really expect is to know how to figure out the error if you don't give 
us the code that the error is pointing at (or the code preceding the error, 
which may be at fault)? Please think before posting.
---
Jeff NewmillerThe .   .  Go Live...
DCN:Basics: ##.#.   ##.#.  Live Go...
  Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/BatteriesO.O#.   #.O#.  with
/Software/Embedded Controllers)   .OO#.   .OO#.  rocks...1k
--- 
Sent from my phone. Please excuse my brevity.

Erin Hodgess  wrote:

>Dear R People:
>
>Here is something that I am sure is very simple.  I'm just trying to
>re-create the C convolution example in the Extensions manual.  Here is
>the subroutine:
>
>void convolve(double *a, int *na, double *b, int *nb, double *ab)
>{
>R_len_t i, j, nab = *na + *nb - 1;
>for(i = 0; i < nab; i++)
>ab[i] = 0.0;
>for(i = 0; i < *na; i++)
>for(j = 0; j < *nb; j++)
>ab[i + j] += a[i] * b[j];
>}
>
>And here are the results from trying to compile:
>
>erin@ubuntu:~$ R CMD SHLIB convolve.c
>gcc -std=gnu99 -I/usr/share/R/include  -fpic  -O3 -pipe  -g -c
>convolve.c -o convolve.o
>convolve.c: In function ‘convolve’:
>convolve.c:3:1: error: unknown type name ‘R_len_t’
>make: *** [convolve.o] Error 1
>
>
>What is wrong, please?
>
>This is on Ubuntu 11.10 with R-2.14.2.  I'm sure that it's totally
>goofy.
>
>Thanks,
>Erin
>
>
>
>-- 
>Erin Hodgess
>Associate Professor
>Department of Computer and Mathematical Sciences
>University of Houston - Downtown
>mailto: erinm.hodg...@gmail.com
>
>__
>R-help@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] replicating C example from the Extensions Manual problem

2012-03-14 Thread Joshua Wiley
Hi Erin,

If you are just starting with including compiled code, I would highly
recommend the Rcpp + inline packages.  I attached a small example of
how it works, but basically you get to inline C++ code in R files.

Cheers,

Josh

P.S. I wrote this snippet awhile ago when I did not know much about
C++ so that code is sloppy, but it demonstrates the point and I am
short on time right now.

On Wed, Mar 14, 2012 at 11:03 PM, Erin Hodgess  wrote:
> Dear R People:
>
> Here is something that I am sure is very simple.  I'm just trying to
> re-create the C convolution example in the Extensions manual.  Here is
> the subroutine:
>
> void convolve(double *a, int *na, double *b, int *nb, double *ab)
> {
> R_len_t i, j, nab = *na + *nb - 1;
> for(i = 0; i < nab; i++)
> ab[i] = 0.0;
> for(i = 0; i < *na; i++)
> for(j = 0; j < *nb; j++)
> ab[i + j] += a[i] * b[j];
> }
>
> And here are the results from trying to compile:
>
> erin@ubuntu:~$ R CMD SHLIB convolve.c
> gcc -std=gnu99 -I/usr/share/R/include      -fpic  -O3 -pipe  -g -c
> convolve.c -o convolve.o
> convolve.c: In function ‘convolve’:
> convolve.c:3:1: error: unknown type name ‘R_len_t’
> make: *** [convolve.o] Error 1
>
>
> What is wrong, please?
>
> This is on Ubuntu 11.10 with R-2.14.2.  I'm sure that it's totally goofy.
>
> Thanks,
> Erin
>
>
>
> --
> Erin Hodgess
> Associate Professor
> Department of Computer and Mathematical Sciences
> University of Houston - Downtown
> mailto: erinm.hodg...@gmail.com
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
Programmer Analyst II, Statistical Consulting Group
University of California, Los Angeles
https://joshuawiley.com/
__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] replicating C example from the Extensions Manual problem

2012-03-14 Thread Berwin A Turlach
G'day Erin,

On Thu, 15 Mar 2012 01:03:59 -0500
Erin Hodgess  wrote:

> What is wrong, please?

Missing

#include 
#include 

In particular the latter is defining R_len_t.  Guess that code snippet
in the manual is only showing the code of the function, but not the
complete file that needs to be compiled. :)

HTH.

Cheers,

Berwin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] replicating C example from the Extensions Manual problem

2012-03-14 Thread Erin Hodgess
Dear R People:

Here is something that I am sure is very simple.  I'm just trying to
re-create the C convolution example in the Extensions manual.  Here is
the subroutine:

void convolve(double *a, int *na, double *b, int *nb, double *ab)
{
R_len_t i, j, nab = *na + *nb - 1;
for(i = 0; i < nab; i++)
ab[i] = 0.0;
for(i = 0; i < *na; i++)
for(j = 0; j < *nb; j++)
ab[i + j] += a[i] * b[j];
}

And here are the results from trying to compile:

erin@ubuntu:~$ R CMD SHLIB convolve.c
gcc -std=gnu99 -I/usr/share/R/include  -fpic  -O3 -pipe  -g -c
convolve.c -o convolve.o
convolve.c: In function ‘convolve’:
convolve.c:3:1: error: unknown type name ‘R_len_t’
make: *** [convolve.o] Error 1


What is wrong, please?

This is on Ubuntu 11.10 with R-2.14.2.  I'm sure that it's totally goofy.

Thanks,
Erin



-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodg...@gmail.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.