• Aucun résultat trouvé

Numerical package for Lua – Cours et formation gratuit

N/A
N/A
Protected

Academic year: 2022

Partager "Numerical package for Lua – Cours et formation gratuit"

Copied!
27
0
0

Texte intégral

(1)

Numlua: a n umer ical pac kage for Lua Luis Car v alho

BrownUniversity carvalho@dam.brown.edu LuaWorkshop July,2008

(2)

Introduction NumericLuaLuaWor

•Alotofproblemsinscientificcomputingneedhighperformance numericalroutines

•Generalapproach:heavycomputationsinlowlevelroutines (FORTRANorC)wrappedinascriptingorOOlanguage(highlevel) •Promisingcandidate:Lua! •Performance:fastexecutionandsmallfootprint •Powerful:GC,functionalfacilities,coroutines,metamethods •Extensible:simpleandwelldefinedAPIinANSIC •Easy:semanticallyrichbutsimple •Free:MITlicense

(3)

Introduction NumericLuaLuaWor

•Alotofproblemsinscientificcomputingneedhighperformance numericalroutines •Generalapproach:heavycomputationsinlowlevelroutines (FORTRANorC)wrappedinascriptingorOOlanguage(highlevel)

•Promisingcandidate:Lua! •Performance:fastexecutionandsmallfootprint •Powerful:GC,functionalfacilities,coroutines,metamethods •Extensible:simpleandwelldefinedAPIinANSIC •Easy:semanticallyrichbutsimple •Free:MITlicense

(4)

Introduction NumericLuaLuaWor

•Alotofproblemsinscientificcomputingneedhighperformance numericalroutines •Generalapproach:heavycomputationsinlowlevelroutines (FORTRANorC)wrappedinascriptingorOOlanguage(highlevel) •Promisingcandidate:Lua!

Performance:fastexecutionandsmallfootprint •Powerful:GC,functionalfacilities,coroutines,metamethods •Extensible:simpleandwelldefinedAPIinANSIC •Easy:semanticallyrichbutsimple •Free:MITlicense

(5)

Introduction NumericLuaLuaWor

•Alotofproblemsinscientificcomputingneedhighperformance numericalroutines •Generalapproach:heavycomputationsinlowlevelroutines (FORTRANorC)wrappedinascriptingorOOlanguage(highlevel) •Promisingcandidate:Lua! •Performance:fastexecutionandsmallfootprint

Powerful:GC,functionalfacilities,coroutines,metamethods •Extensible:simpleandwelldefinedAPIinANSIC •Easy:semanticallyrichbutsimple •Free:MITlicense

(6)

Introduction NumericLuaLuaWor

•Alotofproblemsinscientificcomputingneedhighperformance numericalroutines •Generalapproach:heavycomputationsinlowlevelroutines (FORTRANorC)wrappedinascriptingorOOlanguage(highlevel) •Promisingcandidate:Lua! •Performance:fastexecutionandsmallfootprint •Powerful:GC,functionalfacilities,coroutines,metamethods

Extensible:simpleandwelldefinedAPIinANSIC •Easy:semanticallyrichbutsimple •Free:MITlicense

(7)

Introduction NumericLuaLuaWor

•Alotofproblemsinscientificcomputingneedhighperformance numericalroutines •Generalapproach:heavycomputationsinlowlevelroutines (FORTRANorC)wrappedinascriptingorOOlanguage(highlevel) •Promisingcandidate:Lua! •Performance:fastexecutionandsmallfootprint •Powerful:GC,functionalfacilities,coroutines,metamethods •Extensible:simpleandwelldefinedAPIinANSIC

Easy:semanticallyrichbutsimple •Free:MITlicense

(8)

Introduction NumericLuaLuaWor

•Alotofproblemsinscientificcomputingneedhighperformance numericalroutines •Generalapproach:heavycomputationsinlowlevelroutines (FORTRANorC)wrappedinascriptingorOOlanguage(highlevel) •Promisingcandidate:Lua! •Performance:fastexecutionandsmallfootprint •Powerful:GC,functionalfacilities,coroutines,metamethods •Extensible:simpleandwelldefinedAPIinANSIC •Easy:semanticallyrichbutsimple

Free:MITlicense

(9)

Introduction NumericLuaLuaWor

