Re: [Rd] Computer algebra in R - would that be an idea??

2005-07-17 Thread Ayal Pinkus

Hi,
I am the maintainer of Yacas. I decided to join this mailing list  
after having heard that
the option of linking R to Yacas was being discussed. Please don't  
hesitate to ask
if you have questions, I will try to find the time to help.
Ayal



On Jul 17, 2005, at 8:11 AM, simon blomberg wrote:

>>
>>
>> yacas does have the Groebner function, e.g.
>>
>> In> Groebner({x*(y-1),y*(x-1)})
>> Out> {x*y-x,x*y-y,y-x,y^2-y};
>>
>
> I stand corrected.
>
> Simon.
>
> -- 
> Simon Blomberg, B.Sc.(Hons.), Ph.D, M.App.Stat.
> Centre for Resource and Environmental Studies
> The Australian National University
> Canberra ACT 0200
> Australia
>
> T: +61 2 6125 7800
> F: +61 2 6125 0757
>
> CRICOS Provider # 00120C
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Computer algebra in R - would that be an idea??

2005-07-17 Thread Peter Dalgaard
Ayal Pinkus <[EMAIL PROTECTED]> writes:

> Hi,
> I am the maintainer of Yacas. I decided to join this mailing list  
> after having heard that
> the option of linking R to Yacas was being discussed. Please don't  
> hesitate to ask
> if you have questions, I will try to find the time to help.
> Ayal


Interesting... Nice initiative!

The thing that I wonder is whether it would be possible to embed Yacas
at a lower level than via the parser. E.g. the Tcl embedding has
Tcl_EvalObjEx() and friends, which operate on preparsed Tcl objects.
Using this instead of Tcl_Eval() gives some efficiency gain, but more
importantly, it avoids the "quoting hell" associated with the
construction of the relevant command strings.

Since both R and Yacas are "Lisp under the hood" languages (and Tcl
too for that matter), it is a fairly good guess that their parse trees
are similar, and that it would be a fairly simple task to translate
back and forth between them. Well, between suitable subsets, at least.
R's parse trees can in principle contain arbitrary R objects, but in
this context, we might only need constants, names, operators, and
function calls.

It is probably not quite as easy as it sounds (is it ever?) but it
could be worth it anyway. The main thing that it would require is an
extended Yacas API which allows you to create Yacas objects from C
code.

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Computer algebra in R - would that be an idea??

2005-07-17 Thread Ayal Pinkus

Hi,

>
> The thing that I wonder is whether it would be possible to embed Yacas
> at a lower level than via the parser. E.g. the Tcl embedding has
> Tcl_EvalObjEx() and friends, which operate on preparsed Tcl objects.
> Using this instead of Tcl_Eval() gives some efficiency gain, but more
> importantly, it avoids the "quoting hell" associated with the
> construction of the relevant command strings.
>

Interesting. You are not the first person asking this, actually.

I chose for the C API as it is nice and clean, no name mangling issues
while switching to a new gcc compiler, and it allows people to use it
from C also. Back then, I thought all people would want to do is send a
string and receive one back.


> Since both R and Yacas are "Lisp under the hood" languages (and Tcl
> too for that matter), it is a fairly good guess that their parse trees
> are similar, and that it would be a fairly simple task to translate
> back and forth between them. Well, between suitable subsets, at least.
> R's parse trees can in principle contain arbitrary R objects, but in
> this context, we might only need constants, names, operators, and
> function calls.
>


Very true. The code to chain up the linked list itself would not be very
little code, but we could iron out an initial API of course. It could  
even
be through a C interface that returns void*.

Yacas can Already read a Lisp-style representation, to wit:

 In> FromString("(foo(List a b))")LispRead()
 Out> foo({a,b})

but that would not help you much as you mention you'd like to avoid  
quoting hell.

 From a C perspective, an API could look like this:

 // Creating objects
 void* yacas_create_atom(char* atom);
 void* yacas_create_string(char* string);
 void* yacas_create_number_from_string(char* string);
 void* yacas_create_number_from_long(long number);
 void* yacas_create_number_from_double(double number);
 void* yacas_create_sublist(void* object);

 // Linking linked lists
 void yacas_link_objects(void* head, void* tail);

 // executing an object
 void* yacas_execute(void* object);

 // pulling apart an object again
 void* yacas_get_sublist(void* object);
 char* yacas_get_atom(void* object);
 char* yacas_get_string(void* object);
 int  yacas_object_is_string(void* object);
 int  yacas_object_is_atom(void* object);
 int  yacas_object_is_number(void* object);
 int  yacas_object_is_integer(void* object);
 long yacas_get_long(void* object);
 long yacas_get_double(void* object);

