Changeset 1350 in Sophya


Ignore:
Timestamp:
Nov 28, 2000, 11:18:54 AM (25 years ago)
Author:
cmv
Message:

doc de Poly cmv 28/11/00

File:
1 edited

Legend:

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

    r1347 r1350  
    486486in the HTML pages of the Sophya manual.
    487487
     488\subsection{Polynomial}
     489
     490Polynomials of 1 or 2 variables are supported ({\tt Poly} and {\tt Poly2}).
     491Various operations are supported~:
     492\begin{itemize}
     493\item elementary operations between polynomials $(+,-,*,/) $
     494\item setting or getting coefficients
     495\item computing the value of the polynomial for a given value
     496      of the variable(s),
     497\item derivating
     498\item computing roots (degre 1 or 2)
     499\item fitting the polynomial to vectors of data.
     500\end{itemize}
     501Here is an example of polynomial fitting~:
     502\begin{verbatim}
     503#include "poly.h"
     504// ...
     505Poly pol(2);
     506pol[0] = 100.; pol[1] = 0.; pol[2] = 0.01; // Setting coefficients
     507TVector<r_8> x(100);
     508TVector<r_8> y(100);
     509TVector<r_8> ey(100);
     510for(int i=0;i<100;i++) {
     511  x(i)  = i;
     512  ey(i) = 10.;
     513  y(i)  = pol((double) i) + ey(i)*NorRand();
     514  ey(i) *= ey(i)
     515}
     516
     517TVector<r_8> errcoef;
     518Poly polfit;
     519polfit.Fit(x,y,ey,2,errcoef);
     520
     521cout<<"Fit Result"<<polfit<<endl;
     522cout<<"Errors :"<<errcoef;
     523\end{verbatim}
     524
     525Similar operations can be done on polynomials with 2 variables.
    488526
    489527\section{Module Samba}
Note: See TracChangeset for help on using the changeset viewer.