Skip to main content

Interfaçage

  • Chapter
Introduction à Scilab

Part of the book series: Collection IRIS ((IRIS))

  • 547 Accesses

Abstrait

Supposons que l’on dispose d’une bibliothèque de fonctions externes écrites en C. La bibliothèque contient par exemple la fonction geom qui effectue m*n tirages aléatoires selon une loi géométrique de paramètre p et stocke les résultats dans un tableau d’entiers y de taille m x n. Savoir ce que fait exactement geom n’est pas vraiment utile pour nous ici. Disons simplement que, étant donnés les entiers m et n et le paramètre p, cette fonction retourne le tableau y. Voilà le code C de la procédure geom (qui est fort simple), la seule chose importante ici étant sa liste d’appel :

$$ \begin{gathered} \operatorname{int} {\mathbf{ }}{\text{geom}}{\mathbf{ }}(\operatorname{int} {\mathbf{ }}{\text{m}},{\mathbf{ }}\operatorname{int} {\mathbf{ }}{\text{n}},{\mathbf{ }}{\text{double p}},{\mathbf{ }}\operatorname{int} {\mathbf{ }}{\text{y}}[]) \hfill \\ \{ \hfill \\ {\mathbf{ }}\operatorname{int} {\mathbf{ }}{\text{i}}; \hfill \\ {\mathbf{ }}{\text{if}}{\mathbf{ }}{\text{(}}{\mathbf{ }}{\text{p}}{\mathbf{ }}{\text{ > = }}{\mathbf{ }}{\text{1}}{\text{.0}}{\mathbf{ }}{\text{)}} \hfill \\ {\mathbf{ }}{\text{\{ }} \hfill \\ {\mathbf{ }}{\text{cerro}}{\mathbf{ }}({\text{p}}{\mathbf{ }}{\text{doit - etre}}{\mathbf{ }}{\text{ < }}{\mathbf{ }}{\text{1}}{\mathbf{ }}{\text{);}}{\mathbf{ }}{\text{return}}{\mathbf{ }}{\text{1;}} \hfill \\ {\mathbf{ }}{\text{\} }} \hfill \\ {\mathbf{ }}{\text{for}}{\mathbf{ }}{\text{(i}}{\mathbf{ }}{\text{ = }}{\mathbf{ }}{\text{0}}{\mathbf{ }}{\text{;}}{\mathbf{ }}{\text{i}}{\mathbf{ }}{\text{ < }}{\mathbf{ }}{\text{m*n}}{\mathbf{ }}{\text{;}}{\mathbf{ }}{\text{i + + )}} \hfill \\ {\mathbf{ }}\{ \hfill \\ {\mathbf{ }}{\text{double}}{\mathbf{ }}{\text{z}}{\mathbf{ }} = {\mathbf{ }}{\text{drand}}48(); \hfill \\ {\mathbf{ }}{\text{y[i]}}{\mathbf{ }}{\text{ = }}{\mathbf{ }}{\text{1;}} \hfill \\ {\mathbf{ }}{\text{while}}{\mathbf{ }}{\text{(}}{\mathbf{ }}{\text{z}}{\mathbf{ }}{\text{ < }}{\mathbf{ }}{\text{1}}{\text{.0 - p)}}{\mathbf{ }}{\text{\{ }}{\mathbf{ }}{\text{z}}{\mathbf{ }}{\text{ = }}{\mathbf{ }}{\text{drand48();}}{\mathbf{ }}{\text{y[i]}}{\mathbf{ }}{\text{ + + ;}}{\mathbf{ }}{\text{\} }} \hfill \\ {\mathbf{ }}{\text{\} }} \hfill \\ {\mathbf{ }}{\text{return}}{\mathbf{ }}{\text{0;}} \hfill \\ {\text{\} }} \hfill \\ {\mathbf{ }}{\text{Fichier}}{\mathbf{ }}{\text{source}}{\mathbf{ }}{\text{:}}{\mathbf{ }}{\text{C/geom}}{\text{.c}} \hfill \\ \end{gathered} $$

On souhaite ajouter dans Scilab une fonction (une primitive) de même nom geom dont la syntaxe d’appel est y=geom(m,n,p). La fonction geom est censée effectuer m*n tirages de loi géométrique et renvoyer le résultat sous la forme d’une matrice Scilab de taille m x n.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2007 Springer-Verlag France

About this chapter

Cite this chapter

(2007). Interfaçage. In: Chancelier, JP., Delebecque, F., Gomez, C., Goursat, M., Nikoukhah, R., Steer, S. (eds) Introduction à Scilab. Collection IRIS. Springer, Paris. https://doi.org/10.1007/978-2-287-31017-1_7

Download citation

  • DOI: https://doi.org/10.1007/978-2-287-31017-1_7

  • Publisher Name: Springer, Paris

  • Print ISBN: 978-2-287-25247-1

  • Online ISBN: 978-2-287-31017-1

Publish with us

Policies and ethics