Note in the above list you would only really need get_sublist and  
get_atom,
but using the others might be more efficient.


> It is probably not quite as easy as it sounds (is it ever?) but it
> could be worth it anyway. The main thing that it would require is an
> extended Yacas API which allows you to create Yacas objects from C
> code.
>


Apart from the above API, which I could create and would not take too  
long,
there is of course the task of converting, in the sense that the  
semantics
of R trees will be different from the semantics of the Yacas tree.

The other alternative is OpenMath, but that is just too verbose. I  
don't like
xml-like schemes myself, as it is a very inefficient way of doing this.

Do you have cvs, and the possibility to compile under Windows?
Ayal



[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Computer algebra in R - would that be an idea??

2005-07-17 Thread Ayal Pinkus

I forgot one API call, getting a potential error caused through  
evaluating the object.
And I forgot one argument needed for evaluating, the pointer to the  
environment.
Ayal


On Jul 17, 2005, at 5:29 PM, Ayal Pinkus wrote:

>
> Hi,
>
>
>>
>> The thing that I wonder is whether it would be possible to embed  
>> Yacas
>> at a lower level than via the parser. E.g. the Tcl embedding has
>> Tcl_EvalObjEx() and friends, which operate on preparsed Tcl objects.
>> Using this instead of Tcl_Eval() gives some efficiency gain, but more
>> importantly, it avoids the "quoting hell" associated with the
>> construction of the relevant command strings.
>>
>>
>
> Interesting. You are not the first person asking this, actually.
>
> I chose for the C API as it is nice and clean, no name mangling issues
> while switching to a new gcc compiler, and it allows people to use it
> from C also. Back then, I thought all people would want to do is  
> send a
> string and receive one back.
>
>
>
>> Since both R and Yacas are "Lisp under the hood" languages (and Tcl
>> too for that matter), it is a fairly good guess that their parse  
>> trees
>> are similar, and that it would be a fairly simple task to translate
>> back and forth between them. Well, between suitable subsets, at  
>> least.
>> R's parse trees can in principle contain arbitrary R objects, but in
>> this context, we might only need constants, names, operators, and
>> function calls.
>>
>>
>
>
> Very true. The code to chain up the linked list itself would not be  
> very
> little code, but we could iron out an initial API of course. It could
> even
> be through a C interface that returns void*.
>
> Yacas can Already read a Lisp-style representation, to wit:
>
>  In> FromString("(foo(List a b))")LispRead()
>  Out> foo({a,b})
>
> but that would not help you much as you mention you'd like to avoid
> quoting hell.
>
>  From a C perspective, an API could look like this:
>
>  // Creating objects
>  void* yacas_create_atom(char* atom);
>  void* yacas_create_string(char* string);
>  void* yacas_create_number_from_string(char* string);
>  void* yacas_create_number_from_long(long number);
>  void* yacas_create_number_from_double(double number);
>  void* yacas_create_sublist(void* object);
>
>  // Linking linked lists
>  void yacas_link_objects(void* head, void* tail);
>
>  // executing an object
>  void* yacas_execute(void* object);
>
>  // pulling apart an object again
>  void* yacas_get_sublist(void* object);
>  char* yacas_get_atom(void* object);
>  char* yacas_get_string(void* object);
>  int  yacas_object_is_string(void* object);
>  int  yacas_object_is_atom(void* object);
>  int  yacas_object_is_number(void* object);
>  int  yacas_object_is_integer(void* object);
>  long yacas_get_long(void* object);
>  long yacas_get_double(void* object);
>
> Note in the above list you would only really need get_sublist and
> get_atom,
> but using the others might be more efficient.
>
>
>
>> It is probably not quite as easy as it sounds (is it ever?) but it
>> could be worth it anyway. The main thing that it would require is an
>> extended Yacas API which allows you to create Yacas objects from C
>> code.
>>
>>
>
>
> Apart from the above API, which I could create and would not take too
> long,
> there is of course the task of converting, in the sense that the
> semantics
> of R trees will be different from the semantics of the Yacas tree.
>
> The other alternative is OpenMath, but that is just too verbose. I
> don't like
> xml-like schemes myself, as it is a very inefficient way of doing  
> this.
>
> Do you have cvs, and the possibility to compile under Windows?
> Ayal
>
>
>
> [[alternative HTML version deleted]]
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Computer algebra in R - would that be an idea??

2005-07-17 Thread Søren Højsgaard
Sounds really nice... Due to a not-so-particularly-nice summer weather in 
Denmark, I have started writing a little package called 'yacasR' which 
communicates with Yacas through a socketConnection (on windows, I don't know 
how general this communication method is??). I'll try to 'polish' the package a 
bit more within the next few days and afterwards post it somewhere (not on 
CRAN, though). If the yacasR idea can fly, I hope more people will contribute 
to the package...
 
However, it would be really good if some of you who know more about the 
technical stuff, could find a way of making Yacas communicate with R more 
smoothly... 
 
Best regards
Søren



Fra: [EMAIL PROTECTED] på vegne af Ayal Pinkus
Sendt: sø 17-07-2005 12:06
Til: R-devel@r-project.org
Emne: Re: [Rd] Computer algebra in R - would that be an idea??




Hi,
I am the maintainer of Yacas. I decided to join this mailing list 
after having heard that
the option of linking R to Yacas was being discussed. Please don't 
hesitate to ask
if you have questions, I will try to find the time to help.
Ayal



On Jul 17, 2005, at 8:11 AM, simon blomberg wrote:

>>
>>
>> yacas does have the Groebner function, e.g.
>>
>> In> Groebner({x*(y-1),y*(x-1)})
>> Out> {x*y-x,x*y-y,y-x,y^2-y};
>>
>
> I stand corrected.
>
> Simon.
>
> --
> Simon Blomberg, B.Sc.(Hons.), Ph.D, M.App.Stat.
> Centre for Resource and Environmental Studies
> The Australian National University
> Canberra ACT 0200
> Australia
>
> T: +61 2 6125 7800
> F: +61 2 6125 0757
>
> CRICOS Provider # 00120C
>
> __
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Computer algebra in R - would that be an idea??

2005-07-17 Thread Dirk Eddelbuettel

On 17 July 2005 at 17:29, Ayal Pinkus wrote:
| Do you have cvs, and the possibility to compile under Windows?

Yes on both counts, though CVS got replaced by SVN. 

R builds fine under Windows (though you need to pay attention to the details
which are in the (binary) distribution in the pdf files, in particular: `R
Installation and Administration Manual', a html copy is also on the website;
and the README* and INSTALL files in src/gnuwin32/ ).  These details look
tedious at first, and you may have to install a few things, but it keeps the
sources closely tied between Windoze and the Unixish operating systems on
which many of us prefer to develop.

Allow me to add that this sounds very exciting. On Quantian, the only
'bridge' between Yacas, Maxima, ... and R was in the TeXmacs editor. Getting
the programs to talk directly is a very promising idea. I look forward to
toying with this one day!

Regards, Dirk

-- 
Statistics: The (futile) attempt to offer certainty about uncertainty.
 -- Roger Koenker, 'Dictionary of Received Ideas of Statistics'

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Computer algebra in R - would that be an idea??

2005-07-17 Thread Ayal Pinkus

Hi,

>
> This looks promising.  Thanks for starting it off
> and being so enthusiastic.
>

It does sound like a fun thing, and I think this will be very little  
work for me.

> Taking a look at the APIs for Perl, Python, R, Tcl, Java, etc.
> would also be good. One thing that all of these provide is
> a specific typedef for an object.  I imagine Yacas does also,
> so rather than returning void *, it would be nicer to
> return that type.
>

Good point to have type safety. But Yacas uses classes. A number will
actually be a different object from a string, but derived from the same
base class. The void* would simply mean a pointer to something
derived from the base class. We can perhaps typedef a YacasObject, to
be a pointer to void. Would that already provide enough safety?

The other option indeed is to allow full access to the internals. For  
this
I would probably need to expose the entire set of header files, not just
the file cyacas.h. To me it feels more elegant to expose just what one
wants to expose, hence the clear API definition. We can export certain
methods of certain classes, so you could actually just call  
LispAtom::New
or LispSubList::New, literally the classes that are already available.

The disadvantage with exposing the full internals is that I would  
basically
be promising that the internals will never change in the future. The API
abstracts away the internals. There are discussions currently going  
on on
changing the representation of the trees internally, to experiment with
different algorithms.

It is a matter of design. I am ok with exposing all the internals,  
but I would
rather not promise that I will not overhaul the internals.

Ayal

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Computer algebra in R - would that be an idea??

2005-07-17 Thread Ayal Pinkus


Hi,

>
> R builds fine under Windows (though you need to pay attention to  
> the details
> which are in the (binary) distribution in the pdf files, in  
> particular: `R
> Installation and Administration Manual', a html copy is also on the  
> website;
> and the README* and INSTALL files in src/gnuwin32/ ).  These  
> details look
> tedious at first, and you may have to install a few things, but it  
> keeps the
> sources closely tied between Windoze and the Unixish operating  
> systems on
> which many of us prefer to develop.
>

Ok. Unfortunately I work on a Mac OS X at home (I have access to  
Windows, MS DevStudio
at work but want to keep work and hobby separate). I do work with  
Xcode (have to
delve deeper in to Cocoa still though). Can integration also be done  
on Mac OS X?
If I understood correctly you go the COM route for integration on  
Windows?

CrystalSpace is a 3d engine that has a COM simulation layer for Unix- 
style platforms
I think (last time I looked was a few years back). It would  
essentially be a thin layer
to implementations of abstract classes.

I did download R for Mac OS X. It is quite a nice package! I wish I  
had looked at it earlier.
You did a very good job on the user interface.


> Allow me to add that this sounds very exciting.

I agree!

I am working on a Java port at the moment. I will try to make some  
time later this evening
or perhaps somewhere this week.

Ayal

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Computer algebra in R - would that be an idea??

2005-07-17 Thread Dirk Eddelbuettel

On 17 July 2005 at 20:55, Ayal Pinkus wrote:
| > R builds fine under Windows (though you need to pay attention to  
[...]
| Ok. Unfortunately I work on a Mac OS X at home (I have access to  
| Windows, MS DevStudio

Why didn't you say so earlier? :)

I don't do Mac OS X, so can't help. There is a special interest group
r-sig-mac with its own mailing list -- ask there. But several R Core members
develop on Mac OS X as well so it seem fair to infer that it is possible.

| If I understood correctly you go the COM route for integration on  
| Windows?

I doubt that.

Dirk

-- 
Statistics: The (futile) attempt to offer certainty about uncertainty.
 -- Roger Koenker, 'Dictionary of Received Ideas of Statistics'

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Computer algebra in R - would that be an idea??

2005-07-17 Thread Gabor Grothendieck
On 7/17/05, Ayal Pinkus <[EMAIL PROTECTED]> wrote:
> 
> 
> Hi,
> 
> >
> > R builds fine under Windows (though you need to pay attention to
> > the details
> > which are in the (binary) distribution in the pdf files, in
> > particular: `R
> > Installation and Administration Manual', a html copy is also on the
> > website;
> > and the README* and INSTALL files in src/gnuwin32/ ).  These
> > details look
> > tedious at first, and you may have to install a few things, but it
> > keeps the
> > sources closely tied between Windoze and the Unixish operating
> > systems on
> > which many of us prefer to develop.
> >
> 
> Ok. Unfortunately I work on a Mac OS X at home (I have access to
> Windows, MS DevStudio
> at work but want to keep work and hobby separate). I do work with
> Xcode (have to
> delve deeper in to Cocoa still though). Can integration also be done
> on Mac OS X?
> If I understood correctly you go the COM route for integration on
> Windows?
> 
> CrystalSpace is a 3d engine that has a COM simulation layer for Unix-
> style platforms
> I think (last time I looked was a few years back). It would
> essentially be a thin layer
> to implementations of abstract classes.
> 
> I did download R for Mac OS X. It is quite a nice package! I wish I
> had looked at it earlier.
> You did a very good job on the user interface.

Note that there are also quite a few addon GUIs that various people have
created for R, as well.  See 
  http://www.sciviews.org/_rgui/ 
where they are listed down the left hand side of the page.  JGR, and possibly
several others on the list, are written in Java.  R can also be accessed
directly online at: 
  http://www.math.montana.edu/Rweb/ 
and other sites.

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Computer algebra in R - would that be an idea??

2005-07-17 Thread Gabor Grothendieck
On 7/17/05, Dirk Eddelbuettel <[EMAIL PROTECTED]> wrote:
> 
> On 17 July 2005 at 20:55, Ayal Pinkus wrote:
> | > R builds fine under Windows (though you need to pay attention to
> [...]
> | Ok. Unfortunately I work on a Mac OS X at home (I have access to
> | Windows, MS DevStudio
> 
> Why didn't you say so earlier? :)
> 
> I don't do Mac OS X, so can't help. There is a special interest group
> r-sig-mac with its own mailing list -- ask there. But several R Core members
> develop on Mac OS X as well so it seem fair to infer that it is possible.
> 
> | If I understood correctly you go the COM route for integration on
> | Windows?
> 
> I doubt that.
> 

Actually, via addon packages, COM support is very good in R.  In fact there 
are two different roughly comparable packages that provide COM support 
(both client and server).  I have used the client package of both and they both
seem to work well.

1. rcom at:
  http://sunsite.univie.ac.at/rcom/download/
which also has its own mailing list:
  http://mailman.csd.univie.ac.at/pipermail/rcom-l/
and

2. various omegahat packages at:
  http://www.omegahat.org

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Computer algebra in R - would that be an idea??

2005-07-17 Thread Rob J Goedman
Hi,

Maybe sending an R expression and getting an R expression back
for a 'suitable subset' of expressions is ok initially. Suitable could
cover 3 levels:

1) Mapping of names and standard functions, e.g. pi to Pi and
  sin(x) to Sin(x) etc.

2) It would be nice if we can use threading of functions, which will  
require
  converting R lists, vectors, matrices etc to yacas lists.

3) And finally, what about functions such as apply, quote, etc.?

Not sure how to get around the superfluous parse step when
calling an R function, e.g.  yacas(rExp). Rebuilding the original
argument to pass to yacas with reparse(substitute(rExp)) again
might again be ok initially.

Earlier I asked the question on where to do the back and forth
translation of R expressions to yacas statements. At that time I
focused on R or C++. The latter likely if its done using the
parsed tree.

Two other possibilities might be to 'redo' yacas to make yacas much
closer to R (examples that come to mind is all cases of sin(x) in R to
Sin(x) in yacas - as in 1) above -, although as  Gabor indicated, CForm
helps on the way back). The 2nd option is adding a whole bunch of Rules
to the yacas scripts to do this, e.g '10 # sin(x) <-- Sin(x)'. Not  
sure if
adding a special low level generic object to yacas would help here.

As rules in yacas are global, all of these substitutions could be  
collected
in 1 or a few yacas scripts read in when R's yacas function starts the
yacas_client.

I do work on Mac, have helped Simon and Stefano occasionally with
the Mac OS GUI.  If you have a yacas version as an Xcode project,  
that would
make playing around and trying some of above steps easier. I've  
looked at the
Mac OS GUI version of Yacas, seems based on an older version and  
vanilla 1.0.57
compiles fine on Mac OS. My guess is, if possible, we want a single  
approach
across the different platforms.

Rob


On Jul 17, 2005, at 8:29 AM, Ayal Pinkus wrote:

>> Using this instead of Tcl_Eval() gives some efficiency gain, but more
>> importantly, it avoids the "quoting hell" associated with the
>> construction of the relevant command strings.

> Interesting. You are not the first person asking this, actually.
>
> I chose for the C API as it is nice and clean, no name mangling issues
> while switching to a new gcc compiler, and it allows people to use it
> from C also. Back then, I thought all people would want to do is  
> send a
> string and receive one back.

>> Since both R and Yacas are "Lisp under the hood" languages (and Tcl
>> too for that matter), it is a fairly good guess that their parse  
>> trees
>> are similar, and that it would be a fairly simple task to translate
>> back and forth between them. Well, between suitable subsets, at  
>> least.
>> R's parse trees can in principle contain arbitrary R objects, but in
>> this context, we might only need constants, names, operators, and
>> function calls.

On Jul 15, 2005, at 6:25 AM, Peter Dalgaard wrote:

>> I wonder how difficult it would be to translate expressions back and
>> forth from R to yacas in either R or C++. And maybe strip 'In>'  
>> and 'Out>' like parts.
>
> You could also just do what those examples do and embed the whole
> enchillada in R. The slightly bad news is that the yacas_eval
> interface is text-based, which means that to handle an R expression
> via yacas you're going through a deparse-parse-operate-deparse-parse
> sequence. It would be nicer if you could just convert parse trees
> between the two languages. The good news is that there's a Lisp route
> (see example3), which should make the parser/deparser coding somewhat
> easier.

On Jul 15, 2005, at 3:44 AM, Gabor Grothendieck wrote:

> On 7/15/05, Rob J Goedman <[EMAIL PROTECTED]> wrote:
>
>> I wonder how difficult it would be to translate expressions back and
>> forth from R to yacas in either R
>> or C++. And maybe strip 'In>' and 'Out>' like parts.
>
> Not sure how generally this works but see my prior post:
>http://tolstoy.newcastle.edu.au/R/help/04/03/1299.html

 > system("echo 'WriteString(CForm(Integrate(x)1/x))' | yacas_client")
In> WriteString(CForm(Integrate(x)1/x))
log(x)
Out> True
In>





[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Computer algebra in R - would that be an idea??

2005-07-17 Thread Ayal Pinkus


> where they are listed down the left hand side of the page.  JGR,  
> and possibly
> several others on the list, are written in Java.  R can also be  
> accessed
> directly online at:
>   http://www.math.montana.edu/Rweb/
> and other sites.
>

And as of a week ago or so Yacas can also be accessed through a Java  
applet,
at

 http://www.xs4all.nl/~apinkus/yacasconsole.html

This is work in progress still, as the numeric support is not up to  
par yet for instance.
But in case you feel like taking a look without having to compile  
Yacas, it is now on line :-)
Ayal

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Computer algebra in R - would that be an idea??

2005-07-17 Thread Ayal Pinkus

I took the liberty of already adding the API to compose Yacas  
expression trees,
executing them, and pulling them apart. This is just a preliminary  
stab at it, we
can change it of course (removing void* for something else say). It  
was relatively
little work.

You can get it from our cvs tree at sourceforge. libcyacas.a is the  
library, src/cyacas.h
defines the interface. I rolled a little example embed/example4.c. If  
you run it you see
the spectacular calculation "1+1" being performed :-)

 Input>  (+ 1 1 )
 Output>  2

The source code for this can be found below, to give you an  
indication of how this
API would work.

What do you think? Would that work for you?
Ayal






#include 
#include "cyacas.h"

int verbose_debug = 0;// avoid linkage error

void print_expr(void* object)
{
   if (object == NULL)
 return;
   if (yacas_object_is_sublist(object))
   {
 printf("(");
 print_expr(yacas_get_sublist(object));
 printf(")");
   }
   else
   {
 printf("%s ",yacas_get_atom(object));
 print_expr(yacas_get_next(object));
   }
}
void runexpr(void* object)
{
   printf("Input>  ");
   print_expr(object);
   printf("\n");
   void* result = yacas_execute(object);
   printf("Output>  ");
   print_expr(result);
   printf("\n");
   yacas_delete_object(result);
}

int main(int argc, char** argv)
{
   int i;
   yacas_init();

   void *input =
 yacas_create_sublist(
   yacas_link_objects(
 yacas_create_atom("+"),
 yacas_link_objects(
   yacas_create_atom("1"),
   yacas_create_atom("1")
 )
   )
 );
   runexpr(input);

   yacas_delete_object(input);
   yacas_exit();
   return 0;
}


[[alternative HTML version deleted]]

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Computer algebra in R - would that be an idea??

2005-07-17 Thread Ayal Pinkus

Hi,
sorry, I should have given the link below. You can get the latest  
version of Yacas from:

 http://sourceforge.net/cvs/?group_id=2528

I just checked in the change to the API.
Best wishes,
Ayal

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Computer algebra in R - would that be an idea??

2005-07-17 Thread Peter Dalgaard
Ayal Pinkus <[EMAIL PROTECTED]> writes:

> Hi,
> 
> >
> > R builds fine under Windows (though you need to pay attention to  
> > the details
> > which are in the (binary) distribution in the pdf files, in  
> > particular: `R
> > Installation and Administration Manual', a html copy is also on the  
> > website;
> > and the README* and INSTALL files in src/gnuwin32/ ).  These  
> > details look
> > tedious at first, and you may have to install a few things, but it  
> > keeps the
> > sources closely tied between Windoze and the Unixish operating  
> > systems on
> > which many of us prefer to develop.
> >
> 
> Ok. Unfortunately I work on a Mac OS X at home (I have access to  
> Windows, MS DevStudio
> at work but want to keep work and hobby separate). I do work with  
> Xcode (have to
> delve deeper in to Cocoa still though). Can integration also be done  
> on Mac OS X?
> If I understood correctly you go the COM route for integration on  
> Windows?

Whoa! Be careful there, there is no collective "you"; this is a
mailing list. 

Søren, Dirk, Gabor, and I are four quite distinct people, and at least
Dirk and I are Linux people who would rather not touch COM...
Especially not when there's a perfectly fine library embedding method
available. This approach usually works across all platforms although
Windows and Macs tend to require a few extra twists. (I'm not up to
speed on Macs. I gather that OS X managed to mess up dynamic linking
somewhat but I believe it has all been sorted. You should probably
have a peek at the MacOSX FAQ at
http://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html and the page
http://www.economia.unimi.it/R)

 
> CrystalSpace is a 3d engine that has a COM simulation layer for Unix- 
> style platforms
> I think (last time I looked was a few years back). It would  
> essentially be a thin layer
> to implementations of abstract classes.
> 
> I did download R for Mac OS X. It is quite a nice package! I wish I  
> had looked at it earlier.
> You did a very good job on the user interface.

...and Stefano and Simon who were the main players in this development
are yet another different "you".

> 
> > Allow me to add that this sounds very exciting.
> 
> I agree!
> 
> I am working on a Java port at the moment. I will try to make some  
> time later this evening
> or perhaps somewhere this week.

Sounds good. I wish I had more time for this, but there's a deadline
approaching... 

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] Computer algebra in R - would that be an idea??

2005-07-17 Thread Søren Højsgaard
On my homepage, http://genetics.agrsci.dk/~sorenh/misc/ there is now a small 
yacasR package (runs on windows only). Feel free to comment - or laugh!
Søren



Fra: [EMAIL PROTECTED] på vegne af Gabor Grothendieck
Sendt: sø 17-07-2005 21:15
Til: Ayal Pinkus
Cc: R-devel@r-project.org
Emne: Re: [Rd] Computer algebra in R - would that be an idea??



On 7/17/05, Ayal Pinkus <[EMAIL PROTECTED]> wrote:
>
>
> Hi,
>
> >
> > R builds fine under Windows (though you need to pay attention to
> > the details
> > which are in the (binary) distribution in the pdf files, in
> > particular: `R
> > Installation and Administration Manual', a html copy is also on the
> > website;
> > and the README* and INSTALL files in src/gnuwin32/ ).  These
> > details look
> > tedious at first, and you may have to install a few things, but it
> > keeps the
> > sources closely tied between Windoze and the Unixish operating
> > systems on
> > which many of us prefer to develop.
> >
>
> Ok. Unfortunately I work on a Mac OS X at home (I have access to
> Windows, MS DevStudio
> at work but want to keep work and hobby separate). I do work with
> Xcode (have to
> delve deeper in to Cocoa still though). Can integration also be done
> on Mac OS X?
> If I understood correctly you go the COM route for integration on
> Windows?
>
> CrystalSpace is a 3d engine that has a COM simulation layer for Unix-
> style platforms
> I think (last time I looked was a few years back). It would
> essentially be a thin layer
> to implementations of abstract classes.
>
> I did download R for Mac OS X. It is quite a nice package! I wish I
> had looked at it earlier.
> You did a very good job on the user interface.

Note that there are also quite a few addon GUIs that various people have
created for R, as well.  See
  http://www.sciviews.org/_rgui/
where they are listed down the left hand side of the page.  JGR, and possibly
several others on the list, are written in Java.  R can also be accessed
directly online at:
  http://www.math.montana.edu/Rweb/
and other sites.

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel