Next: Introduction, [Contents][Index]
• Introduction: | Start with TRIP | |
• Semantique : | ||
• Variables globales : | ||
• Variables : | ||
• Series : | ||
• Constantes : | ||
• Chaines : | ||
• Tableaux : | ||
• Structures : | ||
• Vecteurs numeriques : | ||
• Matrices numeriques : | ||
• Graphiques : | ||
• Communications : | ||
• Macros : | ||
• Boucles et conditions : | ||
• Bibliotheques : | ||
• Traitement numerique : | ||
• Utilitaire : | ||
• Index : |
TRIP is a general computer algebra system dedicated to celestial mechanics.
Authors :
With the contributions of E. Paviot, F. Thire, D. Acheroff, M. To, A. Ceyrac, G. Rouault, V. Kelsch, F. Darricau, N. Brucy, F. Boschet.
This software includes a library developped by the NetBSD fundation and its contributors.
This software includes the libraries LAPACK and ’SCSCP C Library’.
This software is dynamically linked to the libraries LTDL, GMP, MPFR et MPC. The source of these libraries could be downloaded from the web site specified in the Chapter References (see References).
TRIP version 1.4.120
Copyright © 1988-2021 J.Laskar/ASD/IMCCE/CNRS
Next: Semantique, Previous: Top, Up: Top [Contents][Index]
In order to execute TRIP, you must
You will see on screen :
**** BIENVENUE SUR TRIP v1.0.0 **** Taper 'help;' ou '?;' pour obtenir de l'aide > |
TRIP is ready to receive your commands. TRIP has a case sensitive interpreter.
In order to compute S=(X+Y)^2, you must just enter :
**** BIENVENUE SUR TRIP v1.0.0 **** Taper 'help;' ou '?;' pour obtenir de l'aide > S=(X+Y)^2; S(X,Y) = 1*Y**2 + 2*Y*X + 1*X**2 |
Use the up-arrow key, you could bring back the previous command. Command-line input can be edited using arrow keys.
To exit TRIP, you enter quit
or exit
.
The reserved keywords for TRIP language are specified in the Annexes. TRIP contains several keyword categories :
When TRIP starts or the commands reset or @@ are executed, it reads these files in the following order :
’$TRIPDIR/etc/trip.ini’ | where $TRIPDIR is the installation directory of TRIP. |
’$HOME/.trip’ | where $HOME is the user home directory. |
’trip.ini’ | in the current directory. |
These file may contain any valid instructions.
Recommendations :
Next: Variables globales, Previous: Introduction, Up: Top [Contents][Index]
• expression: | ||
• identificateur : | ||
• visibilite : |
Next: identificateur, Up: Semantique [Contents][Index]
An expression can contain all defined operators on object identifiers and can call functions or commands.
An expression must be always ended with ;
or $
. The character ;
implies the execution of the expression and displays the result. The character$
implies only the execution of the expression.
Several instructions separated with the character ;
or $
could follow. They will be executed sequentially.
A comment on one or more lines is defined as /* .... */
, like in the C language. A single-line comment starts with the characters //
, like in the C++ language.
> // compute 1+t and display the result > s=1+t; s(t) = 1 + 1*t > // compute 1+t but does not display the result > s1=(1+x+y)^2$ > // display the content of s1 > s1; s1(x,y) = 1 + 2*y + 1*y**2 + 2*x + 2*x*y + 1*x**2 >
Next: visibilite, Previous: expression, Up: Semantique [Contents][Index]
An object identifier must begin with a letter and must contain only letters (lower-case or upper-case) and/or number (09) and the characters _ or ’ .
By default, an object identifier is global, so it will be viewed by any instruction. An object identifier could be local to a macro, so it will be only viewed from this macro and it will be destroy each time the execution of this macro finished. A TRIP reserved keyword can’t be used as the name of an object identifier.
The object identifier can have the following type :
> ch="file1"$ > s=1+x$ > dim t[1:2]; > z=1+2*i; z = (1+i*2) > bilan; ch CHAINE s SERIE t TAB x VAR
The definition of the function, subroutines and variables use the following types :
<object identifier> | object identifier |
<integer> | natural integer number or an operation which returns an integer |
<real> | real floating-point number or an operation which returns a real floating-point number |
<complex> | complex number or an operation which returns a complex number |
<variable> | variable |
<constant> | an operation which returns an integer, a real number or a complex number |
<serie> | serie |
<operation> | an operation which returns a number (constant) or a serie |
<array> | array of series |
<array of variables> | array of variables |
<(array of) variables> | variable or array of variables |
<num. vec.> | numerical vector |
<real vec.> | numerical vector of real numbers |
<complex vec.> | numerical vector of complex numbers |
<array of real vec.> | array of numerical vectors of real numbers |
<array of complex vec.> | array of numerical vectors of complex numbers |
<array of num. vec.> | array of numerical vectors |
<(array of) real vec.> | (array of) numerical vectors of real numbers |
<(array of) num. vec.> | (array of) numerical vectors |
<constant or num. vec.> | a constant or a numerical vector |
<constant or matrix> | a constant or a numerical matrix |
<real or real vec.> | real floating-point number or numerical vector of real numbers |
matrixtype | numerical matrix |
matrixrtype | real matrix |
matrixctype | complex matrix |
<filename> | filename |
<file> | file |
<macro> | macro |
<dimension of an array> | two integers separated with the character : |
<list of dimension> | list of <dimension of an array> separated with a comma |
<two dimensions of a matrix> | list of two dimensions separated with a comma. Each dimension consists of two integers separated with the character : |
<condition> | comparison between two operations |
<string> | an operation which returns a string of characters |
<(array of) string> | an operation which returns a string of characters or an array of string of characters |
<list of variables> | list of variables or an array of variables |
<list of parameters> | list of parameters of a macro |
<body> | list of trip expression |
<scscp client> | connection to a SCSCP server |
<remote object> | object stored on a remote SCSCP server |
<Maple client> | connection to a local Maple session |
<Mathematica client> | connection to a local Mathematica session |
A serie is a polynomial of degree n (n is an integer). It depends on one or more variables.
> s=1+x; s(x) = 1 + 1*x > s2=(1+x+y); s2(x,y) = 1 + 1*y + 1*x > bilan; s SERIE s2 SERIE x VAR y VAR
A constant is an integer, a real, a complex, a rational number or an interval.
In rational numerical mode (_modenum = NUMRAT
or _modenum = NUMRATMP
), the input of 0.5 creates a floating-point number and not the rational number 1/2.
>x = 2; 2 >y = 2.25; 9/4 >z = 1+2*i; (1+i*2) >bilan; x CONST y CONST z CONST > _modenum=NUMDBLINT; _modenum = NUMDBLINT > s = <1|2>; s = [+1.00000000000000E+00,+2.00000000000000E+00]
It’s a list of characters surrounded with " ". It’s used to specify the _path
, to define the name of the files, to display messages, ... . There is no limit on the size. But, for the global variable _path
, it’s length is truncated to 256 (this value depends on the system). To produce a double-quotes (") in a string, two double-quotes must be used.
> ch = "file" + "1"; ch = "file1" > sch = "../" + ch; sch = "../file1" > sch1 = sch + "." + str(12); sch1 = "../file1.12" > ch3="nomsuivide""fin"; ch3 = "nomsuivide"fin"
<nom> = <real> ;
A real floating-point number is always displayed or inputed in base 10. The symbol d
, e
, E
or D
is the exponentiation symbol.
> a=2.125E6; a = 2125000 > q=3D2; q = 300 > r=0.123554545; r = 0.123554545
<nom> = <real> + i * <real> ;
A complex number is allowed. The lower-case i or upper-case I specifies the imaginary part of the complex number.
> x=2+i*3; x = (2+i*3) > y=-5+4*i; y = (-5+i*4)
It’s a string of characters. This string must be surrounded with " " if the string contains the character space " [ ] { } () or more than one points.
A file name could be the content of an object identifier of type string.
These file names are relative to the variable _path, excepted for the file names build with the function file_fullname
(see file_fullname).
> read("fichier.1.dat",T); > s="ell."+str(10)+".asc"; s = "ell.10.asc" > read(s,T);
It’s an object identifier which specifies a file, which is opened in reading or writing mode.
> f = file_open("fichier.1.dat",read); > file_close(f);
Previous: identificateur, Up: Semantique [Contents][Index]
• private: | ||
• public: |
Next: public, Up: visibilite [Contents][Index]
private
<object identifier> x ,
...;
The specified object identifiers will be local to the macro, to the loop (for, while, sum) or to a file. The local object identifiers are destroyed at the end of the execution of the macro or at the end of each iteration of loop (for, while, sum).
If a local object identier is local to a file, this object is visible only to the macros of this file or during the execution of the file.
If a local object identifier has the same name as a global object identifier, then the local object identifier will be used. In this case, the local object identifier hides the global object identifier during the execution of the macro.
private _ALL;
All object identifiers used in a macro and a file will be local to the macro or to a file.
The behavior is similar to the previous definition.
The command public
(see public) allow to access to a global object.
> // S, SY, SXY, SXX, DEL are private objects > macro least_ab[TX,TY,a,b] { private S, SY, SXY, SXX, DEL; S=size(TX)$ SX=sum(TX)$ SY=sum(TY)$ SXY=sum(TX*TY)$ SXX=sum(TX*TX)$ DEL=S*SXX-SX*SX$ a = (S*SXY-SX*SY)/DEL$ b = (SXX*SY-SX*SXY)/DEL$ }; > > tx=1,10; tx double precision real vector : number of elements =10 > ty=3*tx; ty double precision real vector : number of elements =10 > %least_ab[tx,ty,[a],[b]]; > bilan; SX CONST a CONST b CONST tx VNUMR ty VNUMR > > // T2 is a private object > macro detval[T] { private _ALL; dim T2[1:3,1:3]$ T2[:,::]=0$ T2[1,1]=T**2$ T2[2,2]=1-T$ T2[3,3]=T$ return det(T2); }; > %detval[5]; -500 > bilan; SX CONST a CONST b CONST tx VNUMR ty VNUMR >
Previous: private, Up: visibilite [Contents][Index]
public
<object identifier> x ,
...;
This command must be only used after the command private _ALL;
. It specifies that the identifiers of this list will be global whereas the other objects will be local to the macro or to the file.
> // w is local and z is global > macro myfunc[T] { private _ALL; public z; w = cos(T); z = T; }; > %myfunc[5]; w = 0.2836621854632262 z = 5 > bilan; z CONST >
Next: Variables, Previous: Semantique, Up: Top [Contents][Index]
The content of a global variable is performed by entering its name followed with ;
.
The content of all global variables is displayed with the command vartrip
(see vartrip).
All global variables, containing a real number, are stored in a double-precision real number.
• _affc : | ||
• _affdist : | ||
• _comment : | ||
• _cpu : | ||
• _echo : | ||
• _endian : | ||
• _graph : | ||
• _hist : | ||
• _history : | ||
• _info : | ||
• _integnum : | ||
• _language : | ||
• _mode : | ||
• _modenum : | ||
• _modenum_prec : | ||
• _naf_dtour : | ||
• _naf_icplx : | ||
• _naf_iprt : | ||
• _naf_isec : | ||
• _naf_iw : | ||
• _naf_nulin : | ||
• _naf_tol : | ||
• _path : | ||
• _quiet : | ||
• _read : | ||
• _read_history : | ||
• _time : | ||
• _userlibrary_path : | ||
• I : | ||
• PI : |
Next: _affdist, Up: Variables globales [Contents][Index]
_affc =
{1, 2, 3, 4, 5, 6, 7, 8, 9};
Set the format to display the numerical coefficients of series or constants.
Default value = 4.
> _affc=1; _affc = 1 > 1/3; 0.333333 > _affc=2; _affc = 2 > 1/3; 0.33333333 > _affc=3; _affc = 3 > 1/3; 0.3333333333 > _affc=4; _affc = 4 > 1/3; 0.333333333333333 > _affc=5; _affc = 5 > 1/3; 1/3 > _affc=6; _affc = 6 > 1/3; 1/3 > _affc=7; _affc = 7 > 1/3; 1/3 > _affc=8; _affc = 8 > 1/3; 3.333333E-01 > _affc=9; _modenum=NUMDBLINT; _affc = 9 _modenum = NUMDBLINT > 1/3; [+3.333333333333333E-1,+3.333333333333334E-1 ( 5.551115E-17)]
Next: _comment, Previous: _affc, Up: Variables globales [Contents][Index]
_affdist =
{0, 1, 2, 3, 4, 5, 6, 7, 8};
Set the format to display the series
Default value = 2.
_affvar
.
_affvar
, with one term by line for the two parts.
_affvar
, with one term by line for the distributed part and the factorized part is on the same line.
Remarks : if _affvar
is empty, then the format of _affdist
= 6, respectively 7 or 8,
is the same as _affdist
=1, respectively 2.
>_affdist = 2; >x = 1+y; x(y) = 1 + 1*y
Next: _cpu, Previous: _affdist, Up: Variables globales [Contents][Index]
_comment
{on
,off
};
Enable or disable the display of comments.
Default value = off
.
> _comment; _comment OFF > /* série à deriver : /* s=1+x */ : */; > _comment on; > /* série à deriver : /* s=1+x */ : */; série à deriver : s=1+x : > _comment off;
Next: _echo, Previous: _comment, Up: Variables globales [Contents][Index]
_cpu =
<integer> ;
Specify the number of processors which will be used for later computations.
The specified value can’t be greater than the number of available processors or cores on the computer.
Default value : number of active processors or cores on the computer.
> _mode=POLP; _mode = POLP > _cpu=1; _cpu = 1 > time_s; s=(1+x+y+z+t+u)^30$ time_t(usertime, realtime); 03.321s - ( 99.44% CPU) > msg("the real time is %g\n", realtime); the real time is 3.33976 > _cpu=4; _cpu = 4 > time_s; s=(1+x+y+z+t+u)^30$ time_t(usertime, realtime); 03.339s - (322.89% CPU) > msg("the real time is %g\n", realtime); the real time is 1.03414
Next: _endian, Previous: _cpu, Up: Variables globales [Contents][Index]
_echo =
{0, 1};
_echo
{on
,off
};
Enable or disable the display of the echo of the executed commands.
Default value = off
.
>_echo = 1; >msg "exemple"; exemple cde>> msg "exemple";
Next: _graph, Previous: _echo, Up: Variables globales [Contents][Index]
_endian =
{little , big};
Specify the byte order (big-endian or little-endian) in binary files.
Default value = endianness in the computer.
> _endian=big; _endian = big > vnumR ieps; > readbin(file1.dat,"%u",ieps);
Next: _hist, Previous: _endian, Up: Variables globales [Contents][Index]
_graph = gnuplot
;
_graph = grace
;
Specify if the plot, replot, plotps, plotf commands will use the grace or gnuplot (see Graphiques) software to display graphics.
Default value = gnuplot
.
> _graph = grace; _graph = grace > _graph = gnuplot; _graph = gnuplot
Next: _history, Previous: _graph, Up: Variables globales [Contents][Index]
_hist
{on
,off
};
Specify if the file history.trip is opened or not.
If the file is opened, all commands are stored in this file.
Default value = on
.
>_hist; _hist = ON
Next: _info, Previous: _hist, Up: Variables globales [Contents][Index]
_history =
<string> ;
Specify the folder where the file history.trip will be written.
Default value = "".
> _history="/users/toto/"; _history = /users/toto/
Next: _integnum, Previous: _history, Up: Variables globales [Contents][Index]
_info
{on
,off
};
Enable or disable the display of the message information.
Default value = on
.
> _modenum=NUMQUAD; _modenum = NUMQUAD > x1=0,2*pi,2*pi/59$ > x2=0,3,0.5$ > _info off; _info off > sl=interpol(LINEAR,x1,cos(x1),x2)$ > _info on; _info on > sl=interpol(LINEAR,x1,cos(x1),x2)$ Information : interpol perform computations in double precision.
Next: _language, Previous: _info, Up: Variables globales [Contents][Index]
_integnum
= {DOPRI8
,ODEX1
,ADAMS
};
Defines the numerical integrator used by the numerical integration performed by integnum
(see integnum) and integnumfcn
(see integnumfcn).
Default value = DOPRI8
.
> _integnum=ODEX1; _integnum = ODEX1 > _integnum=DOPRI8; _integnum = DOPRI8
Next: _mode, Previous: _integnum, Up: Variables globales [Contents][Index]
_language
= {fr, en };
Select the language to display messages.
Default value =
> _language = en ; _language = en > Exp(x, y); TRIP[ 3 ] : This parameter must be an integer Command :' Exp(x, y);' ^ > _language = fr; _language = fr > Exp(x, y); TRIP[ 3 ] : Cet argument doit etre un entier Commande :'Exp(x, y);'
Next: _modenum, Previous: _language, Up: Variables globales [Contents][Index]
_mode =
{POLY
, POLP
, POLYV
, POLPV
};
Specify the internal representation of the series for their storage in the memory and during the computations.
The internal representation could be changed during the computations.
Default value = POLY
.
> _mode=POLY; _mode = POLY > s1=(1+x)^100$ > s2=1+x^100$ > bilan mem; Nom Memoire (octets) Nb de termes -------------------- -------------------- -------------------- s1 4848 101 s2 96 2 -------------------- -------------------- -------------------- 4944 103 Memoire physique utilisee = 7118848 octets Memoire maximale utilisee = 2783817728 octets > _mode=POLP; _mode = POLP > s1=(1+x)^100$ > s2=1+x^100$ > bilan mem; Nom Memoire (octets) Nb de termes -------------------- -------------------- -------------------- s1 3232 101 s2 3232 2 -------------------- -------------------- -------------------- 6464 103 Memoire physique utilisee = 7208960 octets Memoire maximale utilisee = 2784210944 octets > _mode=POLY$ time_s; s1=(1+x)^100$ time_t; 00.240s - ( 47.74% CPU) > _mode=POLP$ time_s; s1=(1+x)^100$ time_t; 00.013s - ( 40.57% CPU)
Next: _modenum_prec, Previous: _mode, Up: Variables globales [Contents][Index]
_modenum =
{NUMDBL
, NUMRAT
, NUMRATMP
, NUMQUAD
, NUMFPMP
};
Specify the representation of the numerical coefficients in the series and the precision of the floating point numbers in the numerical vectors or matrices.
This mode could be changed during the session.
Default value = NUMDBL
.
The numerical coefficients are encoded as followed :
The absolute value for the numerator and denomiator is between 0 et 2**62 on most computers. If the numerator or denomiator becomes too large, rational number is converted in a double precision floating-point.
The real numbers are stored in double precision format. For example, the coefficient "2.0" will be stored as a double precision floating-point while the coefficient "2" is stored as a rational number.
The absolute value for the numerator and denomiator don’t have any limits.
The real numbers are stored in double precision format. For example, the coefficient "2.0" will be stored as a double precision floating-point while the coefficient "2" is stored as a rational number.
This numerical representation uses the GMP library (type mpz_t or mpq_t). On the 64 bit operating systems, integers smaller than 2^63-1 (in absolute value) use the hardware instructions instead of the GMP library.
The number of number of digits of precision is specified by the global variable _modenum_prec
(see _modenum_prec).
This numerical representation uses the MPFR and the MPC library.
In the mode NUMRAT and NUMRATMP, numerical vectors or matrices contain always double precision floating-points (real or complex numbers).
> _affc=4; _affc = 4 > _modenum=NUMDBL; _modenum = NUMDBL > s=1/11; s = 0.0909090909090909 > _modenum=NUMRAT; _modenum = NUMRAT > s=1/11; s = 1/11 > _modenum=NUMFPMP; _modenum = NUMFPMP > pi; 3.1415926535897932384626433832795028841971693993751058209749445924
Next: _naf_dtour, Previous: _modenum, Up: Variables globales [Contents][Index]
_modenum_prec =
<integer> ;
Variable used if _modenum = NUMFPMP
(see _modenum).
Specify the number of significant decimal digits for the multiprecision real numbers.
Default value = 64.
> _modenum=NUMFPMP; _modenum = NUMFPMP > _modenum_prec= 20; _modenum_prec = 20 > pi; 3.14159265358979323846 > _modenum_prec= 40; _modenum_prec = 40 > pi; 3.1415926535897932384626433832795028841975
Next: _naf_icplx, Previous: _modenum_prec, Up: Variables globales [Contents][Index]
_naf_dtour =
<real> ;
Variable used by naf (see Analyse en frequence).
Specify the "length of the dial turn ".
Default value = 2*pi.
> _naf_dtour=360;
Next: _naf_iprt, Previous: _naf_dtour, Up: Variables globales [Contents][Index]
_naf_icplx
= {0, 1};
Variable used by naf (see Analyse en frequence).
Specify if the function is real or complex.
Default value = 1.
The available values are :
> _naf_icplx=0;
Next: _naf_isec, Previous: _naf_icplx, Up: Variables globales [Contents][Index]
_naf_iprt =
{-1 , 0, 1, 2};
Variable used by naf (see Analyse en frequence).
Specify the verbosity to display messages in the commands naf
and naftab
. Intermediate results are stored in a file.
Default value = -1.
The available values are :
> _naf_iprt = 2;
Next: _naf_iw, Previous: _naf_iprt, Up: Variables globales [Contents][Index]
_naf_isec =
{0, 1};
Variable used by naf (see Analyse en frequence).
Specify if the algorithm "secantes" is used or not in the commands naf
and naftab
.
Default value = 1.
The available values are :
> _naf_isec=1;
Next: _naf_nulin, Previous: _naf_isec, Up: Variables globales [Contents][Index]
_naf_iw =
<integer> ;
Variable used by naf (see Analyse en frequence).
Specify if a window filter is set.
Default value = 1.
The available values are :
avec CE= 0.22199690808403971891E0
> _naf_iw=-1;
Next: _naf_tol, Previous: _naf_iw, Up: Variables globales [Contents][Index]
_naf_nulin =
<integer> ;
Variable used by naf (see Analyse en frequence).
Specify the number of lines to be ignored at the beginning of the data file.
Default value = 1.
> _naf_nulin=0;
Next: _path, Previous: _naf_nulin, Up: Variables globales [Contents][Index]
_naf_tol =
<real> ;
Variable used by naf (see Analyse en frequence).
Specify the tolerance to check if two frencuencies are equal.
Default value = 1E-10.
> _naf_tol=1E-4;
Next: _quiet, Previous: _naf_tol, Up: Variables globales [Contents][Index]
_path =
<string> ;
_path =
"path directory";
Specify the folder used to save or load files. All TRIP commands or functions writing or reading files will prepend the filename with this path. loading trip programs (include), creating psotscript files(plotps) and plotting files (plotf) will use this path.
Default value = "" (current folder).
Remarque :
_path = "/u/gram/trip/"; /* UNIX */ _path = "\u\gram\trip\"; /* WINDOWS */
Next: _read, Previous: _path, Up: Variables globales [Contents][Index]
_quiet
{on
,off
};
Remove, respectively enable, the future display produced by the commands followed by ;
, only in the current macro.
Default value = off
.
> macro silence{ s=1; _quiet on; s=pi; }; > %silence; s = 1 > stat(s); constante has name s and has the value 3.141592653589793
Next: _read_history, Previous: _quiet, Up: Variables globales [Contents][Index]
_read
= ( );
_read
= ( "skipbrokenlines", "skipemptylines"
);
_read
is a list of no, one or more strings which specify the behavior of the functions read
and file_read
when an empty or partial line is encountered.
_read = ()
specifies that these functions will generate an error when such lines are encountered.
Les valeurs possibles sont :
Default value = ()
.
> t1=1,3; t1 double precision real vector : number of elements =3 > t2=11,13; t2 double precision real vector : number of elements =3 > f=file_open(temp001, write); f = file "temp001" opened in write mode > file_writemsg(f,"# header line\n"); > file_write(f,t1); > file_writemsg(f,"err...\n"); > file_write(f,t2); > file_close(f); > _read= ( "skipbrokenlines"); _read = ( "skipbrokenlines" ) > vnumR Q; > read(temp001, Q); Information : The line 1 is ignored : the line is incomplete or invalid Information : The line 5 is ignored : the line is incomplete or invalid > writes(Q); +1.0000000000000000E+00 +2.0000000000000000E+00 +3.0000000000000000E+00 +1.1000000000000000E+01 +1.2000000000000000E+01 +1.3000000000000000E+01
Next: _time, Previous: _read, Up: Variables globales [Contents][Index]
_read_history
= <string> ;
_read_history
specifies the name of the file in which the skipped errors by _read are recorded.
This file is emptied when this variable is assigned.
Each line of this ascii file contains two columns: the line number and the name of the file where the error is produced.
_read_history = ""
specifies that the skipped errors by _read are not recorded in a file.
Default value = ""
.
> t1=1,3; t1 double precision real vector : number of elements =3 > t2=11,13; t2 double precision real vector : number of elements =3 > f=file_open(temp001, write); f = file "temp001" opened in write mode > file_writemsg(f,"# header line\n"); > file_write(f,t1); > file_writemsg(f,"err...\n"); > file_write(f,t2); > file_close(f); > _read=( "skipbrokenlines"); _read = ( "skipbrokenlines" ) > _read_history="errors.dat"; _read_history = "errors.dat" > vnumR Q; > read(temp001, Q); Information : The line 1 is ignored : the line is incomplete or invalid Information : The line 5 is ignored : the line is incomplete or invalid > vnumR lerr; > fmt="%g %s"; fmt = "%g %s" > read("errors.dat", fmt, lerr, ferr); > writes("%g\n",lerr); 1 5 > afftab(ferr); ferr[1] = "temp001" ferr[2] = "temp001"
Next: _userlibrary_path, Previous: _read_history, Up: Variables globales [Contents][Index]
_time
{on
, off
};
enable or disable display of partial time after each executed command.
When the command _time on
is performed, an implicit call to time_s
and the time 0.00s is always displayed after it.
Default value = off
.
> macro temps { s=(1+x+y+z)**20$ _time on; s=(1+x+y+z)**20$ q=s$ _time off; }; > %temps; 00.0s 08.10s 00.12s >
Next: I, Previous: _time, Up: Variables globales [Contents][Index]
_userlibrary_path =
<string> ;
_userlibrary_path =
"path to the user functions";
When this variable is assigned, TRIP reads recursively the specified directory all the file with the extension .t.
It loads all the macros which are preceded by a comment starting by //!trip extern_function
and renders them as functions to the user.
The format of this comment :
//!trip extern_function name_of_the_function attribute="parameter_attribute" "parameter_inout"
The string parameter_attribute
may contain the following keywords separated by a comma. if this string is empty, then the the function is visible by the user.
parametres_inout
must contain the same number of elements as the number of parameter of the function.
Each element are separated with a comma. An element could have the following values :
Several macros may have the same value name_of_the_function
if they have a different number of parameters.
Default value = ""
.
_userlibrary_path="./myuserlibrary/"; userfunc1(3); userfunc2(3,y);
The directorty myuserlibrary contains the following file :
//!trip extern_function userfunc1 "in" macro userfunc1[x] { return 2*x+1; }; //!trip extern_function userfunc2 "in,out" macro userfunc2[x,y] { y=2*x+1; };
Next: PI, Previous: _userlibrary_path, Up: Variables globales [Contents][Index]
i^2 = -1
>z = x + y*i; z(x,y) = (0+i*1)*y+1*x
Previous: I, Up: Variables globales [Contents][Index]
The mathematical symbol pi
>z = pi; 3.14159265358979
Next: Series, Previous: Variables globales, Up: Top [Contents][Index]
• crevar: | ||
• operateurs : |
Next: operateurs, Up: Variables [Contents][Index]
crevar
(<string or name> radical, <integer> indice1, <integer> indice2,...);
Create and return a variable with the name radical+"_"+ indice1 + ... + "_" + indicen.
crevar
(<string or name> radical);
Create and return a variable with the name radical. This function allow to create variables with a non-standard name.
> dimvar t[1:3]; > t[1]:=crevar("t",1); t[1] = t_1 = 1*t_1 > t[3]:=crevar("tab",3,2,1); t[3] = tab_3_2_1 = 1*tab_3_2_1 > afftab(t); t[1] = t_1 = 1*t_1 t[2] = t[3] = tab_3_2_1 = 1*tab_3_2_1 > dimvar u[1:2]; > u[1]:=crevar("\bar{X}"); u[1] = \bar{X} = 1*\bar{X} > u[1]; u[1] = \bar{X} = 1*\bar{X} >
<object identifier> [...] :=
<variable> ;
Create a reference to an existing variable.
> // w is a reference to x > s=(1+x+y)**3$ > w:=x$ > stat(w); Variable x type : 2 ordres : 2 2 2 2 dependances : variables dependant de celle-ci : > deriv(s,w); 3 + 6*y + 3*y**2 + 6*x + 6*x*y + 3*x**2 >
Next: Constantes, Previous: Variables, Up: Top [Contents][Index]
• Operateurs : | ||
• Fonctions usuelles : | ||
• Derivation et integration : | ||
• Division euclidienne : | ||
• Selection : | ||
• Evaluation : |
Next: FoncusSeries, Up: Series [Contents][Index]
TRIP performs the addition (or unary plus), the subtraction (or unary minus), multiplication, or division between series, , variables, numbers and expressions.
To perform the addition, multiplication, subtraction and division of the arrays, the operators are +, *, - and /.
The operators +, *, -, / could be applied on numerical vectors.
The unary + or - could be applied to any type.
Remark : The division by a serie isn’t available.
You should use the function div
to perform the euclidian division.
> s=1+x-y*z+t/2; s(x,y,z,t) = 1 + 1/2*t - 1*y*z + 1*x > _modenum=NUMRATMP; _modenum = NUMRATMP > p=5/3; p = 5/3 > _modenum=NUMQUAD; _modenum = NUMQUAD > p=5/3; p = 1.6666666666666666666666666666666667
<serie> **
<real>
It performs the exponentiation.
It supports integer powers.
The exponentation **-1 on an array, with 2 same dimensions, performs the matrix inversion.
Remarks : The exponentiation, term by term, on arrays isn’t available.
> u=2**3; 8 > z=(1+i)**3; (-2+i*2) > s=(1+x+y)**2; s(y,x) = 1 + 2*x + 1*x**2 + 2*y + 2*y*x + 1*y**2
Next: Derivation et integration, Previous: Operateurs, Up: Series [Contents][Index]
• size : |
Up: FoncusSeries [Contents][Index]
size(
<serie> s )
It returns the number of terms in the serie s.
> s=1+x*y+z*t-i*p; s(x,y,z,t,p) = 1 + (-0-i*1)*p + 1*t*z + 1*y*x > size(s); 4
Next: Division euclidienne, Previous: FoncusSeries, Up: Series [Contents][Index]
• deriv : | ||
• integ : |
Next: integ, Up: Derivation et integration [Contents][Index]
deriv(
<serie> , <variable> )
It computes the total derivative of the serie with respect to one variable .
> s=(1+x+y)**2; s(x,y) = 1 + 2*y + 1*y**2 + 2*x + 2*x*y + 1*x**2 > deriv(s,x); 2 + 2*y + 2*x
Previous: deriv, Up: Derivation et integration [Contents][Index]
integ(
<serie> , <variable> )
It integrates the serie with respect to one variable .
> s=(1+x+y)**2; s(x,y) = 1 + 2*y + 1*y**2 + 2*x + 2*x*y + 1*x**2 > integ(s,x); 1*x + 2*x*y + 1*x*y**2 + 1*x**2 + 1*x**2*y + 1/3*x**3
Next: Selection, Previous: Derivation et integration, Up: Series [Contents][Index]
div(
<serie> f, <serie> g, <object identifier> q, <object identifier> r )
It computes the quotient and the remainder of f divided by g such that f=q\times g +r and degree(r)<degree(g). The quotient is stored in q and the remainder in r.
> div(x^3+x+1, x^2+x+1, q,r); > q; q(x) = - 1 + 1*x > r; r(x) = 2 + 1*x
Next: Evaluation, Previous: Division euclidienne, Up: Series [Contents][Index]
• coef_ext : |
coef_ext(
<serie> , (
<variable> ,
<integer> ),
...)
Return the coefficient of the variable raised to the specified value from the serie.
coef_ext
(S,(X,n),(Y,m)) returns the coefficient of X^n*Y^m in the serie S.
> S= (1+x+y+z)**4 $ > coef_ext(S,(x,1),(y,2)); 12 + 12*z
• coef_num: | ||
• evalnum: |
Next: evalnum, Up: Evaluation [Contents][Index]
coef_num(
<serie> , (
<variable> ,
<constant> ),
...)
Substitute in a serie one (or more) variable(s) by one (or more) numerical value(s).
> S= (1+x+y+z)**4 $ > coef_num(S,(x,0.1),(y,2)); 923521/10000 + 29791/250*z + 2883/50*z**2 + 62/5*z**3 + 1*z**4
Previous: coef_num, Up: Evaluation [Contents][Index]
evalnum(
<serie> ,
{REAL
/COMPLEX
} , (
<variable> ,
<num. vec.> ),
...)
Evaluates the serie with substituting all variables by their value in the associated numerical vectors.
The function returns a numerical vector of real numbers if REAL
is specified
or else a numerical vector of complex numbers COMPLEX
is specified.
All numerical vectors must have the same size.
> serie=sin(x+y)-2*y; serie(y,_EXy1,_EXx1) = ( -0+i* 0.5)*_EXy1**-1*_EXx1**-1 + ( 0-i* 0.5)*_EXy1*_EXx1 - 2*y > TABX=0,pi,pi/6; TABX double precision real vector : number of elements =7 > TABY=-pi,0,pi/6; TABY double precision real vector : number of elements =7 > TABRES=evalnum(serie,REAL,(x,TABX),(y,TABY)); TABRES double precision real vector : number of elements =7 > writes(TABRES); +6.2831853071795862E+00 +4.3699623521985504E+00 +3.3227648010019526E+00 +3.1415926535897931E+00 +2.9604205061776341E+00 +1.9132229549810371E+00 +1.2246467991473532E-16 > writes(TABX); +0.0000000000000000E+00 +5.2359877559829882E-01 +1.0471975511965976E+00 +1.5707963267948966E+00 +2.0943951023931953E+00 +2.6179938779914940E+00 +3.1415926535897931E+00 > TABRES=evalnum(serie,COMPLEX,(x,TABX),(y,TABY)); TABRES Double precision complex vector : number of elements =7 > writes(TABRES); +6.2831853071795862E+00 +1.4997597826618576E-32 +4.3699623521985504E+00 +0.0000000000000000E+00 +3.3227648010019526E+00 +0.0000000000000000E+00 +3.1415926535897931E+00 +0.0000000000000000E+00 +2.9604205061776341E+00 -5.5511151231257827E-17 +1.9132229549810371E+00 +5.5511151231257827E-17 +1.2246467991473532E-16 +0.0000000000000000E+00 >
• Fonctions usuelles : | ||
• Entree/Sortie sur les reels : |
Next: Entree/Sortie sur les reels, Up: Constantes [Contents][Index]
Most of the functions are described in (see Vecteurs numeriques).
• fac : | factoriel. |
fac(
<integer> n);
Return n! (factorial function).
> fac(3); 6 > n=5; n = 5 > fac(n+1); 720 >
Previous: Fonctions usuelles des Constantes, Up: Constantes [Contents][Index]
These functions perform the sequential writing and reading of a text file containing only real values.
ecriture(
<filename> );
Open a file in writing mode in the folder specified by _path
.
If the file doesn’t exist, it will be automatically created.
> ecriture("fichier1.dat");
lecture(
<filename> );
Open a file in reading mode in the folder specified by _path
.
> lecture("fichier1.dat");
print(
<real> );
Write a double-precision floating-point number in the file opened (with the command ecriture
).
> ecriture("fichier1.dat"); > print(atan(1)); /* on écrit pi/4 dans fichier1.dat */
read;
Read a floating-point number in the file opened (with the command lecture
) and return a double-precision floating-point number.
> ecriture("fichier1.dat"); > print(atan(1)); > close; > lecture("fichier1.dat"); > s=read; s = 0.785398163397448 > close;
close;
Close the file of real numbers if it has been opened (for reading or writing).
> ecriture("fichier1.dat"); > print(atan(1)); > close;
Next: Tableaux, Previous: Constantes, Up: Top [Contents][Index]
• Declaration et affectation : | ||
• Concatenation : | ||
• Repetition : | ||
• Extraction : | ||
• Comparaison : | ||
• str : | Convert an integer or a real to a string. | |
• msg : | Convert a list of integers or reals to a string. | |
• coef_num : | Convert a string to an integer or a real. | |
• size : | Length of the strings. |
Next: Concatenation, Up: Chaines [Contents][Index]
Character string’s declaration is implicit. It will be realized when assignment are performed. To produce double-quote (") in a string, you must double it.
<nom> =
<string> ;
/* L'exemple suivant declare les chaines ch et ch2. */ > ch="file"; ch = "file" > ch2=ch+".txt"; ch2 = "file.txt"
Next: Repetition, Previous: Declaration et affectation, Up: Chaines [Contents][Index]
<nom> = <string> +
<string> ;
Operator + concatenates two character strings. Length of string isn’t limited.
> ch = "file" + "1"; ch = "file1" > sch = "../" + ch; sch = "../file1" > sch1 = sch + "." + str(12); sch1 = "../file1.12"
Next: Extractionstring, Previous: Concatenation, Up: Chaines [Contents][Index]
<string> *
<integer>
<integer> *
<string>
Operator * takes an character string and duplicate it as many times as specified by the integer. The integer must be positive or nul. If the integer is 0, then an empty string is returned.
> s=" %g"; s = " %g" > format=4*s+"\n"; format = " %g %g %g %g\n" > t=1,10$ > writes(format, t,t**2, t**3, t**4);
Next: Comparaison, Previous: Repetition, Up: Chaines [Contents][Index]
<string> [
<integer> j ]
Return the value of the element specified by the index j. The index starts at 1.
<string> [
<integer> binf :
<integer> bsup ];
Return an array containing only the elements located between the lower and uper bounds with the specified step.
If the lower bound is omitted then its value is assumed to be 1. If the upper bound is omitted then its value is assumed to be the length of the string.
Remarks : any combination of omission are permitted.
> s="bonjour"; s = "bonjour" > s1=s[4]; s1 = "j" > s2=s[:3]; s2 = "bon" > s3=s[4:5]; s3 = "jo" >
Next: str, Previous: Extractionstring, Up: Chaines [Contents][Index]
<string> ==
<string>
The Operator == returns true if the strings of characters are equal else it returns false.
> s="monchemin"; s = "monchemin" > if (s=="monchemin") then { msg "true"; } else { msg "false"; }; true >
<string> !=
<string>
The Operator != returns false if the strings of characters are equal else it returns true.
> s="monchemin"; s = "monchemin" > if (s=="MON") then { msg "true"; } else { msg "false"; }; false >
<string> s1 <
<string> s2
The Operator < returns true if s1 is less than s2 using the lexicographic order else it returns false.
> s="abc"; s = "abc" > if (s<"abd") then { msg "true"; } else { msg "false"; }; true >
<string> s1 <=
<string> s2
The Operator <= returns true if s1 is less than or equal to s2 using the lexicographic order else it returns false.
> s="abc"; s = "abc" > if (s<="abe") then { msg "true"; } else { msg "false"; }; true >
<string> s1 >
<string> s2
The Operator > returns true if s1 is greater than s2 using the lexicographic order else it returns false.
> s="abc"; s = "abc" > if (s>"abd") then { msg "true"; } else { msg "false"; }; false >
<string> s1 >=
<string> s2
The Operator >= returns true if s1 is greater than or equal to s2 using the lexicographic order else it returns false.
> s="abc"; s = "abc" > if (s>="abe") then { msg "true"; } else { msg "false"; }; false >
Next: msgstring, Previous: Comparaison, Up: Chaines [Contents][Index]
str
( <integer> );
str
( <real> );
str
( <serie> );
str
( <string> format, <real> );
Convert an integer, a real number or an object in a character string. If format is specified, then the integer or real number is converted to this format. The format specification is similar to that for the printf function of the C-language.
The conversion specifiers are
The length modifier aren’t supported. For example, the format "%lg" will be rejected and produce an error.
If the numerical mode NUMRAT or NUMRATMP is selected, then the rational numbers as written as "numerator/denominator" if no format are specified.
> ch = str(1235); ch = "1235" > ch = str(int(2*pi)); ch = "6" > s = str(2E3); s = "2000" > s = str("%.4g",pi); s = "3.142" > _modenum = NUMRATMP; _modenum = NUMRATMP > s = str("%d", 3/2); s = "3/2" > s = str("%g", 3/2); s = "1.5" > s = str(1+x**2); s = " 1 + 1*x**2 " >
Next: coef_numstring, Previous: str, Up: Chaines [Contents][Index]
msg(
<string> textformat,
<real> x,
... );
Create a string using the format with the real constants.
The format is the same as the command printf in language C (see str, for the valid conversion specifiers). This format must be a string and could be on several lines.
To create a double-quotes, two double-quotes must be used.
> ch = msg("pi=%g pi=%.8E",pi,pi); ch = "pi=3.14159 pi=3.14159265E+00" > _modenum=NUMRATMP; _modenum = NUMRATMP > s=msg("%d %g", 1/11, 1/11); s = "1/11 0.0909091"
Next: sizestring, Previous: msgstring, Up: Chaines [Contents][Index]
coef_num
( <string> );
It converts a character string to an integer or a real number.
> d = coef_num("-42"); d = -42 > r = coef_num("3.14E0"); r = 3.14 >
Previous: coef_numstring, Up: Chaines [Contents][Index]
size
( <string> );
it computes the length of the string, that is to compute the number of characters.
> ch = "1235"; ch = "1235" > size(ch); 4
Next: Structures, Previous: Chaines, Up: Top [Contents][Index]
TRIP has 4 types of arrays :
Matrix are arrays of series and constants. For the numerical vectors or matrices, see the appropriate chapter.
• dim : | Declaration de tableaux de series. | |
• Initialisation d'un tableau de series : | ||
• dimvar : | Declaration de tableaux de variables. | |
• Initialisation d'un tableau de variables : | ||
• tabvar : | Generation d’un tableau de variables. | |
• Affectation dans un tableau : | ||
• Taille d'un tableau : | ||
• Bornes d'un tableau : | ||
• afftab : | Affichage d’un tableau. | |
• Extraction d'element : | ||
• Operations sur les tableaux de series : | ||
• Conversion : |
Next: Initialisation d'un tableau de series, Up: Tableaux [Contents][Index]
dim
<name> [ <list of dimension> ], ...;
Define one or more array of series with the specified dimensions.
Each dimension is separated with a comma.
A dimension is defined with two integers, separated by the character :
which specifiy the index of the first element, the index of the last element, and the step for this dimension. If the third integer is missing, the step is 1.
The dimensions may stored in an object identifier.
This type of array can contain series, constants, truncatures, strings of characters... but no variables.
> // It defines the array tl of series or numbers > // with two dimensions > dim tl [1:22,-2:6]; > // it defines 3 arrays t1, t2 , t3 with different bounds > bounds1 = 1:4; bounds1 = bounds [ 1:4 ] > dim t1[bounds1], t2[5:6], t3[-1:3]; > // it defines an array with a step not equal to 1 > dim t5[1:5:2]; > t5[:]=7; > afftab(t5); t5[1] = 7 t5[3] = 7 t5[5] = 7 >
<name> = [<serie> ,... : <serie> , ...];
<name> = dim[<serie> ,... : <serie> , ...];
Create and intialize an array of series with the specified series and constants.
The symbol :
specifies a new line and the symbol ,
separates the colmuns. It must have the same number of columns on each line.
> // define a 2-dimensional array which contains polynomials > tab=[1,2+2*x:(1+x)**2,(2+2*x)**2]; tab [1:2, 1:2 ] number of elements = 4 > stat(tab); Array of series tab [ 1:2 , 1:2 ] list of array's elements : tab [ 1 , 1 ] = constante has name tab and has the value 1 tab [ 1 , 2 ] = serie tab ( x ) number of variables : 1 size of the descriptor : 80 bytes number of terms : 2 size : 304 bytes tab [ 2 , 1 ] = serie tab ( x ) number of variables : 1 size of the descriptor : 80 bytes number of terms : 3 size : 352 bytes tab [ 2 , 2 ] = serie tab ( x ) number of variables : 1 size of the descriptor : 80 bytes number of terms : 3 size : 352 bytes > // define a 2-dimensional array which contains numbers > tab2=[1,2,3:4,5,6]; tab2 [1:2, 1:3 ] number of elements = 6 >
Next: Initialisation d'un tableau de variables, Previous: Initialisation d'un tableau de series, Up: Tableaux [Contents][Index]
dimvar
<name> [ <list of dimension> ], ...;
Define one or more array of variables with the specified dimensions.
Each dimension is separated with a comma. A dimension is defined with two integers which specifiy the index of the first element and the index of the last element for this dimension.
To assign a existing variable to an array of variables, you should the symbol :=
instead of =
.
> // define the array of variables t2 with one dimension > dimvar t2[1:5]; > t2[1] := x; t2[1] = x = 1*x > // we obtain the derivative of S by x. > S=1+3*x$ > deriv(S,t2[1]); 3 > > // we define 2 arrays of variables tv1 and tv2 > dimvar tv1[1:2], tv2[1:3]; >
<name> = dimvar[<serie> ,... : <serie> , ...];
Create and intialize an array of variables with the specified variables.
The symbol :
specifies a new line and the symbol ,
separates the colmuns. It must have the same number of columns on each line.
> // define the array of variables t2 with the variables x, y, z and u > 1+x+y+z$ > t2 = dimvar[x:y:z:u]; t2 [1:4 ] number of elements = 4 >
Next: Affectation dans un tableau, Previous: Initialisation d'un tableau de variables, Up: Tableaux [Contents][Index]
tabvar
( <array of variables> );
Generate automatically the variables inside the specified array. The name of variables use the name of the array as radical and its indice.
> dimvar t[0:3]; > tabvar(t); > afftab(t); t[0] = t_0 = 1*t_0 t[1] = t_1 = 1*t_1 t[2] = t_2 = 1*t_2 t[3] = t_3 = 1*t_3 >
Next: Taille d'un tableau, Previous: tabvar, Up: Tableaux [Contents][Index]
<name> =
<array> ;
Assign the array (operation between arrays) to the specified object identifier.
<array> [<integer> , ...] =
<operation> ;
Assign a value to an element of an array. This operation can be a serie, a constant, a numerical vector, a truncature but not an array.
<array> [
<integer> binf :
<integer> bsup :
<integer> pas ,...]=
<operation> ;
<array> [
<integer> binf :
<integer> bsup ,...]=
<operation> ;
Assign a value to a part of an array.
If the operation is a serie, a constant, a numerical vector, a truncature then the value is copied to each element of this part of array. If the operation is an array then each element of this array will be assigned to the corresponding element. In this case, it verifies that the number of elements and dimension is compatible.
If the lower bound is omitted then its value is assumed to be 1. If the upper bound is omitted then its value is assumed to be the size of the array. If the step is omitted then its value is assumed to be 1.
When the number of dimension is unknown or variable, the variadic statement ... could be provided as the last argument in order to specify an undefined number of :,:,:.
Remarks : any combination of omission are permitted.
> _affc=1$ > dim t[1:4,7:25]; > t[1,7]=1+x; t[1,7] = 1 + 1*x > r=t; r [1:4, 7:25 ] number of elements = 76 > dim t[1:4,7:25]; > dim t2[1:4]; > t2[:]=5; > t[:,8]=t2; > t[:,::2]=1+x; > t[2,...]=3; >
<array> [...] :=
<variable> ;
Assign a variable to an array of variables.
> dimvar X[1:4]; > X[1]:=crevar("e",1,1); X[1] = e_1_1 = 1*e_1_1 > deriv(1+2*e_1_1,X[1]); 2 >
Next: Bornes d'un tableau, Previous: Affectation dans un tableau, Up: Tableaux [Contents][Index]
size
(<array> );
size
(<array> ,<integer> );
Return the number of elements in the first dimension of the array or in the specified dimension by the integer.
If the specified dimension doesn’t exist in the array then the function returns -1.
> dim t[1:4,7:25]; > size(t,2); 19 > size(t); 4 >
num_dim(
<array> t)
It returns the number of dimensions of the array t.
> dim t1[1:5]; > size(t1); 5 > dim t2[1:22,-2:6]; > size(t2); 22 >
Next: afftab, Previous: Taille d'un tableau, Up: Tableaux [Contents][Index]
inf
(<array> ,<integer> );
Return the lower bound of the array of the specified dimension by the integer.
If the specified dimension doesn’t exist in the array then the function returns -1.
> dim t[1:2,0:3]; > inf(t,2); 0 > for k=inf(t,2) to sup(t,2) { t[:,k]= k$ }; > afftab(t); t[1,0] = 0 t[1,1] = 1 t[1,2] = 2 t[1,3] = 3 t[2,0] = 0 t[2,1] = 1 t[2,2] = 2 t[2,3] = 3 >
sup
(<array> ,<integer> );
Return the upper bound of the array of the specified dimension by the integer.
If the specified dimension doesn’t exist in the array then the function returns -1.
> dim t[1:2,0:3]; > sup(t,2); 3 > for k=inf(t,1) to sup(t,1) { t[k,:]= k$ }; > afftab(t); t[1,0] = 1 t[1,1] = 1 t[1,2] = 1 t[1,3] = 1 t[2,0] = 2 t[2,1] = 2 t[2,2] = 2 t[2,3] = 2 >
Next: Extraction d'element, Previous: Bornes d'un tableau, Up: Tableaux [Contents][Index]
afftab
(<array> );
Display the content of the arrays of series or variables.
> _affc=1$ > dim t[1:4]; > t[1]=1+x$ > t[2]=2*i$ > t[3]=({(x,y),2})$ > afftab(t); t[1] = 1 + 1*x t[2] = (0+i*2) t[3] = ({(y, x), 2}) t[4] = >
Next: Operations sur les tableaux de series, Previous: afftab, Up: Tableaux [Contents][Index]
<array> [
<integer> ,...]
;
Return the value of the element specified by the indexes.
<num. vec.> [
<integer> binf :
<integer> bsup :
<integer> pas,... ];
<num. vec.> [
<integer> binf :
<integer> bsup, ... ];
Return an array containing only the elements located between the lower and uper bounds with the specified step.
If the lower bound is omitted then its value is assumed to be the lower bound of that dimension of this array. If the upper bound is omitted then its value is assumed to be the upper bound of that dimension of this array. If the step is omitted then its value is assumed to be 1.
When the number of dimension is unknown or variable, the variadic statement ... could be provided as the last argument in order to specify an undefined number of :,:,:.
Remarks : any combination of omission are permitted.
> _affc=1$ > dim t[1:4]; > t[1]=1+x$ > s=t[1]; s(x) = 1 + 1*x > t1=t[3:]; t1 [3:4 ] number of elements = 2 > dim t[1:4,5:10]; > v2=t[:,6:]; v2 [1:4, 6:10 ] number of elements = 20 > v3=t[4,...]; v3 [5:10 ] number of elements = 6
select (
<condition> ,
<array> );
Return an array which only contains the elements of the array where the condition is true.
If the condition is always false, the function returns the consnt number 0. To test if the consant value 0 was returned, the following code could be used :
if (size(result)==0) then { ... } else { ... }
The condition and the array must have the same number of elements and only one diemnsion size.
> // extract from tm the elmeents such that t1[j]=1 > _modenum=NUMRATMP; _modenum = NUMRATMP > dim t1[1:5], tm[1:5]$ > for j=1 to 5 { t1[j]=abs(3-j)$ tm[j]=(1+x)**j$ }; > q = select(t1==1, tm); q [1:2 ] number of elements = 2 > if (size(q)!=0) then { afftab(q); }; q[1] = 1 + 2*x + 1*x**2 q[2] = 1 + 4*x + 6*x**2 + 4*x**3 + 1*x**4 >
Next: ConversionTab, Previous: Extraction d'element, Up: Tableaux [Contents][Index]
Most of the functions are described in (see Vecteurs numeriques). The following functions could be applied on the arrays of series (as on the series) to avoid the loops for :
• Produit matriciel: | ||
• det: | ||
• inverse d'une matrice: | ||
• eigenvalues: | ||
• eigenvectors: | ||
• Arithmetique: |
Next: det, Up: Operations sur les tableaux de series [Contents][Index]
<array> &*
<array>
Compute the matrix product of the arrays (with 1 or 2 dimensions).
If the array has only one dimension then it’s considered as a column-vector.
Remark : the number of columns of the first array must be same as the number of lines of the second array.
> _affc=1$ _affdist=0$ > t=[x,y:x-y,x+y]$ > t2=[x+y,x-y:x,y]$ > r=t&*t2; r [1:2, 1:2 ] number of elements = 4 > afftab(r); r[1,1] = 2*y*x + x**2 r[1,2] = y**2 - y*x + x**2 r[2,1] = - y**2 + y*x + 2*x**2 r[2,2] = 2*y**2 - y*x + x**2 >
Next: inverse d'une matrice, Previous: Produit matriciel, Up: Operations sur les tableaux de series [Contents][Index]
det
( <array> M )
det
( <array> M,
<string> method )
Computes the determinant of a matrix. The array must have two dimensions.
If method is specified, it uses that algorithm to compute the determinant if the content of the matrix allows it. In other case, the determinant is computed using the default algorithm.
The available values for method are :
> t=[9,0,7 :1,2,3 :4,5,6]; t [1:3, 1:3 ] number of elements = 9 > det(t); -48 >
Next: eigenvalues, Previous: det, Up: Operations sur les tableaux de series [Contents][Index]
<array> **-1
Computes the inverse of a matrix. The array must have two dimensions.
Remarks : When computations are performed in double precision, the Lapack Library is used. The LU algorithm is used in all numerical precision.
> _modenum=NUMRATMP$ > t=[9,0,7 :1,2,3 :4,5,6]; t [1:3, 1:3 ] number of elements = 9 > r=t**-1; r [1:3, 1:3 ] number of elements = 9 > afftab(r); r[1,1] = 1/16 r[1,2] = - 35/48 r[1,3] = 7/24 r[2,1] = - 1/8 r[2,2] = - 13/24 r[2,3] = 5/12 r[3,1] = 1/16 r[3,2] = 15/16 r[3,3] = - 3/8 >
Next: eigenvectors, Previous: inverse d'une matrice, Up: Operations sur les tableaux de series [Contents][Index]
eigenvalues
(<array> )
Compute the eigenvalues of the 2-dimensional array (square matrix) using a QR algorithm (lapack library).
> t=[9,0,7 :1,2,3 :4,5,6]; t [1:3, 1:3 ] number of elements = 9 > l=eigenvalues(t); l [1:3 ] number of elements = 3 > afftab(l); l[1] = 13.76915041895731 l[2] = 4.084362034809442 l[3] = -0.8535124537667539
Next: Arithmetique, Previous: eigenvalues, Up: Operations sur les tableaux de series [Contents][Index]
eigenvectors
(<array> MAT, <array> TVECT, <array> TVAL)
eigenvectors
(<array> MAT, <array> TVECT)
Compute the eigenvectors of the 2-dimensional array MAT (square matrix) using a QR algorithm (lapack library). It stores the eigenvectors in the array TVECT and the eigenvalues in the array TVAL.
> t=[9,0,7 :1,2,3 :4,5,6]; t [1:3, 1:3 ] number of elements = 9 > eigenvectors(t,vectp,valp); > afftab(vectp); vectp[1,1] = -0.8081690381494434 vectp[1,2] = -0.7505769919446202 vectp[1,3] = -0.4846638559537327 vectp[2,1] = -0.209021306608322 vectp[2,2] = 0.3985224414326275 vectp[2,3] = -0.5474094124384613 vectp[3,1] = -0.550611386696964 vectp[3,2] = 0.5270806796287867 vectp[3,3] = 0.6822344772186747 > afftab(valp); valp[1] = 13.76915041895731 valp[2] = 4.084362034809442 valp[3] = -0.8535124537667539 > // first vector > p=vectp[:,1]$ > afftab(p); p[1] = -0.8081690381494434 p[2] = -0.209021306608322 p[3] = -0.550611386696964
Previous: eigenvectors, Up: Operations sur les tableaux de series [Contents][Index]
The arrays must have the same number of elements on each dimension and the number of dimension must be the same.
<array> + <array>
Add term by term two arrays of series.
<array> + <serie>
<serie> + <array>
Add a serie with each element of the array of series.
<array> * <array>
Multiply term by term two arrays of series.
<array> * <serie>
<serie> * <array>
Multiply a serie with each element of the array of series.
<array> - <array>
Substract term by term two arrays of series.
<array> - <serie>
<serie> - <array>
Subtract a serie with each element of the array of series.
<array> / <array>
Divide term by term two arrays of series.
<array> / <serie>
<serie> / <array>
Divide a serie with each element of the array of series.
> _affc=1$ > t2=[x+y,x-y:x,y]; t2 [1:2, 1:2 ] number of elements = 4 > t=[x,y:x-y,x+y]; t [1:2, 1:2 ] number of elements = 4 > r=t*t2*i-t*x; r [1:2, 1:2 ] number of elements = 4 > afftab(r); r[1,1] = (0+i*1)*x*y + (-1+i*1)*x**2 r[1,2] = (-0-i*1)*y**2 + (-1+i*1)*x*y r[2,1] = (1-i*1)*x*y + (-1+i*1)*x**2 r[2,2] = (0+i*1)*y**2 + (-1+i*1)*x*y - 1*x**2 >
Previous: Operations sur les tableaux de series, Up: Tableaux [Contents][Index]
For the convertion to numerical vectors, (see Conversion).
Next: Vecteurs numeriques, Previous: Tableaux, Up: Top [Contents][Index]
• Type declaration : | ||
• Object identifier declaration : | ||
• Access to member attributes : | ||
• Display : | ||
• Constructor macro : | ||
• Member macros : |
The data structures contain other values indexed by their names. These fields may have a global or private visibility. The macros can be associated to these data structures. These macros may access to all the fields.
Next: Object identifier declaration, Up: Structures [Contents][Index]
struct
<structtype> { <list of parameters> ; private
<list of parameters> ; };
struct
<structtype> { <object identifier> = <value> ; ... private
<object identifier> = <value> ; private ...
};
It defines a new type of records whose fields of the first list can be accessed globally and the other list which follows the keyword private
can only be accessed by an associated macro.
The fields my be initialized to a defaut value.
> // declaration of the type POINT > struct POINT { x, y; }; > > // declaration of the type MyData > struct MyData { x = 0; y = 0; z = -1; vnumR v([1:3]); dim armap[1:5]; private name = "NONAME"; private file = "/tmp/myfile"; }; > MyData a; > afftab(a); a@x = 0 a@y = 0 a@z = -1 a@v = a double precision real vector : number of elements =3 a@armap = a [1:5 ] number of elements = 5 a@name = "NONAME" a@file = "/tmp/myfile"
Next: Access to member attributes, Previous: Type declaration, Up: Structures [Contents][Index]
struct
<structtype> <object identifier> p1, <object identifier> p2, ... ;
It creates the object identifiers whose the name are given in the list. These objects are data structure of the specified type.
> // declaration of the type POINT > struct POINT { x, y; }; > // declaration of the object of type POINT > struct POINT p1, p2, p3; > p1; p1 = structure POINT > afftab(p1); p1@x = /* UNINITIALIZED */ p1@y = /* UNINITIALIZED */
Next: Display, Previous: Object identifier declaration, Up: Structures [Contents][Index]
<structure> @
<name>
It allows to access to the value of a field of the data structure. If this field is private, this field can only be accessed from a macro associated to this structure.
> struct MyData { x,y,z; name, file; }; > struct MyData s; > > s@x = 3; s@x = 3 > s@y = 1; s@y = 1 > s@z = s@x + 2*s@y; s@z = 5 > s@name = "temp001"; s@name = "temp001" > s@file=file_open(s@name,write); s@file = file "temp001" opened in write mode >
Next: Constructor macro, Previous: Access to member attributes, Up: Structures [Contents][Index]
afftab(
<structure> x );
It displays the value of all the fields of the data structure x.
> struct MyData { x,y,z; name, file; }; > struct MyData s; > > s@x = 3$ > s@y = 1$ > s@z = s@x + 2*s@y$ > s@name = "temp001"$ > s@file=file_open(s@name,write)$ > afftab(s); s@x = 3 s@y = 1 s@z = 5 s@name = "temp001" s@file = file "temp001" opened in write mode >
Next: Member macros, Previous: Display, Up: Structures [Contents][Index]
macro
<structtype> @ <structtype> { <body> };
It defines a constructor of the data structure with no parameter and a body of trip code. This macro is implicitly called when an object is initialized.
The macro allows to access to all the private or public fields of the data structure. A direct access to these fields is allowed and does not require to be prefixed by @
.
The object self is already defined during the execution of the macro. It refers to the value of the data structure which responsible of the call. This object is useful for a global assignment or to call another macro with this value.
> struct MyData { t; vnumR v([1:3])$ }; > macro MyData@MyData { private _ALL; t = log(2)$ v[:]=4$ }; > > MyData a; > afftab(a); a@t = 0.6931471805599453 a@v = a double precision real vector : number of elements =3 > >
Previous: Constructor macro, Up: Structures [Contents][Index]
macro
<structtype> @ <name> [ <list of parameters> ] { <body> };
macro
<structtype> @ <name> { <body> };
private macro
<structure> @ <name> [ <list of parameters> ] { <body> };
private macro
<structure> @ <name> { <body> };
It defines a member macro of the data structure with 0 or more parameter and a body of trip code.
The macro allows to access to all the private or public fields of the data structure. A direct access to these fields is allowed and does not require to be prefixed by @
.
The object self is already defined during the execution of the macro. It refers to the value of the data structure which responsible of the call. This object is useful for a global assignment or to call another macro with this value.
If the macro is defined as private, then this macro can be called only other macros associated to the same data structure.
> struct MyData { x,y,z; private name, file; }; > > // Define Init as a macro of MyData > macro MyData@Init[vx,vy,vz,vname] { x = vx$ y = vy$ z = vz$ name = vname$ %OpenFile$ afftab(self); }; > > // Define OpenFile as a private macro of MyData > private macro MyData@OpenFile { file = file_open(name,write)$ }; > >
<structure> %
<name> [ <list of parameters> ];
<structure> %
<name> ;
It calls a member macro of the data structure and defines the object self as the value of the data structure during its execution.
> struct MyData { x,y,z; private name, file; }; > > macro MyData@Init[vx,vy,vz,vname] { x = vx$ y = vy$ z = vz$ name = vname$ %OpenFile$ afftab(self); }; > > macro MyData@Clear { %CloseFile; }; > > private macro MyData@OpenFile { file = file_open(name,write)$ }; > > private macro MyData@CloseFile { file_close(file); }; > > struct MyData s; > // execute the macro Init > s%Init[1,2,3,"temp001"]; s@x = 1 s@y = 2 s@z = 3 s@name = "temp001" s@file = file "temp001" opened in write mode > > // execute the macro Clear > s%Clear; >
Next: Matrices numeriques, Previous: Structures, Up: Top [Contents][Index]
• Declaration : | ||
• Initialisation : | ||
• writes: | Affichage. | |
• size : | ||
• resize : | ||
• Bornes : | ||
• Extraction : | ||
• Entree/Sortie : | ||
• Entree/Sortie bas niveau : | ||
• Fonctions mathematiques et usuelles : | ||
• Conditions : | ||
• Conversion : |
The numerical values stored in vectors are always real or complex double-precision, quadruple-precision or multiprecision numbers depending on the current numerical mode. A numerical vector is assumed to be a column vector.
In the numerical mode NUMRATMP, the rational numbers may be stored in the numerical vector of rational numbers.
Next: Initialisation, Up: Vecteurs numeriques [Contents][Index]
• vnumR: | ||
• vnumC: | ||
• vnumQ: |
Explicit declaration for numerical vectors are only required before call to read
, readbin
(see Entree/SortieTabNum) and resize
.
Explicit declaration for array of numerical vectors are always required.
Next: vnumC, Up: Declaration [Contents][Index]
vnumR
<name> ,
... ;
vnumR
<name> [
<dimension of an array> ] ,
... ;
It declares a real vector or an array of real vectors.
The real vector’s size is dynamic. After the declaration, the real vectors are empty.
To set their sizes, the command resize
must be used.
The dimension specifies the number of elements in the array of real vectors.
vnumR
<name> ([
1: <integer> n ]) ,
... ;
vnumR
<name> [
<dimension of an array> ] ([
1: <integer> n ]) ,
... ;
It declares a vector of n reals or an array of vectors of n reals.
After the declaration, the elements of the vector are initialized with the value 0.
> vnumR A, C([1:5]); > stat(A); Numerical vector A contains 0 double precision reals. > stat(C); Numerical vector C contains 5 double precision reals. Size of the array in bytes: 40 > bounds=1:2; bounds = bounds [ 1:2 ] > vnumR TE[bounds], T0[bounds]([1:6]); > stat(TE); Array of series TE [ 1:2 ] list of array's elements : TE [ 1 ] = Numerical vector TE contains 0 double precision reals. TE [ 2 ] = Numerical vector TE contains 0 double precision reals. > stat(T0); Array of series T0 [ 1:2 ] list of array's elements : T0 [ 1 ] = Numerical vector T0 contains 6 double precision reals. Size of the array in bytes: 48 T0 [ 2 ] = Numerical vector T0 contains 6 double precision reals. Size of the array in bytes: 48 >
Next: vnumQ, Previous: vnumR, Up: Declaration [Contents][Index]
vnumC
<name> ,
... ;
vnumC
<name> [
<dimension of an array> ] ,
... ;
It declares a complex vector or an array of complex vectors.
The complex vector’s size is dynamic. After the declaration, the complex vectors are empty.
To set their sizes, the command resize
must be used.
The dimension specifies the number of elements in the array of complex vectors.
vnumC
<name> ([
1: <integer> n ]) ,
... ;
vnumC
<name> [
<dimension of an array> ] ([
1: <integer> n ]) ,
... ;
It declares a vector of n complex numbers or an array of vectors of n complex numbers.
After the declaration, the elements of the vector are initialized with the value 0+i*0.
> vnumC A, C([1:5]); > stat(A); Numerical vector A contains 0 double precision complex. > stat(C); Numerical vector C contains 5 double precision complex. Size of the array in bytes: 80 > vnumC TE[1:2], T0[1:2]([1:6]); > stat(TE); Array of series TE [ 1:2 ] list of array's elements : TE [ 1 ] = Numerical vector TE contains 0 double precision complex. TE [ 2 ] = Numerical vector TE contains 0 double precision complex. > stat(T0); Array of series T0 [ 1:2 ] list of array's elements : T0 [ 1 ] = Numerical vector T0 contains 6 double precision complex. Size of the array in bytes: 96 T0 [ 2 ] = Numerical vector T0 contains 6 double precision complex. Size of the array in bytes: 96 >
Previous: vnumC, Up: Declaration [Contents][Index]
vnumQ
<name> ,
... ;
vnumQ
<name> [
<dimension of an array> ] ,
... ;
It declares a vector of rational numbers or an array of vector of rational numbers.
The rational vector’s size is dynamic. After the declaration, the rational vectors are empty.
To set their sizes, the command resize
must be used.
The dimension specifies the number of elements in the array of rational vectors.
vnumQ
<name> ([
1: <integer> n ]) ,
... ;
vnumQ
<name> [
<dimension of an array> ] ([
1: <integer> n ]) ,
... ;
It declares a vector of n rational numbers or an array of vectors of n rational numbers.
After the declaration, the elements of the vector are initialized with the value 0.
> _modenum=NUMRATMP; _modenum = NUMRATMP > vnumQ A, C([1:5]); > stat(A); Numerical vector A contains 0 rational numbers. > stat(C); Numerical vector C contains 5 rational numbers. Size of the array in bytes: 160 > vnumQ TE[1:2], T0[1:2]([1:6]); > stat(TE); Array of series TE [ 1:2 ] list of array's elements : TE [ 1 ] = Numerical vector TE contains 0 rational numbers. TE [ 2 ] = Numerical vector TE contains 0 rational numbers. > stat(T0); Array of series T0 [ 1:2 ] list of array's elements : T0 [ 1 ] = Numerical vector T0 contains 6 rational numbers. Size of the array in bytes: 192 T0 [ 2 ] = Numerical vector T0 contains 6 rational numbers. Size of the array in bytes: 192 >
Next: writes, Previous: Declaration, Up: Vecteurs numeriques [Contents][Index]
<name> =
<real> binf ,
<real> bsup ,
<real> step ;
It declares and initializes a real vectors such that all elements are initialized by a loop (from binf to bsup with the step bstep):
for (j=1, valeur=binf) to valeur<=bsup step (j=j+1, valeur=valeur+bstep) <name> [j]=valeur
The step bstep is optional; By default, its value is 1.
> t=0,10; t double precision real vector : number of elements =11 > writes(t); +0.0000000000000000E+00 +1.0000000000000000E+00 +2.0000000000000000E+00 +3.0000000000000000E+00 +4.0000000000000000E+00 +5.0000000000000000E+00 +6.0000000000000000E+00 +7.0000000000000000E+00 +8.0000000000000000E+00 +9.0000000000000000E+00 +1.0000000000000000E+01 > tab=-pi, 6, pi/100; tab double precision real vector : number of elements =291 > writes([::30],tab); -3.1415926535897931E+00 -2.1991148575128552E+00 -1.2566370614359170E+00 -3.1415926535897887E-01 +6.2831853071795907E-01 +1.5707963267948966E+00 +2.5132741228718354E+00 +3.4557519189487733E+00 +4.3982297150257113E+00 +5.3407075111026483E+00 >
<name> = vnumR
[
<real> or <real vec.> or <array of real vec.> ,
... :
<real> ,
... ] ;
It declares and initializes a real vector or an array of real vectors with the specified reals or real vectors.
The character :
separates the lines and the character ,
separates the columns.
All columns must have the same line counts.
> // declare an array of 3 vectors of 2 reals. > tab3=vnumR[1,2,3:4,5,6]; tab3 [1:3 ] number of elements = 3 > writes(tab3); +1.0000000000000000E+00 +2.0000000000000000E+00 +3.0000000000000000E+00 +4.0000000000000000E+00 +5.0000000000000000E+00 +6.0000000000000000E+00 > t=7,8; t double precision real vector : number of elements =2 > tab4=vnumR[t,tab3]; tab4 [1:4 ] number of elements = 4 > // declare a vector of 5 reals. > t2=vnumR[1:2:4:8:9]; t2 double precision real vector : number of elements =5 > writes(t2); +1.0000000000000000E+00 +2.0000000000000000E+00 +4.0000000000000000E+00 +8.0000000000000000E+00 +9.0000000000000000E+00 >
<name> = vnumC
[
<complex> or <complex vec.> or <array of complex vec.> ,
... :
<complex> ,
... ] ;
It declares and initializes a complex vector or an array of complex vectors with the specified complexs or complex vectors.
The character :
separates the lines and the character ,
separates the columns .
All columns must have the same line counts.
> // declare a vector of 5 complex numbers > tab3=vnumC[1:1+i:2+2*i:3+3*i]; tab3 Double precision complex vector : number of elements =4 > writes(tab3); +1.0000000000000000E+00 +0.0000000000000000E+00 +1.0000000000000000E+00 +1.0000000000000000E+00 +2.0000000000000000E+00 +2.0000000000000000E+00 +3.0000000000000000E+00 +3.0000000000000000E+00 > vnumC ti; > resize(ti,5,3-5*i); > tab4=vnumC[tab3 : 5+7*i : ti]; tab4 Double precision complex vector : number of elements =10 > // declare an array of 2 vectors of 2 complex numbers > z4=vnumC[5,2+i:4,9+3*i]; z4 [1:2 ] number of elements = 2 > writes("%g %g %g %g\n",z4[1],z4[2]); 5 0 2 1 4 0 9 3 >
Next: size, Previous: Initialisation, Up: Vecteurs numeriques [Contents][Index]
writes([
<integer> :
<integer> :
<integer> ],
<string> ,
<(array of) num. vec.> ,
...);
writes(
<string> ,
<(array of) num. vec.> ,
...);
writes(
<(array of) num. vec.> ,
...);
equivalent to
writes( { [binf:{bsup}:{step}], } {format,} <(array of) num. vec.> ,...).
It prints, to the screen, numerical vectors or the array of numerical vectors in columns form.
format is optional. This format is similar to the C format (cf. printf) and must be between double quotes ("). To display a double quote (") as a character, you must double it :
For example, if the C format is " %g \"titi\" %g", you must write " %g\""titi\"" %g"
A complex vector will be printed on two columns (the first one for the real part and the second one for the imaginary part).
Ecriture de tous les éléments de T et de X. La première colonne correspondra à T. La deuxième colonne correspondra à la partie réelle de X. La troisième colonne correspondra à la partie imaginaire de X. ... > stat(X); vecteur numérique X de 6 complexes. taille en octets du tableau: 96 > stat(T); vecteur numérique T de 6 réels. taille en octets du tableau: 48 > writes(T,X); +9.999993149794888E-02 +1.000000000456180E-01 +1.095970178673141E-06 -2.000000944035095E-01 +9.999999960679056E-03 +1.312007532388499E-07 +3.000000832689856E-01 +1.000000314882390E-03 -1.403292661135361E-08 -4.000000970924361E-01 +9.999995669530993E-05 +1.695880029074994E-09 +4.999999805039361E-01 +1.000003117384769E-05 +3.216502329016007E-11 -5.999999830866213E-01 +9.999979187109419E-07 -1.796078221829677E-12 > Ecriture du 2 au 4 elements de T et de X avec un format "%.1g\t(%.5g+i*%.5E)\n". > writes([2:4],"%.1g\t(%.5g+i*%.5E)\n",T,X); -0.2 (0.01+i*1.31201e-07) 0.3 (0.001+i*-1.40329e-08) -0.4 (0.0001+i*1.69588e-09) Ecriture du 1 au 5 elements de T et de X avec un pas de 2 sans format. > writes([1:5:2],T,X); +9.999993149794888E-02 +1.000000000456180E-01 +1.095970178673141E-06 +3.000000832689856E-01 +1.000000314882390E-03 -1.403292661135361E-08 +4.999999805039361E-01 +1.000003117384769E-05 +3.216502329016007E-11 Ecriture des elements de T et de X avec un pas de 5 sans format. > writes([::5],T,X); +9.999993149794888E-02 +1.000000000456180E-01 +1.095970178673141E-06 -5.999999830866213E-01 +9.999979187109419E-07 -1.796078221829677E-12
Next: resize, Previous: writes, Up: Vecteurs numeriques [Contents][Index]
size(
<num. vec.> )
Return the number of elements in the numerical vector.
> t=1,10; t double precision real vector : number of elements =10 > size(t); 10 > p=-pi,pi,pi/400; p double precision real vector : number of elements =800 > size(p); 800 >
Next: Bornes, Previous: size, Up: Vecteurs numeriques [Contents][Index]
resize(
<(array of) num. vec.> ,
<integer> );
resize(
<(array of) num. vec.> ,
<integer> ,
<constant> );
Change the size of the numerical vector or of the array of numerical vectors.
If a constant isn’t specified then all elements will be initialized to 0 else all elements will initialized with this constant.
> vnumR t; > resize(t,3); > vnumR t2; > resize(t2,3,5); > writes(t,t2); +0.0000000000000000E+00 +5.0000000000000000E+00 +0.0000000000000000E+00 +5.0000000000000000E+00 +0.0000000000000000E+00 +5.0000000000000000E+00 > vnumC t[1:3]; > resize(t[2],2,1-5*i); > writes(t[2]); +1.0000000000000000E+00 -5.0000000000000000E+00 +1.0000000000000000E+00 -5.0000000000000000E+00 >
Next: Extraction, Previous: resize, Up: Vecteurs numeriques [Contents][Index]
inf
(<num. vec.> ,<integer> );
Return the lower bound of the numerical vector. The supplied integer must be equal to 1.
If the specified dimension is not 1, then the function returns -1.
> t=3,10; t double precision real vector : number of elements =8 > inf(t,1); 1 >
sup
(<num. vec.> ,<integer> );
Return the upper bound of the numerical vector. The supplied integer must be equal to 1.
If the specified dimension is not 1, then the function returns -1.
> t=3,10; t double precision real vector : number of elements =8 > sup(t,1); 8 >
Next: Entree/SortieTabNum, Previous: Bornes, Up: Vecteurs numeriques [Contents][Index]
• select: | ||
• operateurs d'extraction : |
Next: operateurs d'extraction, Up: Extraction [Contents][Index]
select (
<condition> ,
<num. vec.> );
Return a numerical vector which only contains the elements of the numerical vector where the condition is true.
The condition and the numerical vector must have the same number of elements.
> // return the elements which are multiple of 3 > t=1,10; t double precision real vector : number of elements =10 > r=select((t mod 3)==0, t); r double precision real vector : number of elements =3 > writes(r); +3.0000000000000000E+00 +6.0000000000000000E+00 +9.0000000000000000E+00 >
Previous: select, Up: Extraction [Contents][Index]
<num. vec.> [
<real vec.> ];
Return a numerical vector which only contains the elements of the numerical vector located at the indexes stored in the real vector.
Remark : The real vector must be an object identifier and not be a operation result.
> r=vnumR[1:5:7:9]; r double precision real vector : number of elements =4 > t=20,30; t double precision real vector : number of elements =11 > b=t[r]; b double precision real vector : number of elements =4 > writes("%g\n",b); 20 24 26 28 >
<num. vec.> [
<integer> binf :
<integer> bsup :
<integer> pas ];
<num. vec.> [
<integer> binf :
<integer> bsup ];
Return a numerical vector which contains only the elements located between the lower bound and the upper bound with the specified step.
If the lower bound isn’t specified, then the lower bound is assumed to be 1.
If the upper bound isn’t specified, then the upper bound is assumed to be the size of the numerical vector.
If the step isn’t specified, then the step is assumed to be 1.
Remark : All missing combinations are allowed.
> t=1,10; t double precision real vector : number of elements =10 > r=t[::2]; r double precision real vector : number of elements =5 > v=t[7:9]; v double precision real vector : number of elements =3 > y=t[5:10:2]; y double precision real vector : number of elements =3 > writes("%g %g\n",v,y); 7 5 8 7 9 9 >
Next: Entree/SortieTabNumbasniveau, Previous: Extraction, Up: Vecteurs numeriques [Contents][Index]
• read : | ||
• readappend : | ||
• write : | ||
• readbin : | ||
• writebin : |
Next: readappend, Up: Entree/SortieTabNum [Contents][Index]
read(
<filename> ,[
<integer> :
<integer> :
<integer> ],
,
... ,
(
<(array of) num. vec.> ,
<integer> ),
...
(
<(array of) num. vec.> ,
<integer> ,
<integer> ),
...);
equivalent to
read(fichier.dat, [binf:bsup:step], T, (T1,n1), (T3,n2,n3));
read(fichier.dat, T, (T1,n1), (T3,n2,n3));
Read in a text file the specified columns and store them to numerical vectors.
If the file contains the strings NAN
or NANQ
, then it assumes to be the value "Not A Number".
If the file contains the strings INF
, Inf
ou Infinity
, then it assumes to be the value "infinite".
When an empty or incomplete line is encountered, the behavior of this function depends on the value of _read
(see _read).
Lecture dans le fichier tessin.out de la ligne 2 à ligne 100 avec un pas de 3. Le vecteur T contiendra la première colonne, la partie réelle de X contiendra la deuxième colonne, la partie imaginaire de X contiendra la troisième colonne, TAB[1] contiendra la 4eme colonne, TAB[2] contiendra la 5eme colonne, TAB[3] contiendra la 6eme colonne. > vnumR T; vnumC X; vnumR TAB[1:3]; read(tessin.out,[2:100:3],T,X,TAB); stat(T); stat(X); stat(TAB); T nb elements reels =0 > X nb elements complexes =0 > TAB [1:3] nb elements = 3 > > Tableau numerique T de 33 reels. taille en octets du tableau: 264 > Tableau numerique X de 33 complexes. taille en octets du tableau: 528 > Tableau de series TAB [ 1:3 ] liste des elements du tableau : TAB [ 1 ] = Tableau numerique de 33 reels. taille en octets du tableau: 264 TAB [ 2 ] = Tableau numerique de 33 reels. taille en octets du tableau: 264 TAB [ 3 ] = Tableau numerique de 33 reels. taille en octets du tableau: 264 > Lecture dans le fichier tessin.out de la ligne 2 a ligne 100. Le vecteur T contiendra la premiere colonne, la partie reelle de X contiendra la 4eme colonne, la partie imaginaire de X sera nulle, TAB[3] contiendra la 5eme colonne. > read(tessin.out,[2:100],T,(X,4),(TAB[3],5)); Lecture dans le fichier tessin.out de l'ensemble des lignes. Le vecteur T contiendra la 2eme colonne, la partie reelle de X contiendra la 3eme colonne, la partie imaginaire de X contiendra la 4eme colonne, TAB[3] contiendra la 5eme colonne. > read(tessin.out,(T,2),(X,3,4),(TAB[3],5)); Lecture dans le fichier tessin.out a partir de la ligne 1000. Le vecteur T contiendra la 2eme colonne, la partie reelle de X contiendra la 3eme colonne, la partie imaginaire de X contiendra la 4eme colonne, TAB[3] contiendra la 5eme colonne. > read(tessin.out,[1000:],(T,2),(X,3,4),(TAB[3],5)); Lecture dans le fichier tessin.out avec un pas de 50 lignes. Le vecteur T contiendra la 2eme colonne, la partie reelle de X contiendra la 3eme colonne, la partie imaginaire de X contiendra la 4eme colonne, TAB[3] contiendra la 5eme colonne. > read(tessin.out,[::50],(T,2),(X,3,4),TAB[3]);
read(
<filename> ,[
<integer> :
<integer> :
<integer> ],
textformat,
,
... ,
(
<(array of) num. vec.> ,
<integer> ),
...
(
<(array of) num. vec.> ,
<integer> ,
<integer> ),
...);
equivalent to
fmt="..."; read(fichier.dat, [binf:bsup:step], textformat, T, (T1,n1), (T3,n2,n3));
fmt="..."; read(fichier.dat, textformat, T, (T1,n1), (T3,n2,n3));
This function is similar to the above command but allows to specify a format to read the data. It is able to read columns of numbers or strings of characters. The type of the data is specified by the format.
The allowed formats are :
For the format specifier %s, the object must not be declared before ; the returned object is an array of string.
For the format specifiers %g, %e, %E, the objects must be declared before this command as a (array of) numerical vector (vnumR). The returned object will be of the same type.
By default, it assumes that the columns are separated by spaces or tabulions. If a length is specified in the format (e.g., %10g or %10s for a column of 10 characters), this length specifies the number of characters of the column. In this case, there is no distinction between spaces, tabulations and other characters.
When an empty or incomplete line is encountered, the behavior of this function depends on the value of _read
(see _read).
Limitation : It is not possible to write the following command : read(file,"....", T1, T2, ...);
.
It must be rewritten as : fmt=" ..."$ read(file,fmt, T1, T2, ...);
.
> // generates a file with 2 columns : asteroid number and name > f=file_open(data.dat, write)$ > file_writemsg(f, " 1 Ceres \n 2 Pallas\n 3 Juno \n"); > file_close(f); > > > // reads two columns like a numerical vector and an array of string > // using a space separator > vnumR id; > fmt="%g %s"; fmt = "%g %s" > read(data.dat, fmt, id, name); > writes(id); +1.0000000000000000E+00 +2.0000000000000000E+00 +3.0000000000000000E+00 > afftab(name); name[1] = "Ceres" name[2] = "Pallas" name[3] = "Juno" > > // reads two columns like a numerical vector and an array of string > // using a fixed size for each column > vnumR id2; > fmt="%5g %7s"; fmt = "%5g %7s" > read(data.dat, fmt, id2, name2); > writes(id2); +1.0000000000000000E+00 +2.0000000000000000E+00 +3.0000000000000000E+00 > afftab(name2); name2[1] = " Ceres " name2[2] = " Pallas" name2[3] = " Juno "
The following example show how to read the astorb data files using the format.
vnumR number, H, Slope,ColorIndex,v1,v2,v3,v4,v5,v6; vnumR arc,observations, epochyy,epochymm, epochdd; vnumR anomaly,perihelion, ascendingnode,Inclination, Eccentricity,Semimajoraxis,Date; fmt="%7s%19s%16s%6s%5g%5s%6s%6s"+6*"%4g"+2*"%g"+"%4g" +2*"%2g"+5*"%11g"+"%12g%9s"; read(astorb.dat,[:10000], fmt, number,name, computer, H,Slope, ColorIndex,diameter,Taxonomic,v1,v2,v3,v4,v5,v6,arc,observations, epochyy,epochymm, epochdd, anomaly,perihelion, ascendingnode, Inclination,Eccentricity,Semimajoraxis,Date);
Next: write, Previous: read, Up: Entree/SortieTabNum [Contents][Index]
readappend(
<filename> ,[
<integer> :
<integer> :
<integer> ],
,
... ,
(
<(array of) num. vec.> ,
<integer> ),
...
(
<(array of) num. vec.> ,
<integer> ,
<integer> ),
...);
equivalent to
readappend(fichier.dat, [binf:bsup:step], T, (T1,n1), (T3,n2,n3));
readappend(fichier.dat, T, (T1,n1), (T3,n2,n3));
This function is similar to the function read
(see read) but it stores read data to the end of the numerical vectors (with an automatic growing step)
instead of overwriting their contents.
> t1=1,5; t1 Tableau de reels double-precision : nb reels =5 > write(temp001, t1); > write(temp002, t1**2); > vnumR w; > readappend(temp001,w); > readappend(temp002,w); > writes(w); +1.0000000000000000E+00 +2.0000000000000000E+00 +3.0000000000000000E+00 +4.0000000000000000E+00 +5.0000000000000000E+00 +1.0000000000000000E+00 +4.0000000000000000E+00 +9.0000000000000000E+00 +1.6000000000000000E+01 +2.5000000000000000E+01
readappend(
<filename> ,[
<integer> :
<integer> :
<integer> ],
textfmt,
,
... ,
(
<(array of) num. vec.> ,
<integer> ),
...
(
<(array of) num. vec.> ,
<integer> ,
<integer> ),
...);
This function is similar to the function read
(see read) using the format textfmt.
But it stores read data to the end of the numerical vectors (with an automatic growing step)
instead of overwriting their contents.
Next: readbin, Previous: readappend, Up: Entree/SortieTabNum [Contents][Index]
write(
<filename> , [
<integer> :
<integer> :
<integer> ],
<string> ,
<(array of) num. vec.> ,
...);
write(
<filename> ,
<string> ,
<(array of) num. vec.> ,
...);
write(
<filename> ,
<(array of) num. vec.> ,
...);
equivalent to
write( fichier.dat, [binf:bsup:step], "format", T, T1, T2).
write( fichier.dat, "format", T, T1, T2).
write( fichier.dat, T, T1, T2).
write( fichier.dat, [binf:bsup:step], T, T1, T2).
Write to a file the numerical vector or the arrays of numerical vectors as columns of numbers.
The format is optional. The format is the format of C language (See printf) and surrounded with double-quotes ("). To obtain a double-quotes, two double-quotes must be used :
For example : if the C format is " %g \"titi\" %E", it must be written as, " %g \""titi\"" %E"
A numerical vector of complex numbers uses two columns (the first one for the real part and the second one for the imaginary part).
Ecriture de tous les elements de T et de X dans le fichier tx.out. La pemiere colonne correspondra a T. la deuxieme colonne correspondra a la partie reelle de X. la troisieme colonne correspondra a la partie imaginaire de X. > vnumR T; vnumC X; ... stat(T); stat(X); > Tableau numerique T de 33 reels. taille en octets du tableau: 264 > Tableau numerique X de 33 complexes. taille en octets du tableau: 528 > write(tx.out,T,X); > Ecriture de 10 au 20 éléments de T et de X dans le fichier tx.out avec un format "%g\t(%8.4E+i*%e)\n". La pemiere colonne correspondra à T. la deuxième colonne correspondra à la partie réelle de X. la troisieme colonne correspondra à la partie imaginaire de X. > write(tx.out,[10:20],"%g\t(%8.4E+i*%e)\n",T,X); Ecriture de 1 au 20 éléments de T et de X avec un pas de 2 dans le fichier tx.out sans format. La pemiere colonne correspondra à T. la deuxième colonne correspondra à la partie réelle de X. la troisieme colonne correspondra à la partie imaginaire de X. > write(tx.out,[1:20:2],T,X); Ecriture des éléments de T et de X avec un pas de 5 dans le fichier tx.out sans format. La pemiere colonne correspondra à T. la deuxième colonne correspondra à la partie réelle de X. la troisieme colonne correspondra à la partie imaginaire de X. > write(tx.out,[::5],T,X);
Next: writebin, Previous: write, Up: Entree/SortieTabNum [Contents][Index]
readbin(
<filename> ,[
<integer> :
<integer> :
<integer> ],
<string> ,
<(array of) real vec.> ,
...);
readbin(
<filename> ,
<string> ,
<(array of) real vec.> ,
...);
equivalent to
readbin(fichier.dat, [binf:bsup:step], format, T, T2, T3);
readbin(fichier.dat, format, T, T2, T3);
Read in a binary file the data with the specified format and store them to numerical vectors.
The allowed format to define a record are :
The number of format must be the same as the number of vectors. If the provided object identifier is an array of real vectors, then it must have the same number of format as the number of elements in the array.
The data are previously converted if the global variable _endian
(see _endian) isn’t the same as its default value.
Lecture dans le fichier binaire test1.dat d'entiers signés sur 4 octets et stockés dans le vecteur de réels T1. vnumR T1; readbin(test1.dat,"%4d",T1); Lecture dans le fichier binaire test1.dat des 30 premiers entiers signés sur 4 octets et stockés dans le vecteur de réels T1. vnumR T1; readbin(test1.dat,[:30],"%4d",T1); Lecture dans le fichier binaire test2.dat dont chaque enregistrement est composé de 2 réels et stockés dans le vecteur de réels T1 et T2. vnumR T1,T2; readbin(test2.dat,[:30],"%g%g",T1,T2); Lecture dans le fichier binaire test3.dat dont chaque enregistrement est composé de 4 réels et stockés dans le tableau T3. vnumR T3[1:4]; readbin(test3.dat,"%g%g%g%g",T3); est équivalent à readbin(test3.dat,"%g%g%g%g",T3[1],T3[2],T3[3],T3[4]);
Previous: readbin, Up: Entree/SortieTabNum [Contents][Index]
writebin(
<filename> ,[
<integer> :
<integer> :
<integer> ],
<string> ,
<(array of) real vec.> ,
...);
writebin(
<filename> ,
<string> ,
<(array of) real vec.> ,
...);
equivalent to
writebin(fichier.dat, [binf:bsup:step], format, T, T2, T3);
writebin(fichier.dat, format, T, T2, T3);
Write the numerical vectors to a binary file the data with the specified format.
The allowed format to define a record are :
The number of format must be the same as the number of vectors. If the provided object identifier is an array of real vectors, then it must have the same number of format as the number of elements in the array.
If the numerical vectors doesn’t have the same size, then the missing data are completed with 0.
The data are previously converted if the global variable _endian
(see _endian) isn’t the same as its default value.
Ecriture du vecteur de réels T1 dans le fichier binaire test1.dat sosu la forme d'entiers signés sur 4 octets. vnumR T1; T1=1,10; writebin(test1.dat,"%4d",T1); Ecriture des 30 premiers éléments du vecteur de réels T1 dans le fichier binaire test1.dat sous la forme d'entiers signés sur 4 octets. vnumR T1; T1=1,100; writebin(test1.dat,[:30],"%4d",T1); Ecriture des 30 premiers éléments du vecteur de réels T1 et de T2 dans le fichier binaire test2.dat dont chaque enregistrement est composé de 2 réels. vnumR T1,T2; T1=1,100; T2=-100,-1; writebin(test2.dat,[:30],"%g%g",T1,T2); Ecriture des vecteurs de réels de T3 dans le fichier binaire test3.dat dont chaque enregistrement est composé de 4 réels. vnumR T3[1:4]; T3[:]=1,10; writebin(test3.dat,"%g%g%g%g",T3); est équivalent à writebin(test3.dat,"%g%g%g%g",T3[1],T3[2],T3[3],T3[4]);
Next: Fonctions mathematiques et usuelles, Previous: Entree/SortieTabNum, Up: Vecteurs numeriques [Contents][Index]
• file_open : | ||
• file_close : | ||
• file_write : | ||
• file_read : | ||
• file_readappend : | ||
• file_writemsg : | ||
• file_writebin : |
Next: file_close, Up: Entree/SortieTabNumbasniveau [Contents][Index]
file_open(
<filename> , read);
file_open(
<filename> , write);
file_open(
<filename> , write, append);
It opens a file in reading or writing mode depending on the value of the second parameter. It returns an object identifier of type file.
In writing mode, the existing file is kept and the new writing operations are performed at the end of the file if append
is given, otherwise, the file is overwritten.
> f=file_open("sim2007.dat",read); f = fichier "sim2007.dat" ouvert en lecture > vnumR t; > file_read(f,t); > file_close(f);
Next: file_write, Previous: file_open, Up: Entree/SortieTabNumbasniveau [Contents][Index]
file_close(
<file> );
It closes a file previously opened with the function file_open
.
> f=file_open("sim2007.dat",read); f = fichier "sim2007.dat" ouvert en lecture > vnumR t; > file_read(f,t); > file_close(f); > stat(f); fichier f = "sim2007.dat" ferme Aucune erreur en lecture/ecriture
Next: file_read, Previous: file_close, Up: Entree/SortieTabNumbasniveau [Contents][Index]
file_write(
<file> , [
<integer> :
<integer> :
<integer> ],
<string> ,
<(array of) num. vec.> ,
...);
file_write(
<file> ,
<string> ,
<(array of) num. vec.> ,
...);
file_write(
<file> ,
<(array of) num. vec.> ,
...);
equivalent to
file_write( fichier, [binf:bsup:step], "format", T, T1, T2).
file_write( fichier, "format", T, T1, T2).
file_write( fichier, T, T1, T2).
file_write( fichier, [binf:bsup:step], T, T1, T2).
This function is similar as the function write
(see write) but this function requires an object identifier of type file instead of a filename.
The function writes data in the file from the current position.
> f=file_open(sim2007.dat, write); f = fichier "sim2007.dat" ouvert en ecriture > t1=1,10; t1 Tableau de reels double-precision : nb reels =10 > t2=-t1; t2 Tableau de reels double-precision : nb reels =10 > file_write(f,t1); > file_write(f,t2); > file_close(f);
Next: file_readappend, Previous: file_write, Up: Entree/SortieTabNumbasniveau [Contents][Index]
file_read(
<file> ,[
<integer> :
<integer> :
<integer> ],
,
... ,
(
<(array of) num. vec.> ,
<integer> ),
...
(
<(array of) num. vec.> ,
<integer> ,
<integer> ),
...);
equivalent to
file_read(fichier, [binf:bsup:step], T, (T1,n1), (T3,n2,n3));
file_read(fichier, T, (T1,n1), (T3,n2,n3));
This function is similar as the function read
(see read) but this function requires an object identifier of type file instead of a filename.
The function reads data from the file from the current position.
> f=file_open(sim2007.dat, read); f = fichier "sim2007.dat" ouvert en lecture > vnumR t; > file_read(f,[:5],t); > vnumR t2; > file_read(f,t2); > writes(t); +1.0000000000000000E+00 +2.0000000000000000E+00 +3.0000000000000000E+00 +4.0000000000000000E+00 +5.0000000000000000E+00 > writes(t2); +6.0000000000000000E+00 +7.0000000000000000E+00 +8.0000000000000000E+00 +9.0000000000000000E+00 +1.0000000000000000E+01 -1.0000000000000000E+00 -2.0000000000000000E+00 -3.0000000000000000E+00 -4.0000000000000000E+00 -5.0000000000000000E+00 -6.0000000000000000E+00 -7.0000000000000000E+00 -8.0000000000000000E+00 -9.0000000000000000E+00 -1.0000000000000000E+01 > file_close(f);
Next: file_writemsg, Previous: file_read, Up: Entree/SortieTabNumbasniveau [Contents][Index]
file_readappend(
<file> ,[
<integer> :
<integer> :
<integer> ],
,
... ,
(
<(array of) num. vec.> ,
<integer> ),
...
(
<(array of) num. vec.> ,
<integer> ,
<integer> ),
...);
equivalent to
file_readappend(fichier, [binf:bsup:step], T, (T1,n1), (T3,n2,n3));
file_readappend(fichier, T, (T1,n1), (T3,n2,n3));
This function is similar as the function readappend
(see readappend) but this function requires an object identifier of type file instead of a filename.
The function reads data from the file from the current position.
> f=file_open(sim2007.dat, read); f = fichier "sim2007.dat" ouvert en lecture > vnumR t; > file_readappend(f,[:5],t); > file_readappend(f,[10:15],t); > writes(t); +1.0000000000000000E+00 +2.0000000000000000E+00 +3.0000000000000000E+00 +4.0000000000000000E+00 +5.0000000000000000E+00 -5.0000000000000000E+00 -6.0000000000000000E+00 -7.0000000000000000E+00 -8.0000000000000000E+00 -9.0000000000000000E+00 -1.0000000000000000E+01 > file_close(f);
Next: file_writebin, Previous: file_readappend, Up: Entree/SortieTabNumbasniveau [Contents][Index]
file_writemsg(
<file> ,
<string> textformat);
file_writemsg(
<file> ,
<string> textformat,
<real> x,
... );
Write formatted messages to a file with(out) real constants.
The real constants must be formatted. The format is the same as the command printf in language C (see str, for the valid conversion specifiers). This message must a be string or a text between double-quotes. The messages could be on several lines.
To display double-quotes, two double-quotes must be used.
> f=file_open("temp001", write); f = fichier "temp001" ouvert en ecriture > x=4; x = 4 > file_writemsg(f," resultat=%g\n", x); > file_writemsg(f," termine\n"); > file_close(f); > !"cat temp001"; resultat=4 termine > f=file_open("data1.txt",write); f = fichier "data1.txt" ouvert en ecriture > file_writemsg(f,"%d\n",3/2); > file_writemsg(f,"%4.2E\n",3/2); > file_close(f); > !"cat data1.txt"; 3/2 1.50E+00 >
Previous: file_writemsg, Up: Entree/SortieTabNumbasniveau [Contents][Index]
file_writebin(
<file> , [
<integer> :
<integer> :
<integer> ],
<string> ,
<(array of) num. vec.> ,
...);
file_writebin(
<file> ,
<string> ,
<(array of) num. vec.> ,
...);
equivalent to
file_writebin( file, [binf:bsup:step], "format", T, T1, T2).
file_writebin( file, "format", T, T1, T2).
This function is similar as the function writebin
(see writebin) but this function requires an object identifier of type file instead of a filename.
The function writes data in the file from the current position.
> f=file_open(sim2007.dat, write); f = file "sim2007.dat" opened in write mode > t1=1,10; t1 double precision real vector : number of elements =10 > t2=-t1; t2 double precision real vector : number of elements =10 > file_writebin(f,"%g",t1); > file_writebin(f,"%g",t2); > file_close(f);
Next: Conditions, Previous: Entree/SortieTabNumbasniveau, Up: Vecteurs numeriques [Contents][Index]
• minimum et maximum : | ||
• somme et produit : | ||
• tris : | ||
• transposevnum : | ||
• fonctions math : |
Next: somme et produit, Up: Fonctions mathematiques et usuelles [Contents][Index]
• imin: | ||
• imax: | ||
• min : | ||
• max : | ||
• IMIN : | ||
• IMAX : | ||
• MIN : | ||
• MAX : |
Next: imaxelt, Up: minimum et maximum [Contents][Index]
imin(
<real vec.> )
Return the index of the minimal value of the numerical vector of real numbers. If more than one elements have the minimal value, then this function returns the index of the first element. If the numerical vector is empty then it returns 0.
> t=-5,5; > imin(t); 1
Next: minelt, Previous: iminelt, Up: minimum et maximum [Contents][Index]
imax(
<real vec.> )
Return the index of the maximal value of the numerical vector of real numbers. If more than one elements have the maximal value, then this function returns the index of the first element. If the numerical vector is empty then it returns 0.
> t=-5,5; > imax(t); 10
Next: maxelt, Previous: imaxelt, Up: minimum et maximum [Contents][Index]
min(
<real or real vec.> ,
...);
Return the minimum value of the parameters which could be real constants or real vectors.
>min(1.5,2.5); 3/2 >x=1.5; >y=2.5; >min(x,y); 3/2 > t=-10,10; > p=abs(t); > min(-5,t,p,20); -10
Next: IMINterme, Previous: minelt, Up: minimum et maximum [Contents][Index]
max(
<real or real vec.> ,
...);
Return the maximum value of the parameters which could be real constants or real vectors.
>max(1.5,2.5); 5/2 >x=1.5; >y=2.5; >max(x,y); 5/2 > t=-10,10; > p=abs(t); > max(p,t,8); 10
Next: IMAXterme, Previous: maxelt, Up: minimum et maximum [Contents][Index]
IMIN(
<array of real vec.> )
Return a numerical vector of real numbers such that its elements have the index of the column where is located the minimal value term by term of each numerical vector.
The numerical vectors must have the same size.
> A=vnumR[1,2,3:6,7,1:9,2,5:13,11,16]$ > writes("%g %g %g\n", A); 1 2 3 6 7 1 9 2 5 13 11 16 > B=IMIN(A); B double precision real vector : number of elements =4 > writes("%g\n", B); 1 3 2 2 >
Next: MINterme, Previous: IMINterme, Up: minimum et maximum [Contents][Index]
IMAX(
<array of real vec.> )
Return a numerical vector of real numbers such that its elements have the index of the column where is located the maximal value term by term of each numerical vector.
The numerical vectors must have the same size.
> A=vnumR[1,2,3:6,7,1:9,2,5:13,11,16]$ > writes("%g %g %g\n", A); 1 2 3 6 7 1 9 2 5 13 11 16 > B=IMAX(A); B double precision real vector : number of elements =4 > writes("%g\n", B); 3 2 1 3 >
Next: MAXterme, Previous: IMAXterme, Up: minimum et maximum [Contents][Index]
MIN(
<real vec.> ,
...)
Return a numerical vector of real numbers such that its elements have the minimal value term by term of each numerical vector.
The numerical vectors must have the same size.
For an array of numerical vector of real numbers, the operation is performed on each element.
> t=0,pi,pi/6$ > a=MIN(cos(t),sin(t))$ > c=MAX(t,cos(t),sin(t))$ > writes(a,c)$ +0.0000000000000000E+00 +1.0000000000000000E+00 +4.9999999999999994E-01 +8.6602540378443871E-01 +5.0000000000000011E-01 +1.0471975511965976E+00 +6.1232339957367660E-17 +1.5707963267948966E+00 -4.9999999999999978E-01 +2.0943951023931953E+00 -8.6602540378443849E-01 +2.6179938779914940E+00 -1.0000000000000000E+00 +3.1415926535897931E+00 > vnumR cs[1:2]$ > cs[1]=cos(t)$ > cs[2]=sin(t)$ > b=MIN(cs)$ > d=MAX(t,cs)$ > writes(b,d); +0.0000000000000000E+00 +1.0000000000000000E+00 +4.9999999999999994E-01 +8.6602540378443871E-01 +5.0000000000000011E-01 +1.0471975511965976E+00 +6.1232339957367660E-17 +1.5707963267948966E+00 -4.9999999999999978E-01 +2.0943951023931953E+00 -8.6602540378443849E-01 +2.6179938779914940E+00 -1.0000000000000000E+00 +3.1415926535897931E+00
Previous: MINterme, Up: minimum et maximum [Contents][Index]
MAX(
<real vec.> ,
...)
Return a numerical vector of real numbers such that its elements have the maximal value term by term of each numerical vector.
The numerical vectors must have the same size.
For an array of numerical vector of real numbers, the operation is performed on each element.
> t=0,pi,pi/6$ > a=MIN(cos(t),sin(t))$ > c=MAX(t,cos(t),sin(t))$ > writes(a,c)$ +0.0000000000000000E+00 +1.0000000000000000E+00 +4.9999999999999994E-01 +8.6602540378443871E-01 +5.0000000000000011E-01 +1.0471975511965976E+00 +6.1232339957367660E-17 +1.5707963267948966E+00 -4.9999999999999978E-01 +2.0943951023931953E+00 -8.6602540378443849E-01 +2.6179938779914940E+00 -1.0000000000000000E+00 +3.1415926535897931E+00 > vnumR cs[1:2]$ > cs[1]=cos(t)$ > cs[2]=sin(t)$ > b=MIN(cs)$ > d=MAX(t,cs)$ > writes(b,d); +0.0000000000000000E+00 +1.0000000000000000E+00 +4.9999999999999994E-01 +8.6602540378443871E-01 +5.0000000000000011E-01 +1.0471975511965976E+00 +6.1232339957367660E-17 +1.5707963267948966E+00 -4.9999999999999978E-01 +2.0943951023931953E+00 -8.6602540378443849E-01 +2.6179938779914940E+00 -1.0000000000000000E+00 +3.1415926535897931E+00
Next: tris, Previous: minimum et maximum, Up: Fonctions mathematiques et usuelles [Contents][Index]
• sum : | ||
• prod : | ||
• accum : |
Next: prod, Up: somme et produit [Contents][Index]
sum(
<num. vec.> )
sum(
<num. vec.> , "kahan" )
sum(
<num. vec.> , "sort", "kahan" )
Return the sum of elements in the numerical vector.
The option "sort" sort the vector using the ascending norm before the summation is done.
If the option "kahan" is set, the function uses the Kahan method to perform the summation (compensated summation).
Reference : Kahan, William (January 1965), "Further remarks on reducing truncation errors", Communications of the ACM 8 (1): 40, http://dx.doi.org/10.1145%2F363707.363723
> r=0,100$ > sum(r); 5050 > p=-10000,10000$ > p=p*pi/10000$ > sum(p); 3.885780586188048E-13 > // compensated summation > sum(p,"sort","kahan"); 0
Next: accum, Previous: sum, Up: somme et produit [Contents][Index]
prod(
<num. vec.> )
Return the product of elements in the numerical vector.
> p=1,10; p Tableau de reels : nb reels =10 > prod(p); 3628800 > c=p+2*i*p; c vecteur de complexes : nb complexes =10 > prod(c); (860025600-i*11307340800)
Previous: prod, Up: somme et produit [Contents][Index]
accum(
<num. vec.> )
Return the partial sum of elements in the numerical vector. Y=accum(X) alors Y[N] = sum(X[1:N])
> tx=1,10; tx Tableau de reels : nb reels =10 > ty=accum(tx); ty Tableau de reels : nb reels =10 > writes(accum(tx)); +1.000000000000000E+00 +3.000000000000000E+00 +6.000000000000000E+00 +1.000000000000000E+01 +1.500000000000000E+01 +2.100000000000000E+01 +2.800000000000000E+01 +3.600000000000000E+01 +4.500000000000000E+01 +5.500000000000000E+01
Next: transposevnum, Previous: somme et produit, Up: Fonctions mathematiques et usuelles [Contents][Index]
• intersectvnum: | ||
• unionvnum: | ||
• reversevnum: | ||
• sort: |
intersectvnum(
<num. vec.> A ,
<num. vec.> B)
It returns the values common to both numerical vectors A and B. The values of returned vector are in sorted order using ascending order.
> A = vnumR[7:1:7:5:4:6]$ > B = vnumR[0:7:4:-2:5:3]$ > C = intersectvnum(A,B); C double precision real vector : number of elements =3 > writes(C); +4.0000000000000000E+00 +5.0000000000000000E+00 +7.0000000000000000E+00 >
Next: reversevnum, Previous: intersectvnum, Up: tris [Contents][Index]
unionvnum(
<num. vec.> A ,
<num. vec.> B)
It returns a vector which contains the combined values from A and B with no repetitions. The values of returned vector are in sorted order using ascending order.
> A = vnumR[7:1:7:5:4:6]$ > B = vnumR[0:7:4:-2:5:3]$ > C = unionvnum(A,B); C double precision real vector : number of elements =8 > writes(C); -2.0000000000000000E+00 +0.0000000000000000E+00 +1.0000000000000000E+00 +3.0000000000000000E+00 +4.0000000000000000E+00 +5.0000000000000000E+00 +6.0000000000000000E+00 +7.0000000000000000E+00 >
reversevnum (
<num. vec.> )
Reverse the order of elements in the numerical vector.
> p=1,10; p Tableau de reels : nb reels =10 > writes(p, reversevnum(p)); +1.000000000000000E+00 +1.000000000000000E+01 +2.000000000000000E+00 +9.000000000000000E+00 +3.000000000000000E+00 +8.000000000000000E+00 +4.000000000000000E+00 +7.000000000000000E+00 +5.000000000000000E+00 +6.000000000000000E+00 +6.000000000000000E+00 +5.000000000000000E+00 +7.000000000000000E+00 +4.000000000000000E+00 +8.000000000000000E+00 +3.000000000000000E+00 +9.000000000000000E+00 +2.000000000000000E+00 +1.000000000000000E+01 +1.000000000000000E+00
Previous: reversevnum, Up: tris [Contents][Index]
sort (
<real vec.> )
Sort in ascending order the elements in the real vector.
sort (
<real vec.> ,
<(array of) num. vec.> ,
...);
Sort the elements in the (array of) numerical vectors according to the ascending sort of the first real vector.
Remarks : If you call ‘sort(TX,TY,TZ);’, the vector TY et TZ are sorted but TX isn’t sorted.
> p=vnumR[5:2:-3:7:1:6]; p Tableau de reels : nb reels =6 > sort(p); > writes(p); -3.000000000000000E+00 +1.000000000000000E+00 +2.000000000000000E+00 +5.000000000000000E+00 +6.000000000000000E+00 +7.000000000000000E+00 > T=vnumC[1+i:2+2*i:3+3*i:4+4*i:5+5*i:7+7*i]; T vecteur de complexes : nb complexes =6 > vnumR TAB[1:2]; > TAB[1]=abs(T); > TAB[2]=-real(T); > sort(-p,T,TAB);
Next: fonctions math, Previous: tris, Up: Fonctions mathematiques et usuelles [Contents][Index]
transposevnum (
<array of num. vec.> )
Transpose the array of numerical vectors.
The array must have only one dimension and its numerical vectors must have the same size.
> t=1,5; t Tableau de reels : nb reels =5 > vnumR TSRC[1:2]; > TSRC[1]=t; > TSRC[2]=reversevnum(t); > writes("%g %g\n",TSRC); 1 5 2 4 3 3 4 2 5 1 > TRES=transposevnum(TSRC); TRES [1:5] nb elements = 5 > writes("%g %g %g %g %g\n",TRES); 1 2 3 4 5 5 4 3 2 1
Previous: transposevnum, Up: Fonctions mathematiques et usuelles [Contents][Index]
• abs : | ||
• acos : | ||
• acosh : | ||
• arg : | ||
• asin : | ||
• asinh : | ||
• atan : | ||
• atanh : | ||
• atan2 : | ||
• conj : | ||
• cos : | ||
• cosh : | ||
• erf : | ||
• erfc : | ||
• exp : | ||
• fac : | ||
• histogram : | ||
• imag : | ||
• int : | ||
• log : | ||
• log10 : | ||
• mod : | ||
• nint : | ||
• real : | ||
• sign : | ||
• sin : | ||
• sinh : | ||
• sqrt : | ||
• tan : | ||
• tanh : |
Next: arg, Up: fonctions math [Contents][Index]
abs(
<constant or num. vec.> )
Return the absolute value of the constant if the value is a constant.
Return a numerical vector containing the absolute value of each element if the value is a numerical vector.
> abs(-2.3); 2.3 > x = 2.3; > abs(x); 2.3 > t=-pi,pi,pi/100; > at=abs(t); at Tableau de reels : nb reels =200 > abs(1+i); 1.4142135623731
Next: realtabnum, Previous: abs, Up: fonctions math [Contents][Index]
arg(
<constant or num. vec.> )
Return the argument (also called phase angle) of the constant if the value is a constant.
Return a numerical vector containing the argument (also called phase angle) of each element if the value is a numerical vector.
> arg(i); 1.5707963267949 > arg(1+i); 0.785398163397448 > t=0,pi,pi/6; t Tableau de reels : nb reels =7 > writes(arg(exp(i*t))); +0.000000000000000E+00 +5.235987755982987E-01 +1.047197551196598E+00 +1.570796326794897E+00 +2.094395102393195E+00 +2.617993877991494E+00 +3.141592653589793E+00
Next: imagtabnum, Previous: arg, Up: fonctions math [Contents][Index]
real(
<constant or num. vec.> )
Return the real part of the constant if the value is a constant.
Return a numerical vector containing the real part of each element if the value is a numerical vector.
> real(i); 0 > real(2+3*i); 2 > t=0,pi,pi/6; t Tableau de reels : nb reels =7 > writes(real(exp(i*t))); +1.000000000000000E+00 +8.660254037844387E-01 +5.000000000000000E-01 -0.000000000000000E+00 -4.999999999999998E-01 -8.660254037844385E-01 -1.000000000000000E+00 > real(4); 4
Next: conj, Previous: realtabnum, Up: fonctions math [Contents][Index]
imag(
<constant or num. vec.> )
Return the imaginary part of the constant if the value is a constant.
Return a numerical vector containing the imaginary part of each element if the value is a numerical vector.
> imag(i); 1 > imag(2+3*i); 3 > t=0,pi,pi/6; > writes(real(exp(i*t))); +1.000000000000000E+00 +8.660254037844387E-01 +5.000000000000000E-01 -0.000000000000000E+00 -4.999999999999998E-01 -8.660254037844385E-01 -1.000000000000000E+00 > imag(4); 0
Next: erf, Previous: imagtabnum, Up: fonctions math [Contents][Index]
conj(
<constant or num. vec.> )
Return the conjugate of the constant if the value is a constant.
Return a numerical vector containing the conjugate of each element if the value is a numerical vector.
> conj(1+i); (1-i*1) > conj(3); 3 > z=vnumC[1+i:3-5*i:i]; z vecteur de complexes : nb complexes =3 > writes(conj(z)); +1.000000000000000E+00 -1.000000000000000E+00 +3.000000000000000E+00 +5.000000000000000E+00 +0.000000000000000E+00 -1.000000000000000E+00
Next: erfc, Previous: conj, Up: fonctions math [Contents][Index]
erf(
<real or real vec.> )
Return the error function of the constant if the value is a real.
Return a numerical vector containing the error function of each element if the value is a numerical vector of real numbers.
The error function is defined by : erf(x) = (2/sqrt(pi) * integral from 0 to x of exp(-t*t) dt)
> erf(1); 0.842700792949715 > erf(0.5); 0.520499877813047 > t=-2,2; t Tableau de reels : nb reels =5 > r=erf(t); r Tableau de reels : nb reels =5 > writes(t,r); -2.0000000000000000E+00 -9.9532226501895271E-01 -1.0000000000000000E+00 -8.4270079294971478E-01 +0.0000000000000000E+00 +0.0000000000000000E+00 +1.0000000000000000E+00 +8.4270079294971478E-01 +2.0000000000000000E+00 +9.9532226501895271E-01
Next: exptabnum, Previous: erf, Up: fonctions math [Contents][Index]
erfc(
<real or real vec.> )
Return the complementary error function of the constant if the value is a real.
Return a numerical vector containing the complementary error function of each element if the value is a numerical vector of real numbers.
The complementary error function is defined by : erfc(x) = 1 - (2/sqrt(pi) * integral from 0 to x of exp(-t*t) dt)
> erf(1); 0.842700792949715 > erf(0.5); 0.520499877813047 > t=-2,2; t Tableau de reels : nb reels =5 > r=erf(t); r Tableau de reels : nb reels =5 > writes(t,r); -2.0000000000000000E+00 -9.9532226501895271E-01 -1.0000000000000000E+00 -8.4270079294971478E-01 +0.0000000000000000E+00 +0.0000000000000000E+00 +1.0000000000000000E+00 +8.4270079294971478E-01 +2.0000000000000000E+00 +9.9532226501895271E-01
Next: factabnum, Previous: erfc, Up: fonctions math [Contents][Index]
exp(
<constant or num. vec.> )
Return the base-e exponential of the constant if the value is a constant.
Return a numerical vector containing the base-e exponential of each element if the value is a numerical vector.
> exp(1.2); 3.32011692273655 > x = 1.2; > exp(x); 3.32011692273655 > exp(2*i); (-0.416146836547142+i*0.909297426825682) > t=-2,2; t Tableau de reels : nb reels =5 > r=exp(t); r Tableau de reels : nb reels =5 > writes(t,r); -2.000000000000000E+00 +1.353352832366127E-01 -1.000000000000000E+00 +3.678794411714423E-01 +0.000000000000000E+00 +1.000000000000000E+00 +1.000000000000000E+00 +2.718281828459045E+00 +2.000000000000000E+00 +7.389056098930650E+00
Next: sqrttabnum, Previous: exptabnum, Up: fonctions math [Contents][Index]
fac(
<constant or num. vec.> )
Return the factorial of a non-negative integer of the constant if the value is a constant.
Return a numerical vector containing the factorial of each element if the value is a numerical vector.
> fac(10); 3628800 > t=1,5; t double precision real vector : number of elements =5 > r=fac(t); r double precision real vector : number of elements =5 > writes(t,r); +1.0000000000000000E+00 +1.0000000000000000E+00 +2.0000000000000000E+00 +2.0000000000000000E+00 +3.0000000000000000E+00 +6.0000000000000000E+00 +4.0000000000000000E+00 +2.4000000000000000E+01 +5.0000000000000000E+00 +1.2000000000000000E+02 >
Next: costabnum, Previous: factabnum, Up: fonctions math [Contents][Index]
sqrt(
<constant or num. vec.> )
Return the square root of the constant if the value is a constant.
Return a numerical vector containing the square root of each element if the value is a numerical vector.
> x = 4; > sqrt(x); 2 > sqrt(1+i); (1.09868411346781+i*0.455089860562227) > t=0,5; t Tableau de reels : nb reels =6 > ts=sqrt(t); ts Tableau de reels : nb reels =6 > writes(t,ts); +0.000000000000000E+00 +0.000000000000000E+00 +1.000000000000000E+00 +1.000000000000000E+00 +2.000000000000000E+00 +1.414213562373095E+00 +3.000000000000000E+00 +1.732050807568877E+00 +4.000000000000000E+00 +2.000000000000000E+00 +5.000000000000000E+00 +2.236067977499790E+00
Next: sintabnum, Previous: sqrttabnum, Up: fonctions math [Contents][Index]
cos(
<constant or num. vec.> )
Return the cosine of the constant if the value is a constant.
Return a numerical vector containing the cosine of each element if the value is a numerical vector.
> cos(0.12); 0.992808635853866 > x=0; x = 0 > cos(x); >t=-pi,pi,pi/100; > at=cos(t); > cos(1+i); (0.833730025131149-i*0.988897705762865)
Next: tan, Previous: costabnum, Up: fonctions math [Contents][Index]
sin(
<constant or num. vec.> )
Return the sine of the constant if the value is a constant.
Return a numerical vector containing the sine of each element if the value is a numerical vector.
> sin(0.12); 0.119712207288912 > x = 0.12; > sin(x); 0.119712207288912 > t=-pi,pi,pi/100; > s=sin(t); > sin(4*i); (0+i*27.2899171971277)
Next: acos, Previous: sintabnum, Up: fonctions math [Contents][Index]
tan(
<constant or num. vec.> )
Return the tangent of the constant if the value is a constant.
Return a numerical vector containing the tangent of each element if the value is a numerical vector.
> x = 1.2; > tan(x); 2.57215162212632 > t=-pi,pi,pi/100; > at=tan(t); > tan(-1+i); (-0.271752585319512+i*95227/87854)
Next: asin, Previous: tan, Up: fonctions math [Contents][Index]
acos(
<real or real vec.> )
Return the principal value of the arc cosine of the real number if the value is a real number.
Return a real vector containing the principal value of the arc cosine of each element if the value is a real vector.
> acos(0.12); 1.4505064440011 > x = 0.12; > acos(x); 1.4505064440011 > t=-pi,pi,pi/100; > at=acos(t);
Next: atan, Previous: acos, Up: fonctions math [Contents][Index]
asin(
<real or real vec.> )
Return the principal value of the arc sine of the real number if the value is a real number.
Return a real vector containing the principal value of the arc sine of each element if the value is a real vector.
> asin(0.12); 0.120289882394788 > x = 0.12; > asin(x); 0.120289882394788 > t=-pi,pi,pi/100; > at=asin(t);
Next: cosh, Previous: asin, Up: fonctions math [Contents][Index]
atan(
<real or real vec.> )
Return the principal value of the arc tangent of the real number if the value is a real number.
Return a real vector containing the principal value of the arc tangent of each element if the value is a real vector.
> atan(2); 1.10714871779409 > x = 2; > atan(x); 1.10714871779409 > t=-pi,pi,pi/100; > at=atan(t);
Next: sinh, Previous: atan, Up: fonctions math [Contents][Index]
cosh(
<constant or num. vec.> )
Return the hyperbolic cosine of the constant if the value is a constant.
Return a numerical vector containing the hyperbolic cosine of each element if the value is a numerical vector.
> cosh(0.12); 1.0072086414827 > x = 0.12; > cosh(x); 1.0072086414827 > t=-pi,pi,pi/100; > at=cosh(t); > cosh(1+i); (0.833730025131149+i*0.988897705762865)
Next: tanh, Previous: cosh, Up: fonctions math [Contents][Index]
sinh(
<constant or num. vec.> )
Return the hyperbolic sine of the constant if the value is a constant.
Return a numerical vector containing the hyperbolic sine of each element if the value is a numerical vector.
> sinh(1.2); 1.50946135541217 > x = 1.2; > sinh(x); 1.50946135541217 > t=-pi,pi,pi/100; > s=sinh(t); > sinh(-1+3*i); (1.16344036370325+i*0.217759551622152)
Next: acosh, Previous: sinh, Up: fonctions math [Contents][Index]
tanh(
<constant or num. vec.> )
Return the hyperbolic tangent of the constant if the value is a constant.
Return a numerical vector containing the hyperbolic tangent of each element if the value is a numerical vector.
> x = 1.2; > tanh(x); 0.833654607012155 > tanh(1+i); (95227/87854+i*0.271752585319512) > t=0,10; t Tableau de reels : nb reels =11 > tanh(t);
Next: asinh, Previous: tanh, Up: fonctions math [Contents][Index]
acosh(
<constant or num. vec.> )
Return the inverse of the hyperbolic cosine of the constant if the value is a constant.
Return a numerical vector containing the inverse of the hyperbolic cosine of each element if the value is a numerical vector.
> acosh(1.2); 0.6223625037147786 > t=1,2,0.1; t Tableau de reels double-precision : nb reels =11 > acosh(t); Tableau de reels double-precision : nb reels =11
Next: atanh, Previous: acosh, Up: fonctions math [Contents][Index]
asinh(
<constant or num. vec.> )
Return the inverse of the hyperbolic sine of the constant if the value is a constant.
Return a numerical vector containing the inverse of the hyperbolic sine of each element if the value is a numerical vector.
> asinh(1.2); 1.015973134179692 > t=1,2,0.1; t Tableau de reels double-precision : nb reels =11 > asinh(t); Tableau de reels double-precision : nb reels =11
Next: atan2, Previous: asinh, Up: fonctions math [Contents][Index]
asinh(
<constant or num. vec.> )
Return the inverse of the hyperbolic tangent of the constant if the value is a constant.
Return a numerical vector containing the inverse of the hyperbolic tangent of each element if the value is a numerical vector.
> atanh(0.2); 0.2027325540540822 > t=0,1,0.1; t Tableau de reels double-precision : nb reels =11 > atanh(t); Tableau de reels double-precision : nb reels =11
Next: mod, Previous: atanh, Up: fonctions math [Contents][Index]
atan2(
<real or real vec.> ,
<real or real vec.> )
Return the principal value of the arc tangent of the first argument divided by the second argument using the signs of both arguments to determine the quadrant of the return value.
> y = 11.5; > x = 14; > atan2(y,x); 0.68767125603875
Next: int, Previous: atan2, Up: fonctions math [Contents][Index]
mod(
<real or real vec.> ,
<real or real vec.> )
<real or real vec.> mod
<real or real vec.>
Return the modulo of the first and second value. The result has the same sign as the first argument nd magnitude less than the magnitude of the second argument.
> mod(4,2); 0 > x=4$ > y=2$ > mod(x,y); 0 > t=21,30; > r=1,10; > f=mod(t,r); > g=mod(t,3);
Next: logtabnum, Previous: mod, Up: fonctions math [Contents][Index]
int(
<real or real vec.> )
Return the integer part of the real number if the value is a real.
Return a real vector containing the integer part of each element if the value is a real vector.
>x=1.23; >int(x); 1 > t=-pi,pi,pi/100; > at=int(t);
Next: log10, Previous: int, Up: fonctions math [Contents][Index]
log(
<constant or num. vec.> )
Return the neperian logarithm of the constant if the value is a constant.
Return a numerical vector containing the neperian logarithm of each element if the value is a numerical vector.
> log(3); 1.09861228866811 > x = 3; > log(x); 1.09861228866811 > r=1,10; > at=log(r); > log(2+i); (0.80471895621705+i*0.463647609000806)
Next: nint, Previous: logtabnum, Up: fonctions math [Contents][Index]
log10(
<constant or num. vec.> )
Return the decimal logarithm (base 10) of the constant if the value is a constant.
Return a numerical vector containing the decimal logarithm of each element if the value is a numerical vector.
> log(3); 1.09861228866811 > x = 3; > log(x); 1.09861228866811 > r=1,10; > at=log(r); > log(2+i); (0.80471895621705+i*0.463647609000806)
Next: sign, Previous: log10, Up: fonctions math [Contents][Index]
nint(
<real or real vec.> )
Return the nearest integer of the real number if the value is a real.
Return a real vector containing the nearest integer of each element if the value is a real vector.
> x=1.23; x = 1.23 > nint(x); 1 > nint(1.78); 2 > t=-1,1,0.1; t Tableau de reels : nb reels =21 > nint(t);
Next: histogram, Previous: nint, Up: fonctions math [Contents][Index]
sign(
<real or real vec.> )
Return the sign of the real number if the value is a real.
Return a real vector containing the sign of each element if the value is a real vector.
The function is defined with the following rules :
> sign(3); 1 > sign(-3); -1 > sign(0); 0 > t=-3,3; t Tableau de reels : nb reels =7 > writes(t,sign(t)); -3.0000000000000000E+00 -1.0000000000000000E+00 -2.0000000000000000E+00 -1.0000000000000000E+00 -1.0000000000000000E+00 -1.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +1.0000000000000000E+00 +1.0000000000000000E+00 +2.0000000000000000E+00 +1.0000000000000000E+00 +3.0000000000000000E+00 +1.0000000000000000E+00
Previous: sign, Up: fonctions math [Contents][Index]
histogram(
<real vec.> TY,
<real vec.> TX)
Return the histogram of TY with the specified ranges TX :
TZ=histogram(TY,TX) : TZ[N] contains the number of elements in TY such that TX[N]<=TY[j]<TX[N+1].
For the last range TX, the relation is : TX[N]<=TY[j]<=TX[N+1]
> TY=vnumR[0:1:4:5:6:9:10:11:-1:-2:-5]$ > TX=-3,9,2$ > writes("%g\n",TX); -3 -1 1 3 5 7 9 > TZ=histogram(TY,TX)$ > writes("%g\n",TZ); 1 2 1 1 2 1
Next: Conversion, Previous: Fonctions mathematiques et usuelles, Up: Vecteurs numeriques [Contents][Index]
?(
<condition>)
Return a numerical vector which contains only the numbers 0 or 1. For each element of the array : if the condition at index j is true then <name> [j]=1 else <name> [j]=0
?(
<condition>):
<constant or num. vec.> tabvrai :
<constant or num. vec.> tabfaux
Return a numerical vector which contains only the numbers 0 or 1. For each element of the array : if the condition at index j is true then <name> [j]=tabvrai[j] else <name> [j]=tabfaux[j]
All vectors must have the same size.
> t=0,5; t double precision real vector : number of elements =6 > r=5-t; r double precision real vector : number of elements =6 > q=?(t<=r); q double precision real vector : number of elements =6 > writes(q); +1.0000000000000000E+00 +1.0000000000000000E+00 +1.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 > l= ?(t<=r):i:5; l Double precision complex vector : number of elements =6 > writes(l); +0.0000000000000000E+00 +1.0000000000000000E+00 +0.0000000000000000E+00 +1.0000000000000000E+00 +0.0000000000000000E+00 +1.0000000000000000E+00 +5.0000000000000000E+00 +0.0000000000000000E+00 +5.0000000000000000E+00 +0.0000000000000000E+00 +5.0000000000000000E+00 +0.0000000000000000E+00 > m = ?(t>2):r:t; m double precision real vector : number of elements =6 > writes(m); +0.0000000000000000E+00 +1.0000000000000000E+00 +2.0000000000000000E+00 +2.0000000000000000E+00 +1.0000000000000000E+00 +0.0000000000000000E+00 >
Previous: Conditions, Up: Vecteurs numeriques [Contents][Index]
• dimtovnumR : | ||
• dimtovnumC : | ||
• vnumtodim : | ||
• strtabnum : | str. |
For the conversion from or to a numerical matrix, see Conversion.
Next: dimtovnumC, Up: Conversion [Contents][Index]
dimtovnumR
( <array> )
Return a numerical vector of real numbers from the array of series.
The array of series must contain only real numbers. The array must have only one dimension.
> dim ts[1:3]; > ts[1]=1$ > ts[2]=4$ > ts[3]=6$ > tr=dimtovnumR(ts)$ > writes(tr); +1.000000000000000E+00 +4.000000000000000E+00 +6.000000000000000E+00 > ltr=log(dimtovnumR(ts)); ltr Tableau de reels : nb reels =3
Next: vnumtodim, Previous: dimtovnumR, Up: Conversion [Contents][Index]
dimtovnumC
( <array> )
Return a numerical vector of complex numbers from the array of series.
The array of series must contain only complex numbers. The array must have only one dimension.
> dim ts[1:3]; > ts[1]=1+i$ > ts[2]=3*i$ > ts[3]=-5+i$ > tc=dimtovnumC(ts)$ > writes(tc); +1.000000000000000E+00 +1.000000000000000E+00 +0.000000000000000E+00 +3.000000000000000E+00 -5.000000000000000E+00 +1.000000000000000E+00 > ltc=exp(dimtovnumC(ts)); ltc vecteur de complexes : nb complexes =3
Next: strtabnum, Previous: dimtovnumC, Up: Conversion [Contents][Index]
vnumtodim
( <(array of) num. vec.> )
Return an array of series (constants) from the array of numerical vectors or from the numerical vector.
> tr=1,4; tr Tableau de reels : nb reels =4 > tsr=vnumtodim(tr); tsr [1:4] nb elements = 4 > afftab(tsr); tsr[1] = 1 tsr[2] = 2 tsr[3] = 3 tsr[4] = 4 > vnumC tc[1:2]; > tc[1]=i*tr$ > tc[2]=tr+i*tr**2$ > tsc=vnumtodim(tc); tsc [1:4, 1:2] nb elements = 8 > afftab(tsc); tsc[1,1] = (0+i*1) tsc[1,2] = (1+i*1) tsc[2,1] = (0+i*2) tsc[2,2] = (2+i*4) tsc[3,1] = (0+i*3) tsc[3,2] = (3+i*9) tsc[4,1] = (0+i*4) tsc[4,2] = (4+i*16)
Previous: vnumtodim, Up: Conversion [Contents][Index]
str
( <real vec.> );
str
( <string> format, <real vec.> );
Convert an vector of real numbers in an array of character strings. If format is specified, then each element of the vector is converted to this format.
For the description of the formats, see str.
> t = 8,10; t double precision real vector : number of elements =3 > tabs = str("%04g", t); tabs [1:3 ] number of elements = 3 > afftab(tabs); tabs[1] = "0008" tabs[2] = "0009" tabs[3] = "0010"
Next: Graphiques, Previous: Vecteurs numeriques, Up: Top [Contents][Index]
• Declaration : | ||
• Initialisation : | ||
• writes: | ||
• size : | ||
• Extraction : | ||
• Entree/Sortie : | ||
• Entree/Sortie bas niveau : | ||
• Fonctions mathematiques et usuelles : | ||
• Conditions : | ||
• Conversion : |
The numerical values stored in matrices are always real or complex double-precision, quadruple-precision or multiprecision numbers depending on the current numerical mode.
A numerical matrix is assumed to be a two-dimensional matrix. The numerical matrix are not resizeable.
The first dimension is the lines of the matrix and the second dimension is the columns of the matrix.
Next: InitialisationMat, Up: Matrices numeriques [Contents][Index]
• matrixR: | ||
• matrixC: |
Explicit declaration for numerical matrices are only required before call to read
, readbin
(see Entree/SortieTabNum) and assignment of a single or several elements.
Explicit declaration for array of numerical matrices are always required.
Next: matrixC, Up: DeclarationMat [Contents][Index]
matrixR
<name> ([
<two dimensions of a matrix> MxN ]) ,
... ;
matrixR
<name> [
<dimension of an array> ] ([
<two dimensions of a matrix> MxN ]) ,
... ;
It declares a real matrix of dimension MxN or an array of real matrices of dimension MxN.
After the declaration, the elements of the matrix are initialized with the value 0.
> matrixR C([1:3, 1:5]); > stat(C); Double precision real matrix C [ 1:3 , 1:5 ]. Size of the array in bytes: 120 > bounds= 1:3,1:6; bounds = bounds [ 1:3, 1:6 ] > matrixR T0[1:2]([bounds]); > stat(T0); Array of series T0 [ 1:2 ] list of array's elements : T0 [ 1 ] = Double precision real matrix T0 [ 1:3 , 1:6 ]. Size of the array in bytes: 144 T0 [ 2 ] = Double precision real matrix T0 [ 1:3 , 1:6 ]. Size of the array in bytes: 144 >
Previous: matrixR, Up: DeclarationMat [Contents][Index]
matrixC
<name> ([
<two dimensions of a matrix> MxN ]) ,
... ;
matrixC
<name> [
<dimension of an array> ] ([
<two dimensions of a matrix> MxN ]) ,
... ;
It declares a complex matrix of dimension MxN or an array of complex matrices of dimension MxN .
After the declaration, the elements of the matrix are initialized with the value 0+i*0.
> matrixC C([1:3, 1:5]); > stat(C); Double precision complex matrix C [ 1:3 , 1:5 ]. Size of the array in bytes: 240 > bounds=1:3,1:6; bounds = bounds [ 1:3, 1:6 ] > matrixC T0[1:2]([bounds]); > stat(T0); Array of series T0 [ 1:2 ] list of array's elements : T0 [ 1 ] = Double precision complex matrix T0 [ 1:3 , 1:6 ]. Size of the array in bytes: 288 T0 [ 2 ] = Double precision complex matrix T0 [ 1:3 , 1:6 ]. Size of the array in bytes: 288 >
Next: AffichageMat, Previous: DeclarationMat, Up: Matrices numeriques [Contents][Index]
<name> = matrixR
[
<real> or <real vec.> or <array of real vec.> ,
... :
<real> ,
... ] ;
It declares and initializes a real matrix with the specified reals or real vectors.
The character :
separates the lines and the character ,
separates the columns.
All columns must have the same line counts.
> // declare a real matrix 2x3 > tab3=matrixR[1,2,3:4,5,6]; tab3 double precision real matrix [ 1:2 , 1:3 ] > writes(tab3); +1.0000000000000000E+00 +2.0000000000000000E+00 +3.0000000000000000E+00 +4.0000000000000000E+00 +5.0000000000000000E+00 +6.0000000000000000E+00 >
<name> = matrixC
[
<complex> or <complex vec.> ,
... :
<complex> ,
... ] ;
It declares and initializes a complex matrix with the specified complex numbers or complex vectors.
The character :
separates the lines and the character ,
separates the columns.
All columns must have the same line counts.
> // declare a complex matrix 2x3 > tab3=matrixC[1+2*i,3+4*i,5:2,4*i, -7+2*i]; tab3 double precision complex matrix [ 1:2 , 1:3 ] > writes(tab3); +1.0000000000000000E+00 +2.0000000000000000E+00 +3.0000000000000000E+00 +4.0000000000000000E+00 +5.0000000000000000E+00 +0.0000000000000000E+00 +2.0000000000000000E+00 +0.0000000000000000E+00 +0.0000000000000000E+00 +4.0000000000000000E+00 -7.0000000000000000E+00 +2.0000000000000000E+00 >
Next: sizeMat, Previous: InitialisationMat, Up: Matrices numeriques [Contents][Index]
writes([
<integer> :
<integer> :
<integer> ],
<string> ,
<(array of) matrix> ,
...);
writes(
<string> ,
<(array of) matrix> ,
...);
writes(
<(array of) matrix> ,
...);
equivalent to
writes( { [binf:{bsup}:{step}], } {format,} <(array of) matrix> ,...).
It prints, to the screen, numerical matrices or the array of numerical matrices in columns form.
format is optional. This format is similar to the C format (cf. printf) and must be between double quotes ("). The format must contain the same number of format specifiers (e.g., %g) as the number of columns.
A complex matrix will be printed on two times more columns (the first for the real part and the second for the imaginary part).
> // display a real matrix 2x3 > mat3=matrixR[1,2,3:4,5,6]; mat3 double precision real matrix [ 1:2 , 1:3 ] > writes(mat3); +1.0000000000000000E+00 +2.0000000000000000E+00 +3.0000000000000000E+00 +4.0000000000000000E+00 +5.0000000000000000E+00 +6.0000000000000000E+00 > // display a complex matrix 2x3 > mat4=matrixC[1+2*i,3+4*i,5:2,4*i, -7+2*i]; mat4 double precision complex matrix [ 1:2 , 1:3 ] > writes(6*"%g "+"\n", mat4); 1 2 3 4 5 0 2 0 0 4 -7 2 >
afftab(
<matrix> );
It prints, to the screen, a numerical matrix. Each line of the matrix is surrounded by the characters [].
> _affc=1$ > // display a real matrix 2x3 > mat3=matrixR[1,2,3:4,5,6]; mat3 double precision real matrix [ 1:2 , 1:3 ] > afftab(mat3); [ 1 2 3] [ 4 5 6] > // display a complex matrix 2x3 > mat4=matrixC[1+2*i,3+4*i,5:2,4*i, -7+2*i]; mat4 double precision complex matrix [ 1:2 , 1:3 ] > afftab(mat4); [(1+i*2) (3+i*4) 5] [ 2 (0+i*4) (-7+i*2)] >
Next: ExtractionMat, Previous: AffichageMat, Up: Matrices numeriques [Contents][Index]
size(
<matrix> ,
<integer> n )
Return the number of lines of the numerical matrix if n=1.
Return the number of columns of the numerical matrix if n=2.
> mat3=matrixR[1,2,3:4,5,6]; mat3 double precision real matrix [ 1:2 , 1:3 ] > size(mat3,1); 2 > size(mat3,2); 3 >
Next: Entree/SortieMat, Previous: sizeMat, Up: Matrices numeriques [Contents][Index]
<matrix> [
<integer> binfli :
<integer> bsupli :
<integer> pasli
,
<integer> binfcol :
<integer> bsupcol :
<integer> pascol ];
Return a numerical matrix which contains only the elements located between the lower bound and the upper bound with the specified step.
If the lower bound isn’t specified, then the lower bound is assumed to be 1.
If the upper bound isn’t specified, then the upper bound is assumed to be the size of the numerical vector.
If the step isn’t specified, then the step is assumed to be 1.
Remark : All missing combinations are allowed.
> M=matrixR[1,2,3:4,5,6:7,8,9]; M double precision real matrix [ 1:3 , 1:3 ] > r=M[::2,::2]; r double precision real matrix [ 1:2 , 1:2 ] > writes(r); +1.0000000000000000E+00 +3.0000000000000000E+00 +7.0000000000000000E+00 +9.0000000000000000E+00 > v=M[1:2,2:3]; v double precision real matrix [ 1:2 , 1:2 ] > writes(v); +2.0000000000000000E+00 +3.0000000000000000E+00 +5.0000000000000000E+00 +6.0000000000000000E+00 >
Next: Entree/SortieMatbasniveau, Previous: ExtractionMat, Up: Matrices numeriques [Contents][Index]
The following functions work on the numerical matrices in the same behavior as on the numerical vectors :
• sauve_c : | ||
• sauve_fortran : | ||
• sauve_tex : | ||
• sauve_ml : | ||
• write : | ||
• writebin : |
Next: sauve_fortranMat, Up: Entree/SortieMat [Contents][Index]
sauve_c(
<matrix> ,
<filename> );
It saves the matrix to the file using the C language (version C99).
The file is created in the directory specified by _path
.
sauve_c(
<matrix> ,
<file> );
It saves the matrix to the file, previously opened in written mode, using the C language (version C99).
> A=matrixR[9,0,7 :1,2,3 :4,5,6]; A double precision real matrix [ 1:3 , 1:3 ] > sauve_c(A, "prog.c"); >
Next: sauve_texMat, Previous: sauve_cMat, Up: Entree/SortieMat [Contents][Index]
sauve_fortran(
<matrix> ,
<filename> );
It saves the matrix to the file using the Fortran language (version 77 or later).
The file source format is compatible with the fixed and free format.
The file is created in the directory specified by _path
.
sauve_fortran(
<matrix> ,
<file> );
It saves the matrix to the file, previously opened in written mode, using the Fortran language (version 77 or later). The file source format is compatible with the fixed and free format.
> A=matrixR[9,0,7 :1,2,3 :4,5,6]; A double precision real matrix [ 1:3 , 1:3 ] > sauve_fortran(A, "prog.f"); >
Next: sauve_mlMat, Previous: sauve_fortranMat, Up: Entree/SortieMat [Contents][Index]
sauve_tex(
<matrix> ,
<filename> );
It saves the matrix to the file using the TeX form.
The file is created in the directory specified by _path
.
sauve_tex(
<serie> ,
<file> );
It saves the matrix to the file, previously opened in written mode, using the TeX form.
> A=matrixR[9,0,7 :1,2,3 :4,5,6]; A double precision real matrix [ 1:3 , 1:3 ] > sauve_tex(A, "essai.tex"); >
Next: writeMat, Previous: sauve_texMat, Up: Entree/SortieMat [Contents][Index]
sauve_ml(
<matrix> ,
<filename> );
It saves the matrix to the file using the MathML 2.0 (concept) form.
The file is created in the directory specified by _path
.
sauve_ml(
<matrix> ,
<file> );
It saves the matrix to the file, previously opened in written mode, using the MathML 2.0 (concept) form.
> A=matrixR[9,0,7 :1,2,3 :4,5,6]; A double precision real matrix [ 1:3 , 1:3 ] > sauve_ml(A, "essai.ml"); >
Next: writebinMat, Previous: sauve_mlMat, Up: Entree/SortieMat [Contents][Index]
This function works on the numerical matrices in the same behavior as on the numerical vectors (see write).
Previous: writeMat, Up: Entree/SortieMat [Contents][Index]
This function works on the numerical matrices in the same behavior as on the numerical vectors (see writebin).
Next: FonctionsmathematiquesMat, Previous: Entree/SortieMat, Up: Matrices numeriques [Contents][Index]
The following functions work on the numerical matrices in the same behavior as on the numerical vectors :
file_write
(see file_write)
Next: ConditionsMat, Previous: Entree/SortieMatbasniveau, Up: Matrices numeriques [Contents][Index]
• Matrix multiplication : | ||
• Kronecker product : | ||
• Determinant: | ||
• Inverse of a matrix : | ||
• Trace of a matrix : | ||
• Transpose of a matrix: | ||
• Identity matrix : | ||
• eigenvalues: | ||
• eigenvectors: | ||
• Arithmetique: |
The following functions work on the numerical matrices in the same behavior as on the numerical vectors. These operations apply on each element of the matrix.
abs
acos
acosh
arg
asin
asinh
atan
atanh
atan2
conj
cos
cosh
erf
erfc
exp
imag
int
log
log10
MAX
MIN
mod
nint
real
sign
sin
sinh
tan
tanh
The following functions work on the numerical matrices in the same behavior as on the numerical vectors. These operations apply on the matrix.
max
min
sum
Next: KroneckerMat, Up: FonctionsmathematiquesMat [Contents][Index]
<matrix> &*
<matrix>
Compute the matrix product of the numerical matrix.
Remark : the number of columns of the first matrix must be same as the number of lines of the second matrix.
> _affc=1$ > A = matrixR[1,3,5 :2,4,6]; A double precision real matrix [ 1:2 , 1:3 ] > B = matrixR[5,8,11 :7,6,8 :4,0,8]; B double precision real matrix [ 1:3 , 1:3 ] > C = A&*B; C double precision real matrix [ 1:2 , 1:3 ] > afftab(C); [ 46 26 75] [ 62 40 102] >
<matrix> &*
<num. vec.>
<num. vec.> &*
<matrix>
Compute the matrix product of the numerical matrix and a numerical vector.
Next: detMat, Previous: ProdMat, Up: FonctionsmathematiquesMat [Contents][Index]
kroneckerproduct(
<matrix> A ,
<matrix> B)
It returns the Kronecker prouct of two numerical matrices.
> _affc=1$ > A = matrixR[1,2,3:4,5,6]$ > B = matrixR[5,0:10,1:7,3]$ > C = kroneckerproduct(A,B)$ > afftab(C); [ 5 0 10 0 15 0] [ 10 1 20 2 30 3] [ 7 3 14 6 21 9] [ 20 0 25 0 30 0] [ 40 4 50 5 60 6] [ 28 12 35 15 42 18] >
Next: InvMat, Previous: KroneckerMat, Up: FonctionsmathematiquesMat [Contents][Index]
det(
<matrix> )
Computes the determinant of a square matrix.
Remarks : When computations are performed in double precision, the Lapack Library is used. The LU algorithm is used in all numerical precision.
> t=matrixR[9,0,7 :1,2,3 :4,5,6]; t double precision real matrix [ 1:3 , 1:3 ] > det(t); -48 >
Next: TraceMat, Previous: detMat, Up: FonctionsmathematiquesMat [Contents][Index]
invertmatrix(
<matrix> )
Computes the inverse of a square matrix.
Remarks : When computations are performed in double precision, the Lapack Library is used. The LU algorithm is used in all numerical precision.
> _affc=2$ > A=matrixR[9,0,7 :1,2,3 :4,5,6]; A double precision real matrix [ 1:3 , 1:3 ] > B=invertmatrix(A); B double precision real matrix [ 1:3 , 1:3 ] > afftab(B); [ 0.0625 - 0.72916667 0.29166667] [ - 0.125 - 0.54166667 0.41666667] [ 0.0625 0.9375 - 0.375] >
Next: TransposeMat, Previous: InvMat, Up: FonctionsmathematiquesMat [Contents][Index]
tracematrix(
<matrix> )
Computes the trace of a square matrix.
> A=matrixR[9,0,7 :1,2,3 :4,5,6]; A double precision real matrix [ 1:3 , 1:3 ] > t=tracematrix(A); t = 17 >
Next: IdentityMat, Previous: TraceMat, Up: FonctionsmathematiquesMat [Contents][Index]
transposematrix(
<matrix> )
Computes the transpose of a square matrix.
> _affc=1$ > A=matrixR[9,0,7 :1,2,3]; A double precision real matrix [ 1:2 , 1:3 ] > B=transposematrix(A); B double precision real matrix [ 1:3 , 1:2 ] > afftab(B); [ 9 1] [ 0 2] [ 7 3] > >
Next: eigenvaluesMat, Previous: TransposeMat, Up: FonctionsmathematiquesMat [Contents][Index]
identitymatrix(
<operation> n )
Computes the identity matrix of size n. This matrix is a nxn square matrix with ones on the main diagonal and zeros elsewhere.
> _affc=1$ > I3=identitymatrix(3); I3 double precision real matrix [ 1:3 , 1:3 ] > afftab(I3); [ 1 0 0] [ 0 1 0] [ 0 0 1] >
Next: eigenvectorsMat, Previous: IdentityMat, Up: FonctionsmathematiquesMat [Contents][Index]
eigenvalues
(<matrix> )
Computes the eigenvalues of the square matrix using a QR algorithm (lapack library).
> A=matrixR[9,0,7 :1,2,3 :4,5,6]; A double precision real matrix [ 1:3 , 1:3 ] > B=eigenvalues(A); B Double precision complex vector : number of elements =3 > writes(B); +1.3769150418957313E+01 +0.0000000000000000E+00 +4.0843620348094420E+00 +0.0000000000000000E+00 -8.5351245376675389E-01 +0.0000000000000000E+00
Next: ArithmetiqueMat, Previous: eigenvaluesMat, Up: FonctionsmathematiquesMat [Contents][Index]
eigenvectors
(<matrix> MAT, <matrix> TVECT, <matrix> TVAL)
eigenvectors
(<matrix> MAT, <matrix> TVECT)
Compute the eigenvectors of the square matrix MAT using a QR algorithm (lapack library). It stores the eigenvectors in the matrix TVECT and the eigenvalues in the vector TVAL.
> _affc=1$ > A=matrixR[9,0,7 :1,2,3 :4,5,6]; A double precision real matrix [ 1:3 , 1:3 ] > eigenvectors(A,vectp,valp); > afftab(vectp); [ - 0.808169 - 0.750577 - 0.484664] [ - 0.209021 0.398522 - 0.547409] [ - 0.550611 0.527081 0.682234] > writes(valp); +1.3769150418957313E+01 +0.0000000000000000E+00 +4.0843620348094420E+00 +0.0000000000000000E+00 -8.5351245376675389E-01 +0.0000000000000000E+00 > // first vector > p=vectp[:,1]$ > writes(p); -8.0816903814944341E-01 +0.0000000000000000E+00 -2.0902130660832199E-01 +0.0000000000000000E+00 -5.5061138669696397E-01 +0.0000000000000000E+00
Previous: eigenvectorsMat, Up: FonctionsmathematiquesMat [Contents][Index]
The matrices must have the same number of elements on each dimension.
<matrix> + <matrix>
Add term by term two matrices.
<matrix> + <constant>
<constant> + <matrix>
Add a constant with each element of the matrix.
<matrix> + <num. vec.>
<num. vec.> + <matrix>
Add term by term the numerical vector and the matrix. The matrix must contain only one column.
<matrix> * <matrix>
Multiply term by term two matrices.
<matrix> * <constant>
<constant> * <matrix>
Multiply a constant with each element of the matrix.
<matrix> * <num. vec.>
<num. vec.> * <matrix>
Multiply term by term the numerical vector and the matrix. The matrix must contain only one column.
<matrix> - <matrix>
Substract term by term two matrices.
<matrix> - <constant>
<constant> - <matrix>
Subtract a numerical constant with each element of the matrix.
<matrix> - <num. vec.>
<num. vec.> - <matrix>
Subtract term by term the numerical vector and the matrix. The matrix must contain only one column.
<matrix> / <matrix>
Divide term by term two matrices.
<matrix> / <constant>
<constant> / <matrix>
Divide a numerical constant with each element of the matrix.
<matrix> / <num. vec.>
<num. vec.> / <matrix>
Divide term by term the numerical vector and matrix. The matrix must contain only one column.
Next: ConversionMat, Previous: FonctionsmathematiquesMat, Up: Matrices numeriques [Contents][Index]
?(
<condition>)
Return a real matrix which contains only the numbers 0 or 1. For each element of the array : if the condition at index i,j is true then <name> [i,j]=1 else <name> [i,j]=0
?(
<condition>):
<constant or matrix> tabvrai :
<constant or matrix> tabfaux
Return a numerical vector which contains only the numbers 0 or 1.
For each element of the condition : if the condition at index i,j is true then <name> [i,j]=tabvrai[i,j] else <name> [i,j]=tabfaux[j]
All matrix must have the same size.
> mat1=matrixR[1,2,3:4,5,6:7,8,9]; mat1 double precision real matrix [ 1:3 , 1:3 ] > mat2=matrixR[3,0,6:5,2,7:1,4,11]; mat2 double precision real matrix [ 1:3 , 1:3 ] > q=?(mat1<=5); q double precision real matrix [ 1:3 , 1:3 ] > writes(3*"%g "+"\n",q); 1 1 1 1 1 0 0 0 0 > m = ?(mat1>2):mat2:-1; m double precision real matrix [ 1:3 , 1:3 ] > writes(3*"%g "+"\n",m); -1 -1 6 5 2 7 1 4 11 >
Previous: ConditionsMat, Up: Matrices numeriques [Contents][Index]
matrixR(
<object identifier> )
Return a real matrix with the object identifier. The object identifier may be an array, a numerical vector ou an array of numerical vectors. The object must contain only real numbers.
> _affc=1$ > // convert an array of numbers to a real matrix > tab3=[1,2,3 :4,5,6]; tab3 [1:2, 1:3 ] number of elements = 6 > mat3=matrixR(tab3); mat3 double precision real matrix [ 1:2 , 1:3 ] > afftab(mat3); [ 1 2 3] [ 4 5 6] > // convert an numerical vector to a real matrix > v2= 1,10; v2 double precision real vector : number of elements =10 > mat2=matrixR(v2); mat2 double precision real matrix [ 1:10 , 1:1 ] >
matrixC(
<object identifier> )
Return a complex matrix with the object identifier. The object identifier may be an array, a numerical vector ou an array of numerical vectors. The object must contain only complex numbers.
> _affc=1$ > // convert an array of numbers to a complex matrix > tab3=[1+2*i,3+4*i,5 :2,4*i,-7+2*i]; tab3 [1:2, 1:3 ] number of elements = 6 > mat3=matrixC(tab3); mat3 double precision complex matrix [ 1:2 , 1:3 ] > afftab(mat3); [(1+i*2) (3+i*4) 5] [ 2 (0+i*4) (-7+i*2)] > // convert an numerical vector to a complex matrix > v2 = 1,10$ > v2 = exp(I*v2); v2 Double precision complex vector : number of elements =10 > mat2 = matrixC(v2); mat2 double precision complex matrix [ 1:10 , 1:1 ] >
vnumR(
<matrix> )
Return a real vector from the matrix. The matrix must have a single column.
> // convert a real matrix to a real vector > mat1=matrixR[2:3:5]; mat1 double precision real matrix [ 1:3 , 1:1 ] > v1=vnumR(mat1); v1 double precision real vector : number of elements =3 > writes(v1); +2.0000000000000000E+00 +3.0000000000000000E+00 +5.0000000000000000E+00 >
vnumC(
<matrix> )
Return a real vector from the matrix. The matrix must have a single column.
> // convert a complex matrix to a complex vector > mat1=matrixC[1+2*i:4*i:-7+2*i]; mat1 double precision complex matrix [ 1:3 , 1:1 ] > v1=vnumC(mat1); v1 Double precision complex vector : number of elements =3 > writes(v1); +1.0000000000000000E+00 +2.0000000000000000E+00 +0.0000000000000000E+00 +4.0000000000000000E+00 -7.0000000000000000E+00 +2.0000000000000000E+00 >
Next: Communications, Previous: Matrices numeriques, Up: Top [Contents][Index]
TRIP requires the following versions of gnuplot to work :
TRIP requires the following versions of grace to work :
The commands plot, replot, plotf, plotps, plotps_end and plotreset use grace or gnuplot depending on the global variable _graph (see _graph).
• plot : | ||
• replot : | ||
• plotf : | ||
• plotps : | ||
• plotps_end : | ||
• plotreset : | ||
• gnuplot : | ||
• grace : |
Next: replot, Up: Graphiques [Contents][Index]
plot(
<(array of) real vec.> TX,
<(array of) real vec.> TY);
plot(
<(array of) real vec.> TX,
<(array of) real vec.> TY,
<(array of) string> options);
Executes gnuplot or grace and plots the contents of the numerical vector TY function of TX.
The string options is directly sent to gnuplot or grace as an argument of the command plot.
If the string options contains double-quotes, two double-quotes must be used.
Remarks : Temporary files are created and will be destroyed at the end of the session.
plot(
<(array of) real vec.> TX,
<(array of) real vec.> TY,
<(array of) real vec.> TZ);
plot(
<(array of) real vec.> TX,
<(array of) real vec.> TY,
<(array of) real vec.> TZ,
<(array of) string> options);
Executes gnuplot or grace and plots in 3D the contents of the numerical vector TZ function of TY and TX.
plot(
<string> cmd,
<(array of) real vec.> TX,
<(array of) real vec.> TY);
plot(
<string> cmd,
<(array of) real vec.> TX,
<(array of) real vec.> TY,
<(array of) string> options);
It executes gnuplot or grace if necessary. It sends to gnuplot or grace the command cmd and plots the contents of the numerical vector TY function of TX.
plot(
<string> cmd,
<(array of) real vec.> TX,
<(array of) real vec.> TY,
<(array of) real vec.> TZ);
plot(
<string> cmd,
<(array of) real vec.> TX,
<(array of) real vec.> TY,
<(array of) real vec.> TZ,
<(array of) string> options);
It executes gnuplot or grace if necessary. It sends to gnuplot or grace the command cmd and plots in 3D the contents of the numerical vector TZ function of TY and TX.
plot( (
<(array of) real vec.> TX,
<(array of) real vec.> TY), ... );
plot( (
<(array of) real vec.> TX,
<(array of) real vec.> TY,
<(array of) string> options), ...);
Executes gnuplot or grace and overlays all draws of each couplet with plotting the contents of the numerical vector TY function of TX.
plot( (
<(array of) real vec.> TX,
<(array of) real vec.> TY,
<(array of) real vec.> TZ), ...);
plot( (
<(array of) real vec.> TX,
<(array of) real vec.> TY,
<(array of) real vec.> TZ,
<(array of) string> options), ...);
Executes gnuplot or grace and overlays all draws of each triplet with plotting in 3D the contents of the numerical vector TZ function of TY and TX. session.
plot(
<string> cmd, (
<(array of) real vec.> TX,
<(array of) real vec.> TY), ...);
plot(
<string> cmd, (
<(array of) real vec.> TX,
<(array of) real vec.> TY,
<(array of) string> options), ...);
It executes gnuplot or grace if necessary. It sends to gnuplot or grace the command cmd and plots the contents of each couplet of the numerical vector TY function of TX.
plot(
<string> cmd, (
<(array of) real vec.> TX,
<(array of) real vec.> TY,
<(array of) real vec.> TZ), ...);
plot(
<string> cmd, (
<(array of) real vec.> TX,
<(array of) real vec.> TY,
<(array of) real vec.> TZ,
<(array of) string> options), ...);
It executes gnuplot or grace if necessary. It sends to gnuplot or grace the command cmd and plots in 3D the contents of each triplet of the vectors TZ function of TY and TX.
Tracer cos(x) pour x=-pi à pi avec un pas de pi/100. > x=-pi,pi,pi/100; x Tableau de reels : nb reels =200 > y=cos(x); y Tableau de reels : nb reels =200 > plot(x,y); > plot(x,y,cos(x)); > plot(x,y,"notitle w points pt 5"); > plot(x,y,"title ""x,cos(x)"" "); > t=1,10; t Tableau de reels : nb reels =10 > plot("set xrange[2:5]",t,log(t)); > t=0,pi,pi/100; > vnumR ta[1:3]; > ta[1]=cos(t); > ta[2]=sin(t); > ta[3]=cosh(t); > dim nom[1:3]; > nom[1]="title 'cos' w l"; > nom[2]="title 'sin' w l"; > nom[3]="title 'cosh' w l"; > plot((t,ta,nom));
Next: plotf, Previous: plot, Up: Graphiques [Contents][Index]
replot(
<(array of) real vec.> TX,
<(array of) real vec.> TY);
replot(
<(array of) real vec.> TX,
<(array of) real vec.> TY,
<(array of) string> options);
replot(
<(array of) real vec.> TX,
<(array of) real vec.> TY,
<(array of) real vec.> TZ);
replot(
<(array of) real vec.> TX,
<(array of) real vec.> TY,
<(array of) real vec.> TZ,
<(array of) string> options);
replot(
<string> cmd,
<(array of) real vec.> TX,
<(array of) real vec.> TY);
replot(
<string> cmd,
<(array of) real vec.> TX,
<(array of) real vec.> TY,
<(array of) string> options);
replot(
<string> cmd,
<(array of) real vec.> TX,
<(array of) real vec.> TY,
<(array of) real vec.> TZ);
replot(
<string> cmd,
<(array of) real vec.> TX,
<(array of) real vec.> TY,
<(array of) real vec.> TZ,
<(array of) string> options);
replot( (
<(array of) real vec.> TX,
<(array of) real vec.> TY), ... );
replot( (
<(array of) real vec.> TX,
<(array of) real vec.> TY,
<(array of) string> options), ...);
replot( (
<(array of) real vec.> TX,
<(array of) real vec.> TY,
<(array of) real vec.> TZ), ...);
replot( (
<(array of) real vec.> TX,
<(array of) real vec.> TY,
<(array of) real vec.> TZ,
<(array of) string> options), ...);
replot(
<string> cmd, (
<(array of) real vec.> TX,
<(array of) real vec.> TY), ...);
replot(
<string> cmd, (
<(array of) real vec.> TX,
<(array of) real vec.> TY,
<(array of) string> options), ...);
replot(
<string> cmd, (
<(array of) real vec.> TX,
<(array of) real vec.> TY,
<(array of) real vec.> TZ), ...);
replot(
<string> cmd, (
<(array of) real vec.> TX,
<(array of) real vec.> TY,
<(array of) real vec.> TZ,
<(array of) string> options), ...);
This command is very similar to the command plot
but it overlays the draws on the previous draws.
It uses the same arguments as the command plot
(see plot).
replot;
Executes gnuplot or grace and send a command to redraw all graphics.
Tracer cos(x) et sin(x) pour x=-pi à pi avec un pas de pi/100 dans la même fenêtre. > x=-pi,pi,pi/100; x Tableau de reels : nb reels =200 > y=cos(x); y Tableau de reels : nb reels =200 > y1=sin(x); y1 Tableau de reels : nb reels =200 > plot(x,y); > replot(x,y1); > plot(x,y,y1); > replot(x,y,sin(2.*x)); > replot(x,sin(x),"notitle"); > replot(x,y,"w points pt 5");
Next: plotps, Previous: replot, Up: Graphiques [Contents][Index]
plotf(
<filename> filename,
<integer> ncolTX,
<integer> ncolTY);
It executes gnuplot or grace and plots the contents of the column ncolTY function of ncolTX in the file filename.
plotf(
<filename> filename,
<integer> ncolTX,
<integer> ncolTY,
<integer> ncolTZ);
It executes gnuplot or grace and plots the contents of the column ncolTZ function of ncolTY and ncolTX in the file filename.
gnuplot will ignore lines beginning by the character #
.
Afficher la troisieme colonne en fonction de la première colonne du fichier tab.out > plotf(tab.out,1,3); Afficher la troisieme colonne en fonction de la première et deuxième colonne du fichier tab.out > plotf(tab.out,1,2,3);
Next: plotps_end, Previous: plotf, Up: Graphiques [Contents][Index]
plotps
<filename> ;
It executes gnuplot or grace and set the terminal of gnuplot or grace in postscript.
All graphics will be stored in the specified postscript file.
This file will be located in the folder specified by _path
.
To close the postscript file, the command plotps_end
must be executed.
Tracer cos(x) pour x=-pi à pi avec un pas de pi/100 et le stocker dans le fichier res.ps. > x=-pi,pi,pi/100; x nb elements réels =200 > y=cos(x); y nb elements réels =200 > plotps res.ps; > plot(x,y); > plotps_end;
Next: plotreset, Previous: plotps, Up: Graphiques [Contents][Index]
plotps_end;
Close the file created by plotps
.
For gnuplot, it sets the terminal to its default value.
Remarks :
Tracer cos(x) pour x=-pi à pi avec un pas de pi/100 et le stocker dans le fichier res.ps. > x=-pi,pi,pi/100; x nb elements réels =200 > y=cos(x); y nb elements réels =200 > plotps res.ps; > plot(x,y); > plotps_end;
Next: gnuplot, Previous: plotps_end, Up: Graphiques [Contents][Index]
plotreset;
Send a command to reinitialize gnuplot or grace.
For gnuplot, it sends the command reset
.
For grace, it sends the command new
followed with redraw
.
> _graph=grace; _graph = grace > t=0,10; t Tableau de reels : nb reels =11 > plot(t,t); > plotreset;
Next: grace, Previous: plotreset, Up: Graphiques [Contents][Index]
gnuplot;
<gnuplot command>
<gnuplot command>@
<string> @
<gnuplot command>
%
<trip command> \
<trip command>
end;
An alternative syntax to gnuplot; ... end;
is gnuplot; ... gnuplot_end;
.
TRIP takes the gnuplot commands and sends them to gnuplot (line after line). Gnuplot is executed if it wasn’t started. The prompt becomes ‘gnuplot>’ when the user could enter the gnuplot commands.
When the first character is %, then the end of this line is one or more commands trip. This trip command could follow on several lines : the last character must be \ to indicates that the command follows on the next line.
Strings declared in trip could be send to gnuplot by surrounding with the character @.
> gnuplot; gnuplot> plot 'tftf' using 1:3 gnuplot> set xrange[1:10] gnuplot> replot gnuplot> end$ > > > gnuplot; gnuplot> set terminal macintosh singlewin Terminal type set to 'macintosh' Options are 'nogx singlewin novertical' gnuplot> %plot(t,log(t),"notitle"); gnuplot> %replot(t,exp(t),"notitle \ w points pt 5"); gnuplot> set terminal macintosh multiwin Terminal type set to 'macintosh' Options are 'nogx multiwin novertical' > ch="title 'sinus'"; ch = "title 'sinus'" > gnuplot; gnuplot> plot sin(x) @ch@ gnuplot> end;
Previous: gnuplot, Up: Graphiques [Contents][Index]
grace;
<commande grace>
<commande grace>@
<string> @
<commande grace>
%
<commande trip> \
<commande trip>
end;
TRIP takes the grace commands and sends them to grace (line after line). Grace is executed if it wasn’t started. The prompt becomes ‘grace>’ when the user could enter the grace commands.
WHen the first character is %, then the end of this line is one or more commands trip. This trip command could follow on several lines : the last character must be \ to indicates that the command follows on the next line.
Strings declared in trip could be send to grace by surrounding with the character @.
> grace; grace> grace> with g0 grace> read block "/USER/toto" grace> block xy "1:2" grace> read block "/USER/toto" grace> block xy "1:3" grace> redraw grace> title "2courbes" grace> %t=1,10; t Tableau de reels : nb reels =10 grace> %msg "deux lignes\ fin deligne"; deux lignesfin deligne grace> end; > >
Next: Macros, Previous: Graphiques, Up: Top [Contents][Index]
TRIP have different communication tools :
• Communications avec Maple : | ||
• Communications avec Mathematica : | ||
• Communications avec les autres systemes de calcul formel : | ||
• Librairie dynamique : |
TRIP communicates with other computer algebra systems on the same computer. These computer algebra systems must be able to import and export computations using the MathML 2.0 protocol.
A global common session is avaible for each computer algebra system. Several different session for each computer algebra system may be defined.
Next: Communications avec Mathematica, Up: Communications [Contents][Index]
TRIP communicates with Maple1 on all operating systems which could run maple.
The required version of maple must be equal or greater than 11.
• maple_put : | ||
• maple_get : | ||
• maple : |
Next: maple_get, Up: Communications avec Maple [Contents][Index]
maple_put(
<object identifier> id);
Send the object identifier to the global maple session. This starts maple if it isn’t running.
> _affdist=1$ > s=1+x; s(x) = 1 + x > maple_put(s); > maple; > s; 1 + x > end; >
maple_put(
<Maple client> session ,
<object identifier> id);
Send the object identifier to the maple session specified by session, which must be started previously.
> _affdist=1$ > fm=maple; > z:=1; z := 1 > end; > s=1+x; s(x) = 1 + x > maple_put(fm,s); > maple(fm); > z+s; 2 + x > end; >
Next: maple, Previous: maple_put, Up: Communications avec Maple [Contents][Index]
maple_get(
<object identifier> id);
Get the value of an object identifier from the global Maple session.
> _affdist=1$ > maple; > s:=1+y; s := 1 + y > end; > maple_get(s); > s; s(y) = 1 + y
maple_get(
<Maple client> session ,
<object identifier> id);
Get the value of an object identifier from the specified Maple session.
> _affdist=1$ > fm=maple; > s:=1+y; s := 1 + y > end; > maple_get(fm, s); > s; s(y) = 1 + y
Previous: maple_get, Up: Communications avec Maple [Contents][Index]
maple;
<commande maple>
%
<commande maple> \
<commande maple>
%
<commande trip> \
<commande trip>
end;
TRIP accepts maple commands and send them to the global Maple session (line after line). maple will be started if the global session is not already started. The prompt becomes ‘maple>’ when you could enter maple commands.
This maple command could continue on several lines : To continue the command on a new line, the last character of the line must be a \ .
If the first character is a %, then the end of the line will be considered as a TRIP command and not as a maple command. This TRIP command could continue on several lines : To continue the command on a new line, the last character of the line must be a \ .
The function maple_get
retrieves objects (series, vectors, ...) from maple.
The command maple_put
sends objects to maple.
> maple; > s:=gcd((x+1)*(x-1),(x-1)); s := x - 1 > %maple_get(s); > %s; s(x) = - 1 + 1*x > end; >
<Maple client> = maple;
<commande maple>
end;
This command is similar to the previous one but it starts a new session every time. It returns an object which specifies the session for the commands maple_put
and maple_get
.
An existing session could be continued by the command maple(
<Maple client> ); ... end;
.
The session may be closed by the command delete(
<Maple client> );
.
maple(
<Maple client> );
<commande maple>
end;
This command continues the existing session.
> fm=maple; > f:=gcd((x+1)*(x-1),(x-1)); f := x - 1 > g:=f+2; g := x + 1 > end; > maple_get(fm,g); > delete(fm);
Next: Communications avec les autres systemes de calcul formel, Previous: Communications avec Maple, Up: Communications [Contents][Index]
TRIP communicates with Mathematica2 on all operating systems which could run mathematica.
The required version of mathematica must be equal or greater than 9.
• mathematica_put : | ||
• mathematica_get : | ||
• mathematica : |
Next: mathematica_get, Up: Communications avec Mathematica [Contents][Index]
mathematica_put(
<object identifier> id);
Send the object identifier to the global mathematica session. This starts mathematica if it isn’t running.
> _affdist=1$ > s=1+x; s(x) = 1 + x > mathematica_put(s); > mathematica; > s 1 + x > end; >
mathematica_put(
<Mathematica client> session ,
<object identifier> id);
Send the object identifier to the mathematica session specified by session, which must be started previously.
> _affdist=1$ > fm=mathematica; > z:=1; > end; > s=1+x; s(x) = 1 + x > mathematica_put(fm,s); > mathematica(fm); > z+s; > end; >
Next: mathematica, Previous: mathematica_put, Up: Communications avec Mathematica [Contents][Index]
mathematica_get(
<object identifier> id);
Get the value of an object identifier from the global mathematica session.
> _affdist=1$ > mathematica; > s:=1+y; > end; > mathematica_get(s); > s; s(y) = 1 + y >
mathematica_get(
<Mathematica client> session ,
<object identifier> id);
Get the value of an object identifier from the specified Mathematica session.
> _affdist=1$ > fm=mathematica; > s:=1+y; > end; > mathematica_get(fm, s); > s; s(y) = 1 + y >
Previous: mathematica_get, Up: Communications avec Mathematica [Contents][Index]
mathematica;
<commande mathematica>
%
<commande mathematica> \
<commande mathematica>
%
<commande trip> \
<commande trip>
end;
TRIP accepts mathematica commands and send them to the globale session of Mathematica (line after line). mathematica will be started if the global session not already started. The prompt becomes ‘mathematica>’ when you could enter mathematica commands.
This mathematica command could continue on several lines : To continue the command on a new line, the last character of the line must be a \ .
If the first character is a %, then the end of the line will be considered as a TRIP command and not as a mathematica command. This TRIP command could continue on several lines : To continue the command on a new line, the last character of the line must be a \ .
The function mathematica_get
retrieves objects (series, vectors, ...) from mathematica.
The command mathematica_put
sends objects to mathematica.
> mathematica; > s=PolynomialGCD[(x+1)*(x-1),(x-1)] -1 + x > %mathematica_get(s); > %s; s(x) = - 1 + 1*x > end; >
<Mathematica client> = mathematica;
<commande mathematica>
end;
This command is similar to the previous one but it starts a new session every time. It returns an object which specifies the session for the commands mathematica_put
and mathematica_get
.
An existing session could be continued by the command mathematica(
<Mathematica client> ); ... end;
.
The session may be closed by the command delete(
<Mathematica client> );
.
mathematica(
<Mathematica client> );
<commande mathematica>
end;
This command continues the existing session.
> fm=mathematica; > f=PolynomialGCD[(x+1)*(x-1),(x-1)] -1 + x > g=f+2 1 + x > end; > mathematica_get(fm,g); > delete(fm); >
Next: Librairie dynamique, Previous: Communications avec Mathematica, Up: Communications [Contents][Index]
TRIP communicates with other computer algebra systems on the same or remote computer. These computer algebra systems must be able to compatible with the "Symbolic Computation Software Composability Protocol" (SCSCP) version 1.3 (http://www.symcomp.org/). It supports the OpenMath symbols from the scscp1 content dictionary (http://www.win.tue.nl/SCIEnce/cds/scscp1.html) and from the scscp2 content dictionary (http://www.win.tue.nl/SCIEnce/cds/scscp2.html). The list of OpenMath content dictionary is given in the appendice (see Supported OpenMath Content Dictionaries).
Multiple connections could be opened at the same time. TRIP could run in client or server mode.
Before using any functions from this module, you must execute the following command in the TRIP session. This command defines many subroutines which contain the definition of the Openmath symbols.
include libscscpserver.t; |
• serveur SCSCP: | ||
• client SCSCP: |
In order to start the SCSCP server of TRIP, you should execute the following command in a TRIP session :
include libscscpserver.t; port = 26133; %scscp_runserver[port]; |
The value of the variable of port may be changed. The default is 26133 for SCSCP servers.
The global variables of TRIP, such as _modenum
, could be modified before starting the SCSCP server.
The file libscscpserver.t
exports some symbols from the standard OpenMath content dictionaries.
New symbols could be exported to add new functionalities to the SCSCP server.
The function scscp_map_macroassymbolcd
, defined in the file libscscpserver.t
, must be used.
scscp_map_macroassymbolcd(
<string> macroname, <string> cdname, <string> symbolname );
Associate the symbol symbolname of the content dictionary cdname with the macro macroname. When this symbol is found by theSCSCP server or the SCSCP client in a exchanged message, then this macro is executed.
include libscscpserver.t; _modenum=NUMRATMP; macro myscscp_evalmul[P1, P2, value] { t=value,value; q=evalnum(P1*P2,REAL, (x,t)); return q[1]; }; scscp_map_macroassymbolcd("myscscp_evalmul", "SCSCP_transient_1","scscp_muleval"); %scscp_runserver[26133];
see scscp_disable_cd.
The SCSCP server of TRIP allow the following operations through the content dictionary scscp_transient_1
:
> with(SCSCP): > with(Client): > cookie := StorePersistent("localhost:26133", x*y+1); cookie := "TempOID1@localhost:26133" > Retrieve("localhost:26133", cookie); Error, (in SCSCP:-Client:-ExtractAnswer) unsupported_CD, <OMS cd = 'polyr' name = 'term'/> > CallService("localhost", "scscp_transient_1", "serverdisablecd", ["polyr"]): > CallService("localhost", "scscp_transient_1", "serverdisablecd", ["polyu"]): > Retrieve("localhost:26133", cookie); 1.0000000000000000 + 1.0000000000000000 x y
Previous: serveur SCSCP, Up: Communications avec les autres systemes de calcul formel [Contents][Index]
TRIP communicates with other computer algebra systems providing a SCSCP server.
• scscp_connect : | ||
• scscp_close : | ||
• scscp_put : | ||
• scscp_get : | ||
• scscp_delete : | ||
• scscp_execute : | ||
• scscp_disable_cd : |
Next: scscp_close, Up: client SCSCP [Contents][Index]
scscp_connect(
<string> computername, <integer> port );
Connect to the computer algebra system on the remote computer using the specified port. This function returns an scscp client object which manages that connection.
> include libscscpserver.t; Loading the SCSCP client/server library... Registering the OpenMath CD... > port=26133; port = 26133 > sc=scscp_connect("localhost", port); sc = client SCSCP connecte au serveur SCSCP localhost > scscp_close(sc); > stat(sc); client SCSCP sc : deconnecte
Next: scscp_put, Previous: scscp_connect, Up: client SCSCP [Contents][Index]
scscp_close(
<scscp client> sc );
Close the connection to the computer algebra system specified by sc.
> include libscscpserver.t; Loading the SCSCP client/server library... Registering the OpenMath CD... > port=26133; port = 26133 > sc=scscp_connect("localhost", port); sc = client SCSCP connecte au serveur SCSCP localhost > scscp_close(sc); > stat(sc); client SCSCP sc : deconnecte
Next: scscp_get, Previous: scscp_close, Up: client SCSCP [Contents][Index]
scscp_put(
<scscp client> sc, <operation> x );
scscp_put(
<scscp client> sc, <operation> x, <string> storeoption );
Send the object identifier x to the computer algebra system using the scscp client sc, previously opened with scscp_connect
.
This function returns a remote object.
If storeoption isn’t specified, then its value is "persistent".
The string storeoption must be one of the following values :
> include libscscpserver.t; Loading the SCSCP client/server library... Registering the OpenMath CD... > port=26133; port = 26133 > sc=scscp_connect("localhost", port); sc = client SCSCP connecte au serveur SCSCP localhost > r=1+x; r(x) = 1 + 1*x > remoter=scscp_put(sc, r); remoter = objet distant "TempOID1@localhost:26133" > scscp_close(sc);
Next: scscp_delete, Previous: scscp_put, Up: client SCSCP [Contents][Index]
scscp_get(
<remote object> remoteobjectid );
Get the value of the object identifier from the remote computer algebra system using the object remoteobjectid, previously returned by scscp_put
.
> include libscscpserver.t; Loading the SCSCP client/server library... Registering the OpenMath CD... > port=26133; port = 26133 > sc=scscp_connect("localhost", port); sc = client SCSCP connecte au serveur SCSCP localhost > s=(1+x+y)**2; s(x,y) = 1 + 2*y + 1*y**2 + 2*x + 2*x*y + 1*x**2 > remoteS = scscp_put(sc, s); remoteS = objet distant "TempOID1@localhost:26133" > q=scscp_get(remoteS); q(x,y) = 1 + 2*y + 1*y**2 + 2*x + 2*x*y + 1*x**2 > scscp_close(sc);
Next: scscp_execute, Previous: scscp_get, Up: client SCSCP [Contents][Index]
scscp_delete(
<remote object> remoteobjectid );
Destroy the value of the object identifier from the remote computer algebra system using the object remoteobjectid, previously returned by scscp_put
.
> include libscscpserver.t; Loading the SCSCP client/server library... Registering the OpenMath CD... > port=26133; port = 26133 > sc=scscp_connect("localhost", port); sc = client SCSCP connecte au serveur SCSCP localhost > s=(1+x+y)**2; s(x,y) = 1 + 2*y + 1*y**2 + 2*x + 2*x*y + 1*x**2 > remoteS = scscp_put(sc, s); remoteS = objet distant "TempOID1@localhost:26133" > delete(remoteS); > scscp_close(sc);
Next: scscp_disable_cd, Previous: scscp_delete, Up: client SCSCP [Contents][Index]
scscp_execute(
<scscp client> sc, <string> returnoption , <string> CDname , <string> remotecommand , <operation> , ... );
It executes the command remotecommand of the OpenMath CD CDname on the remote computer algebra system specified by sc. The parameters are specified just after the name of the command.
The string returnoption must be one of the following values :
> include libscscpserver.t; Loading the SCSCP client/server library... Registering the OpenMath CD... > port=26133; port = 26133 > sc=scscp_connect("localhost", port); sc = client SCSCP connecte au serveur SCSCP localhost > q = scscp_execute(sc,"object", "SCSCP_transcient_1", "SCSCP_MUL", 1+7*x,2+3*x); q(x) = 2 + 17*x + 21*x**2 > qr = scscp_execute(sc,"cookie", "SCSCP_transcient_1", "SCSCP_MUL", 1+7*x,2+3*x); qr = objet distant "TempOID6@localhost:26133" > scscp_close(sc);
Previous: scscp_execute, Up: client SCSCP [Contents][Index]
scscp_disable_cd(
<string> CDname , );
It disable the content dictionary CDname. This dictionary will not be used for the OpenMath output and for the communication with the remote computer algebra system.
> include libscscpserver.t; Loading the SCSCP client/server library... Registering the OpenMath CD... > port=26133; port = 26133 > sc=scscp_connect("localhost", port); sc = client SCSCP connecte au serveur SCSCP localhost > scscp_disable_cd("polyr"); > scscp_disable_cd("polyu"); > s=(1+x+y)**2$ > q=scscp_put(sc, s); q = objet distant "TempOID1@localhost:26133" > scscp_close(sc);
Previous: Communications avec les autres systemes de calcul formel, Up: Communications [Contents][Index]
TRIP can load a dynamic library and execute functions of this library. The dynamic libraries have the extensions .so, .dll, .dylib depending on the operating system. The function prototypes is required in order to perform the conversion of the parameters.
• extern_function : | ||
• extern_lib : | ||
• extern_type : | ||
• extern_display : |
Next: extern_lib, Up: Librairie dynamique [Contents][Index]
extern_function(
<filename> filelib,
<string> declfunc);
extern_function(
<filename> filelib,
<string> declfunc,
<string> declinout);
It loads the dynamic library filelib. It adds the specific extension (.dll, .so, .dylib) of the operating system. It checks the availability of the function in this library. The function could be called as any other standard function of TRIP.
It checks the validity of the prototype of the function specified by declfunc. The prototype must be written in C language. The implementation function could be written in another language (fortran, ...).
If the dynamic library depends on other libraries , then it requires to load the other libraries with the command extern_lib
.
By default, all arguments are input only. To specify that arguments are input-output, it must be specified in the string declinout. This string must contain the same number of elements as the number of parameter of the function. Each element are separated with a comma. An element could have the following values :
For output arguments, an object identifier must be given to the function to get the value.
Remarks : the function could not have structure or derived type.
> extern_function("libm", "double j0(double);"); > r = j0(0.5); r = 0.9384698072408129
/* Appel de sa propre librairie libtest1 contenant test1.c */ > !"cat test1.c"; #include <math.h> double mylog1p(double x) { return log1p(x); } void mylog1parray(double tabdst[], double tabsrc[], int n) { int i; for(i=0; i<n; i++) tabdst[i]=log1p(tabsrc[i]); } > > extern_function(libtest1,"double mylog1p(double x);"); > mylog1p(10); 2.39789527279837 > log(11); 2.39789527279837 > extern_function(libtest1, "void mylog1parray(double tabdst[], double tabsrc[], int n);", "inout,in,in"); > t=1,10; t Tableau de reels : nb reels =10 > vnumR res; resize(res,10); > mylog1parray(res,t,10); > writes(t,res); +1.0000000000000000E+00 +6.9314718055994529E-01 +2.0000000000000000E+00 +1.0986122886681098E+00 +3.0000000000000000E+00 +1.3862943611198906E+00 +4.0000000000000000E+00 +1.6094379124341003E+00 +5.0000000000000000E+00 +1.7917594692280550E+00 +6.0000000000000000E+00 +1.9459101490553132E+00 +7.0000000000000000E+00 +2.0794415416798357E+00 +8.0000000000000000E+00 +2.1972245773362196E+00 +9.0000000000000000E+00 +2.3025850929940459E+00 +1.0000000000000000E+01 +2.3978952727983707E+00
Next: extern_type, Previous: extern_function, Up: Librairie dynamique [Contents][Index]
extern_lib(
<filename> filelib);
Load the dynamic library filelib. It adds the specific extension (.dll, .so, .dylib) of the operating system. This function is used to load librairies required by other librairies.
> extern_lib("libm"); > extern_function("libm", "double j0(double);"); > r = j0(0.5); r = 0.9384698072408129
Next: extern_display, Previous: extern_lib, Up: Librairie dynamique [Contents][Index]
extern_lib(
<string> type);
Declares an external type type. The external functions can use or return pointer to objects of this type. type could be a C data structure whose fields may be read or modified.
> extern_type("t_calcephbin"); > extern_function("libcalceph", "t_calcephbin* calceph_open(const char *filename);"); > eph = calceph_open("inpop06c_m100_p100_littleendian.dat");
Previous: extern_type, Up: Librairie dynamique [Contents][Index]
extern_display;
Display the list of external types or functions previously loaded with the command extern_function
or extern_type
.
> extern_function("libm", "double j0(double);"); > extern_function("libm", "double j1(double);"); > extern_display; Liste des fonctions externes : double j1(double); double j0(double);
Next: Boucles et conditions, Previous: Communications, Up: Top [Contents][Index]
• Declaration : | ||
• Execution : | ||
• return : | ||
• Liste des macros : | ||
• affmac : | Affichage du code. | |
• Effacement : | ||
• Comment redefinir une macro : | ||
• Comment sauver une macro : |
macro
<name> [ <list of parameters> ] { <body> };
macro
<name> { <body> };
MACRO
<name> [ <list of parameters> ] { <body> };
MACRO
<name> { <body> };
private macro
<name> [ <list of parameters> ] { <body> };
private macro
<name> { <body> };
Define a macro with 0 or more parameter and a body of trip code.
The list of parameters are separated by a comma. The parameter must a name. There is no limitation with the number of parameters. The macros support recursivity but a limit exists (often 70 times).
The last parameter could be ...
to specify that this macro could receive one or more optional argument when it’s called.
To access to each optional argument, the keyword macro_optargs[]
is used.
To acces to the optional argument of index j, you just write macro_optargs[j]
.
To know the number of provided optional argument, the function size(macro_optargs)
must be used.
The values corresponding to the ...
could be given as an argument to the execution of a macro using macro_optargs
.
The execution of the macro could be immediately stopped using the stop
command (see stop).
The macro may define local object identifiers, See private.
The visibility of a macro is restricted to the source file which contains it if the declaration is prefixed by the keyword private
. Only other macros of the same file can call it.
The following example shows the definition of a macro a which assigns to r the sum of x and y. x and y are transmitted by arguments. The macro b displays the contents of the current directory.
> macro a [x,y] {r = x+y;}; > macro b { ! "ls";}; > macro macvar[x,y,...] { s=x+y; l = size(macro_optargs); msg("number of optional argument %g\n", l); for j=1 to l { msg("The optional argument %g :", j); macro_optargs[j]; }; }; > %macvar[P1,P2]; s(P1,P2) = 1*P2 + 1*P1 l = 0 number of optional argument 0 > %macvar[P1,P2,"arg1", 3,5, 7]; s(P1,P2) = 1*P2 + 1*P1 l = 4 number of optional argument 4 The optional argument 1 :macro_optargs[1] = "arg1" The optional argument 2 :macro_optargs[2] = 3 The optional argument 3 :macro_optargs[3] = 5 The optional argument 4 :macro_optargs[4] = 7 > macro macopt[x,y,...] { %macvar[x, macro_optargs]; };
Next: return, Previous: DeclarationMacro, Up: Macros [Contents][Index]
%
<name> [ <list of parameters> ];
%
<name> ;
Execute a macro. The list of parameters is a list of parameters separated by a comma.
The parameters can be object identifier, series (result of a computation), strings of characters, arrays or numerical vectors.
The parameter can be transmitted by value or reference.
Parameters given by value can only be a result of a computation, strings of characters, arrays or numerical vectors.
Parameters given by reference can be any object identifier or an element of array. To give a parameter by reference, it must be surrounded with additional brackets []. In this case, the object identifier can be modified or created during the execution of the macro.
The execution of the macro returns a value if the command return
has been called in the body of the macro.
The execution of the macro continues after the command return
.
The execution of the macro could be immediately stopped using the stop
command (see stop).
Execution of the macro a and b:
> %a[1,5+3*6]; /*ou si S = x + y*/ > %a[S,5]; >%b; >%c[[t],[u[5]],1+x]; Usage des chaines de caractères: > macro nomfichier[name,j] {msg name + str(j);}; > %nomfichier["file_",2]; file_2 > ch="file_1.2."; ch = "file_1.2." > %nomfichier[ch,3]; file_1.2.3 >
Remarks : The parameters (x,y,...) keep their values. To give an expression, it mustn’t be surrounded with brackets [].
- Si x vaut z et que l'on applique la macro a, une fois la macro exécutée, x vaudra z. Alors que si x n'est pas défini, sa valeur sera celle qu'il avait à la fin de l'exécution de la macro. Example : Si on veut ajouter à 'S' la variable 'x': > %a[S,[x]]; et on aura r(x,y) = 1*y + 2*x - Déclaration d'une matrice. L'identificateur R1 n'existe pas. /*creation d'une matrice */ >macro matrix_create[_nom, _nbligne, _nbcol] { dim _nom[0:_nbligne, 0: _nbcol]; for iligne=1 to _nbligne { for icol=1 to _nbcol {_nom[iligne,icol]=0$};}; /*met le nb de ligne en 0,0 et met le nb de col en 0,1 */ _nom[0, 0]=_nbligne$ _nom[0, 1]=_nbcol$ }; >%matrix_create[[R1],n,3]; Le tableau sera alors crée et initialise. En sortie de la macro, _nom, _nbligne, _nbcol n'existeront plus.
Next: Liste des macros, Previous: Execution, Up: Macros [Contents][Index]
return
(<operation> );
return
<operation> ;
Return the result of an operation when the macro is executed.
The execution of the macro continues after the command return
. Only the stop
command stops the execution of the macro.
return
(<operation> , <operation> , ...);
Return using an one-dimensional array the list of operations as the result of the execution of the macro. The first index of the array is 1.
> _affdist=1$ > macro func1 { s=1+y$ return s; }; > b=%func1; b(y) = 1 + y > macro func2 { v=1,10$ ch="file1"$ return (v, ch); }; > (a, s)=%func2; > a; a double precision real vector : number of elements =10 > s; s = "file1" > t=%func2; t [1:2 ] number of elements = 2 > afftab(t); t[1] = t double precision real vector : number of elements =10 t[2] = "file1" >
@
;
Display the list of the defined macros.
> @; Voici le nom des macros que je connais: a [x ,y ] b
Next: Effacement, Previous: Liste des macros, Up: Macros [Contents][Index]
affmac
<macro>;
Display the body (trip code) of the macro.
> affmac b; mon nom est : b !"ls";
Next: Comment redefinir une macro, Previous: affmac, Up: Macros [Contents][Index]
• effmac : | ||
• effmacros : |
Next: effmacros, Up: Effacement [Contents][Index]
effmac
<macro>;
Delete a macro.
> macro a[x] { return (x*2);}; > @; Voici le nom des macros que je connais : a [ x] > effmac a; > @; je ne connais aucune macro
Previous: effmac, Up: Effacement [Contents][Index]
effmacros
;
Remove all defined macros.
> macro a[x] { return (x*2);}; > macro b {!"ls";}; > @; Voici le nom des macros que je connais : a [ x] b [] > effmacros; > @; je ne connais aucune macro
Next: Comment sauver une macro, Previous: Effacement, Up: Macros [Contents][Index]
We write a new macro using the command
macro
.
> macro a [n] {n;}; > @; Voici le nom des macros que je connais: a [n ] > affmac a; mon nom est : a n;
Previous: Comment redefinir une macro, Up: Macros [Contents][Index]
To save the macros on disk, the best solution is to use a text editor such as vi, emacs or nedit. The name of the file which contains trip code should be ended with .t .
Next: Bibliotheques, Previous: Macros, Up: Top [Contents][Index]
• boucles : | ||
• condition : |
Next: condition, Up: Boucles et conditions [Contents][Index]
• while : | ||
• for : | ||
• sum : | ||
• prod : | ||
• stop : |
while (
<condition> ) do {
<body> };
Execute the body loop while the condition is true.
The while
loop is more yielding than for
loop because condition could be sophisticated.
A while
loop could be immediately stopped using the stop
command.
For the condition description, See condition.
The loop may define local object identifiers, See private. They will destroyed at the end of each iteration.
> // It displays the numbers from 1 to n: > p=1$ > while(p<=5) do { p; p=p+1$ }; p = 1 p = 2 p = 3 p = 4 p = 5 >
for
<nom> =
<real> to
<real> {
<body> };
for
<nom> =
<real> to
<real> step
<real> {
<body> };
Execute the loop "for ... until ..." (similar to the for loop in pascal, C or fortran languages).
The argument after step
is the loop step.
A for
loop could be immediately stopped using the stop
command.
The loop may define local object identifiers, See private. They will destroyed at the end of each iteration.
Remarks :
> for p = 1 to 5 step 2 {p; }; p = 1 p = 3 p = 5 > for p = 5 to -1 step -2 {p; }; p = 5 p = 3 p = 1 p = -1
The loop for may be parallelized using the terminology OpenMP. TRIP does not parallelize the loop if global objets are written or if functions which modified the global state of TRIP are called. In these cases, a warning is printed.
If the keyword distribute
is used,
the parallelization is performed on all computing nodes
if the application tripcluster runs this code.
/*!trip omp parallel for */
<nom>
for=
<real> to
<real> {
<body> };
/*!trip omp parallel for distribute */
<nom>
for=
<real> to
<real> {
<body> };
s=(1+x+y+z+t)**(20)$ dim f[1:8]; n=size(f)$ // parallel execution time_s; /*!trip omp parallel for */ for p = 1 to n { f[p]=s/p$ }; time_t; utilisateur 00.119s - reel 00.023s - systeme 00.019s - (594.73% CPU) // sequential execution time_s; for p = 1 to n { f[p]=s/p$ }; time_t; utilisateur 00.118s - reel 00.116s - systeme 00.008s - (109.27% CPU)
sum
<nom> =
<real> to
<real> {
<body> };
sum
<nom> =
<real> to
<real> step
<real> {
<body> };
Execute the loop "sum ... until ...". It replaces the for loop statement "s=0$ for j=1 to n { s=s+...$}".
The value returned by the statement return
is used for the summation.
The argument after step
is the loop step.
A sum
loop could be immediately stopped using the stop
command.
The loop may define local object identifiers, See private. They will destroyed at the end of each iteration.
Remarks :
> s=sum j=1 to 5 { return j; }; s = 15 > s=sum j=1 to 10 step 2 { a=3*j$ if (mod(j,2)==0) then { return a; } else { return -a; }; }; s = -75
prod
<nom> =
<real> to
<real> {
<body> };
prod
<nom> =
<real> to
<real> step
<real> {
<body> };
Execute the loop "prod ... until ...". It replaces the for loop statement "s=1$ for j=1 to n { s=s*...$}".
The value returned by the statement return
is used for the product.
The argument after step
is the loop step.
A prod
loop could be immediately stopped using the stop
command.
The loop may define local object identifiers, See private. They will destroyed at the end of each iteration.
Remarks :
> p = prod j = 1 to 10 { return j$ }; p = 3628800
stop;
Immediately stops the execution of a for
or while
loop or of a macro.
Remarks : if stop is used outside a for
or while
loop or macro statement, a warning message is displayed but the execution continues.
for p = 1 to 5 { if (p>3) then {stop;} fi; p;}; 1 2
Previous: boucles, Up: Boucles et conditions [Contents][Index]
• if : | ||
• operateur de comparaison: | ||
• switch : |
Next: operateur de comparaison, Up: condition [Contents][Index]
if (
<condition>) then {
<body> };
if (
<condition>) then {
<body> } else {
<body> };
if (
<condition>) then {
<body> } fi;
(obsolete statement)
Execute the first body (after the then statement) if the condition is true. The second body is executed if the condition is false.
> if (n == 2) then {msg "VRAI";} else {msg"FAUX";}; FAUX > n=2; 2 > if (( n >= 0) && (n < 3)) then {msg "VRAI";} else {msg "FAUX";}; VRAI
Remarks : All object identifiers should be intialized before the execution of the condition. Because otherwise, uninitialized object identifiers will be created as variables and the condition will return false.
<operation> !=
<operation>
This test returns true if the two operations are not equal.
Remarks : the test could be performed on polynomials.
<real vec.> !=
<real vec.>
This test could be used with the operator ?::
(see Conditions) or the command select
(see Extraction). It returns a numerical vector which contains only 0 or 1.
It compares each element of the two vectors. The numerical vector of real numbers must have the same size.
> if (n != 2) then {} else {}; > // Condition between two vectors > t = 0,10$ > r = 10,0,-1$ > q = ?(t!=r); q double precision real vector : number of elements =11 > q = ?(t!=5); q double precision real vector : number of elements =11 >
<operation> ==
<operation>
This test returns true if the two operations are equal.
If the two operands are the values NaN
(not a number) , then the test returns false.
Remarks : the test could be performed on polynomials.
<real vec.> ==
<real vec.>
This test could be used with the operator ?::
(see Conditions) or the command select
(see Extraction). It returns a numerical vector which contains only 0 or 1.
It compares each element of the two vectors. The numerical vector of real numbers must have the same size.
> if (n == 2) then {} else {}; > // Condition between two vectors > t = 0,10$ > r = 10,0,-1$ > q = ?(t==r); q double precision real vector : number of elements =11 > q = ?(t==5); q double precision real vector : number of elements =11 >
<real> <
<real>
This test returns true if the first real number is less than the second number.
<real vec.> <
<real vec.>
This test could be used with the operator ?::
(see Conditions) or the command select
(see Extraction). It returns a numerical vector which contains only 0 or 1.
It compares each element of the two vectors. The numerical vector of real numbers must have the same size.
> n=3$ > if (n < 2) then {} else {}; > > // Condition between two vectors > t = 0,10$ > r = 10,0,-1$ > q = ?(t<r); q double precision real vector : number of elements =11 > q = ?(t<5); q double precision real vector : number of elements =11 >
<real> >
<real>
This test returns true if the first real number is greater than the second number.
<real vec.> >
<real vec.>
This test could be used with the operator ?::
(see Conditions) or the command select
(see Extraction). It returns a numerical vector which contains only 0 or 1.
It compares each element of the two vectors. The numerical vector of real numbers must have the same size.
> n=3$ > if (n > 2) then {} else {}; > > // Condition between two vectors > t = 0,10$ > r = 10,0,-1$ > q = ?(t>r); q double precision real vector : number of elements =11 > q = ?(t>5); q double precision real vector : number of elements =11 >
<real> <=
<real>
This test returns true if the first real number is less or equal than the second number.
<real vec.> <=
<real vec.>
This test could be used with the operator ?::
(see Conditions) or the command select
(see Extraction). It returns a numerical vector which contains only 0 or 1.
It compares each element of the two vectors. The numerical vector of real numbers must have the same size.
> n=3$ > if (n <= 2) then {} else {}; > > // Condition between two vectors > t = 0,10$ > r = 10,0,-1$ > q = ?(t<=r); q double precision real vector : number of elements =11 > q = ?(t<=5); q double precision real vector : number of elements =11 >
<real> >=
<real>
This test returns true if the first real number is greater or equal than the second number.
<real vec.> >=
<real vec.>
This test could be used with the operator ?::
(see Conditions) or the command select
(see Extraction). It returns a numerical vector which contains only 0 or 1.
It compares each element of the two vectors. The numerical vector of real numbers must have the same size.
> n=3$ > if (n >= 2) then {} else {}; > > // Condition between two vectors > t = 0,10$ > r = 10,0,-1$ > q = ?(t>=r); q double precision real vector : number of elements =11 > q = ?(t>=5); q double precision real vector : number of elements =11 >
<condition> &&
<condition>
This test returns true if the two conditions are true.
This test could be apply on numerical vectors when the operator ?::
(see Conditions) or the command select
(see Extraction) are used. It returns a numerical vector which contains only 0 or 1.
It compares each element of the two vectors. The numerical vector of real numbers must have the same size.
The test in parenthesis are required if the tests include several &&
and ||
.
> if ((x==2)&&(y==3)) then {} else {}; > > // Example using two vectors > t=0,10; t double precision real vector : number of elements =11 > r=10,0,-1; r double precision real vector : number of elements =11 > q=?((t>r) && (t!=5)); q double precision real vector : number of elements =11 >
<condition> ||
<condition>
This test returns true if at least one condition is true.
This test could be apply on numerical vectors when the operator (see Conditions) or the command select
(see Extraction) are used. It returns a numerical vector which contains only 0 or 1.
It compares each element of the two vectors. The numerical vector of real numbers must have the same size.
The test in parenthesis are required if the tests include several &&
and ||
.
> if ((x==2)||(y==3)) then {} else {}; > > // Example using two vectors > t=0,10; t double precision real vector : number of elements =11 > r=10,0,-1; r double precision real vector : number of elements =11 > q=?((t>r) || (t!=5)); q double precision real vector : number of elements =11 >
Previous: operateur de comparaison, Up: condition [Contents][Index]
switch (
<operation> expr )
{
case <operation> : {
<body> };
case <operation> , ..., <operation> : {
<body> };
else {
<body> }
};
The instruction switch
control complex conditional on the same value and branching operations.
expr can be a string, a serie or a constant. The value of expr are tested successively with each value of the case
statements with the operator ==.
When expr is equal to one of the values of a case
statement, the body statement after this case is executed.
The statement else
is executed if no case
constant-expression is equal to the value of expr. The statement else {
<body> }
is optional and has no semi-column after its body.
n=0; z=0; j=5; switch( j ) { case -1 : { n=n+1; }; case 0,1 : { z=z+1; }; case "mystring" : { msg "j is a string"; }; else { msg "j is invalid"; } };
Next: Traitement numerique, Previous: Boucles et conditions, Up: Top [Contents][Index]
• Lapack : |
Up: Bibliotheques [Contents][Index]
• Resolution de AX=B: | ||
• Moindres Carres: | ||
• Factorisations: | ||
• Decompositions en Valeurs Singulieres: | ||
• Valeurs Propres et Vecteurs Propres: |
Next: Moindres Carres, Up: Lapack [Contents][Index]
• lapack_dgesv: | ||
• lapack_dgbsv: | ||
• lapack_dgtsv: | ||
• lapack_dsysv: | ||
• lapack_dposv: | ||
• lapack_dpbsv: | ||
• lapack_dptsv: | ||
• lapack_zgesv: | ||
• lapack_zgbsv: | ||
• lapack_zgtsv: | ||
• lapack_zsysv: | ||
• lapack_zhesv: | ||
• lapack_zposv: | ||
• lapack_zpbsv: | ||
• lapack_zptsv: |
Real case for general matrices, (see lapack_dgesv)
Real case for band matrices, (see lapack_dgbsv)
Real case for tridiagonal matrices, (see lapack_dgtsv)
Real case for symmetric matrices, (see lapack_dsysv)
Real case for symmetric definite positive matrices (see lapack_dposv)
Real case for symmetric definite positive band matrices (see lapack_dpbsv)
Real case for symmetric definite positive tridiagonal matrices (see lapack_dptsv)
Complex case for general matrices, (see lapack_zgesv)
Complex case for band matrices, (see lapack_zgbsv)
Complex case for tridiagonal matrices, (see lapack_zgtsv)
Complex case for symmetric matrices, (see lapack_zsysv)
Complex case for hermitian matrices, (see lapack_zhesv)
Complex case for hermitian definite positive matrices (see lapack_zposv)
Complex case for hermitian definite positive band matrices (see lapack_zpbsv)
Complex case for hermitian definite positive tridiagonal matrices (see lapack_zptsv)
Next: lapack_dgbsv, Up: Resolution de AX=B [Contents][Index]
lapack_dgesv(
<real matrix> A ,
<real matrix> B)
It computes the solution to a real system of linear equations AX=B, where A is an N-by-N matrix and X and B are N-by-NRHS matrices. It uses the LU decomposition.
More information available at http://www.netlib.org/lapack/double/dgesv.f
> // resolves a real system of linear equations AX=B > // where A is a square matrix > _affc=1$ > A = matrixR[ 22.22, -11.11: -35.07, 78.01]$ > B = matrixR[ -88.88: 382.18]$ > S = lapack_dgesv(A, B)$ > afftab(S); [ - 2] [ 4] >
Next: lapack_dgtsv, Previous: lapack_dgesv, Up: Resolution de AX=B [Contents][Index]
lapack_dgbsv(
<real matrix> A ,
<real matrix> B)
It computes the solution to a real system of linear equations AX=B, where A is a band matrix of order N, and X and B are N-by-NRHS matrices. It uses the LU decomposition.
More information available at http://www.netlib.org/lapack/double/dgbsv.f
> // resolves a real system of linear equations AX=B > // where A is a square matrix > _affc=1$ > A = matrixR[ -22.22, 0: 15.4, -4.1]; A double precision real matrix [ 1:2 , 1:2 ] > B = matrixR[ -88.88: 69.8]; B double precision real matrix [ 1:2 , 1:1 ] > S = lapack_dgbsv(A, B); S double precision real matrix [ 1:2 , 1:1 ] > afftab(S); [ 4] [ - 2] >
Next: lapack_dsysv, Previous: lapack_dgbsv, Up: Resolution de AX=B [Contents][Index]
lapack_dgtsv(
<real matrix> A ,
<real matrix> B)
It computes the solution to a real system of linear equations AX=B, where A is an N-by-N tridiagonal matrix and X and B are N-by-NRHS matrices.
More information available at http://www.netlib.org/lapack/double/dgtsv.f
> // example of dgtsv routine > _affc=1$ > A = matrixR[ 3.0, 2.1, 0, 0, 0: 3.4, 2.3, -1.0, 0, 0: 0, 3.6, -5.0, 1.9, 0: 0, 0, 7.0, -0.9, 8.0: 0, 0, 0, -6.0, 7.1]$ > B = matrixR[ 2.7: -0.5: 2.6: 0.6: 2.7]$ > S = lapack_dgtsv(A, B); S double precision real matrix [ 1:5 , 1:1 ] > afftab(S); [ - 4] [ 7] [ 3] [ - 4] [ - 3] >
Next: lapack_dposv, Previous: lapack_dgtsv, Up: Resolution de AX=B [Contents][Index]
lapack_dsysv(
<real matrix> A ,
<real matrix> B)
It computes the solution to a real system of linear equations AX=B, where A is an N-by-N symmetric matrix and X and B are N-by-NRHS matrices.
More information available at http://www.netlib.org/lapack/double/dsysv.f
> // resolves a real system of linear equations AX=B > // where A is a symmetric matrix > _affc=1$ > A = matrixR[ -1.81, 2 : 2, 1.15]$ > B = matrixR[ 0.19: 3.15]$ > S=lapack_dsysv(A,B)$ > afftab(S); [ 1] [ 1] >
Next: lapack_dpbsv, Previous: lapack_dsysv, Up: Resolution de AX=B [Contents][Index]
lapack_dposv(
<real matrix> A ,
<real matrix> B)
It computes the solution to a real system of linear equations AX=B, where A is an N-by-N symmetric positive definite matrix and X and B are N-by-NRHS matrices.
More information available at http://www.netlib.org/lapack/double/dposv.f
> // resolves a real system of linear equations AX=B > // where A is a symmetric positive difinite matrix > _affc=1$ > A = [ 4.16, -3.12: -3.12, 5.03]$ > B = matrixR[ 10.40: -13.18]$ > S=lapack_dposv(A,B)$ > afftab(S); [ 1] [ - 2] >
Next: lapack_dptsv, Previous: lapack_dposv, Up: Resolution de AX=B [Contents][Index]
lapack_dpbsv(
<real matrix> A ,
<real matrix> B)
It computes the solution to a real system of linear equations AX=B, where A is an N-by-N symmetric positive definite band matrix and X and B are N-by-NRHS matrices.
More information available at http://www.netlib.org/lapack/double/dpbsv.f
> // example of dpbsv routine > _affc=1$ > A = matrixR[ 5.49, 2.68, 0, 0: 2.68, 5.63, -2.39, 0: 0, -2.39, 2.60, -2.22: 0, 0, -2.22, 5.17]$ > B = matrixR[ 22.09: 9.31: -5.24: 11.83]$ > S = lapack_dpbsv(A, B); AB double precision real matrix [ 1:2 , 1:4 ] S double precision real matrix [ 1:4 , 1:1 ] > afftab(S); [ 5] [ - 2] [ - 3] [ 1] >
Next: lapack_zgesv, Previous: lapack_dpbsv, Up: Resolution de AX=B [Contents][Index]
lapack_dptsv(
<real matrix> A ,
<real matrix> B)
It computes the solution to a real system of linear equations AX=B, where A is an N-by-N symmetric positive definite tridiagonal matrix and X and B are N-by-NRHS matrices.
More information available at http://www.netlib.org/lapack/double/dptsv.f
> // example of dptsv routine > _affc=1$ > A = matrixR[ 4.0, -2.0, 0, 0, 0: -2.0, 10.0, -6.0, 0, 0: 0, -6.0, 29.0, 15.0, 0: 0, 0, 15.0, 25.0, 8.0: 0, 0, 0, 8.0, 5.0]$ > B = matrixR[ 6.0: 9.0: 2.0: 14.0: 7.0]$ > S = lapack_dptsv(A, B); S double precision real matrix [ 1:5 , 1:1 ] > afftab(S); [ 2.5] [ 2] [ 1] [ - 1] [ 3] >
Next: lapack_zgbsv, Previous: lapack_dptsv, Up: Resolution de AX=B [Contents][Index]
lapack_zgesv(
<complex matrix> A ,
<complex matrix> B)
It computes the solution to a complex system of linear equations AX=B, where A is an N-by-N matrix and X and B are N-by-NRHS matrices. It uses the LU decomposition.
A is a square matrix. B est une matrice.
On entry, A is a complex matrix of order N and B has N rows. More information available at http://www.netlib.org/lapack/complex16/zgesv.f
> // resolves a complex system of linear equations AX=B > // where A is a square matrix > _affc=1$ > A = matrixC[ 1*i, 0: 0, 2*i]$ > B = matrixC[ 7.37*i: 14.74]$ > S=lapack_zgesv(A,B)$ > afftab(S); [ 7.37] [(0-i*7.37)] >
Next: lapack_zgtsv, Previous: lapack_zgesv, Up: Resolution de AX=B [Contents][Index]
lapack_zgbsv(
<complex matrix> A ,
<complex matrix> B)
It computes the solution to a complex system of linear equations AX=B, where A is a band matrix of order N with KL subdiagonals and KU superdiagonals, and X and B are N-by-NRHS matrices. It uses the LU decomposition.
A is a band matrix. B est une matrice.
If A is diagonal, the call is equivalent to "lapack_zgesv(A,B);"
More information available http://www.netlib.org/lapack/complex16/zgbsv.f
> // resolves a complex system of linear equations AX=B > // where A is a square matrix > _affc=1$ > A = matrixC[ -1.65+2.26*i, -2.05-0.85*i, 0.97-2.84*i, 0: 6.30*i, -1.48-1.75*i, -3.99+4.01*i, 0.59-0.48*i: 0, -0.77+2.83*i, -1.06+1.94*i, 3.33-1.04*i: 0, 0, 4.48-1.09*i, -0.46-1.72*i]$ > B = matrixC[ -1.06+21.50*i: -22.72-53.90*i: 28.24-38.60*i: -34.56+16.73*i]$ > S = lapack_zgbsv(A, B); S double precision complex matrix [ 1:4 , 1:1 ] > afftab(S); [(-3+i*2)] [(1-i*7)] [(-5+i*4)] [(6-i*8)] >
Next: lapack_zsysv, Previous: lapack_zgbsv, Up: Resolution de AX=B [Contents][Index]
lapack_zgtsv(
<complex matrix> A ,
<complex matrix> B)
It computes the solution to a complex system of linear equations AX=B, where A is an N-by-N tridiagonal matrix and X and B are N-by-NRHS matrices.
More information available at http://www.netlib.org/lapack/complex16/zgtsv.f
> // example of zgtsv routine > _affc=1$ > A = matrixC[ -1.3+1.3*i, 2-1*i, 0, 0, 0: 1-2*i, -1.3+1.3*i, 2+1*i, 0, 0: 0, 1+i, -1.3+3.3*i, -1+i, 0: 0, 0, 2-3*i, -0.3+4.3*i, 1-i: 0, 0, 0, 1+i, -3.3+1.3*i]$ > B = matrixC[ 2.4-5*i: 3.4+18.2*i: -14.7+9.7*i: 31.9-7.7*i: -1.0+1.6*i]$ > S = lapack_zgtsv(A, B); S double precision complex matrix [ 1:5 , 1:1 ] > afftab(S); [(1+i*1)] [(3-i*1)] [(4+i*5)] [(-1-i*2)] [(1-i*1)] >
Next: lapack_zhesv, Previous: lapack_zgtsv, Up: Resolution de AX=B [Contents][Index]
lapack_zsysv(
<complex matrix> A ,
<complex matrix> B)
It computes the solution to a complex system of linear equations AX=B, where A is an N-by-N symmetric matrix and X and B are N-by-NRHS matrices.
More information available at http://www.netlib.org/lapack/complex16/zsysv.f
> // example of zsysv routine > _affc=1$ > A = matrixC[ -0.56+0.12*i, -1.54-2.86*i, 5.32-1.59*i, 3.80+0.92*i: -1.54-2.86*i, -2.83-0.03*i, -3.52+0.58*i, -7.86-2.96*i: 5.32-1.59*i, -3.52+0.58*i, 8.86+1.81*i, 5.14-0.64*i: 3.80+0.92*i, -7.86-2.96*i, 5.14-0.64*i, -0.39-0.71*i]$ > B = matrixC[ -6.43+19.24*i: -0.49-1.47*i: -48.18+66*i: -55.64+41.22*i]$ > S = lapack_zsysv(A, B); S double precision complex matrix [ 1:4 , 1:1 ] > afftab(S); [(-4+i*3)] [(3-i*2)] [(-2+i*5)] [(1-i*1)] >
Next: lapack_zposv, Previous: lapack_zsysv, Up: Resolution de AX=B [Contents][Index]
lapack_zhesv(
<complex matrix> A ,
<complex matrix> B)
It computes the solution to a complex system of linear equations AX=B, where A is an N-by-N hermitian matrix and X and B are N-by-NRHS matrices.
More information available at http://www.netlib.org/lapack/complex16/zhesv.f
> // example of zhesv routine > _affc=1$ > A = matrixC[ -1.84, 0.11-0.11*i, -1.78-1.18*i, 3.91-1.50*i: 0.11+0.11*i, -4.63, -1.84+0.03*i, 2.21+0.21*i: -1.78+1.18*i, -1.84-0.03*i, -8.87, 1.58-0.90*i: 3.91+1.50*i, 2.21-0.21*i, 1.58+0.90*i, -1.36]$ > B = matrixC[ 2.98-10.18*i: -9.58+3.88*i: -0.77-16.05*i: 7.79+5.48*i]$ > S = lapack_zhesv(A, B); S double precision complex matrix [ 1:4 , 1:1 ] > afftab(S); [(2+i*1)] [(3-i*2)] [(-1+i*2)] [(1-i*1)] >
Next: lapack_zpbsv, Previous: lapack_zhesv, Up: Resolution de AX=B [Contents][Index]
lapack_zposv(
<complex matrix> A ,
<complex matrix> B)
It computes the solution to a complex system of linear equations AX=B, where A is an N-by-N hermitian positive definite matrix and X and B are N-by-NRHS matrices.
More information available at http://www.netlib.org/lapack/complex16/zposv.f
> // example of zposv routine > _affc=1$ > A = matrixC[ 3.23, 1.51-1.92*i, 1.90+0.84*i, 0.42+2.50*i: 1.51+1.92*i, 3.58, -0.23+1.11*i, -1.18+1.37*i: 1.90-0.84*i, -0.23-1.11*i, 4.09, 2.33-0.14*i: 0.42-2.50*i, -1.18-1.37*i, 2.33+0.14*i, 4.29]$ > B = matrixC[ 3.93-6.14*i: 6.17+9.42*i: -7.17-21.83*i: 1.99-14.38*i]$ > S = lapack_zposv(A, B); S double precision complex matrix [ 1:4 , 1:1 ] > afftab(S); [(1-i*1)] [(-4.34355E-15+i*3)] [(-4-i*5)] [(2+i*1)] >
Next: lapack_zptsv, Previous: lapack_zposv, Up: Resolution de AX=B [Contents][Index]
lapack_zpbsv(
<complex matrix> A ,
<complex matrix> B)
It computes the solution to a complex system of linear equations AX=B, where A is an N-by-N hermitian positive definite band matrix and X and B are N-by-NRHS matrices.
More information available at http://www.netlib.org/lapack/complex16/zpbsv.f
> // example of zpbsv routine > _affc=1$ > A = matrixC[ 16, 16-16*i, 0, 0: 16+16*i, 41, 18+9*i, 0: 0, 18-9*i, 46, 1+4*i: 0, 0, 1-4*i, 21]$ > B = matrixC[ 64+16*i: 93+62*i: 78-80*i: 14-27*i]$ > S = lapack_zpbsv(A, B); AB double precision complex matrix [ 1:2 , 1:4 ] S double precision complex matrix [ 1:4 , 1:1 ] > afftab(S); [(2+i*1)] [(1+i*1)] [(1-i*2)] [(1-i*1)] >
Previous: lapack_zpbsv, Up: Resolution de AX=B [Contents][Index]
lapack_zptsv(
<complex matrix> A ,
<complex matrix> B)
It computes the solution to a complex system of linear equations AX=B, where A is an N-by-N hermitian positive definite tridiagonal matrix and X and B are N-by-NRHS matrices.
More information available at http://www.netlib.org/lapack/complex16/zptsv.f
> // example of zptsv routine > _affc=1$ > A = matrixC[ 9.39, 1.08-1.73*i, 0, 0: 1.08+1.73*i, 1.69, -0.04+0.29*i, 0: 0, -0.04-0.29*i, 2.65, -0.33+2.24*i: 0, 0, -0.33-2.24*i, 2.17]$ > B = matrixC[ -12.42+68.42*i: -9.93+0.88*i: -27.30-0.01*i: 5.31+23.63*i]$ > S = lapack_zptsv(A, B); S double precision complex matrix [ 1:4 , 1:1 ] > afftab(S); [(-1+i*8)] [(2-i*3)] [(-4-i*5)] [(7+i*6)] >
Next: Factorisations, Previous: Resolution de AX=B, Up: Lapack [Contents][Index]
• lapack_dgels: | ||
• lapack_dgelss: | ||
• lapack_dgglse: | ||
• lapack_dggglm: | ||
• lapack_zgels: | ||
• lapack_zgelss: | ||
• lapack_zgglse: | ||
• lapack_zggglm: |
Real case for general matrices, (see lapack_dgels)
Real case for general matrices, using the singular value decomposition (see lapack_dgelss)
Real case for the linear equality-constrained least squares (LSE) problems, (see lapack_dgglse)
Real case for Gauss-Markov linear model (GLM) problems, (see lapack_dggglm)
Complex case for general matrices, (see lapack_zgels)
Complex case for general matrices, using the singular value decomposition (see lapack_zgelss)
Complex case for the linear equality-constrained least squares (LSE) problems, (see lapack_zgglse)
Complex case for Gauss-Markov linear model (GLM) problems, (see lapack_zggglm)
Next: lapack_dgelss, Up: Moindres Carres [Contents][Index]
lapack_dgels(
<real matrix> A ,
<real matrix> B ,
<string> TRANS)
It solves overdetermined or underdetermined real linear systems involving an M-by-N matrix A, or its transpose, using a QR or LQ factorization of A. It is assumed that A has full rank.
Four options are provided:
Output formats:
More information available at http://www.netlib.org/lapack/double/dgels.f
> // real least squares problem: minimize ||B-A*X|| > _affc=1$ > A = matrixR[ -3, 1: 1, 1: 4-7, 1: 5, 1]$ > B = matrixR[ 70: 21: 110: -35]$ > S = lapack_dgels(A, B, "N")$ > afftab(S); [ - 15.7727] [ 41.5] [ 28.5243] [ - 4.13405] > > // the residual squares sum can be obtained computing: > // sqrt(S[3]**2+S[4]**2) > resid=sqrt(S[3,1]**2+S[4,1]**2); resid = 28.8223 > > // minimum norm solution to the underdetermined system AX=B > A = matrixR[ 1, 2, 3, 4: 5, 6, 7, 8: 9, 10, 11, 12]$ > B = matrixR[ 30: 70: 110]$ > S = lapack_dgels(A, B, "N")$ > afftab(S); [ 1] [ 2] [ 3] [ 4] > > // beware of the row number of the solution > size(B); 3 > size(S); 4 > > // minimum norm solution of an undetermined system A**T*X=B, > // where A**T is the transpose of A > A = matrixR[ 1, 5, 9: 2, 6, 10: 3, 7, 11: 4, 8, 12]$ > B = matrixR[ 30: 70: 110]$ > S = lapack_dgels(A, B, "T")$ > afftab(S); [ 1] [ 2] [ 3] [ 4] > > // same here, beware of the row number of the solution > size(B); 3 > size(S); 4 > > // real least squares problem: minimize ||B-A**T*X|| > A = matrixR[ -3, 1, -7, 5: 1, 1, 1, 1]$ > B = matrixR[ 70: 21: 110: -35]$ > S = lapack_dgels(A, B, "T")$ > afftab(S); [ - 12.1] [ 29.4] [ - 6.80331] [ - 4.23261] > > // the residual squares sum can be obtained computing: > // sqrt(S[3]**2+S[4]**2) > resid=sqrt(S[3,1]**2+S[4,1]**2); resid = 8.01249
Next: lapack_dgglse, Previous: lapack_dgels, Up: Moindres Carres [Contents][Index]
lapack_dgelss(
<real matrix> A ,
<real matrix> B ,
<integer> RCOND)
It computes the minimum norm solution to a real linear least squares problem: Minimize || |B-A*X| || using the singular value decomposition (SVD) of A. A is an M-by-Nmatrix which may be rank-deficient.
B has M rows. RCOND is the input precision. Assign -1 to RCOND enables machine precision computation.
Rows 1 to N of the output matrix contain the least squares solution vectors. If A has rank N and M>=N, then rows N+1 to M contain the residual squares.
More information available at http://www.netlib.org/lapack/double/dgelss.f
> // real least squares problem: minimize ||B-A*X|| > _affc=1$ > > A = [ -0.09, 0.14, -0.46, 0.68, 1.29: -1.56, 0.20, 0.29, 1.09, 0.51: -1.48, -0.43, 0.89, -0.71, -0.96: -1.09, 0.84, 0.77, 2.11, -1.27: 0.08, 0.55, -1.13, 0.14, 1.74: -1.59, -0.72, 1.06, 1.24, 0.34]$ > B = matrixR[ 7.4: 4.2: -8.3: 1.8: 8.6: 2.1]$ > > // we use a 1.E-2 precision > S = lapack_dgelss(A, B, 1E-2)$ > afftab(S); [ 0.634385] [ 0.969928] [ - 1.44025] [ 3.36777] [ 3.39917] [ - 0.00347521] > > // using machine precision > S = lapack_dgelss(A, B, -1)$ > afftab(S); [ - 0.799745] [ - 3.28796] [ - 7.47498] [ 4.93927] [ 0.767833] [ - 0.00347521] > >
Next: lapack_dggglm, Previous: lapack_dgelss, Up: Moindres Carres [Contents][Index]
lapack_dgglse(
<real matrix> A ,
<real matrix> B ,
<real matrix> C ,
<real matrix> D)
lapack_dgglse(
<real matrix> A ,
<real matrix> B ,
<real matrix> C ,
<real matrix> D ,
<object identifier> T ,
<object identifier> R ,
<object identifier> S)
It solves the linear equality-constrained least squares problem:
minimize || C - A*X || subject to B*X = D
where A is an M-by-N matrix, B is a P-by-N matrix, C is a given M-vector, and D is a given P-vector.
It is assumed that P <= N <= M+P, and
rank(B) = P and rank( (A) ) = N. ( (B) )
It uses a generalized QR factorization of matrices (B,A) where B = (0 R)*Q and A = Z*T*Q.
In the complete version of lapack_dgglse, you can get T, R and the residual squares vector S. S is M-N+P long.
More information available at http://www.netlib.org/lapack/double/dgglse.f
> // dgglse routine example > _affc=1$ > A = matrixR[ 1, 2: 3, 4: 5, 6]$ > B = matrixR[ 2.50, 0.00: 0.00, 2.50]$ > C = matrixR[ -1: -2: -3]$ > D = matrixR[ 3.00: 4.00]$ > S = lapack_dgglse(A,B,C,D)$ > afftab(S); [ 1.2] [ 1.6]
Next: lapack_zgels, Previous: lapack_dgglse, Up: Moindres Carres [Contents][Index]
lapack_dggglm(
<real matrix> A ,
<real matrix> B ,
<real matrix> D ,
<object identifier> X ,
<object identifier> Y)
lapack_dggglm(
<real matrix> A ,
<real matrix> B ,
<real matrix> D ,
<object identifier> X ,
<object identifier> Y ,
<object identifier> T ,
<object identifier> R)
It solves a general Gauss-Markov linear model (GLM) problem:
minimize || Y ||_2 subject to D = A*X + B*Y X where A is an N-by-M matrix, B is an N-by-P matrix, and D is a given N-vector. It is assumed that M <= N <= M+P, rank(A) = M and rank(AB) = N.
It uses a generalized QR factorization of matrices (B,A) where B = Q*T*Z and A = Q*(R). (0)
In particular, if matrix B is square nonsingular, then the problem GLM is equivalent to the following weighted linear least squares problem
minimize || inv(B)*(D-A*X) ||_2 X where inv(B) denotes the inverse of B.
In the complete version of lapack_dggglm, you can get T and R.
More information available at http://www.netlib.org/lapack/double/dggglm.f
> // dggglm routine example > _affc=1$ > A = matrixR[ 7687, 13450.888: 9999, 15499.08: 7594, 12450.12]$ > B = matrixR[ 2.50, 11.77: 7, 7: 12.00, 2.50]$ > D = matrixR[ 20777: 35713: 21777]$ > lapack_dggglm(A, B, D, X, Y)$ > afftab(X); [ 11.8512] [ - 5.31511] > afftab(Y); [ - 200.172] [ 141.898]
Next: lapack_zgelss, Previous: lapack_dggglm, Up: Moindres Carres [Contents][Index]
lapack_zgels(
<complex matrix> A ,
<complex matrix> B ,
<string> TRANS)
It solves overdetermined or underdetermined complex linear systems involving an M-by-N matrix A, or its conjuguate-transpose, using a QR or LQ factorization of A. It is assumed that A has full rank.
Four options are provided:
Formats de sortie:
More information available at http://www.netlib.org/lapack/complex16/zgels.f
> // resolves a complex least square problem: minimize ||B-A*X|| > _affc=1$ > A = matrixC[ -0.57, -1.28, -0.39, 0.25: -1.93, 1.08, -0.31, -2.14: 2.30, 0.24, 0.40, -0.35: -1.93, 0.64, -0.66, 0.08: 0.15, 0.30, 0.15, -2.13: -0.02, 1.03, -1.43, 0.50]$ > B = matrixC[ -2.67: -0.55: 3.34: -0.77: 0.48: 4.10+i]$ > S = lapack_zgels(A, B, "N")$ > afftab(S); [(1.53387+i*0.158054)] [(1.87075+i*0.0726528)] [(-1.52407-i*0.621165)] [(0.039183-i*0.0141075)] [(-0.0085366-i*0.0685483)] [(0.0204427+i*0.205957)] >
Next: lapack_zgglse, Previous: lapack_zgels, Up: Moindres Carres [Contents][Index]
lapack_zgelss(
<complex matrix> A ,
<complex matrix> B ,
<real> RCOND)
It computes the minimum norm solution to a complex linear least squares problem: Minimize || |B-A*X| || using the singular value decomposition (SVD) of A. A is an M-by-Nmatrix which may be rank-deficient.
B has M rows. RCOND is the input precision. Assign -1 to RCOND enables machine precision computation.
Rows 1 to N of the output matrix contain the least squares solution vectors. If A has rank N and M>=N, then rows N+1 to M contain the residual squares.
More information available at http://www.netlib.org/lapack/complex16/zgelss.f
> // real least squares problem: minimize ||B-A*X|| > _affc=1$ > > A = [ -0.09, 0.14, -0.46, 0.68, 1.29: -1.56, 0.20, 0.29, 1.09, 0.51: -1.48, -0.43, 0.89, -0.71, -0.96: -1.09, 0.84, 0.77, 2.11, -1.27: 0.08, 0.55, -1.13, 0.14, 1.74: -1.59, -0.72, 1.06, 1.24, 0.34]$ > B = matrixC[ 7.4: 4.2*i: -8.3*i: 1.8*i: 8.6: 2.1*i]$ > > // we use a 1.E-2 precision > S = lapack_zgelss(A, B, 1E-2)$ > afftab(S); [(-1.88522+i*2.51961)] [(2.23426-i*1.26433)] [(-2.22465+i*0.784398)] [(-0.257364+i*3.62513)] [(2.36045+i*1.03872)] [(3.35419-i*3.35767)] > > // using machine precision > S = lapack_zgelss(A, B, -1)$ > afftab(S); [(307.51-i*308.309)] [(920.819-i*924.107)] [(1299.69-i*1307.17)] [(-339.29+i*344.229)] [(570.037-i*569.27)] [(3.35419-i*3.35767)] > > // wrong result. Beware of the RCOND value >
Next: lapack_zggglm, Previous: lapack_zgelss, Up: Moindres Carres [Contents][Index]
lapack_zgglse(
<complex matrix> A ,
<complex matrix> B ,
<complex matrix> C ,
<complex matrix> D)
lapack_zgglse(
<complex matrix> A ,
<complex matrix> B ,
<complex matrix> C ,
<complex matrix> D ,
<object identifier> T ,
<object identifier> R ,
<object identifier> S)
It solves the linear equality-constrained least squares problem:
minimize || C - A*X || subject to B*X = D
where A is an M-by-N matrix, B is a P-by-N matrix, C is a given M-vector, and D is a given P-vector.
It is assumed that P <= N <= M+P, and
rank(B) = P and rank( (A) ) = N. ( (B) )
It uses a generalized QR factorization of matrices (B,A) where B = (0 R)*Q and A = Z*T*Q.
In the complete version of lapack_zgglse, you can get T, R and the residual squares vector S. S is M-N+P long.
More information available at http://www.netlib.org/lapack/complex16/zgglse.f
> // zgglse routine example > _affc=1$ > A = matrixC[ 1, 2: 3, 4: 5, 6]$ > B = matrixC[ 2.50*i, 0.00: 0.00, 2.50]$ > C = matrixC[ -1: -2*i: -3]$ > D = matrixC[ 3.00: 4.00*i]$ > S = lapack_zgglse(A,B,C,D)$ > afftab(S); [(0-i*1.2)] [(0+i*1.6)]
Previous: lapack_zgglse, Up: Moindres Carres [Contents][Index]
lapack_zggglm(
<complex matrix> A ,
<complex matrix> B ,
<complex matrix> D ,
<object identifier> X ,
<object identifier> Y)
lapack_zggglm(
<complex matrix> A ,
<complex matrix> B ,
<complex matrix> D ,
<object identifier> X ,
<object identifier> Y ,
<object identifier> T ,
<object identifier> R)
It solves a general Gauss-Markov linear model (GLM) problem:
minimize || Y ||_2 subject to D = A*X + B*Y X where A is an N-by-M matrix, B is an N-by-P matrix, and D is a given N-vector. It is assumed that M <= N <= M+P, rank(A) = M and rank(AB) = N.
It uses a generalized QR factorization of matrices (B,A) where B = Q*T*Z and A = Q*(R). (0)
In particular, if matrix B is square nonsingular, then the problem GLM is equivalent to the following weighted linear least squares problem
minimize || inv(B)*(D-A*X) ||_2 X where inv(B) denotes the inverse of B.
In the complete version of lapack_zggglm, you can get T and R.
More information available at http://www.netlib.org/lapack/complex16/zggglm.f
> // zggglm routine example > _affc=1$ > A = matrixC[ 7687, 13450.888: 9999, 15499.08: 7594, 12450.12]$ > B = matrixC[ 2.50, 11.77*i: 7*i, 7: 12.00, 2.50]$ > D = matrixC[ 20777*i: 35713*i: 21777*i]$ > lapack_zggglm(A, B, D, X, Y)$ > afftab(X); [(-1.49403+i*10.5244)] [(0.851288-i*4.50903)] > afftab(Y); [(45.469-i*168.668)] [(80.5683+i*6.76462)] >
Next: Decompositions en Valeurs Singulieres, Previous: Moindres Carres, Up: Lapack [Contents][Index]
• lapack_dgeqrf: | ||
• lapack_dgeqlf: | ||
• lapack_dpotrf: | ||
• lapack_zgeqrf: | ||
• lapack_zgeqlf: | ||
• lapack_zpotrf: |
Real general case for QL factorization, (see lapack_dgeqrf)
Real general case for QL factorization, (see lapack_dgeqlf)
Real case for Cholesky factorization, (see lapack_dpotrf)
Complex general case for QL factorization, (see lapack_zgeqrf)
Complex case for Cholesky factorization, (see lapack_zpotrf)
Next: lapack_dgeqlf, Up: Factorisations [Contents][Index]
lapack_dgeqrf(
<real matrix> A ,
<object identifier> Q ,
<object identifier> R)
It computes a QR factorization of a real M-by-N matrix A:
A = Q*R.
More information available at http://www.netlib.org/lapack/double/dgeqrf.f
> // computes a QR factorization of a matrix A > _affc=1$ > A = matrixR[ 2, 3, -1, 0, 20: -6, -5, 0, 2, -33: 2, -5, 6, -6, -43: 4, 6, 2, -3, 49]$ > lapack_dgeqrf(A, Q, R)$ > afftab(Q); [ - 0.258199 - 0.182574 0.208237 - 0.925547] [ 0.774597 0 - 0.535468 - 0.336563] [ - 0.258199 0.912871 - 0.267734 - 0.168281] [ - 0.516398 - 0.365148 - 0.773453 0.0420703] > afftab(R); [ - 7.74597 - 6.45497 - 2.32379 4.64758 - 44.9266] [ 0 - 7.30297 4.9295 - 4.38178 - 60.7972] [ 0 0 - 3.36155 2.85583 - 4.55148] [ 0 0 0 0.210352 1.89316]
Next: lapack_dpotrf, Previous: lapack_dgeqrf, Up: Factorisations [Contents][Index]
lapack_dgeqlf(
<real matrix> A ,
<object identifier> Q ,
<object identifier> L)
It computes a QL factorization of a real M-by-N matrix A:
A = Q*L.
We assume M >= N.
More information available at http://www.netlib.org/lapack/double/dgeqlf.f
> // computes a QL factorization of a matrix A > _affc=1$ > A = matrixR[ 2, 3, -1, 0: -6, -5, 0, 2: 2, -5, 6, -6: 4, 6, 2, -3: 20, -33, -43, 49]$ > lapack_dgeqlf(A, Q, L)$ > afftab(Q); [ 0.258503 - 0.0987267 - 0.446322 0] [ - 0.0598575 0.395467 0.782976 - 0.0404061] [ - 0.292516 - 0.875179 0.329003 0.121218] [ - 0.914354 0.236816 - 0.28182 0.0606092] [ - 0.089356 - 0.108807 - 0.00892644 - 0.989949] > afftab(L); [ - 5.15342 0 0 0] [ - 5.54949 7.11392 0 0] [ - 6.2383 - 8.29521 2.24054 0] [ - 19.0717 32.6279 43.4164 - 49.4975]
Next: lapack_zgeqrf, Previous: lapack_dgeqlf, Up: Factorisations [Contents][Index]
lapack_dpotrf(
<real matrix> A )
It computes the Cholesky decomposition (L) of a real symmetric positive matrix A:
A = L*L**T
More information available at http://www.netlib.org/lapack/double/dpotrf.f
> _affc=1$ > > A=matrixR[4.16, -3.12 , 0.56, -0.10: -3.12 , 5.03 , -0.83 , 1.18: 0.56 , -0.83, 0.76 , 0.34 : -0.10 , 1.18 , 0.34 , 1.18 ]; A double precision real matrix [ 1:4 , 1:4 ] > > L=lapack_dpotrf(A); L double precision real matrix [ 1:4 , 1:4 ] > afftab(L); [ 2.03961 0 0 0] [ - 1.52971 1.64012 0 0] [ 0.274563 - 0.249981 0.788749 0] [ - 0.049029 0.67373 0.661658 0.534689]
Next: lapack_zgeqlf, Previous: lapack_dgeqlf, Up: Factorisations [Contents][Index]
lapack_zgeqrf(
<complex matrix> A ,
<object identifier> Q ,
<object identifier> R)
It computes a QR factorization of a complex M-by-N matrix A:
A = Q*R.
More information available at http://www.netlib.org/lapack/complex16/zgeqrf.f
> // computes a QR factorization of a matrix A > _affc=1$ > A = matrixC[ 1+i, -5-i, 3+5*i: 0, 8*i, 27: 0, 0, 2+3*i]$ > lapack_zgeqrf(A, Q, R)$ > afftab(Q); [(-0.707107-i*0.707107) 0 0] [ 0 (0-i*1) 0] [ 0 0 (-0.5547-i*0.83205)] > afftab(R); [ - 1.41421 (4.24264-i*2.82843) (-5.65685-i*1.41421)] [ 0 - 8 (0+i*27)] [ 0 0 - 3.60555] >
Next: lapack_zpotrf, Previous: lapack_zgeqrf, Up: Factorisations [Contents][Index]
lapack_zgeqlf(
<complex matrix> A ,
<object identifier> Q ,
<object identifier> L)
It computes a QL factorization of a complex M-by-N matrix A:
A = Q*L.
We assume M >= N.
More information available at http://www.netlib.org/lapack/complex16/zgeqlf.f
> // computes a QL factorization of a matrix A > _affc=1$ > A = matrixC[ 1+i, 0, 0: -5-i, 8*i, 0: 3+5*i, 27, 2+3*i]$ > lapack_zgeqlf(A, Q, L)$ > afftab(Q); [(-0.707107-i*0.707107) 0 0] [ 0 (0-i*1) 0] [ 0 0 (-0.5547-i*0.83205)] > afftab(L); [ - 1.41421 0 0] [(1-i*5) - 8 0] [(-5.82435-i*0.27735) (-14.9769+i*22.4654) - 3.60555]
Previous: lapack_zgeqlf, Up: Factorisations [Contents][Index]
lapack_zpotrf(
<complex matrix> A )
It computes the Cholesky decomposition (L) of a Hermitian, positive-definite matrix A:
A = L*L**H
where L**H is the conjugate-transpose of L
More information available at http://www.netlib.org/lapack/double/zpotrf.f
> A=matrixC[ 3.23+I* 0.00 , 1.51-I* 1.92 , 1.90-I*-0.84 , 0.42-I*-2.50 : 1.51+I* 1.92 , 3.58+I* 0.00 , -0.23-I*-1.11 , -1.18-I*-1.37 : 1.90+I*-0.84 , -0.23+I*-1.11 , 4.09-I* 0.00 , 2.33-I* 0.14 : 0.42+I*-2.50 , -1.18+I*-1.37 , 2.33+I* 0.14 , 4.29+I* 0.00 ]; A double precision complex matrix [ 1:4 , 1:4 ] > > L=lapack_zpotrf(A); L double precision complex matrix [ 1:4 , 1:4 ] > afftab(L); [ 1.797220075561143 0 0 0] [( 0.8401864749527325+i* 1.068316577423342) 1.316353439509685 0 0] [( 1.057188279741849-i* 0.467388502622712) ( -0.4701749470106329+i* 0.3130658155999464) 1.560392977137124 0] [( 0.233694251311356-i* 1.391037210186643) ( 0.08335250923944196+i* 0.03676071443037474) ( 0.9359617337923402+i* 0.9899692192815739) 0.6603332973655888]
Next: Valeurs Propres et Vecteurs Propres, Previous: Factorisations, Up: Lapack [Contents][Index]
• lapack_dgesvd: | ||
• lapack_dgesdd: | ||
• lapack_zgesvd: | ||
• lapack_zgesdd: |
Real general case for SVD, (see lapack_dgesvd)
Real general case for SVD using Divide and Conquer algorithm, (see lapack_dgesdd)
Complex general case for SVD, (see lapack_zgesvd)
Complex general case for SVD using Divide and Conquer algorithm, (see lapack_zgesdd)
Next: lapack_dgesdd, Up: Decompositions en Valeurs Singulieres [Contents][Index]
lapack_dgesvd(
<real matrix> A ,
<object identifier> U ,
<object identifier> SIGMA ,
<object identifier> VT)
It computes the singular value decomposition (SVD) of a real M-by-N matrix A : A = U*SIGMA*VT where U is the left singular vectors matrix, VT is the transpose matrix of the right singular vectors one, and the diagonal elements of SIGMA are the singular values of A.
More information available at http://www.netlib.org/lapack/double/dgesvd.f
> // DGESVD computes the singular values decomposition of A > _affc=1$ > A = matrixR[ 1, 2: 3, 4]$ > lapack_dgesvd(A, U, SIGMA, VT)$ > afftab(U); [ - 0.404554 - 0.914514] [ - 0.914514 0.404554] > afftab(SIGMA); [ 5.46499 0] [ 0 0.365966] > afftab(VT); [ - 0.576048 - 0.817416] [ 0.817416 - 0.576048] >
Next: lapack_zgesvd, Previous: lapack_dgesvd, Up: Decompositions en Valeurs Singulieres [Contents][Index]
lapack_dgesdd(
<real matrix> A ,
<object identifier> U ,
<object identifier> SIGMA ,
<object identifier> VT)
It computes the singular value decomposition (SVD) of a real M-by-N matrix A : A = U*SIGMA*VT where U is the left singular vectors matrix, VT is the transpose matrix of the right singular vectors one, and the diagonal elements of SIGMA are the singular values of A.
It uses a divide and conquer algorithm.
More information available at http://www.netlib.org/lapack/double/dgesdd.f
> // DGESDD computes the singular values decomposition of A > _affc=1$ > A = matrixR[ 1, 2: 3, 4]$ > lapack_dgesdd(A, U, SIGMA, VT)$ > afftab(U); [ - 0.404554 - 0.914514] [ - 0.914514 0.404554] > afftab(SIGMA); [ 5.46499 0] [ 0 0.365966] > afftab(VT); [ - 0.576048 - 0.817416] [ 0.817416 - 0.576048] >
Next: lapack_zgesdd, Previous: lapack_dgesdd, Up: Decompositions en Valeurs Singulieres [Contents][Index]
lapack_zgesvd(
<complex matrix> A ,
<object identifier> U ,
<object identifier> SIGMA ,
<object identifier> VT)
It computes the singular value decomposition (SVD) of a complex M-by-N matrix A : A = U*SIGMA*VT where U is the left singular vectors matrix, VT is the transconjugate matrix of the right singular vectors one, and the diagonal elements of SIGMA are the singular values of A.
More information available at http://www.netlib.org/lapack/complex16/zgesvd.f
> // ZGESVD computes the singular values decomposition of A > _affc=1$ > A = matrixC[ 1+i, -2-i: 3, 2*i]$ > lapack_zgesvd(A, U, SIGMA, VT)$ > afftab(U); [(-0.158181-i*0.528862) (0.497893-i*0.668869)] [(-0.824631+i*0.12356) (0.391736+i*0.388921)] > afftab(SIGMA); [ 4.2049 0] [ 0 1.52278] > afftab(VT); [ - 0.751728 (0.259779-i*0.606152)] [ 0.659474 (0.29612-i*0.690947)] >
Previous: lapack_zgesvd, Up: Decompositions en Valeurs Singulieres [Contents][Index]
lapack_zgesdd(
<complex matrix> A ,
<object identifier> U ,
<object identifier> SIGMA ,
<object identifier> VT)
It computes the singular value decomposition (SVD) of a complex M-by-N matrix A : A = U*SIGMA*VT where U is the left singular vectors matrix, VT is the transconjugate matrix of the right singular vectors one, and the diagonal elements of SIGMA are the singular values of A.
It uses a divide and conquer algorithm.
More information available at http://www.netlib.org/lapack/complex16/zgesdd.f
Previous: Decompositions en Valeurs Singulieres, Up: Lapack [Contents][Index]
• lapack_dsyev: | ||
• lapack_dsbev: | ||
• lapack_dstev: | ||
• lapack_dgeev: | ||
• lapack_dsygv: | ||
• lapack_dggev: | ||
• lapack_dgges: | ||
• lapack_zheev: | ||
• lapack_zhbev: | ||
• lapack_zgeev: | ||
• lapack_zhegv: |
Real symmetric case, (see lapack_dsyev)
Real symmetric case for band matrices, (see lapack_dsbev)
Real symmetric case for tridiagonal matrices, (see lapack_dstev)
Real non-symmetric case, (see lapack_dgeev)
Generalized Eigenproblem, real symmetric case, (see lapack_dsygv)
Generalized Eigenproblem, real non-symmetric case, (see lapack_dggev)
Generalized Eigenproblem and Schur matrices, (see lapack_dgges)
Complex hermitian case, (see lapack_zheev)
Complex hermitian case for band matrices, (see lapack_zhbev)
Complex non-hermitian case, (see lapack_zgeev)
Generalized Eigenproblem, complex hermitian case, (see lapack_zhegv)
Next: lapack_dsbev, Up: Valeurs Propres et Vecteurs Propres [Contents][Index]
lapack_dsyev(
<real matrix> A,
<object identifier> VALUES ,
<object identifier> VECTORS)
It computes all the eigenvalues and eigenvectors of a real symmetricmatrix A. Eigenvalues are put in VALUES, eigenvectors in VECTORS.
More information available at http://www.netlib.org/lapack/double/dsyev.f
> // dsyev routine test > _affc=1$ > A = matrixR[ 451.27, 0: 0, 512.75]$ > lapack_dsyev(A, values, vectors); vectors double precision real matrix [ 1:2 , 1:2 ] > writes(values); +4.5126999999999998E+02 +5.1275000000000000E+02 > afftab(vectors); [ 1 0] [ 0 1] >
Next: lapack_dstev, Previous: lapack_dsyev, Up: Valeurs Propres et Vecteurs Propres [Contents][Index]
lapack_dsbev(
<real matrix> A,
<object identifier> VALUES ,
<object identifier> VECTORS)
It computes all the eigenvalues and eigenvectors of a real symmetric band matrix A. Eigenvalues are put in VALUES, eigenvectors in VECTORS.
More information available at http://www.netlib.org/lapack/double/dsbev.f
> // example of dsbev routine > _affc=1$ > A = matrixR[ 1, 2, 3, 0, 0: 2, 2, 3, 4, 0: 3, 3, 3, 4, 5: 0, 4, 4, 4, 5: 0, 0, 5, 5, 5]$ > lapack_dsbev(A, Values, Vectors); > writes(Values); -3.2473787952520272E+00 -2.6633015451836046E+00 +1.7511163179896112E+00 +4.1598880678262953E+00 +1.4999675954619729E+01 > afftab(Vectors); [ 0.0393846 0.623795 0.563458 - 0.516534 0.15823] [ 0.572127 - 0.257506 - 0.389612 - 0.595543 0.316058] [ - 0.437179 - 0.590046 0.400815 - 0.147035 0.527682] [ - 0.44235 0.430844 - 0.558098 0.0469667 0.552286] [ 0.533217 0.103873 0.242057 0.595564 0.540002] >
Next: lapack_dgeev, Previous: lapack_dsbev, Up: Valeurs Propres et Vecteurs Propres [Contents][Index]
lapack_dstev(
<real matrix> A,
<object identifier> VALUES ,
<object identifier> VECTORS)
It computes all the eigenvalues and eigenvectors of a real symmetric tridiagonal matrix A. Eigenvalues are put in VALUES, eigenvectors in VECTORS.
More information available at http://www.netlib.org/lapack/double/dstev.f
> // example of dstev routine > _affc=1$ > A = matrixR[ 1, 1, 0, 0: 1, 4, 2, 0: 0, 2, 9, 3: 0, 0, 3, 16]$ > lapack_dstev(A, Values, Vectors); > writes(Values); +6.4756286546948838E-01 +3.5470024748920901E+00 +8.6577669890059994E+00 +1.7147667670632423E+01 > afftab(Vectors); [ 0.939572 0.338755 - 0.04937 0.00337683] [ - 0.33114 0.86281 - 0.378064 0.0545279] [ 0.0852772 - 0.364803 - 0.855782 0.356769] [ - 0.0166639 0.0878831 0.349668 0.932594] >
Next: lapack_dsygv, Previous: lapack_dstev, Up: Valeurs Propres et Vecteurs Propres [Contents][Index]
lapack_dgeev(
<real matrix> A ,
<object identifier> VALUES ,
<object identifier> LVECTOR ,
<object identifier> RVECTOR)
It computes all the eigenvalues and eigenvectors of a real matrix A. It can be non-symmetric. Eigenvalues are put in VALUES, left eigenvectors in LVECTOR and right eigenvectors in RVECTOR.
It solves
A*RVECTOR=VALUES*RVECTOR and
LVECTOR**T*A=VALUES*LVECTOR**T
where LVECTOR**T is the conjugate transpose of LVECTOR
More information available at http://www.netlib.org/lapack/double/dgeev.f
> // dgeev routine example > _affc=1$ > A = matrixR[ 10, 6: 4, 12]$ > lapack_dgeev(A, Values, LVector, RVector)$ > writes(Values); +6.0000000000000000E+00 +1.6000000000000000E+01 > afftab(LVector); [ - 0.707107 - 0.5547] [ 0.707107 - 0.83205] > afftab(RVector); [ - 0.83205 - 0.707107] [ 0.5547 - 0.707107] >
Next: lapack_dggev, Previous: lapack_dgeev, Up: Valeurs Propres et Vecteurs Propres [Contents][Index]
lapack_dsygv(
<integer> ITYPE ,
<real matrix> A ,
<real matrix> B ,
<object identifier> VALUES ,
<object identifier> VECTORS)
It computes all the eigenvalues and eigenvectors of a real generalized symmetric-definite eigenproblem. Here A and B are assumed to be symmetric and B is also positive definite. Eigenvalues are put in VALUES, eigenvectors in VECTORS.
3 problems are provided:
More information available at http://www.netlib.org/lapack/double/dsygv.f
> // example with B*A*X = (lambda)*X > _affc=1$ > B = matrixR[ 10, 0: 0, 10]$ > A = matrixR[ 451.27, 0: 0, 512.75]$ > lapack_dsygv(3, A, B, Values, Vectors); Vectors double precision real matrix [ 1:2 , 1:2 ] > writes(Values); +4.5127000000000007E+03 +5.1275000000000009E+03 > afftab(Vectors); [ 3.16228 0] [ 0 3.16228]
Next: lapack_dgges, Previous: lapack_dsygv, Up: Valeurs Propres et Vecteurs Propres [Contents][Index]
lapack_dggev(
<real matrix> A ,
<real matrix> B ,
<object identifier> VALUES ,
<object identifier> LVECTOR ,
<object identifier> RVECTOR)
It computes all the eigenvalues and eigenvectors of a real generalized eigenproblem. Here A and B can be non-symmetric. Eigenvalues are put in VALUES, left eigenvectors in LVECTOR and right eigenvectors in RVECTOR.
It solves:
where LVECTOR**H is the conjugate-transpose of LVECTOR
More information available at http://www.netlib.org/lapack/double/dggev.f
> // dggev routine example > _affc=1$ > A = matrixR[ 10, 6: 4, 12]$ > B = matrixR[ 8, 10: 0.3, 12]$ > lapack_dggev(A, B, Values, LVector, RVector)$ > writes(Values); +9.3655913978494620E-01 +3.9384647034270903E-01 +9.3655913978494620E-01 -3.9384647034270914E-01 > afftab(LVector); [(0.629444-i*0.320052) (0.629444+i*0.320052)] [(-0.704921-i*0.295079) (-0.704921+i*0.295079)] > afftab(RVector); [(0.7792-i*0.2208) (0.7792+i*0.2208)] [(-0.283744-i*0.56193) (-0.283744+i*0.56193)] >
Next: lapack_zheev, Previous: lapack_dggev, Up: Valeurs Propres et Vecteurs Propres [Contents][Index]
lapack_dgges(
<real matrix> A ,
<real matrix> B ,
<object identifier> VALUES ,
<object identifier> S ,
<object identifier> T ,
<object identifier> VSL ,
<object identifier> VSR)
It computes for a pair of N-by-N real nonsymmetric matrices (A,B), the generalized eigenvalues, the generalized real Schur form and the left and right matrices of Schur vectors. Eigenvalues are put in VALUES, the real Schur form of A in S, the real Schur form of B in T, the left matrix of Schur vectors in VSL, and the right matrix of Schur vectors in VSR.
It gives the generalized Schur factorization:
(A,B) = ( (VSL)*S*(VSR)**T, (VSL)*T*(VSR)**T )
where VSR**T is the transpose of VSR
More information available at http://www.netlib.org/lapack/double/dgges.f
> // dgges routine example > _affc=1$ > A = matrixR[ 10, 6: 4, 12]$ > B = matrixR[ 8, 10: 0.3, 12]$ > lapack_dgges(A, B, Values, S, T, VSL, VSR)$ > writes(Values); +9.3655913978494620E-01 +3.9384647034270903E-01 +9.3655913978494620E-01 -3.9384647034270914E-01 > afftab(S); [ 15.3566 4.77834] [ - 3.02259 5.31087] > afftab(T); [ 16.6388 0] [ 0 5.58935] > afftab(VSL); [ 0.735209 0.677841] [ 0.677841 - 0.735209] > afftab(VSR); [ 0.365713 0.930728] [ 0.930728 - 0.365713] >
Next: lapack_zhbev, Previous: lapack_dgges, Up: Valeurs Propres et Vecteurs Propres [Contents][Index]
lapack_zheev(
<complex matrix> A,
<object identifier> VALUES ,
<object identifier> VECTORS)
It computes all the eigenvalues and eigenvectors of a complex hermitian matrix A. Eigenvalues are put in VALUES, eigenvectors in VECTORS.
More information available at http://www.netlib.org/lapack/complex16/zheev.f
> // zheev routine test > _affc=1$ > A = matrixC[ 8+8*i, 8: 8, 8+8*i]$ > lapack_zheev(A, Values, Vectors); Vectors double precision complex matrix [ 1:2 , 1:2 ] > writes(Values); +0.0000000000000000E+00 +1.6000000000000000E+01 > afftab(Vectors); [ - 0.707107 0.707107] [ 0.707107 0.707107]
Next: lapack_zgeev, Previous: lapack_zheev, Up: Valeurs Propres et Vecteurs Propres [Contents][Index]
lapack_zhbev(
<complex matrix> A,
<object identifier> VALUES ,
<object identifier> VECTORS)
It computes all the eigenvalues and eigenvectors of a complex hermitian band matrix A. Eigenvalues are put in VALUES, eigenvectors in VECTORS.
More information available at http://www.netlib.org/lapack/complex16/zhbev.f
> // zhbev routine test > _affc=1$ > A = matrixC[ 8+8*i, 15+i: 15-i, 8+8*i]$ > lapack_zheev(A, Values, Vectors); Vectors double precision complex matrix [ 1:2 , 1:2 ] > writes(Values); -7.0332963783729099E+00 +2.3033296378372910E+01 > afftab(Vectors); [(0.705541+i*0.047036) (0.705541+i*0.047036)] [ - 0.707107 0.707107] >
Next: lapack_zhegv, Previous: lapack_zhbev, Up: Valeurs Propres et Vecteurs Propres [Contents][Index]
lapack_zgeev(
<complex matrix> A ,
<object identifier> VALUES ,
<object identifier> LVECTOR ,
<object identifier> RVECTOR)
It computes all the eigenvalues and eigenvectors of a complex matrix A. Eigenvalues are put in VALUES, left eigenvectors in LVECTOR and right eigenvectors in RVECTOR.
It solves
A*RVECTOR=VALUES*RVECTOR and
LVECTOR**T*A=VALUES*LVECTOR**T
where LVECTOR**T is the transpose of LVECTOR
More information available at http://www.netlib.org/lapack/complex16/zgeev.f
> //Fr exemple de la routine zgeev > // zgeev routine test > _affc=1$ > A = matrixC[ 8, 0: 0, 8]$ > lapack_zgeev(A, Values, LV, RV); > writes(Values); +8.0000000000000000E+00 +0.0000000000000000E+00 +8.0000000000000000E+00 +0.0000000000000000E+00 > afftab(LV); [ 1 0] [ 0 1] > afftab(RV); [ 1 0] [ 0 1] >
Previous: lapack_zgeev, Up: Valeurs Propres et Vecteurs Propres [Contents][Index]
lapack_zhegv(
<integer> ITYPE ,
<complex matrix> A ,
<complex matrix> B ,
<object identifier> VALUES ,
<object identifier> VECTORS)
It computes all the eigenvalues and eigenvectors of a complex generalized positive definite eigenproblem. Here A and B are assumed to be hermitian and B is also positive definite. Eigenvalues are put in VALUES, eigenvectors in VECTORS.
3 problems are provided:
More information available at http://www.netlib.org/lapack/complex16/zhegv.f
> // zhegv routine test > _affc=1$ > B = matrixC[ 10,i: -1*i, 10]$ > A = matrixC[ 451.27, 0: 0, 512.75]$ > lapack_zhegv(3, A, B, Values, Vectors); > afftab(Vectors); [(0+i*2.69134) (0+i*1.66033)] [ - 1.38287 2.84388] > writes(Values); +4.2492379742004214E+03 +5.3909620257995803E+03
Next: Utilitaire, Previous: Bibliotheques, Up: Top [Contents][Index]
• Analyse en frequence : | ||
• fft : | Transformee de Fourier. | |
• ifft : | Transformee de Fourier Inverse. | |
• integnum : | Integration numerique. | |
• integnumfcn : | Integration numerique de fonction externe. | |
• integral : | ||
• iternum : | Iteration. | |
• interpol : | Interpolation. | |
• Changement de coordonnees : |
Next: fft, Up: Traitement numerique [Contents][Index]
• naf : | ||
• naftab : | ||
• freqa : | ||
• freqareson : | ||
• sertrig : |
Next: naftab, Up: Analyse en frequence [Contents][Index]
naf(
KTABS,
fichiersource,
fichierresultat,
XH,
T0,
NTERM,
CX,
CY);
with :
It performs the frequency analysis of the data in the source file and stores the found frequencies to the file fichierresultat.sol. It uses KTABS+1 values.
KTABS is rounded to the nearest least value such that KTABS = 6n with n positive integer.
The used parameters are stored to the file fichierresultat.par.
The intermediate results are stored to the file fichierresultat.prt if _naf_iprt
>=0.
It uses the global variables _naf_nulin
, _naf_iprt
, _naf_isec
, _naf_iw
, _naf_dtour
, _naf_icplx
.
The file fichierresultat.sol contains:
Le fichier "tessin.out" contient des données sur 32996 lignes avec une ligne d'entete. tels que la colonne 2 contient la partie réelle des données. la colonne 3 contient la partie imaginaire des données. la première ligne du fichier est à ignorer. Le temps initial est 0 et le pas est de 0.01. Nous recherchons 10 frequences. Le fichier resultat à pour nom "tesnaf". > _naf_nulin=1; > naf(32996,tessin.out, tesnaf, 0.01, 0, 10, 2, 3); Le premier argument de naf n'est pas multiple de 6. Le premier argument de naf devient 32994. Les frequences trouvees sont sauves dans le fichier :tesnaf.sol Les paramètres employees sont sauves dans le fichier :tesnaf.par Le fichier tesnaf.par contient : NOMFPAR = tesnaf.par NOMFOUT = NOMFDAT = tessin.out NOMFSOL = tesnaf.sol DTOUR = 6. 83185307179586E+00 T0 = 0.000000000000000E+00 XH = 1.000000000000000E-02 KTABS = 32994 DNEPS = 1.000000000000000E+100 NTERM = 10 ICPLX = 1 IW = 1 ISEC = 1 NULIN = 1 ICX = 2 ICY = 3 IPRNAF = -1
Next: freqa, Previous: naf, Up: Analyse en frequence [Contents][Index]
naftab(
TX, TY, A, F, KTABS, XH, T0, NTERM);
naftab(
TX, TY, A, F, KTABS, XH, T0, NTERM, TRESX, TRESY);
naftab(
TX, TY, A, F, KTABS, XH, T0, NTERM, TRESX, TRESY, (
FMIN1, FMAX1, NTERM1)
,...);
with :
It performs the frequency analysis of the dat in the vectors (TX+i*TY) and store the found frequencies to F and the complex amplitudes to A.
KTABS is rounded to the nearest least value such that KTABS = 6n+1 with n positive integer.
It uses the global variables_naf_isec
, _naf_iw
, _naf_dtour
, _naf_icplx
.
It finds an approximation of TX+iTY in the form of sum from l=0 to size(F) { A[l]*exp(i*F[l]*t) }
In this case, A is a numerical vector of complex numbers ( <complex vec.> ).
The triplets (FMINx, FMAXx, NTERMx) define the windows. Only the frequencies in the window are searched if a window is specified.
Le fichier "tessin.out" contient des données sur 32998 lignes avec une ligne d'entete. tels que la colonne 2 contient la partie réelle des données. la colonne 3 contient la partie imaginaire des données. Le temps initial est 0 et le pas est de 0.01. Nous recherchons 10 frequences. > vnumR X,Y,F; vnumC A; read(tessin2.out, [1:32000],(X,2),(Y,3)); naftab(X,Y,A,F,32000,0.01, 0, 10); B=abs(A); Le premier argument de naf n'est pas multiple de 6. Le premier argument de naf devient 31998. CORRECTION DE IFR = 1 AMPLITUDE = 8.72192e-07 B Tableau de reels : nb reels =6 > writes(F,B,A); +9.999993149794888E-02 +1.000000E-01 +1.000E-01 +1.095970178673141E-06 -2.000000944035095E-01 +9.999999E-03 +9.999E-03 +1.312007532388499E-07 +3.000000832689856E-01 +1.000000E-03 +1.000E-03 -1.403292661135361E-08 -4.000000970924361E-01 +9.999995E-05 +9.999E-05 +1.695880029074994E-09 +4.999999805039361E-01 +1.000003E-05 +1.000E-05 +3.216502329016007E-11 -5.999999830866213E-01 +9.999979E-07 +9.999E-07 -1.796078221829677E-12 >
Next: freqareson, Previous: naftab, Up: Analyse en frequence [Contents][Index]
freqa(
TFREQ, TFREQREF, TABCOMBI, TINDIC, ORDREMAX, EPSILON, TFREQRESIDU)
with :
For each frequency in the vector TFREQ, it finds the integer combination of the fundamental frequencies stored in TFREQREF with the accuracy EPSILON and the maximal order ORDREMAX. For each frequency in the vector TFREQ, the searching will be stop as soon as a valid integer combination is found. The searching is performed by increasing the total order.
If a combination is found, then
If a combination isn’t found, then alors
On exit, TABCOMBI is an array of size(
TFREQREF)
numerical vectors of size(
TFREQ)
integers,
TINDIC is a numerical vector of size(
TFREQ)
integers (0/1),
TFREQRESIDUis a numerical vector of size(
TFREQ)
reals.
On exit, all elements of the array TABCOMBI verify
1<=sum(abs(TABCOMBI[i][]))<=ORDREMAX.
> freqfond=1,5; > freqfond[1]=3.1354; > freqfond[2]=5.452; > freqfond[3]=7.888; > freqfond[4]=11.111; > freqfond[5]=19.777; > freq=1,5; > freq=freq*freqfond[1]+freq*freqfond[2]+freq*freqfond[3]+ > freq*freqfond[4]+freq*freqfond[5]; > freqa(freq,freqfond,tabcomb, tabind,20,1E-6, freqres); > %writesfreqa[[freq],[freqfond],[tabcomb],[tabind] , [freqres]]; > freqfond[1] = 15677/5000 > freqfond[2] = 1363/250 > freqfond[3] = 986/125 > freqfond[4] = 11111/1000 > freqfond[5] = 19777/1000 Frequence Frequence residuelle combinaison ------------------------------------------------------------------- 4.736340000000000E+01 +0.000000000000000E+00 1 1 1 1 1 9.472680000000000E+01 +0.000000000000000E+00 2 2 2 2 2 1.420902000000000E+02 +0.000000000000000E+00 3 3 3 3 3 1.894536000000000E+02 +0.000000000000000E+00 4 4 4 4 4 2.368170000000000E+02
Next: sertrig, Previous: freqa, Up: Analyse en frequence [Contents][Index]
freqareson(
FREQ, TFREQREF, TABCOMBI, ORDREMAX, EPSILON, TFREQRESIDU)
with :
For the frequency FREQ, it finds all integer combinations of the fundamental frequencies TFREQREF with the accuracyn EPSILON and the maximal order ORDREMAX.
On exit, for each found combination,
On exit, TABCOMBI is an array of size(
TFREQREF)
numerical vectors of integers.
On exit, all elements of the array TABCOMBI verify
sum(abs(TABCOMBI[i][]))<=ORDREMAX.
>vnumR freqfond; >resize(freqfond,5); >freqfond[1]=3.1354; >freqfond[2]=5.452; >freqfond[3]=2*freqfond[3]; >freqfond[4]=11.111; >freqfond[5]=19.777; >freq=2*freqfond[1]+freqfond[2]-freqfond[3]+freqfond[4]-freqfond[5]; >freqareson(freq,freqfond,tabcomb, 8,1E-6, freqres); >writes("%+-g\t%+-g\t%+-g\t%+-g\t%+-g\n",tabcomb); +2 -1 +0 +1 -1 +2 +1 -1 +1 -1 +2 -3 +1 +1 -1
Previous: freqareson, Up: Analyse en frequence [Contents][Index]
sertrig(
<complex vec.> TAMP, <real vec.> TFREQ, <variable> VAR)
sertrig(
<complex vec.> TAMP, <real vec.> TFREQ, <variable> VAR, <real> FACT )
with :
The vector TAMP et TFREQ must have the same size.
It computes the sum : for each element j of the vectors : TAMP[j]*exp(i*TFREQ[j]*VARIABLE) or for each element j of the vectors : TAMP[j]*exp(i*2*pi*TFREQ[j]*VARIABLE/FACT)
The part exp(i*...)is represented as an angular variable where the argument is the frequency and the phase is null. The amplitude is the coefficient of this variable. All angular variables have the prefix _Ex. There will be the same number of angular variables as the frequencies’ one. The serie will contain the same number of terms as the size of the numerical vectors.
Le F contient les frequences et le tableau A contient les amplitudes. > writes(F,A); +9.999993149794888E-02 +1.000000000456180E-01 +1.095970178673141E-06 -2.000000944035095E-01 +9.999999960679056E-03 +1.312007532388499E-07 +3.000000832689856E-01 +1.000000314882390E-03 -1.403292661135361E-08 -4.000000970924361E-01 +9.999995669530993E-05 +1.695880029074994E-09 +4.999999805039361E-01 +1.000003117384769E-05 +3.216502329016007E-11 -5.999999830866213E-01 +9.999979187109419E-07 -1.796078221829677E-12 > s=sertrig(A,F,t); s(_EXt1,_EXt2,_EXt3,_EXt4,_EXt5,_EXt6) = (9.99997918710942E-07-i*1.79607822182968E-12)*_EXt6 + (1.00000311738477E-05+i*3.21650232901601E-11)*_EXt5 + (9.99999566953099E-05+i*1.69588002907499E-09)*_EXt4 + (0.00100000031488239-i*1.40329266113536E-08)*_EXt3 + (0.00999999996067906+i*1.3120075323885E-07)*_EXt2 + (0.100000000045618+i*1.09597017867314E-06)*_EXt1
Next: ifft, Previous: Analyse en frequence, Up: Traitement numerique [Contents][Index]
fft (
TX, TY, TAMP, TFREQ, XH, T0, DTOUR, IW)
with :
It computes the Fast Fourier Transform of TX+i*TY and stores the amplitudes and frequencies to the vectors TAMP et TFREQ.
It keeps only the first "N" elements of TX and TY such that "N" is the greatest power of 2 less than the size of the vector TX.
Remarks: TX and TY must have the same size.
>vnumC z; vnumR freq; xin=vnumR[7.:5.:6.:9.]; yin=vnumR[0:0:0:0]; fft(xin,yin,z,freq,1,0,pi,0); writes(z,freq); > -2.500000000000000E-01 +0.000000000000000E+00 -1.570796326794897E+00 +2.499999999999993E-01 -1.000000000000000E+00 -7.853981633974483E-01 +6.750000000000000E+00 +0.000000000000000E+00 +0.000000000000000E+00 +2.500000000000007E-01 +1.000000000000000E+00 +7.853981633974483E-01 -2.500000000000000E-01 +0.000000000000000E+00 +1.570796326794897E+00
Next: integnum, Previous: fft, Up: Traitement numerique [Contents][Index]
ifft (
TAMP, TX, TY, XH, T0)
with :
It computes the Inverse Fast Fourier Transform of TAMP and stores the results to TX+i*TY.
TAMP is a numerical vector of 2**N+1 complex numbers. On exit, TX and TY contains 2**N numbers.
>vnumC z; vnumR freq; xin=vnumR[7.:5.:6.:9.]; yin=vnumR[0:0:0:0]; fft(xin,yin,z,freq,1,0,pi,0); ifft(z,xout,yout,1,0); writes(xout,yout); > +7.000000000000000E+00 +0.000000000000000E+00 +5.000000000000000E+00 +0.000000000000000E+00 +6.000000000000000E+00 +0.000000000000000E+00 +9.000000000000000E+00 +0.000000000000000E+00
Next: integnumfcn, Previous: ifft, Up: Traitement numerique [Contents][Index]
integnum(
T0, TF, PAS, PREC, DOPRIMAX, PASDOPRI, FICHIER,
{ REAL ,(
VAR1, SER1, VI1),
...},
{ COMPLEX ,(
VAR2, SER2, VI2),
...});
integnum(
T0, TF, PAS, PREC, DOPRIMAX, PASDOPRI, FICHIER,
{ REAL ,(
VAR1, SER1, VI1),
...},
{ COMPLEX ,(
VAR2, SER2, VI2),
...},
);
with :
It performs the numerical integration of the series in the list with the initial conditions and stores the results to the file FICHIER.
The used numerical integrator depends on the value of _integnum
(see _integnum).
The equations are triplets of integrated variable, serie and initial condition.
If RESTARTSTATE is specified and doesnot exist, the initial condition are taken from the equations. If RESTARTSTATE exists then the initial conditions are taken RESTARTSTATE and T0 is ignored. At the end of the integration, RESTARTSTATE is updated. RESTARTSTATE is usefull to restart an integration. It is possible to change the integration step, depending on the integrator.
<array of real vec.> = integnum(
T0, TF, PAS, PREC, DOPRIMAX, PASDOPRI,
{ REAL ,(
VAR1, SER1, VI1),
...},
{ COMPLEX ,(
VAR2, SER2, VI2),
...});
All parameters are similar to the previous form, except FICHIER which is not present.
It performs the numerical integration of the series in the list with the initial conditions and stores the results to an array of numerical vectors.
The used numerical integrator depends on the value of _integnum
(see _integnum).
integnum(
T0, TF, PAS, PREC, DOPRIMAX, PASDOPRI, FICHIER,
{ REAL ,(
TVAR1, TSER1, TVI1),
...},
{ COMPLEX ,(
TVAR2, TSER2, TVI2),
...});
with :
All parameters are similar to the first form, except TVAR, TSER and TVI. The equations are triplets of array of integrated variables, array of series and arrays of initials conditions.
<array of real vec.> = integnum(
T0, TF, PAS, PREC, DOPRIMAX, PASDOPRI,
{ REAL ,(
TVAR1, TSER1, TVI1),
...},
{ COMPLEX ,(
TVAR2, TSER2, TVI2),
...});
with :
All parameters are similar to the second form, except TVAR, TSER and TVI. The equations are triplets of array of integrated variables, array of series and array of initials conditions.
We want to integrate the following system : { dx/dt = -y , dy/dt= x } with the initial values x=1 and y=0 between 0 and 2*pi with the step pi/10 and a precision of 1E-12. The step of the integrator will be pi/20 et the maximal step will be pi/10. The results will be stored to the file icossin.out The solution is : x = cos(t) and y = sin(t) >integnum(0,2*pi, pi/10, 1E-12, pi/10, pi/20, icossin.out, REAL, (x, -y, 1),(y,x, 0)); The content of the file icossin.out is : time x y +0.000000000000000E+00 +1.000000000000000E+00 +0.000000000000000E+00 +3.141592653589793E-01 +9.510565162951542E-01 +3.090169943749471E-01 +6.283185307179586E-01 +8.090169943749489E-01 +5.877852522924729E-01 +9.424777960769379E-01 +5.877852522924752E-01 +8.090169943749478E-01 +1.256637061435917E+00 +3.090169943749500E-01 +9.510565162951550E-01 +1.570796326794897E+00 +2.567125951231441E-15 +1.000000000000003E+00 +1.884955592153876E+00 -3.090169943749455E-01 +9.510565162951576E-01 +2.199114857512855E+00 -5.877852522924724E-01 +8.090169943749527E-01 +2.513274122871834E+00 -8.090169943749485E-01 +5.877852522924791E-01 +2.827433388230814E+00 -9.510565162951568E-01 +3.090169943749536E-01 +3.141592653589793E+00 -1.000000000000005E+00 +5.403107187863445E-15 +3.455751918948772E+00 -9.510565162951610E-01 -3.090169943749436E-01 +3.769911184307752E+00 -8.090169943749564E-01 -5.877852522924716E-01 +4.084070449666731E+00 -5.877852522924830E-01 -8.090169943749488E-01 +4.398229715025710E+00 -3.090169943749571E-01 -9.510565162951583E-01 +4.712388980384690E+00 -8.301722685091165E-15 -1.000000000000008E+00 +5.026548245743669E+00 +3.090169943749417E-01 -9.510565162951644E-01 +5.340707511102648E+00 +5.877852522924709E-01 -8.090169943749602E-01 +5.654866776461628E+00 +8.090169943749494E-01 -5.877852522924867E-01 +5.969026041820607E+00 +9.510565162951601E-01 -3.090169943749604E-01 +6.283185307179586E+00 +1.000000000000011E+00 -1.085302505620242E-14
> // Instead of storing the result in a file, > // we store the result in an array q. > p = pi/10; p = 0.3141592653589793 > q = integnum(0, 2*pi, p, 1E-12, p, p/2,REAL,(x,-y,1),(y,x,0)); q [1:3 ] number of elements = 3 > stat(q); Array of series q [ 1:3 ] list of array's elements : q [ 1 ] = Numerical vector q contains 21 double precision reals. Size of the array in bytes: 168 q [ 2 ] = Numerical vector q contains 21 double precision reals. Size of the array in bytes: 168 q [ 3 ] = Numerical vector q contains 21 double precision reals. Size of the array in bytes: 168 > writes(q); +0.0000000000000000E+00 +1.0000000000000000E+00 +0.0000000000000000E+00 +3.1415926535897931E-01 +9.5105651629515420E-01 +3.0901699437494706E-01 +6.2831853071795862E-01 +8.0901699437494889E-01 +5.8778525229247280E-01 +9.4247779607693793E-01 +5.8778525229247525E-01 +8.0901699437494767E-01 +1.2566370614359172E+00 +3.0901699437495000E-01 +9.5105651629515486E-01 +1.5707963267948966E+00 +2.6090241078691179E-15 +1.0000000000000027E+00 +1.8849555921538759E+00 -3.0901699437494545E-01 +9.5105651629515764E-01 +2.1991148575128552E+00 -5.8778525229247236E-01 +8.0901699437495267E-01 +2.5132741228718345E+00 -8.0901699437494845E-01 +5.8778525229247902E-01 +2.8274333882308138E+00 -9.5105651629515675E-01 +3.0901699437495334E-01 +3.1415926535897931E+00 -1.0000000000000053E+00 +5.1625370645069779E-15 +3.4557519189487724E+00 -9.5105651629516097E-01 -3.0901699437494379E-01 +3.7699111843077517E+00 -8.0901699437495633E-01 -5.8778525229247180E-01 +4.0840704496667311E+00 -5.8778525229248280E-01 -8.0901699437494901E-01 +4.3982297150257104E+00 -3.0901699437495678E-01 -9.5105651629515842E-01 +4.7123889803846897E+00 -7.9658502016854982E-15 -1.0000000000000080E+00 +5.0265482457436690E+00 +3.0901699437494201E-01 -9.5105651629516430E-01 +5.3407075111026483E+00 +5.8778525229247114E-01 -8.0901699437496011E-01 +5.6548667764616276E+00 +8.0901699437494945E-01 -5.8778525229248657E-01 +5.9690260418206069E+00 +9.5105651629516008E-01 -3.0901699437496022E-01 +6.2831853071795862E+00 +1.0000000000000107E+00 -1.0685896612017132E-14 >
integnum(
T0, TF, PAS, PREC, DOPRIMAX, PASDOPRI, FICHIER, MACRO, VI );
with :
It performs the numerical integration using the system defined in the macro with the vector of initial conditions and stores the results to the file FICHIER.
The used numerical integrator depends on the value of _integnum
(see _integnum).
The macro must be refined as macro nom [N,T,Y,DY] {... }
This macro will evaluate the derivate of Y at time T ( DY=dY/dt=f(Y,T) ).
This macro will be called by integnum
with the following parameter :
The macro could access to global objects.
<array of real vec.> = integnum(
T0, TF, PAS, PREC, DOPRIMAX, PASDOPRI, MACRO, VI );
All parameters are similar to the previous form, execpt FICHIER which is not present.
It performs the numerical integration using the system defined in the macro with the vector of initial conditions and stores the results to an array of numerical vectors.
The used numerical integrator depends on the value of _integnum
(see _integnum).
We want to integrate the following system : { dx/dt = -y , dy/dt= x } with the initial values x=1 and y=0 between 0 and 2*pi with the step pi/10 and a precision of 1E-12. The step of the integrator will be pi/20 et the maximal step will be pi/10. The results will be stored to the file icossin.out The solution is : x = cos(t) and y = sin(t) macro fcn [N,X,Y,DY] { DY[1]=-Y[2]$ DY[2]=Y[1]$ }; vnumR v; resize(v,2); v[1]=1; v[2]=0; integnum(0,2*pi, pi/10, 1E-12, pi/10, pi/20, output.dat, fcn, v); The content of the file icossin.out is : time x y +0.000000000000000E+00 +1.000000000000000E+00 +0.000000000000000E+00 +3.141592653589793E-01 +9.510565162951542E-01 +3.090169943749471E-01 +6.283185307179586E-01 +8.090169943749489E-01 +5.877852522924729E-01 +9.424777960769379E-01 +5.877852522924752E-01 +8.090169943749478E-01 +1.256637061435917E+00 +3.090169943749500E-01 +9.510565162951550E-01 +1.570796326794897E+00 +2.567125951231441E-15 +1.000000000000003E+00 +1.884955592153876E+00 -3.090169943749455E-01 +9.510565162951576E-01 +2.199114857512855E+00 -5.877852522924724E-01 +8.090169943749527E-01 +2.513274122871834E+00 -8.090169943749485E-01 +5.877852522924791E-01 +2.827433388230814E+00 -9.510565162951568E-01 +3.090169943749536E-01 +3.141592653589793E+00 -1.000000000000005E+00 +5.403107187863445E-15 +3.455751918948772E+00 -9.510565162951610E-01 -3.090169943749436E-01 +3.769911184307752E+00 -8.090169943749564E-01 -5.877852522924716E-01 +4.084070449666731E+00 -5.877852522924830E-01 -8.090169943749488E-01 +4.398229715025710E+00 -3.090169943749571E-01 -9.510565162951583E-01 +4.712388980384690E+00 -8.301722685091165E-15 -1.000000000000008E+00 +5.026548245743669E+00 +3.090169943749417E-01 -9.510565162951644E-01 +5.340707511102648E+00 +5.877852522924709E-01 -8.090169943749602E-01 +5.654866776461628E+00 +8.090169943749494E-01 -5.877852522924867E-01 +5.969026041820607E+00 +9.510565162951601E-01 -3.090169943749604E-01 +6.283185307179586E+00 +1.000000000000011E+00 -1.085302505620242E-14 Instead of storing the result in a file, we store the result in an array q. q = integnum(0,2*pi, pi/10, 1E-12, pi/10, pi/20, fcn, v);
Next: integral, Previous: integnum, Up: Traitement numerique [Contents][Index]
integnumfcn(
T0, TF, PAS, PREC, DOPRIMAX, PASDOPRI, FICHIER, LIBRAIRIE,
{ REAL ,(
VAR1, VI1),
...},
{ COMPLEX ,(
VAR2, VI2),
...});
with :
It performs the numerical integration of the function integfcn located in the external library LIBRAIRIE with the initial conditions and stores the results to the file FICHIER.
The used numerical integrator depends on the value of _integnum
(see _integnum).
The integrated variables are only used for the names in the output file.
<array of real vec.> = integnumfcn(
T0, TF, PAS, PREC, DOPRIMAX, PASDOPRI, LIBRAIRIE,
{ REAL ,(
VAR1, VI1),
...},
{ COMPLEX ,(
VAR2, VI2),
...});
All parameters are similar to the previous form of integnumfcn, execpt FICHIER which is not present.
It performs the numerical integration of the function integfcn located in the external library LIBRAIRIE with the initial conditions and store the results to an array of numerical vectors.
The used numerical integrator depends on the value of _integnum
(see _integnum).
The name of the integrated variables are ignored by this function.
The functions of the dynamic library must have the following definition :
This function is called before the integration starts.
This function must initialize dy such that dy/dt=f(y,t) and must return 1.
This function is called after the integration stops.
In order to create a dynamic library from a source file written in the language C, it should usually compiled with the following command :
The dynamic library libfcn.(so,dylib,dll) contains the results of the compilation of the following source file fcn.c : #include <math.h> void integfcnbegin(const int * neq, void **data) { } int integfcn(const int * neq, const double *x, const double *y, double *yp, void* data) { yp[0] = sqrt(1.E0+cos(y[1])); yp[1] = y[0]+y[1]; return 1; } void integfcnend(void *data) { } To integrate the system { dx/dt = sqrt(1+cos(y)) , dy/dt = x+y } with the initial condition x=1 and y=0 and to store the result in the file output.dat : > integnumfcn(0,2*pi, pi/10, 1E-12, pi/10, pi/20, output.dat, libfcn, REAL, (x, 1),(y,0)); To integrate the same system but it stores the result to the array of numerical vectors q : > q = integnumfcn(0,2*pi, pi/10, 1E-12, pi/10, pi/20, libfcn, REAL, (x, 1),(y,0));
integnumfcn(
T0, TF, PAS, PREC, DOPRIMAX, PASDOPRI, FICHIER, LIBRAIRIE,
{ REAL ,(
VAR1, VI1),
...},
{ COMPLEX ,(
VAR2, VI2),
...}
,
evalnum, REAL
,TB, TB_0, TB_PAS,TF, TF_0, TF_PAS )
with :
It performs the numerical integration of the function integfcn located in the external library LIBRAIRIE with the initial conditions and time series. It stores the results to the file FICHIER.
The numerical integrator specified by _integnum
must be ADAMS (see _integnum).
This function supplies to the function integfcn the extracted data from the time series TB or TF for the time where the second member must be evaluated. For example, if the second member must be evaluated at the time t, it extracts from TB or TF the data corresponding to the time t. For the beginning of the ADAMS method, it interpolates the data of TB and supplies these interpolated values to the function integfcn. For the time between T0 and TF, it only extracts the values without any interpolation. For example, if TB and TF are arrays of 4 vectors of 1000 numbers, the function integfcn will be called with a vector of 4 numbers.
The function requires that TB_0 and TF_0 must have the same value as T0. Moreover, PAS must be a multiple of TB_PAS and TF_PAS.
The integrated variables are only used for the names in the output file.
The functions of the dynamic library must have the following definition :
This function is called before the integration starts.
This function must initialize dy such that dy/dt=f(y,tabdata(t),t) and must return 1.
This function is called after the integration stops.
In order to create a dynamic library from a source file written in the language C, it should usually compiled with the following command :
The dynamic library libfcn.(so,dylib,dll) contains the results of the compilation of the following source file fcn.c : #include <math.h> void integfcnbegin(const int * neq, void **data) { } int integfcn(const int * neq, const double *x, const double *y, double *yp, const double *tabdata) { yp[0] = sqrt(1.E0+cos(y[1])*tabdata[0]); yp[1] = y[0]*tabdata[1]+y[1]; return 1; } void integfcnend(void *data) { } To integrate the system { dx/dt = sqrt(1+cos(y)*sin(a*t)) , dy/dt = cos(b*t)*x+y } with a=0.5, b=0.9 and the initial condition x=1 and y=0 and to store the result in the file output.dat : > t0 = 0; > tf = 2*pi; > pas=pi/10; > vnumR tabb[1:2], tabf[1:2]; > t=-30*pas,t0,pas; > a=0.5; b=0.9; > tb[1]=sin(a*t); tb[2]=cos(b*t); > t=t0, tf+2*pas,pas; > tf[1]=sin(a*t); tf[2]=cos(b*t); > > integnumfcn(t0,tf, pas, 1E-12,pas, pas/2, output.dat, libfcn, REAL, (x, 1),(y,0), evalnum, REAL, tb, t0, -pas, tf, t0, pas);
Next: iternum, Previous: integnumfcn, Up: Traitement numerique [Contents][Index]
integral(
<num. vec.> TY, <real> XH, <integer> ORDRE, <object identifier> N)
integral(
<num. vec.> TY, <real> XH, <integer> ORDRE, <object identifier> N, "kahan" )
with :
It computes the integral, using Newton-Cotes formulas, of order ORDRE, of the numerical vector TY where data are equally spaced of XH.
It returns in N the index of the last element used to compute the integral. The value of N verifies : N=int((size(TY)-1)/ORDRE)*ORDRE+1
If the option "kahan" is set, the function uses the Kahan method to perform the summation (compensated summation).
Reference : For Newton-Cotes formulas, see the book "Introduction to Numerical Analysis", chapter integration, of Stoer and Burlisch.
Kahan, William (January 1965), "Further remarks on reducing truncation errors", Communications of the ACM 8 (1): 40, http://dx.doi.org/10.1145%2F363707.363723
> t=0,10000; t Tableau de reels : nb reels =10001 > t=t*pi/10000; > X=-cos(t)+1; > for j=1 to 6 { s=integral(sin(t),pi/10000,j,N); delta=s-X[N];}; s = 1.99999998355066 delta = -1.64493392240672E-08 s = 1.99999999999999 delta = -7.54951656745106E-15 s = 1.99999995065198 delta = 5.55111512312578E-15 s = 2 delta = -4.44089209850063E-16 s = 2 delta = 8.88178419700125E-16 s = 1.99999921043176 delta = 5.77315972805081E-15
Next: interpol, Previous: integral, Up: Traitement numerique [Contents][Index]
iternum(
nbiteration, passortie, fichierresultat ,
REAL ,(
variable1, serie1, valeurinitiale1),...
},
COMPLEX ,(
variable2, serie2, valeurinitiale2),...
});
with :
It performs nbiteration iterations on the equations specified in lists. it writes results to file every passortie iterations.
The equations are triplets of the iterated variable, serie and initial value.
The initial value could be a real or a complex number.
> iternum(10,1,sortie.txt,REAL,(un,un+2,3)); Le fichier "sortie.txt" contient : time un +0.000000000000000E+00 +3.000000000000000E+00 1 +5.000000000000000E+00 2 +7.000000000000000E+00 3 +9.000000000000000E+00 4 +1.100000000000000E+01 5 +1.300000000000000E+01 6 +1.500000000000000E+01 7 +1.700000000000000E+01 8 +1.900000000000000E+01 9 +2.100000000000000E+01 10 +2.300000000000000E+01 > iternum(5,1,sortie.txt,REAL,(vn,un-1,3),(un,vn+un,2)); Le fichier "sortie2.txt" contient : time vn un +0.000000000000000E+00 +3.000000000000000E+00 +2.000000000000000E+00 1 +1.000000000000000E+00 +5.000000000000000E+00 2 +4.000000000000000E+00 +6.000000000000000E+00 3 +5.000000000000000E+00 +1.000000000000000E+01 4 +9.000000000000000E+00 +1.500000000000000E+01 5 +1.400000000000000E+01 +2.400000000000000E+01
Next: Changement de coordonnees, Previous: iternum, Up: Traitement numerique [Contents][Index]
interpol(LINEAR ,
TX, DTX, TY)
interpol(QUADRATIC ,
TX, DTX, TY)
interpol(SPLINE ,
TX, DTX, TY)
interpol(HERMITE ,
TX, DTX, TY, DEG)
with :
It performs the linear, spline, quadratic or hermitian interpolation. It returns a numerical vector of interpolated values at the time TY from the known data (TX, DTX).
Remarks : it assumes that TX et TY are sorted in ascending or descending order.
If TY[i] isn’t in the interval [ TX[0], TX[size(TX)] ], then DTY[i] is extrapolated.
The algorithm of the hermitian interpolation is described in the Stoer and Burlish’s book, 1993, "Introduction to Numerical Analysis, Chap 2, pages 52-57".
> x1=0,2*pi,2*pi/59; > x2=0,3,0.5; > sl=interpol(LINEAR,x1,cos(x1),x2); > writes("%.2E %.4E %.4E\n",x2, cos(x2), sl); 0.00E+00 1.0000E+00 1.0000E+00 5.00E-01 8.7758E-01 8.7652E-01 1.00E+00 5.4030E-01 5.3958E-01 1.50E+00 7.0737E-02 7.0719E-02 2.00E+00 -4.1615E-01 -4.1576E-01 2.50E+00 -8.0114E-01 -8.0001E-01 3.00E+00 -9.8999E-01 -9.8920E-01
Previous: interpol, Up: Traitement numerique [Contents][Index]
• ell_to_xyz : | ||
• xyz_to_ell : |
Next: xyz_to_ell, Up: Changement de coordonnees [Contents][Index]
ell_to_xyz(
ELL, MU, X, XP );
with :
It converts the elliptic coordinates ELL to cartesian coordinates X (positions) and XP (velocities).
/* calcul d'une seule valeur */ GM= 0.2959122082855911d-03; mu = GM*1.05; n=2*pi/221.6; varpi = 138*pi/180; vnumR ell[1:6]; resize(ell,1); ell[1][1] = (mu/n**2)**(1./3.); ell[2][1] = varpi; ell[3][1] = 0.54*cos(varpi); ell[4][1] = 0.54*sin(varpi); ell[5][1] = 0.0; ell[6][1] = 0.0; ell_to_xyz(ell,mu,x,xp); writes(x); writes(xp);
/* calcul de plusieurs valeurs contenues dans un fichier */ mu = 1; vnumR ell[1:6]; read(file1,ell); ell_to_xyz(ell,mu,x,xp); writes(x); writes(xp);
Previous: ell_to_xyz, Up: Changement de coordonnees [Contents][Index]
xyz_to_ell(
X, XP, MU, ELL );
with :
It converts the cartesian coordinates X (positions) and XP (velocities) to the elliptic coordinates ELL.
mu = 1; vnumR x[1:3],xp[1:3]; read(file2,x,xp); xyz_to_ell(x,xp,mu,ell); writes(ell);
Next: Index, Previous: Traitement numerique, Up: Top [Contents][Index]
• aide : | ||
• sortie : | ||
• cls : | ||
• msg : | ||
• error : | ||
• try : | ||
• pause : | ||
• delete : | ||
• include : | ||
• reset : | ||
• @@ : | ||
• vartrip : | ||
• bilan : | ||
• stat : | ||
• save_env : | ||
• rest_env : | ||
• random : | ||
• nameof : | ||
• typeof : | ||
• file_fullname : | ||
• Temps d execution : | ||
• Appel au shell : |
Next: sortie, Up: Utilitaire [Contents][Index]
help;
?;
Display help.
On Unix and MacOS X operating systems, the help program uses the software info (provided by Texinfo) to display help. On Windows operating systems, the help file (chm format) is displayed.
help <motreserve>;
? <motreserve>;
It displays the help in the reference manual for the keyword of TRIP. On Unix and MacOS X operating systems, this function calls the program info (provided by Texinfo).
> ? vartrip;
Next: cls, Previous: aide, Up: Utilitaire [Contents][Index]
quit;
exit;
Stop the execution of TRIP.
Next: pause, Previous: sortie, Up: Utilitaire [Contents][Index]
cls;
Clear the current screen (similar to the Unix command clear).
Next: msg, Previous: cls, Up: Utilitaire [Contents][Index]
pause;
Display a message, suspend execution until the user hits a key. If the user hits the key RET, then the execution continues. If the user hits the key q+RET or e+RET, then the execution stops and the user returns to the prompt.
pause(
<integer> x);
Suspend execution for x seconds.
> for j=1 to 3 { j; pause; time_s; pause(2); time_t; }; 1 Appuyez sur la touche 'return' pour continuer ou la touche 'q' ou 'e' pour revenir au prompt ... 02.000s 2 Appuyez sur la touche 'return' pour continuer ou la touche 'q' ou 'e' pour revenir au prompt ... 02.000s 3 Appuyez sur la touche 'return' pour continuer ou la touche 'q' ou 'e' pour revenir au prompt ... 02.000s
Next: error, Previous: pause, Up: Utilitaire [Contents][Index]
msg
<string> ;
msg(
<string> textformat);
Display unformatted messages to the screen.
This message must a be string or a text between double-quotes. The messages could be on several lines.
msg(
<string> textformat,
<real> x,
... );
Display formatted messages to the screen with(out) real constants.
The real constants must be formatted. The format is the same as the command printf in language C (see str, for the valid conversion specifiers). This message must a be string or a text between double-quotes. The messages could be on several lines.
To display double-quotes, two double-quotes must be used.
Under the numerical mode NUMRATMP only, the integers or rational numbers are converted to double-precision floating-point numbers before they are displayed if the format is ’%g’, ’%e’ or ’%f’. if the format is ’%d’ or ’%i’, the integers or rational numbers are written without any conversion.
The function msg
(see msg) has the same behavior but writes the result into a string of characters.
> file="fichier1.dat"$ > msg"écriture du fichier "+file; écriture du fichier fichier1.dat > msg "je vais faire un guillemet : ""cette chaine est encadre par des guillemets""."; je vais faire un guillemet : "cette chaine est encadre par des guillemets". > msg("pi=%g pi=%.8E\n",pi,pi); pi=3.14159 pi=3.14159265E+00
Next: try, Previous: msg, Up: Utilitaire [Contents][Index]
error(
<string> textformat);
Raise an error and display the unformatted text to the screen.
This message must a be string or a text between double-quotes. The message could be on several lines.
> x=2; x = 2 > if (x==2) then { error("raise an error : x=2"); }; TRIP[ 3 ] : raise an error : x=2 Commande :'if (x==2) then { error("raise an error : x=2"); };' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Next: delete, Previous: error, Up: Utilitaire [Contents][Index]
try
{
<body> bodytry }
catch {
<body> bodycatch };
Normally, it executes all statements of bodytry. if an error occurs during this execution, then it ignores the remaining statements of bodytry and it executes the statements of bodycatch.
If the global variable _info is equal to on
, then an information message is displayed when the error occurs in the statements of bodytry.
If the global variable _info is equal to off
, then no information message is displayed when the error occurs in the statements of bodytry.
If an error occurs during the execution of the statements of bodycatch then an error is generated. This error could be catched if the current statement try-catch is inside another statement try-catch.
It is allowed to imbricate a statement try-catch inside the statements of bodytry or of bodycatch.
> // displays a warning message but it continues > _info on; _info on > b = 0; b = 0 > q = 2; q = 2 > try { s = "invalid"+q; b = 2; } catch { b = 1; }; TRIP[ 1 ] : Can't add Command :' try { s = "invalid"+q; b = 2; } catch { b = 1; };' ^^^^^^^^^^^ Information : Continue on error (catch statement) b = 1 > > // does not display a warning message but it continues > _info off; _info off > b = 0; b = 0 > q = 2; q = 2 > try { s = "invalid"+q; b = 2; } catch { b = 1; }; b = 1 >
Next: reset, Previous: try, Up: Utilitaire [Contents][Index]
delete(
<object identifier> );
Delete any object (serie, variable, array, ...).
Remarks :
> file="fichier1.dat"; file = "fichier1.dat" > X=expi(x,1,0); 1*X > delete(file); > delete(x); La variable angulaire X est convertie en variable polynomiale.
Next: include, Previous: delete, Up: Utilitaire [Contents][Index]
reset;
Reinitialize TRIP : TRIP global variables are set to default values and delete all object identifiers in memory.
Next: resetinclude, Previous: reset, Up: Utilitaire [Contents][Index]
include
<filename> ;
include
<string> ;
It loads the file "fichier" and run it.
This file must be located in the current directory or in the directory specified by the variable _path
.
The file extension could have any value. The recommanded file extension is .t
.
Remarks : If the file is an object identifier of type string, then it loads the file which its name is the contents of the string.
>include ellip; >include fct.t; > file="fperplanumH"; file = "fperplanumH" > include file; /*exécute le fichier "fperplanumH" */
Next: vartrip, Previous: include, Up: Utilitaire [Contents][Index]
@@;
Reinitialize TRIP. Then it loads and executes the last file executed by the command include
.
Next: bilan, Previous: resetinclude, Up: Utilitaire [Contents][Index]
vartrip;
Displays the status of all TRIP global variables.
> vartrip; Etat des variables globales de Trip : _affc = 6 _affdist = 0 _affhomog = 0 _echo = 0 _path = /exemples/ _history = /unixfiles/ _hist = ON _naf_iprt = -1 _naf_icplx = 1 _naf_iw = 1 _naf_isec = 1 _naf_dtour = 6.283185307179586E+00 _naf_nulin = 1 _naf_tol = 1.000000000000000E-10 _time = OFF _comment = OFF _affvar = ( )
Next: stat, Previous: vartrip, Up: Utilitaire [Contents][Index]
bilan;
Displays all object identifiers in memory with their type :
SERIE | the object is a serie. |
VARIABLE | the object is a variable. |
CONST | the object is a constant. |
MATRIXR | the object is a numerical matrix of real numbers. |
MATRIXC | the object is a numerical matrix of complex numbers. |
TAB | the object is an array. |
TABVAR | the object is a array of variables. |
VNUMR | the object is a numerical vector of real numbers. |
VNUMC | the object is a numerical vector of complex numbers. |
STRING | the object is a string. |
EXTERNAL STRUCTURE | the object is an external structure. |
FILE | the object is a file. |
REMOTE OBJECT | the object is a remote object stored on a SCSCP server. |
SCSCP CLIENT | the object is a connection to a SCSCP server. |
bilan mem;
For each serie or array of series, it displays the memory used and the number of terms.
The total number of terms and total memory used for series are displayed.
> bilan; A VAR ASR SERIE ASRp SERIE RSA SERIE X VAR _AsR SERIE _CosE SERIE _Expiv SERIE _RsA SERIE _RsASinv SERIE _SinE SERIE e VAR ep VAR g VAR ga VAR lp VAR x VAR > bilan mem; Nom Memoire (octets) Nb de termes -------------------- -------------------- -------------------- ASR 1704 64 ASRp 1704 64 RSA 2136 81 _AsR 1704 64 _CosE 2112 80 _Expiv 1728 64 _RsA 2136 81 _RsACosv 2112 80 _RsAExpiv 1728 64 _RsASinv 2112 80 _SinE 2112 80 -------------------- -------------------- -------------------- 21288 802
Next: save_env, Previous: bilan, Up: Utilitaire [Contents][Index]
stat;
It displays all objects in memory. These objects are ordred by their type. For each object, it displays a small description. For the series, it displays their contents.
> S = (1+x+y)**2$ > vnumR R$ > vnumC C$ > dim T[1:2]$ > stat; Summary of objects : Series: S(x,y) = 1 + 2*y + 1*y**2 + 2*x + 2*x*y + 1*x**2 Variables : Variable x type : 2 ordres : 2 2 2 2 dependances : variables dependant de celle-ci : Variable y type : 2 ordres : 3 3 3 3 dependances : variables dependant de celle-ci : Arrays of series : T [1:2 ] number of elements = 2 Double precision real vectors : Numerical vector R contains 0 double precision reals. Double precision complex vectors : Numerical vector C contains 0 double precision complex. >
stat(
<object identifier> );
stat(
<object identifier> , "puismin" );
stat(
<object identifier> , "puismax" );
stat(
<object identifier> , "puismin" , "puismax" );
Depending on the object type, it displays information on number of terms and the memory used by the object.
If the option "puismin" is set, the function displays the minimal degree of each variable in the serie.
If the option "puismax" is set, the function displays the maximal degree of each variable in the serie.
> s = (1+x+y)**2$ > stat(s); serie s ( x , y ) number of variables : 2 size of the descriptor : 96 bytes number of terms : 6 size : 608 bytes > stat(s,"puismin","puismax"); serie s ( x , y ) number of variables : 2 size of the descriptor : 96 bytes number of terms : 6 size : 608 bytes puismin : x ^ 0 , y ^ 0 puismax : x ^ 2 , y ^ 2
Next: rest_env, Previous: stat, Up: Utilitaire [Contents][Index]
save_env;
Save TRIP global variables to a stack.
> _mode; _mode = POLP > save_env; > _mode=POLH; _mode = POLH > rest_env; > _mode; _mode = POLP
Next: random, Previous: save_env, Up: Utilitaire [Contents][Index]
rest_env;
Restore the TRIP global variables saved by save_env
from a stack.
> _path="/users/"; _path = /users/ > save_env; > _path="/users/toto/"; _path = /users/toto/ > /*instructions utilisant le chemin specifique */; > rest_env; > _path; _path = /users/
Next: nameof, Previous: rest_env, Up: Utilitaire [Contents][Index]
random(
<integer> x)
Return a pseudo-random number in the range from 0 and x-1.
> random(10); 1 > random(10); 7 > random(10); 0 > random(10); 9 > random(10); 8
Next: typeof, Previous: random, Up: Utilitaire [Contents][Index]
nameof(
<object identifier> x)
It returns as a string the name of the object.
If the object is an expression, then the empty string "" is returned.
> c=3$ > n1= nameof(c); n1 = "c" > s="abcde"$ > n2 = nameof(s); n2 = "s" >
Next: file_fullname, Previous: nameof, Up: Utilitaire [Contents][Index]
typeof(
<object identifier> x)
It returns as a string the type of the object.
The returned strings are described in the command bilan
(see bilan).
If the object doesn’t exist, then the empty string "" is returned.
> typeof(2); "CONST" > typeof(1+x); "SERIE" > t=1,10; t double precision real vector : number of elements =10 > if (typeof(t)=="VNUMR") then { stat(t); }; Numerical vector t contains 10 double precision reals. Size of the array in bytes: 80 >
Next: Temps d execution, Previous: typeof, Up: Utilitaire [Contents][Index]
file_fullname(
<string> name)
It builds an absolute file name. All later usage of the returned string will ignore the variable _path.
> _path; _path = /users/guest/data/ > vnumR t; > fn=file_fullname("/tmp/mydata.txt"); fn = nom de fichier '/tmp/mydata.txt' > read(fn,t);
Next: Appel au shell, Previous: file_fullname, Up: Utilitaire [Contents][Index]
• time_s: | ||
• time_t: | ||
• time_l: |
Next: time_l, Up: Temps d execution [Contents][Index]
time_s;
Initialize the starting time for computations in functions time_l
and time_t
.
Next: time_t, Previous: time_s, Up: Temps d execution [Contents][Index]
time_l;
Displays the consumed user CPU time, the elapsed real time, and the consumed system CPU time, since the last call to time_l
.
If no previous call to time_l
was performed, then it displays the user time used since the last call to time_s
.
> time_s; for j=1 to 3 { (1+x+y+z+t+u+v)**18$ time_l; }; utilisateur 00.313s - reel 00.183s - systeme 00.057s - (202.43% CPU) utilisateur 00.307s - reel 00.170s - systeme 00.055s - (213.11% CPU) utilisateur 00.311s - reel 00.173s - systeme 00.055s - (211.93% CPU)
Previous: time_l, Up: Temps d execution [Contents][Index]
time_t;
Displays the consumed user CPU time, the elapsed real time, and the consumed system CPU time, since the last call to time_s
.
time_t(
<object identifier> usertime ,
<object identifier> realtime );
Displays the consumed user CPU time, the elapsed real time, and the consumed system CPU time, since the last call to time_s
.
usertime will contain the sum of the user and system CPU time and realtime the elapsed real time.
> time_s; for j=1 to 3 { (1+x+y+z+t+u+v)**18$ time_t; }; time_t(usertime, realtime); utilisateur 00.310s - reel 00.178s - systeme 00.055s - (205.29% CPU) utilisateur 00.615s - reel 00.347s - systeme 00.111s - (209.44% CPU) utilisateur 00.928s - reel 00.519s - systeme 00.168s - (211.23% CPU) utilisateur 00.928s - reel 00.519s - systeme 00.168s - (211.20% CPU) > usertime; usertime = 1.097452 > realtime; realtime = 0.5196029999999999
Previous: Temps d execution, Up: Utilitaire [Contents][Index]
!
<string> ;
Execute a shell command specified in a string.
> dir ="ls -al"; dir = "ls -al" > ! dir; total 8136 drwxr-sr-x 20 xxxx ttt 1536 Sep 27 17:16 . drwxr-sr-x 22 xxxx ttt 512 Sep 06 12:16 .. -rw-r----- 1 xxxx ttt 281 Sep 08 1998 .Guidefaults -rw------- 1 xxxx ttt 204 Sep 27 10:46 .Xauthority
str(!
<string> );
Execute a shell command specified in a string and return the standard output as a string. If the error output is not empty, an error is raised.
> s=str(!"uname"); s = "Darwin "
Previous: Utilitaire, Up: Top [Contents][Index]
• References : | ||
• Supported OpenMath Content Dictionaries : | ||
• Index of the global variables : | ||
• Index of the procedures : | ||
• Full index : |
Next: Supported OpenMath Content Dictionaries, Up: Index [Contents][Index]
version 6.0.0, 2014
Torbjorn Granlund et al.
version 2.4.6, 2014
2007, ACM Trans. Math. Softw. 33, 2 (Jun. 2007) 13.
Fousse, L., Hanrot, G., Lefèvre, V., Pélissier, P., and Zimmermann, P.
Version 1.0.3, February 2015
Andreas Enge and Mickaël Gastineau and Philippe Théveny and Paul Zimmermann
Version 1.3, 2009
S.Freundt, P.Horn, A.Konovalov, S.Linton, D.Roozemond.
D. Roozemond
D. Roozemond
Version 1.0.2, May 2016
M. Gastineau
Next: Index of the global variables, Previous: References, Up: Index [Contents][Index]
The following list are the OpenMath objects supported by the SCSCP server and client.
CD | Symbol |
---|---|
arith1 | abs, divide, minus, plus, power, times, unary_minus |
alg1 | one, zero |
bigfloat1 | bigflat |
arith1 | abs, divide, minus, plus, power, times, unary_minus |
complex1 | argument, complex_cartesian, complex_polar, conjugate, imaginary, real |
fieldname1 | C, Q, R |
interval1 | interval_cc, integer_interval, interval |
linalg2 | matrix, matrixrow, vector |
list1 | list |
logic1 | not, and, xor, or, true, false |
nums1 | e,i, infinity, NaN, pi, rational |
polyd1 | poly_ring_d_named, SDMP, DMP, term |
polyu | poly_u_rep, term |
polyr | poly_r_rep, term |
setname1 | C, N, P, Q, R, Z |
transc1 | arccos, arccosh, arcsin, arcsinh, arctan, arctanh, cos, cosh, exp, ln, log, sin, sinh, tan, tanh |
The following list are the OpenMath objects supported only by the SCSCP server.
CD | Symbol |
---|---|
scscp2 | get_allowed_heads, get_transient_cd, get_signature, store, retrieve, unbind |
The following list are the OpenMath objects supported only by the SCSCP client.
CD | Symbol |
---|---|
scscp2 | symbol_set, signature, service_description, |
Next: Index of the procedures, Previous: Supported OpenMath Content Dictionaries, Up: Index [Contents][Index]
Jump to: | _
I P |
---|
Jump to: | _
I P |
---|
Next: Full index, Previous: Index of the global variables, Up: Index [Contents][Index]
Jump to: | !
%
&
(
*
+
,
-
/
:
<
=
>
?
@
[
\
^
A C D E F G H I K L M N O P Q R S T U V W X |
---|
Jump to: | !
%
&
(
*
+
,
-
/
:
<
=
>
?
@
[
\
^
A C D E F G H I K L M N O P Q R S T U V W X |
---|
Previous: Index of the procedures, Up: Index [Contents][Index]
Maple is a registered trademark of Waterloo Maple Inc.
Mathematica is a registered trademark of Wolfram Research Inc.