•Alotofproblemsinscientificcomputingneedhighperformance numericalroutines •Generalapproach:heavycomputationsinlowlevelroutines (FORTRANorC)wrappedinascriptingorOOlanguage(highlevel) •Promisingcandidate:Lua! •Performance:fastexecutionandsmallfootprint •Powerful:GC,functionalfacilities,coroutines,metamethods •Extensible:simpleandwelldefinedAPIinANSIC •Easy:semanticallyrichbutsimple •Free:MITlicense

(10)

NumericLua NumericLuaLuaWor

•Basedon“classical”numericalpackages

•Motivation:keepminimalistapproachfromLuainordertoprovidea basisformoreelaboratedscientificpackages •Components •Complexnumbers •Specialfunctions(Exps+CDFs+PDFs) •Randomnumbergeneration(MT+Ranlib) •Numericallinearalgebra(BLAS+LAPACK)

(11)

NumericLua NumericLuaLuaWor

•Basedon“classical”numericalpackages •Motivation:keepminimalistapproachfromLuainordertoprovidea basisformoreelaboratedscientificpackages

•Components •Complexnumbers •Specialfunctions(Exps+CDFs+PDFs) •Randomnumbergeneration(MT+Ranlib) •Numericallinearalgebra(BLAS+LAPACK)

(12)

NumericLua NumericLuaLuaWor

•Basedon“classical”numericalpackages •Motivation:keepminimalistapproachfromLuainordertoprovidea basisformoreelaboratedscientificpackages •Components •Complexnumbers •Specialfunctions(Exps+CDFs+PDFs) •Randomnumbergeneration(MT+Ranlib) •Numericallinearalgebra(BLAS+LAPACK)

(13)

Numlua–Features NumericLuaLuaWor

•SomeOOandfunctionalflavor,butnoparadigmcompromise

•Matrixtypesystem:general,triangular,symmetric,andposdef •Small:interpreter+libs≈1.25Mb(staticlink)or200Kb(dynamiclink) •ImplementedinANSICandthusasportableasLua •StandardinterfacetoBLAS/LAPACK:canbelinkedtomanyoptimized libs •MITlicense

(14)

Numlua–Features NumericLuaLuaWor

•SomeOOandfunctionalflavor,butnoparadigmcompromise •Matrixtypesystem:general,triangular,symmetric,andposdef

•Small:interpreter+libs≈1.25Mb(staticlink)or200Kb(dynamiclink) •ImplementedinANSICandthusasportableasLua •StandardinterfacetoBLAS/LAPACK:canbelinkedtomanyoptimized libs •MITlicense

(15)

Numlua–Features NumericLuaLuaWor

•SomeOOandfunctionalflavor,butnoparadigmcompromise •Matrixtypesystem:general,triangular,symmetric,andposdef •Small:interpreter+libs≈1.25Mb(staticlink)or200Kb(dynamiclink)

•ImplementedinANSICandthusasportableasLua •StandardinterfacetoBLAS/LAPACK:canbelinkedtomanyoptimized libs •MITlicense

(16)

Numlua–Features NumericLuaLuaWor

•SomeOOandfunctionalflavor,butnoparadigmcompromise •Matrixtypesystem:general,triangular,symmetric,andposdef •Small:interpreter+libs≈1.25Mb(staticlink)or200Kb(dynamiclink) •ImplementedinANSICandthusasportableasLua

•StandardinterfacetoBLAS/LAPACK:canbelinkedtomanyoptimized libs •MITlicense

(17)

Numlua–Features NumericLuaLuaWorkshop’08

•SomeOOandfunctionalflavor,butnoparadigmcompromise •Matrixtypesystem:general,triangular,symmetric,andposdef •Small:interpreter+libs≈1.25Mb(staticlink)or200Kb(dynamiclink) •ImplementedinANSICandthusasportableasLua •StandardinterfacetoBLAS/LAPACK:canbelinkedtomanyoptimized libs

•MITlicense

(18)

Numlua–Features NumericLuaLuaWorkshop’08

•SomeOOandfunctionalflavor,butnoparadigmcompromise •Matrixtypesystem:general,triangular,symmetric,andposdef •Small:interpreter+libs≈1.25Mb(staticlink)or200Kb(dynamiclink) •ImplementedinANSICandthusasportableasLua •StandardinterfacetoBLAS/LAPACK:canbelinkedtomanyoptimized libs •MITlicense

