Save serie objects

28 views
Skip to first unread message

Ivan Morozov

unread,
Feb 12, 2017, 2:37:02 PM2/12/17
to trip-support
Hi,

I what to use TRIP to expand nested polynomial expression.

1. How serie can be imported into TRIP (in linux)? 
I've tried to generate .t file (smth like <expression>; exit; ) with expression to expand and it seem to work but trip doesn't exit , so I have to manually kill it.
Is there a better way to import an expression?
Can an expression be passed as a command line argument?

2. How a serie can be saved? write doesn't work on a serie. 
Can I generate an output similar to what automatic differentiation libs do or output to stdout?

Could you provide a minimal example of import--expansion--export procedure for serie?

Thanks,
I.M.

Mickaël Gastineau

unread,
Feb 13, 2017, 5:48:57 AM2/13/17
to trip-s...@googlegroups.com
Hi,

1. To import the polynomial , you have to put this polynomial in a text file with the
extension .t and you have to specify its name before the expression. You put $ or ; after
the expression.

For example, if you want to import (x+y)*(2*x-y)*(x+7*y)**3 as th polynomial P, the
content of the file is :

$ cat pfactor.t
P=(x+y)*(2*x-y)*(x+7*y)**3$

Then to import it in a TRIP, you start trip and you execute :

include pfactor.t;

It imports and expand the polynomial P.
You can't give the expression as a command line argument.

The (smth like <expression>; exit; ) doesn't exit trip.
You have to run as :

trip < myfile.t


2. To export the expanded polynomial in a text file, you need to use the following version
available at:

http://www.imcce.fr/fr/presentation/equipes/ASD/trip/trip_1_4_34/trip_amd64_linux.tar.gz
http://www.imcce.fr/fr/presentation/equipes/ASD/trip/trip_1_4_34/trip_amd64_macos10_10.dmg

I provide this full link because our website is being reorganized.
The following program export the polynomial P in a text file (pexpand.txt):


The exportation could be done using the command str to generate a string. The output to
the file could be done using the functions file_open, file_writemsg and file_close.


_affdist=1$
f=file_open("pexpand.txt",write);
file_writemsg(f,str(P));
file_close(f);


You can change the value of _affist=2, if you want it on multiple lines.


So the complete example is :

$ cat pfactor.t
P=(x+y)*(2*x-y)*(x+7*y)**3$

$ cat prog.t
_language=en$
include pfactor.t;
stat(P);
_affdist=1$
f=file_open("pexpand.txt",write);
file_writemsg(f,str(P));
file_close(f);

$ trip <prog.t

**** BIENVENUE SUR TRIP v1.4.34, ****

Taper 'help;' ou '?;' pour obtenir de l'aide

serie P ( x , y )
number of variables : 2 size of the descriptor : 96 bytes
number of terms : 6 size : 752 bytes
f = file "/trip_supp1/pexpand.txt" opened in write mode

Si vous avez apprecie, vous y reviendrez...

$ cat pexpand.txt
- 343*y**5 + 196*x*y**4 + 812*x**2*y**3 + 314*x**3*y**2 + 43*x**4*y + 2*x**5


best regards,

Mickaël
> --
> You received this message because you are subscribed to the Google Groups "trip-support"
> group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> trip-support...@googlegroups.com <mailto:trip-support...@googlegroups.com>.
> To post to this group, send email to trip-s...@googlegroups.com
> <mailto:trip-s...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/trip-support.
> For more options, visit https://groups.google.com/d/optout.


--
**********************************************
* Mickaël Gastineau
* Observatoire de Paris - IMCCE
* CNRS UMR 8028
* 77, avenue Denfert Rochereau
* 75014 PARIS
* tel. France : 01 40 51 20 05
* fax : 01 40 51 20 55
* e-mail : Mickael....@obspm.fr
* http://www.imcce.fr
**********************************************

Ivan Morozov

unread,
Feb 13, 2017, 12:28:46 PM2/13/17
to trip-support, gast...@imcce.fr
Great, everything works now.
Thanks alot for your quick reply!

I.M.
Reply all
Reply to author
Forward
0 new messages