Changeset 4065 in Sophya for trunk/SophyaLib/Manual/sophya.tex


Ignore:
Timestamp:
Apr 27, 2012, 12:39:18 AM (13 years ago)
Author:
ansari
Message:

MAJ fichier modifs.tex pour changement classes CExpressionEvaluator/introduction CE_VarListInterface, ajout description classes PrimeNumbers, QNumber, Units et PhysQty dans le user's guide de Sophya, Reza 27/04/2012

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/Manual/sophya.tex

    r3858 r4065  
    2020\usepackage[ps2pdf,bookmarks,bookmarksnumbered,%
    2121              urlcolor=blue,citecolor=blue,linkcolor=blue,%
    22                 pagecolor=blue,%hyperindex,%
     22                pagecolor=blue, % hyperindex, %
    2323                 colorlinks=true,hyperfigures=true,hyperindex=true
    2424           ]{hyperref}
     
    4949\vspace{1cm}
    5050\begin{center}
    51 {\bf \Large SOPHYA Version: 2.2 (V\_Sep2010) }
     51{\bf \Large SOPHYA Version: 2.230 (V\_Avr2012) }
    5252\end{center}
    5353\titrebp{1}
     
    234234\item[] {\bf AnaLC} contains program files extracted from the EROS/PEIDA software
    235235and adapted to be compiled with SOPHYA. It can be used in particular to read and analyse
    236 EROS light curve data files (fichiers de suivi).
     236EROS light curve data files (fichiers de suivi). Check the README file in AnaLC directory.
    237237\item[] {\bf LUC}  ( {\bf L}ittle {\bf U}niverse {\bf C}alculator) is a module containing classes to
    238238perform basic computation related to the universe geometry (FRW metric).
     
    295295In order to use the shared libraries, the {\bf LD\_LIBRARY\_PATH} variable
    296296should contain the Sophya shared library path
    297 ({\tt \$SOPHYABASE/slb}).
     297({\tt \$SOPHYABASE/slb}). On Mac OSX, the environment variable {\bf DYLD\_LIBRARY\_PATH}
     298is used instead of LD\_LIBRARY\_PATH.
    298299On Silicon Graphics machines with IRIX64 operating system,
    299300the default SOPHYA configuration correspond to the 64 bit architecture.
     
    951952\end{enumerate}
    952953
     954 \subsection{Prime and rational numbers}
     955\index{PrimeNumbers} \index{QNumber}  \label{primeqnumb}
     956The library provides basic computation possibilities for prime and rational numbers
     957through the  {\bf PrimeNumbers} and {\bf QNumber} classes. Check the header file
     958{\tt pqnumber.h} to see the provided functionalities. 
     959The class {\bf PrimeNumbers} can be used to perform basic computation with
     960prime numbers. Integer numbers are represented by machine size long integer (8 bytes).
     961The class is thread safe, whith basic algorithms to find prime numbers or perform
     962decomposition to prime factors. It has been mainly designed to
     963enable computation with rational numbers.
     964\begin{verbatim} 
     965// Create a PrimeNumbers object
     966PrimeNumbers primes;
     967// Print the prime numbers from rank 20 to 25 ...
     968cout << " Primes[20...30]: " ;
     969for(size_t k=19; k<30; k++) cout << primes(k) << "  ";
     970// Print all prime numbers less than some max values
     971uint_8 p = primes.Next();  uint_8 pmax = 223;
     972cout << endl << " Primes < " << pmax << " : " << endl;
     973while (p<pmax) {
     974 cout << p << "  ";
     975 p = primes.Next();
     976}
     977cout << endl;
     978// Compute and print prime factor decomposition:
     979uint_8 nombre=247890;
     980vector<uint_8> pfac=primes.PrimeFactors(nombre, true);
     981cout << " PrimeFactors[" << nombre << "]: ";
     982for(size_t i=0; i<pfac.size(); i++) cout << pfac[i] << "   ";   
     983cout << endl;
     984\end{verbatim}
     985
     986The class {\bf QNumber} can be used to represent and perform computation on rational
     987numbers. The four basic arithmetic operations (addition $+$, subtraction $-$, multiplication $\times$
     988division $/$) are defined, as well as comparison operators ($==  , != , < , > , \leq , \geq $).   
     989The QNumber class does not inherit from AnyDataObj, but can be serialized to/from PPF streams
     990as a pair of long integers.
     991\begin{verbatim} 
     992// Create rational numbers from pairs of integers
     993QNumber q1(3,4), q2(5,6), q3(6,8);
     994// Operations and comparsion
     995QNumber q4 = q1+q2;
     996cout << q1 << " + " << q2 << " = " << q4 << endl;
     997QNumber qa(q1), qb(q2);
     998cout << " Test qa==qb : -> " << qa << " ?== " << qb;
     999if (qa == qb)  cout << " -> true " << endl;
     1000else cout << " -> false " << endl;
     1001qb = q3;
     1002cout << " Test qa==qb : -> " << qa << " ?== " << qb;
     1003if (qa == qb)  cout << " -> true " << endl;
     1004else cout << " -> false " << endl;
     1005QNumber qq(3*7*17*5,(-5)*7*11*2);
     1006cout << " qq= " << qq << "  qq.Simplify() = " << qq.Simplify() << endl;
     1007\end{verbatim}
     1008
     1009\subsection{Physical units and constants}
     1010\index{Units} \index{PhysQty}  \label{physunits}
     1011\begin{figure}[hbt]
     1012\dclsbb{AnyDataObj}{Units}
     1013\dclsbb{AnyDataObj}{PhysQty}
     1014\end{figure}
     1015The {\bf Units} class is used to represent physical quantities in terms of the SI system base
     1016quantities: length, mass, time, electrical current, thermodynamic temperature, amount of substance
     1017and luminous intensity. Check the BIPM
     1018\href{http://www.bipm.org/fr/si/}{http://www.bipm.org/fr/si/}
     1019 or NIST \href{http://physics.nist.gov/cuu/Units/}{http://physics.nist.gov/cuu/Units/} 
     1020web sites for detailed information on the SI system and units. Basic usage of this class
     1021consist of calling static methods which return usual units. New units can be constructed using the
     1022product and divide operators (*,/) or the {\tt power} method. The Unit class has a PPF handler and
     1023can be serialized to or from PPF streams.
     1024\begin{verbatim} 
     1025Units w=Units::watt();
     1026cout << " Power unit (watt) : " << w.Name() << " (" << w << ")" << endl;
     1027// define the speed SI unit (m/s) :
     1028Units mos = Units::meter()/Units::second() ;
     1029cout << " SI speed unit : " << mos << "  -> "; mos.Print() ; 
     1030// mutiple of an existing unit :
     1031Units mw=Units::watt().mega();
     1032cout << " Megawatt: " << mw.Name() << " (" << mw << ")  -> "; mw.Print() ;
     1033\end{verbatim}
     1034
     1035This class represents physical quantities and constants, corresponding to a value associated
     1036with a unit. A relative precision and a name are optionally associated with the object. Most
     1037physical constants and usual quantities can  be obtained as PhysQty objects through static methods.
     1038The PhysQty class has a PPF handler and can be serialized to or from PPF streams.
     1039\begin{verbatim} 
     1040cout <<  " k_Boltzmann: " << PhysQty::k() << endl;
     1041cout <<  " m_e: " << PhysQty::electron_mass() << endl;
     1042// Conversion of a quantity to a different unit
     1043PhysQty aj(Units::joule(), 25.);
     1044PhysQty aev=aj.ConvertTo(Units::electronvolt().giga());
     1045cout <<  " A : " << aj << " -> " << aev << endl;
     1046\end{verbatim}
     1047
     1048
    9531049%%%%%%%%%%%%
    9541050\newpage
     
    32233319csh> tmtdt SWFITS 50000 1
    32243320\end{verbatim}
    3225 
     3321\item {\bf tcmd } tests the command interpreter and expression evaluator classes
     3322(Commander, CExpressionEvaluator, RPNExpressionEvaluator) and the Timer class
     3323 \begin{verbatim}
     3324csh> tcmd cexptst
     3325 ===> OK if RC=0
     3326csh> tcmd cexptv
     3327 ===> OK if RC=0   
     3328csh> tcmd cexptvp
     3329 ===> OK if RC=0   
     3330csh> tcmd rpntst
     3331 ===> OK if RC=0   
     3332csh> tcmd timer
     3333 ===> Check output
     3334csh> tcmd commander
     3335 ===> Interactive Commander class test
     3336\end{verbatim}
     3337 
    32263338\end{enumerate}
    32273339
     
    32323344SOPHYA library defines a set of exceptions which are used
    32333345for signalling error conditions. From version V2.2 , all SOPHYA exceptions inherit from
    3234 the standard C++ exception class ( {\bf std::std::exception}). The method {\tt const char* what()} is
     3346the standard C++ exception class ( {\bf std::exception}). The method {\tt const char* what()} is
    32353347thus implemented and returns the corresponding error message.
    32363348The figure below shows a partial class diagram for exception classes in SOPHYA.
     
    32623374\addcontentsline{toc}{section}{Index}
    32633375\printindex
     3376
    32643377\end{document}
    32653378 
Note: See TracChangeset for help on using the changeset viewer.