(19)

Numlua–Examples NumericLuaLuaWor

functioncirc1(v) localn=table.getn(v) localm=matrix.zeros(n) fori=1,ndo forj=1,ndo m[i][j]=v[(j-i)%n+1] end end returnm end

functioncirc2(v) localn=table.getn(v) returnmatrix.zeros(n):apply( function(i,j)returnv[(j-i)%n+1]end) end

(20)

Numlua–Examples NumericLuaLuaWor

functioncirc1(v) localn=table.getn(v) localm=matrix.zeros(n) fori=1,ndo forj=1,ndo m[i][j]=v[(j-i)%n+1] end end returnm end functioncirc2(v) localn=table.getn(v) returnmatrix.zeros(n):apply( function(i,j)returnv[(j-i)%n+1]end) end

(21)

Numlua–Examples NumericLuaLuaWor

localr=rng(os.clock()) functionmvnorm(mean,var,n) localu,info=matrix.chol(var)--u’ *u=var assert(info==0,"matrixisnotpositivedefinite") --y:col(i)N(0_m,I_m) localm=mean:size() localy=matrix(m,n):map( function(e)returnr:norm(0,1)end) --u’*y+meanN(mean,var) y=#u*y fori,j,einy:entries()do y[i][j]=e+mean[i] end returny end

(22)

Futurework NumericLuaLuaWor

•Documentation!

•MovetoLuarocks •Newinternalrepresentationformatrices •Usetokenfilterstomakematrixdeclarationeasier(lesspainfull) •Extensions:HDF5,sparsematrices,statlibrary,plottinglibrary,...

(23)

Futurework NumericLuaLuaWor

•Documentation! •MovetoLuarocks

•Newinternalrepresentationformatrices •Usetokenfilterstomakematrixdeclarationeasier(lesspainfull) •Extensions:HDF5,sparsematrices,statlibrary,plottinglibrary,...

(24)

Futurework NumericLuaLuaWor

•Documentation! •MovetoLuarocks •Newinternalrepresentationformatrices

•Usetokenfilterstomakematrixdeclarationeasier(lesspainfull) •Extensions:HDF5,sparsematrices,statlibrary,plottinglibrary,...

(25)

Futurework NumericLuaLuaWor

•Documentation! •MovetoLuarocks •Newinternalrepresentationformatrices •Usetokenfilterstomakematrixdeclarationeasier(lesspainfull)

•Extensions:HDF5,sparsematrices,statlibrary,plottinglibrary,...

(26)

Futurework NumericLuaLuaWor

•Documentation! •MovetoLuarocks •Newinternalrepresentationformatrices •Usetokenfilterstomakematrixdeclarationeasier(lesspainfull) •Extensions:HDF5,sparsematrices,statlibrary,plottinglibrary,...

(27)

Thankyou! NumericLuaLuaWor

Lua Nu

er m

ic

Références

Documents relatifs

- Les candidats doivent respecter les notations de l'énoncé et préciser, dans chaque cas, la numérotation de la question. - On accordera la plus grande attention à la clarté de

Identification : Afin d’identifier les param`etres du mod`ele de l’actionneur, diff´erents tests ont ´et´e effectu´es (voir

Complète les phrases ci-dessous en utilisant ta règle graduée ou ton compas :. • Le cercle (C 1 ) de centre J passant par G passe également par les

2- Décrire avec précision le protocole expérimental à suivre pour préparer la solution (S f )... Essayons maintenant avec la fiole de 500ml, de la même façon, on trouve V

The formula [T.. the last formula becomes.. 358) 1 and the rest were evaluated in terms of ordinary generalized hypergeometric function whose asymptotic expansion has

✘Ouvrez le fichier MOTO.WAV dans Audacity. Un micro posé au bord de la route a enregistré le passage d’une moto. 1) En réalisant le spectre du son enregistré lors de

il faut par contre préciser qu'en régime stationnaire, la température de la résistance restant constante, celle-ci elle transmet au liquide sous forme de chaleur autant

La méthode de Mohr utilise comme indicateur le précipité Ag 2 CrO 4 (rouge), on ajoute donc quelques gouttes de solution de K 2 CrO 4 , mais on pourrait