GitHub - tscode/MathGL.jl

文章推薦指數: 80 %
投票人數:10人

Making MathGL accessible from the julia programming language - GitHub - tscode/MathGL.jl: Making MathGL accessible from the julia programming language. Skiptocontent {{message}} tscode / MathGL.jl Public Notifications Star 1 Fork 1 MakingMathGLaccessiblefromthejuliaprogramminglanguage Viewlicense 1 star 1 fork Star Notifications Code Issues 0 Pullrequests 0 Actions Projects 0 Wiki Security Insights More Code Issues Pullrequests Actions Projects Wiki Security Insights master Branches Tags Couldnotloadbranches Nothingtoshow Loading {{refName}} default Couldnotloadtags Nothingtoshow {{refName}} default Loading 1 branch 0 tags Code Loading Latestcommit   Gitstats 50 commits Files Permalink Failedtoloadlatestcommitinformation. Type Name Latestcommitmessage Committime examples     graphs     src     .gitignore     LICENSE.md     README.md     REQUIRE     changes.md     notes.md     Viewcode Contents MathGL.jl Requirements UsageandExamples TheCInterface TheHigherLevelJulianInterface AbusingtheMatrixSyntax:ImitatingMathGLScriptsinJulia Examples Installing ChangestoMathGL TODO README.md Contents Requirements UsageandExamples TheCInterface TheHigherLevelJulianInterface AbusingTheMatrixSyntax:ImitatingMglScriptsinJulia Examples Installing ChangestoMathGL TODO MathGL.jl Thisrepositoryprobablystillhasmajorissuesandisaworkin progress MathGL.jlprovidesawrapperforthefeature-richscientificvisualization libraryMathGLwritteninC++.Itrelies ontheCinterfaceofMathGL,wrappingitwithjuliatoaconvenient degree. MathGL.jliscurrentlyunderconstruction,stilllacksapartofthe functionsprovidedbyMathGLandisprobablynotportable(onlylinux tested).Mostfunctionsrelatedto(non-gui-)plottingshouldbe implemented,though. ThemainpriorityofMathGL.jlistomakeMathGL'scapacitytocreate graphsavailableinjulia;implementingotherpartsofthelibrary (numericalroutines,classesforstoringnumercialdata,thepdesolvers, andfittingprocedures)haslowerpriority.Tostillaccessthese,the low-levelCapimustbeusedasofnow(seebelow). FormoreinformationaboutMathGL,seeits documentation Requirements Besidesthecodeofthisrepositoryandjulia4+,youwillneedaworking andup-to-dateversionoflibmgl(version2.3)inafolderthatjuliacanfindvia find_library.Foradditionalguifeatures(whicharenotsupportedyet), likeqt,glut,etc.thecorrespondinglibraries(e.g.libmgl-qt5)must alsobeinstalledproperly. UsageandExamples TheCInterface TheCfunctionsprovidedbyMathGLarecallableviatheCapisubmoduleof MathGL.TheCapi-moduleismoreorlesscomplete(somefunctionsmaybe missing,butmostfunctionalityiscertainlyimplemented);however, itisnotcomfortabletouse.DocumentationregardingtheCapi(function namesandtheirdescription)maybefoundinthe MathGLdocumentation. Anexample: usingMathGL.Capi mgl=MathGL.Capi gr=mgl.create_graph(800,500) dat=mgl.create_data() mgl.data_link(dat,0.8*sin(linspace(-4pi,4pi,200)),200,1,1) mgl.label(gr,'x',"x",0,"") mgl.label(gr,'y',"y",0,"") mgl.box(gr) mgl.axis(gr,"xyz","","") mgl.axis_grid(gr,"xyz","H|","") mgl.plot(gr,dat,"","") mgl.write_frame(gr,"sin_C.png","") Notehowever,thattheCinterfaceonlyconductslimitedtypechecks,so expectsegfaultswhenusingthewrongargumenttypes. TheHigherLevelJulianInterface Thetypestructurewas(quiteloosely)modeledaftertheC++class structureofMathGL,themostimportanttypebeingtheGraph.The functionnames(e.g.text,surf,plot,xtics,...)were--whenever possible--chosentobethecorrespondingcommandsoftheMathGLscripting language(seethedocumentationfor thedetails).Thiswasdoneforseveralreasons: Thenamesofthemglcommandsareveryjulian(e.g.fewunderscores, heavilyoverloaded) TheCinterfaceistediousandtheC++interfacedoesnotreally fitwell Anabuseofjulia'smatrixconstructionsyntaxmakesitpossibleto writemglscriptcodedirectlyinjulia(withsomeslight alterations,seebelow). Thereare,however,importantfunctionsthatarenotcoveredbythe scriptinglanguage,whichisdesignedtohandleonegraphonly. Someofthesedeviationsoffunctionnamescanbefoundinthefile changes.md,themostimportantonesaregiven below. Anequivalentexampletotheoneaboveinthejulianinterface: usingMathGL mgl=MathGL gr=mgl.Graph(800,500) mgl.xlabel(gr,"x") mgl.ylabel(gr,"y") mgl.box(gr) mgl.axis(gr) mgl.grid(gr) mgl.plot(gr,0.8*sin(linspace(-4pi,4pi,200))) mgl.write(gr,"sin_julia.png") AbusingtheMatrixSyntax:ImitatingMathGLScriptsinJulia Tomakeitshort,thefollowingcodesampleisperfectlyequivalenttothe oneabove: usingMathGL gr=MathGL.Graph(800,500) @mglplotgr[ xlabel"x" ylabel"y" box axis grid plot0.8*sin(linspace(-4pi,4pi,200)) write"sin_mgl.png" ] Thisisnicebecausethesyntaxgiveninthemacroresemblesthe MGLscriptsyntaxquitewell.Ofcoursetherearedeviations(e.g.always thekeywordstlisused,neverfntorschor...). Examples Examplescanbefoundinthefolderexamples.Rightnowtheonlyrelevant exampleistheonecreatingthepictureatthetopofthisrepository, here. Installing Simplyclonetherepository,and--ifsodesired--addthesrc subdirectorytoyourJULIA_LOAD_PATH.BewarethatatthemomentIdon't knowhowtocheckifa64bitversion(usingdoubles)ora32bit version(usingfloats)ofMathGLisinstalled,sothevalueofthe typealiasFloatinsrc/capi.jlmustbeadoptedmanually. ChangestoMathGL Additionalproperties(likelinecolor,dashed-ness,...)arenormallysetin MGLscriptbykeywordargumentslikepen,stl,fnt,orsch.MathGL.jl alwaysusesstl(forstyle). TheCandC++functionsofMathGLsometimesexpectlistsof strings/labelsbyhandingoveronebigstringoftheform "string1\nstring2\nstring3".InMathGL.jlthesefunctionsexpectarrays ["string1","string2","string3"]. FunctionnamesforwhichnocorrespondigMGLscriptfunctionisnamedin themanualorforwhichthenamesaremissleadingwererenamed: showwithasfunctionwrappingtheMathGLCfunctionmgl_show_image. get_width,get_heightarecalledwidth,heigth. axisisusedinMGLscriptforboth(1)plottingtheaxesofthe coordinatesystemand(2)settingthecoordinatesystem(e.g.logarithmic axes).InMathGL.jlaxisisusedfor(1),butcoordsisusedfor (2)instead,withkeywordargumentsX,Y,Z,C. Addedsubgridfunction(whichisjustgridwith'!'added. TODO Makeallplottingfunctionsaccessiblefromjulia Providesomemoreutilityfunctions Writesomedocumentation/tutorialsfortheusageofMathGL ImplementtheguigraphclassesofMathGL Testing!Notmuchistested,therearecertainlytonsofbugsyet undiscovered(buteasytoresolve) DocumentthechangescomparedtoMathGL Usemoreprecisearraysubtypes About MakingMathGLaccessiblefromthejuliaprogramminglanguage Resources Readme License Viewlicense Releases Noreleasespublished Packages0 Nopackagespublished Languages Julia 100.0% Youcan’tperformthatactionatthistime. Yousignedinwithanothertaborwindow.Reloadtorefreshyoursession. Yousignedoutinanothertaborwindow.Reloadtorefreshyoursession.



請為這篇文章評分?