├── modules ├── Windows │ ├── .gitignore │ └── library │ │ ├── .gitignore │ │ └── src │ │ ├── registry.h │ │ ├── string-util.c │ │ └── util.h ├── System │ ├── Numerics │ │ ├── .gitignore │ │ ├── library │ │ │ ├── src │ │ │ │ ├── stdafx.c │ │ │ │ ├── zeta-impl.c │ │ │ │ ├── util.h │ │ │ │ ├── stdafx.h │ │ │ │ ├── ortho-poly-impl.c │ │ │ │ ├── agm-impl.c │ │ │ │ ├── acb-impl-onearg.inc │ │ │ │ └── acb-impl-twoarg.inc │ │ │ └── .gitignore │ │ ├── simplify-hypgeom.pmath │ │ ├── simplify-ortho-poly.pmath │ │ └── simplify-airy.pmath │ ├── InputOutput │ │ ├── .gitignore │ │ ├── library │ │ │ ├── src │ │ │ │ ├── stdafx.c │ │ │ │ └── stdafx.h │ │ │ └── .gitignore │ │ └── init.pmath │ └── QuantityUnits │ │ ├── powers.pmath │ │ ├── sums.pmath │ │ └── products.pmath ├── Java │ ├── .gitignore │ ├── library │ │ ├── .gitignore │ │ ├── src │ │ │ ├── pj-load-pmath.h │ │ │ ├── pmath_Core.h │ │ │ ├── pmath_ParserArguments.h │ │ │ ├── pj-threads.h │ │ │ ├── pj-objects.h │ │ │ ├── pj-values.h │ │ │ └── pjvm.h │ │ └── run-java-32.bat │ ├── classpath │ │ ├── javassist.jar │ │ └── pmath │ │ │ ├── package-info.java │ │ │ └── util │ │ │ ├── package-info.java │ │ │ ├── InternalException.java │ │ │ ├── NoExitSecurityManager.java │ │ │ └── WrappedException.java │ ├── build-java.sh │ ├── example │ │ ├── Gui │ │ │ └── using-awt.pmath │ │ └── Interrupt │ │ │ └── Test1.java │ └── start-jshell.bat ├── Developer.pmath ├── Eigen │ └── src │ │ └── classification.h └── hello │ └── main.c ├── richmath ├── documents │ └── empty.pmathdoc ├── info │ ├── Design.txt │ ├── format3.txt │ ├── format2.txt │ └── format.txt ├── resources │ ├── pin16.bmp │ ├── pin24.bmp │ ├── pin32.bmp │ ├── touch.cur │ ├── touch.png │ ├── app-icon.ico │ ├── grabbing.cur │ ├── grabbing.pdn │ ├── pen_tip.cur │ ├── pen_tip.png │ ├── file-icon.ico │ ├── grab_hand.cur │ ├── grab_hand.pdn │ ├── no_select.cur │ ├── no_select.png │ ├── document_beam.cur │ ├── document_beam.png │ ├── grabbing_win7.cur │ ├── grabbing_win7.pdn │ ├── section_beam.cur │ ├── section_beam.png │ ├── text_beam_e.cur │ ├── text_beam_e.png │ ├── text_beam_n.cur │ ├── text_beam_n.png │ ├── text_beam_ne.cur │ ├── text_beam_ne.png │ ├── text_beam_nw.cur │ ├── text_beam_nw.png │ ├── text_beam_s.cur │ ├── text_beam_s.png │ ├── text_beam_se.cur │ ├── text_beam_se.png │ ├── text_beam_sw.cur │ ├── text_beam_sw.png │ ├── text_beam_w.cur │ ├── text_beam_w.png │ ├── grab_hand_win7.cur │ ├── grab_hand_win7.pdn │ ├── grabbing_win7.cur.bak │ ├── images │ │ ├── frame - fog.png │ │ ├── screenshot.png │ │ ├── frame - moon.png │ │ ├── File-Icon │ │ │ ├── icon.ico │ │ │ ├── icon16.pdn │ │ │ ├── icon24.pdn │ │ │ ├── icon32.pdn │ │ │ ├── icon48.pdn │ │ │ ├── icon-all.pdn │ │ │ └── icon256.pdn │ │ ├── Paper-Icon │ │ │ ├── icon.ico │ │ │ ├── temp.png │ │ │ ├── icon16.pdn │ │ │ ├── icon32.pdn │ │ │ ├── icon48.pdn │ │ │ ├── icon64.pdn │ │ │ ├── icon-all.pdn │ │ │ └── projection.pdn │ │ ├── Romanesco │ │ │ ├── frame.png │ │ │ ├── frame (original).jpg │ │ │ └── sources.txt │ │ ├── frame - hearts.png │ │ ├── frame - van gogh.png │ │ ├── Window-Icon │ │ │ ├── icon16.pdn │ │ │ ├── icon24.pdn │ │ │ ├── icon32.pdn │ │ │ ├── icon48.pdn │ │ │ ├── app-icon.ico │ │ │ ├── icon-all.pdn │ │ │ └── icon256.pdn │ │ └── frame - romanesco.png │ ├── resources.h │ └── richmath.rc ├── src │ ├── graphics │ │ ├── glyphs.cpp │ │ ├── basic-sequence-iterator.cpp │ │ └── syntax-styles.cpp │ ├── gui │ │ ├── win32 │ │ │ ├── ole │ │ │ │ └── combase.cpp │ │ │ └── api │ │ │ │ └── win32-version.cpp │ │ ├── color-dialog.cpp │ │ ├── font-dialog.cpp │ │ └── recent-documents.cpp │ └── eval │ │ └── interpolation.cpp ├── dependencies │ └── default │ │ ├── Asana-Math.ttf │ │ ├── pMathFallback.ttf │ │ ├── GFSNeohellenicMath.ttf │ │ └── maininit.pmath ├── include │ ├── eval │ │ ├── cubic-bezier-easing-function.h │ │ ├── interpolation.h │ │ ├── simple-evaluator.h │ │ ├── binding.h │ │ ├── partial-dynamic.h │ │ ├── server.h │ │ ├── eval-contexts.h │ │ └── current-value.h │ ├── util │ │ ├── autobool.h │ │ ├── selection-tracking.h │ │ ├── autovaluereset.h │ │ ├── text-gathering.h │ │ ├── filesystem.h │ │ ├── double-point.h │ │ └── alignment.h │ ├── gui │ │ ├── edit-helper.h │ │ ├── messagebox.h │ │ ├── gtk │ │ │ ├── mgtk-colordialog.h │ │ │ ├── mgtk-fontdialog.h │ │ │ ├── mgtk-cursors.h │ │ │ ├── mgtk-recent-documents.h │ │ │ ├── mgtk-messagebox.h │ │ │ ├── mgtk-dragdrophandler.h │ │ │ ├── mgtk-filedialog.h │ │ │ ├── mgtk-css.h │ │ │ └── mgtk-icons.h │ │ ├── win32 │ │ │ ├── win32-colordialog.h │ │ │ ├── win32-fontdialog.h │ │ │ ├── win32-messagebox.h │ │ │ ├── win32-recent-documents.h │ │ │ ├── menus │ │ │ │ ├── win32-menu-gutter-slider.h │ │ │ │ └── win32-custom-menu-overlay.h │ │ │ ├── win32-filedialog.h │ │ │ ├── api │ │ │ │ ├── stylusutil.h │ │ │ │ └── win32-hd-trackpad.h │ │ │ └── win32-dragdrophandler.h │ │ ├── font-dialog.h │ │ ├── color-dialog.h │ │ ├── dragdrophandler.h │ │ ├── recent-documents.h │ │ ├── control-glow.h │ │ ├── event-handlers.h │ │ ├── common-tooltips.h │ │ └── documents.h │ ├── boxes │ │ ├── box-factory.h │ │ ├── sectionornament.h │ │ ├── tooltipbox.h │ │ ├── graphics │ │ │ ├── pointbox.h │ │ │ ├── linebox.h │ │ │ └── circleordiskbox.h │ │ ├── interpretationbox.h │ │ ├── framebox.h │ │ └── panebox.h │ ├── syntax │ │ ├── scope-colorizer.h │ │ └── autocompletion.h │ └── graphics │ │ └── callout-triangle.h ├── scripts │ ├── auto │ │ └── frontend │ │ │ ├── dialogs.pmath │ │ │ ├── menu-message-formatter.pmath │ │ │ ├── showdefinition.pmath │ │ │ └── import.pmath │ └── resources │ │ ├── StyleSheets │ │ ├── Palette.pmathdoc │ │ └── Default.pmathdoc │ │ └── Palettes │ │ └── Memory Usage.pmathdoc ├── post-build-windows.ps1 └── post-build-linux.sh ├── util └── .gitignore ├── library ├── console-win │ └── .gitignore ├── scripts │ ├── AutoDiff │ │ └── init.pmath │ ├── maininit.5.txt │ ├── AutoCompletion │ │ └── init.pmath │ └── auto │ │ ├── core │ │ ├── ConditionalExpression.pmath │ │ ├── format │ │ │ ├── highlighted.pmath │ │ │ ├── accents.pmath │ │ │ ├── griditems.pmath │ │ │ ├── brackets.pmath │ │ │ ├── syntax.pmath │ │ │ └── rawboxes.pmath │ │ ├── gui │ │ │ ├── OpenerView.pmath │ │ │ └── nofront.pmath │ │ ├── nothing.pmath │ │ ├── surd.pmath │ │ ├── thisthat.pmath │ │ ├── Developer │ │ │ └── OpenTextFile.pmath │ │ ├── streams.pmath │ │ ├── text │ │ │ ├── maketextboxes.pmath │ │ │ ├── init.pmath │ │ │ └── maketextexpression.pmath │ │ └── echo.pmath │ │ └── hyper-console │ │ └── init.pmath ├── test-suite │ ├── tests │ │ ├── comparisons.pmath │ │ ├── PowerMod.pmath │ │ ├── Union.pmath │ │ ├── parsing-reals.pmath │ │ ├── Chop.pmath │ │ ├── integer-roots.pmath │ │ ├── SetPrecision.pmath │ │ ├── serialization.pmath │ │ ├── ToCharacterCode.pmath │ │ ├── number-idenity.pmath │ │ └── FromCharacterCode.pmath │ ├── data │ │ └── blob.dat │ ├── test-all-release-builds.bat │ └── Run Test Suite (MSVC x64 Release).bat ├── doxygen │ └── images │ │ └── map-tasks.png ├── run.sh ├── profile-run.sh ├── test │ ├── post-build-linux.sh │ └── Makefile ├── console │ ├── post-build-linux.sh │ └── src │ │ └── console.h ├── include │ ├── pmath-util │ │ ├── strtod.h │ │ ├── hash │ │ │ ├── incremental-hash-private.h │ │ │ └── sha1.h │ │ ├── concurrency │ │ │ └── threadlocks-private.h │ │ ├── garbage-collection-private.h │ │ ├── user-format-private.h │ │ ├── files │ │ │ ├── filesystem.h │ │ │ ├── mixed-buffer.h │ │ │ └── text-from-binary.h │ │ ├── modules-private.h │ │ ├── stacks-private.h │ │ ├── version.h │ │ ├── security-private.h │ │ └── version-private.h │ ├── pmath-private.h │ ├── pmath-builtins │ │ ├── datetime-private.h │ │ ├── manipulate-private.h │ │ ├── parallel-private.h │ │ ├── control │ │ │ ├── messages-private.h │ │ │ └── flow-private.h │ │ ├── language-private.h │ │ └── io-private.h │ └── pmath-core │ │ └── custom-private.h ├── src │ ├── pmath-builtins │ │ ├── control │ │ │ ├── flow │ │ │ │ ├── internal-abortmessage.c │ │ │ │ ├── tryevaluatesecured.c │ │ │ │ └── finally.c │ │ │ ├── hash.c │ │ │ ├── definitions │ │ │ │ └── update.c │ │ │ ├── memoryusage.c │ │ │ ├── match.c │ │ │ └── loadlibrary.c │ │ ├── parallel │ │ │ ├── threadidle.c │ │ │ └── getthreadid.c │ │ ├── language │ │ │ ├── frompackedarray.c │ │ │ ├── getrefcount.c │ │ │ └── symbolname.c │ │ ├── lists │ │ │ ├── append.c │ │ │ ├── total.c │ │ │ ├── nest.c │ │ │ ├── mean.c │ │ │ ├── flatten.c │ │ │ ├── nestlist.c │ │ │ └── leafcount.c │ │ ├── formating │ │ │ └── baseform.c │ │ ├── logic │ │ │ ├── xor.c │ │ │ └── boole.c │ │ ├── datetime │ │ │ └── timing.c │ │ ├── number-theory │ │ │ ├── bitnot.c │ │ │ ├── bitget.c │ │ │ └── jacobisymbol-and-kroneckersymbol.c │ │ ├── io │ │ │ └── characters.c │ │ ├── gui │ │ │ └── button.c │ │ └── arithmetic │ │ │ ├── fractionalpart.c │ │ │ └── minus-and-subtract.c │ └── pmath-core │ │ └── packed-arrays-errdef-pack_from_to.inc ├── build-all.bat └── post-build-linux.sh ├── .vscode ├── .gitignore ├── settings.json └── astylerc ├── debugging ├── gdb │ ├── pmath_gdb │ │ └── __init__.py │ └── readme.txt └── windbg │ ├── print-escape-char.wds │ ├── inspect.wds │ ├── inspect-object-bits.wds │ └── init.wds ├── .gitattributes ├── .tgitconfig ├── pmath.workspace ├── editors └── pmath-vscode │ ├── language-configuration.json │ └── package.json └── .gitignore /modules/Windows/.gitignore: -------------------------------------------------------------------------------- 1 | /bin -------------------------------------------------------------------------------- /richmath/documents/empty.pmathdoc: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /util/.gitignore: -------------------------------------------------------------------------------- 1 | /dependency-cache -------------------------------------------------------------------------------- /modules/System/Numerics/.gitignore: -------------------------------------------------------------------------------- 1 | /bin -------------------------------------------------------------------------------- /library/console-win/.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /obj -------------------------------------------------------------------------------- /modules/System/InputOutput/.gitignore: -------------------------------------------------------------------------------- 1 | /bin -------------------------------------------------------------------------------- /modules/Java/.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | /bin 3 | /doc -------------------------------------------------------------------------------- /modules/Windows/library/.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /obj -------------------------------------------------------------------------------- /modules/Java/library/.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | /bin 3 | /obj -------------------------------------------------------------------------------- /modules/System/Numerics/library/src/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /.vscode/.gitignore: -------------------------------------------------------------------------------- 1 | .BROWSE.VC.DB 2 | /c_cpp_properties.json 3 | /ipch 4 | -------------------------------------------------------------------------------- /modules/System/InputOutput/library/src/stdafx.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | -------------------------------------------------------------------------------- /modules/System/InputOutput/library/.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /obj 3 | /src/stdafx.h.gch/* -------------------------------------------------------------------------------- /modules/System/Numerics/library/.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /obj 3 | /src/stdafx.h.gch/* -------------------------------------------------------------------------------- /library/scripts/AutoDiff/init.pmath: -------------------------------------------------------------------------------- 1 | Get(ToFileName(DirectoryName($Input), "autodiff.pmath")) 2 | -------------------------------------------------------------------------------- /library/test-suite/tests/comparisons.pmath: -------------------------------------------------------------------------------- 1 | 2 | AssertFalse(1 = 0) 3 | 4 | AssertTrue(1 != 0) 5 | -------------------------------------------------------------------------------- /library/scripts/maininit.5.txt: -------------------------------------------------------------------------------- 1 | Get(ToFileName({DirectoryName($Input, 5), "scripts"}, "maininit.pmath")) 2 | -------------------------------------------------------------------------------- /richmath/info/Design.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/info/Design.txt -------------------------------------------------------------------------------- /library/scripts/AutoCompletion/init.pmath: -------------------------------------------------------------------------------- 1 | Get(ToFileName(DirectoryName($Input), "autocompletion.pmath")) 2 | -------------------------------------------------------------------------------- /richmath/resources/pin16.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/pin16.bmp -------------------------------------------------------------------------------- /richmath/resources/pin24.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/pin24.bmp -------------------------------------------------------------------------------- /richmath/resources/pin32.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/pin32.bmp -------------------------------------------------------------------------------- /richmath/resources/touch.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/touch.cur -------------------------------------------------------------------------------- /richmath/resources/touch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/touch.png -------------------------------------------------------------------------------- /richmath/src/graphics/glyphs.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | using namespace richmath; 5 | 6 | -------------------------------------------------------------------------------- /richmath/resources/app-icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/app-icon.ico -------------------------------------------------------------------------------- /richmath/resources/grabbing.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/grabbing.cur -------------------------------------------------------------------------------- /richmath/resources/grabbing.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/grabbing.pdn -------------------------------------------------------------------------------- /richmath/resources/pen_tip.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/pen_tip.cur -------------------------------------------------------------------------------- /richmath/resources/pen_tip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/pen_tip.png -------------------------------------------------------------------------------- /library/test-suite/data/blob.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/library/test-suite/data/blob.dat -------------------------------------------------------------------------------- /richmath/resources/file-icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/file-icon.ico -------------------------------------------------------------------------------- /richmath/resources/grab_hand.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/grab_hand.cur -------------------------------------------------------------------------------- /richmath/resources/grab_hand.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/grab_hand.pdn -------------------------------------------------------------------------------- /richmath/resources/no_select.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/no_select.cur -------------------------------------------------------------------------------- /richmath/resources/no_select.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/no_select.png -------------------------------------------------------------------------------- /library/doxygen/images/map-tasks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/library/doxygen/images/map-tasks.png -------------------------------------------------------------------------------- /modules/Java/classpath/javassist.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/modules/Java/classpath/javassist.jar -------------------------------------------------------------------------------- /richmath/resources/document_beam.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/document_beam.cur -------------------------------------------------------------------------------- /richmath/resources/document_beam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/document_beam.png -------------------------------------------------------------------------------- /richmath/resources/grabbing_win7.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/grabbing_win7.cur -------------------------------------------------------------------------------- /richmath/resources/grabbing_win7.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/grabbing_win7.pdn -------------------------------------------------------------------------------- /richmath/resources/section_beam.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/section_beam.cur -------------------------------------------------------------------------------- /richmath/resources/section_beam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/section_beam.png -------------------------------------------------------------------------------- /richmath/resources/text_beam_e.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/text_beam_e.cur -------------------------------------------------------------------------------- /richmath/resources/text_beam_e.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/text_beam_e.png -------------------------------------------------------------------------------- /richmath/resources/text_beam_n.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/text_beam_n.cur -------------------------------------------------------------------------------- /richmath/resources/text_beam_n.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/text_beam_n.png -------------------------------------------------------------------------------- /richmath/resources/text_beam_ne.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/text_beam_ne.cur -------------------------------------------------------------------------------- /richmath/resources/text_beam_ne.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/text_beam_ne.png -------------------------------------------------------------------------------- /richmath/resources/text_beam_nw.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/text_beam_nw.cur -------------------------------------------------------------------------------- /richmath/resources/text_beam_nw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/text_beam_nw.png -------------------------------------------------------------------------------- /richmath/resources/text_beam_s.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/text_beam_s.cur -------------------------------------------------------------------------------- /richmath/resources/text_beam_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/text_beam_s.png -------------------------------------------------------------------------------- /richmath/resources/text_beam_se.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/text_beam_se.cur -------------------------------------------------------------------------------- /richmath/resources/text_beam_se.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/text_beam_se.png -------------------------------------------------------------------------------- /richmath/resources/text_beam_sw.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/text_beam_sw.cur -------------------------------------------------------------------------------- /richmath/resources/text_beam_sw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/text_beam_sw.png -------------------------------------------------------------------------------- /richmath/resources/text_beam_w.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/text_beam_w.cur -------------------------------------------------------------------------------- /richmath/resources/text_beam_w.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/text_beam_w.png -------------------------------------------------------------------------------- /richmath/resources/grab_hand_win7.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/grab_hand_win7.cur -------------------------------------------------------------------------------- /richmath/resources/grab_hand_win7.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/grab_hand_win7.pdn -------------------------------------------------------------------------------- /modules/Java/classpath/pmath/package-info.java: -------------------------------------------------------------------------------- 1 | /** Main classes to bridge between Java and the pMath runtime. 2 | */ 3 | package pmath; -------------------------------------------------------------------------------- /richmath/resources/grabbing_win7.cur.bak: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/grabbing_win7.cur.bak -------------------------------------------------------------------------------- /richmath/resources/images/frame - fog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/frame - fog.png -------------------------------------------------------------------------------- /richmath/resources/images/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/screenshot.png -------------------------------------------------------------------------------- /richmath/resources/images/frame - moon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/frame - moon.png -------------------------------------------------------------------------------- /debugging/gdb/pmath_gdb/__init__.py: -------------------------------------------------------------------------------- 1 | import pmath_gdb.expr 2 | import pmath_gdb.printers 3 | import pmath_gdb.util 4 | import pmath_gdb.commands 5 | -------------------------------------------------------------------------------- /modules/Java/classpath/pmath/util/package-info.java: -------------------------------------------------------------------------------- 1 | /** Utility classes to bridge between Java and the pMath runtime. 2 | */ 3 | package pmath.util; -------------------------------------------------------------------------------- /richmath/dependencies/default/Asana-Math.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/dependencies/default/Asana-Math.ttf -------------------------------------------------------------------------------- /richmath/resources/images/File-Icon/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/File-Icon/icon.ico -------------------------------------------------------------------------------- /richmath/resources/images/File-Icon/icon16.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/File-Icon/icon16.pdn -------------------------------------------------------------------------------- /richmath/resources/images/File-Icon/icon24.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/File-Icon/icon24.pdn -------------------------------------------------------------------------------- /richmath/resources/images/File-Icon/icon32.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/File-Icon/icon32.pdn -------------------------------------------------------------------------------- /richmath/resources/images/File-Icon/icon48.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/File-Icon/icon48.pdn -------------------------------------------------------------------------------- /richmath/resources/images/Paper-Icon/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/Paper-Icon/icon.ico -------------------------------------------------------------------------------- /richmath/resources/images/Paper-Icon/temp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/Paper-Icon/temp.png -------------------------------------------------------------------------------- /richmath/resources/images/Romanesco/frame.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/Romanesco/frame.png -------------------------------------------------------------------------------- /richmath/resources/images/frame - hearts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/frame - hearts.png -------------------------------------------------------------------------------- /richmath/resources/images/frame - van gogh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/frame - van gogh.png -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.sh binary 2 | 3 | *.nb linguist-documentation 4 | *.pmathdoc linguist-documentation 5 | *.inc linguist-language=C 6 | -------------------------------------------------------------------------------- /richmath/dependencies/default/pMathFallback.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/dependencies/default/pMathFallback.ttf -------------------------------------------------------------------------------- /richmath/resources/images/File-Icon/icon-all.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/File-Icon/icon-all.pdn -------------------------------------------------------------------------------- /richmath/resources/images/File-Icon/icon256.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/File-Icon/icon256.pdn -------------------------------------------------------------------------------- /richmath/resources/images/Paper-Icon/icon16.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/Paper-Icon/icon16.pdn -------------------------------------------------------------------------------- /richmath/resources/images/Paper-Icon/icon32.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/Paper-Icon/icon32.pdn -------------------------------------------------------------------------------- /richmath/resources/images/Paper-Icon/icon48.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/Paper-Icon/icon48.pdn -------------------------------------------------------------------------------- /richmath/resources/images/Paper-Icon/icon64.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/Paper-Icon/icon64.pdn -------------------------------------------------------------------------------- /richmath/resources/images/Window-Icon/icon16.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/Window-Icon/icon16.pdn -------------------------------------------------------------------------------- /richmath/resources/images/Window-Icon/icon24.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/Window-Icon/icon24.pdn -------------------------------------------------------------------------------- /richmath/resources/images/Window-Icon/icon32.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/Window-Icon/icon32.pdn -------------------------------------------------------------------------------- /richmath/resources/images/Window-Icon/icon48.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/Window-Icon/icon48.pdn -------------------------------------------------------------------------------- /richmath/resources/images/frame - romanesco.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/frame - romanesco.png -------------------------------------------------------------------------------- /richmath/resources/images/Paper-Icon/icon-all.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/Paper-Icon/icon-all.pdn -------------------------------------------------------------------------------- /richmath/resources/images/Paper-Icon/projection.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/Paper-Icon/projection.pdn -------------------------------------------------------------------------------- /richmath/resources/images/Window-Icon/app-icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/Window-Icon/app-icon.ico -------------------------------------------------------------------------------- /richmath/resources/images/Window-Icon/icon-all.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/Window-Icon/icon-all.pdn -------------------------------------------------------------------------------- /richmath/resources/images/Window-Icon/icon256.pdn: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/Window-Icon/icon256.pdn -------------------------------------------------------------------------------- /richmath/dependencies/default/GFSNeohellenicMath.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/dependencies/default/GFSNeohellenicMath.ttf -------------------------------------------------------------------------------- /richmath/include/eval/cubic-bezier-easing-function.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/include/eval/cubic-bezier-easing-function.h -------------------------------------------------------------------------------- /richmath/resources/images/Romanesco/frame (original).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/peter-frentrup/pMath/HEAD/richmath/resources/images/Romanesco/frame (original).jpg -------------------------------------------------------------------------------- /.tgitconfig: -------------------------------------------------------------------------------- 1 | [bugtraq] 2 | url = https://bitbucket.org/pfrentrup/pmath/issues/%BUGID% 3 | [bugtraq] 4 | logregex = "[Ii]ssues?(\\s*(,\\s*)?(and\\s+)?#\\d+)+\n(\\d)+" 5 | -------------------------------------------------------------------------------- /library/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$(pwd)/$(dirname $1)" 4 | export PMATH_BASEDIRECTORY="$(pwd)/$(dirname $1)" 5 | 6 | $(pwd)/$@ 7 | -------------------------------------------------------------------------------- /modules/Developer.pmath: -------------------------------------------------------------------------------- 1 | /* Add Developer` to the $NamespacePath 2 | */ 3 | 4 | If(IsFreeOf($NamespacePath, "Developer`"), 5 | $NamespacePath:= Prepend($NamespacePath, "Developer`")); 6 | -------------------------------------------------------------------------------- /library/test-suite/tests/PowerMod.pmath: -------------------------------------------------------------------------------- 1 | 2 | AssertEqual(PowerMod(2, 10, 3), 1) 3 | 4 | AssertEqual(PowerMod(2, 10^9, 18), 16) 5 | 6 | AssertEqual(PowerMod(2, {10,11,12,13,14}, 5), {4, 3, 1, 2, 4}) 7 | -------------------------------------------------------------------------------- /library/profile-run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$(pwd)/$(dirname $1)" 4 | export PMATH_BASEDIRECTORY="$(pwd)/$(dirname $1)" 5 | 6 | valgrind --tool=callgrind ./$@ 7 | -------------------------------------------------------------------------------- /modules/Java/classpath/pmath/util/InternalException.java: -------------------------------------------------------------------------------- 1 | package pmath.util; 2 | 3 | public class InternalException extends RuntimeException { 4 | public InternalException(){ 5 | super(); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /library/test-suite/test-all-release-builds.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | for /D %%I in (%~dp0..\console-win\bin\windows\*release*) do ( 4 | echo "%%~fI ..." 5 | "%%I\console-win.exe" -q -l run-all.pmath 6 | ) 7 | 8 | pause 9 | -------------------------------------------------------------------------------- /richmath/dependencies/default/maininit.pmath: -------------------------------------------------------------------------------- 1 | Get(ToFileName({DirectoryName($Input, 5), "library", "scripts"}, "maininit.pmath")) 2 | Get(ToFileName({DirectoryName($Input, 4), "scripts"}, "frontinit-stage1.pmath")) 3 | 4 | -------------------------------------------------------------------------------- /library/scripts/auto/core/ConditionalExpression.pmath: -------------------------------------------------------------------------------- 1 | Begin("System`ConditionalExpression`") 2 | 3 | MakeBoxes(ConditionalExpression(~a, ~b))::= TemplateBox({MakeBoxes(a), MakeBoxes(b)}, "ConditionalExpression") 4 | 5 | End() 6 | -------------------------------------------------------------------------------- /library/test-suite/tests/Union.pmath: -------------------------------------------------------------------------------- 1 | 2 | AssertEqual(Union({a,b}, {c,d,a}), {a,b,c,d}) 3 | AssertEqual(Union({}, {1,3,2,3}), {1,2,3}) 4 | AssertEqual(Union({}), {}) 5 | 6 | AssertEqual(Union(Array(5), Array(5)-3), Array(-2..5)) 7 | -------------------------------------------------------------------------------- /richmath/src/graphics/basic-sequence-iterator.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | using namespace richmath; 5 | 6 | //{ class BasicSequenceIterator ... 7 | 8 | //} ... class BasicSequenceIterator 9 | -------------------------------------------------------------------------------- /richmath/resources/images/Romanesco/sources.txt: -------------------------------------------------------------------------------- 1 | frame (original).jpg: 2 | by: Darya Pino ("SummerTomato") 3 | license: CC BY 2.0 4 | date: 2012-09-07 5 | url: http://www.flickr.com/photos/summertomato/3540719643/ 6 | -------------------------------------------------------------------------------- /library/test-suite/tests/parsing-reals.pmath: -------------------------------------------------------------------------------- 1 | 2 | AssertEqual( 16^^3e.ad961ed0cb92`.InputForm.ToString.ToExpression, 16^^3e.ad961ed0cb92` ) 3 | 4 | AssertEqual( 16^^21.3822cbd80c4e`.InputForm.ToString.ToExpression, 16^^21.3822cbd80c4e` ) 5 | -------------------------------------------------------------------------------- /richmath/info/format3.txt: -------------------------------------------------------------------------------- 1 | _____ 2 | 1 + \/ "x" = RowBox({"1+", SqrtBox(RowBox({"x"}))}) ~> 1 + sqrt("x") 3 | _____ 4 | "1+\/ "x" " = RowBox({"\"1+", SqrtBox(RowBox({"\"x\""})), "\""}) ~> "1+\(SqrtBox(RowBox({\"\\\"x\\\"\"}))\)" -------------------------------------------------------------------------------- /library/test/post-build-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | 4 | pushd $1 5 | 6 | # add $ORIGIN to the rpath. Due to the $ sign, this cannot be done through any more Code::Blocks IDE with "-Wl,-rpath,\\$$ORIGIN" 7 | chrpath -r '$ORIGIN' ./test 8 | 9 | popd 10 | 11 | -------------------------------------------------------------------------------- /debugging/windbg/print-escape-char.wds: -------------------------------------------------------------------------------- 1 | $$ ${pmath-print-escape-char} character 2 | 3 | .if($scmp("${$arg1}", "\"") == 0) { 4 | .printf "\\\"" 5 | } 6 | .elsif($scmp("${$arg1}", "\\") == 0) { 7 | .printf "\\\\" 8 | } 9 | .else { 10 | .printf "%c", ${$arg1} 11 | } 12 | -------------------------------------------------------------------------------- /library/console/post-build-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | 4 | pushd $1 5 | 6 | # add $ORIGIN to the rpath. Due to the $ sign, this cannot be done through any more Code::Blocks IDE with "-Wl,-rpath,\\$$ORIGIN" 7 | chrpath -r '$ORIGIN' ./pmathc 8 | 9 | popd 10 | 11 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Platzieren Sie Ihre Einstellungen in dieser Datei, um Standard- und Benutzereinstellungen zu überschreiben. 2 | { 3 | "C_Cpp.formatting": "Disabled", 4 | "astyle.astylerc": "${workspaceRoot}/.vscode/astylerc", 5 | "sourcetrail.startServerAtStartup": true 6 | } -------------------------------------------------------------------------------- /library/scripts/auto/core/format/highlighted.pmath: -------------------------------------------------------------------------------- 1 | Begin("System`Private`") 2 | 3 | %FrameBox(MakeBoxes(expr), BaseStyle->"Highlighted", StripOnInput->True) 4 | MakeBoxes(Highlighted(~expr, opts: OptionsPattern()))::= TemplateBox({MakeBoxes(expr), opts}, "Highlighted") 5 | 6 | End() 7 | -------------------------------------------------------------------------------- /modules/Java/build-java.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | javac -source 6 -target 6 classpath/pmath/*.java 4 | javac -source 6 -target 6 classpath/pmath/util/*.java 5 | 6 | javac -source 6 -target 6 -cp classpath example/App/*.java 7 | javac -source 6 -target 6 -cp classpath example/Interrupt/*.java 8 | -------------------------------------------------------------------------------- /library/scripts/auto/core/gui/OpenerView.pmath: -------------------------------------------------------------------------------- 1 | Begin("System`Private`") 2 | 3 | MakeBoxes(OpenerView({~a, ~b}, open: True | False | ~:Dynamic | ~:PureArgument))::= 4 | TemplateBox({MakeBoxes(a), MakeBoxes(b), open}, "OpenerView") 5 | 6 | OpenerView(~states)::= OpenerView(states, False) 7 | 8 | End() 9 | -------------------------------------------------------------------------------- /library/scripts/auto/core/nothing.pmath: -------------------------------------------------------------------------------- 1 | 2 | BeginPackage("System`") 3 | 4 | Nothing 5 | 6 | Begin("System`Private`") 7 | 8 | 9 | Nothing(~~~)::= Nothing 10 | Nothing/: list:{~~~,Nothing,~~~}::= Replace(Unevaluated(list), Nothing -> Sequence(), 1) 11 | 12 | 13 | End() 14 | 15 | EndPackage() 16 | -------------------------------------------------------------------------------- /library/include/pmath-util/strtod.h: -------------------------------------------------------------------------------- 1 | #ifndef __PMATH_UTIL__STRTOD_H__ 2 | #define __PMATH_UTIL__STRTOD_H__ 3 | 4 | #include 5 | 6 | /**\brief locale-neutral strtod 7 | */ 8 | PMATH_API double pmath_strtod(const char *str, const char **end); 9 | 10 | #endif // __PMATH_UTIL__STRTOD_H__ 11 | -------------------------------------------------------------------------------- /library/include/pmath-private.h: -------------------------------------------------------------------------------- 1 | #ifndef __PMATH_PRIVATE_H__ 2 | #define __PMATH_PRIVATE_H__ 3 | 4 | #ifndef BUILDING_PMATH 5 | #error This header file is not part of the public pMath API 6 | #endif 7 | 8 | PMATH_PRIVATE 9 | pmath_bool_t _pmath_is_running(void); 10 | 11 | #endif /* __PMATH_PRIVATE_H__ */ 12 | -------------------------------------------------------------------------------- /library/scripts/auto/core/gui/nofront.pmath: -------------------------------------------------------------------------------- 1 | Begin("System`Private`") 2 | 3 | DocumentOpen(~~~)::= (Message(DocumentOpen::nofront); $Failed) 4 | SelectedDocument(~~~)::= (Message(SelectedDocument::nofront); $Failed) 5 | SetSelectedDocument(~~~)::= (Message(SetSelectedDocument::nofront);$Failed) 6 | 7 | End() 8 | -------------------------------------------------------------------------------- /modules/System/InputOutput/init.pmath: -------------------------------------------------------------------------------- 1 | 2 | BeginPackage("System`InputOutput`") 3 | 4 | % Print("Load pmath-inout.dll") 5 | LoadLibrary(ToFileName( 6 | {DirectoryName($Input), "bin", $SystemID, $ProcessorType}, 7 | If($SystemID === "Windows", 8 | "pmath-inout.dll", 9 | "pmath-inout.so"))) 10 | 11 | EndPackage() 12 | -------------------------------------------------------------------------------- /modules/Java/library/src/pj-load-pmath.h: -------------------------------------------------------------------------------- 1 | #ifndef __PJ_LOAD_PMATH_H__ 2 | #define __PJ_LOAD_PMATH_H__ 3 | 4 | 5 | #include 6 | #include 7 | 8 | PMATH_PRIVATE void pj_companion_run_init(void); 9 | 10 | PMATH_PRIVATE pmath_bool_t pj_load_pmath(JNIEnv *env); 11 | 12 | 13 | #endif // __PJ_LOAD_PMATH_H__ 14 | -------------------------------------------------------------------------------- /library/test-suite/tests/Chop.pmath: -------------------------------------------------------------------------------- 1 | 2 | AssertEqual(Chop(10.0^-9), 10.0^-9) 3 | 4 | AssertEqual(Chop(10.0^-11), 0) 5 | 6 | AssertEqual(Chop(10^-11), 10^-11) 7 | 8 | AssertEqual(Chop({-1.0, 0.0, 0.000001, -1.0*^-17}), {-1.0, 0, 0.000001, 0}) 9 | 10 | AssertEqual(Chop({-2, -2.0, 4, 4.0, -7, -7.0}, 3), {-2, 0, 4, 4.0, -7, -7.0}) 11 | -------------------------------------------------------------------------------- /richmath/include/util/autobool.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__UTIL__AUTOBOOL_H__INCLUDED 2 | #define RICHMATH__UTIL__AUTOBOOL_H__INCLUDED 3 | 4 | namespace richmath { 5 | enum AutoBoolValues { 6 | AutoBoolFalse = 0, 7 | AutoBoolTrue = 1, 8 | AutoBoolAutomatic = 2 9 | }; 10 | } 11 | 12 | #endif // RICHMATH__UTIL__AUTOBOOL_H__INCLUDED 13 | -------------------------------------------------------------------------------- /library/test-suite/Run Test Suite (MSVC x64 Release).bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem %~dp0..\test\bin\windows\msvc-release-x64\test.exe -q -l run-all.pmath 4 | rem %~dp0..\console-win\bin\windows\msvc-release-x64\console-win.exe --quit --load run-all.pmath 5 | %~dp0..\console-win\bin\windows\msvc-release-x64\console-win.exe --load run-all.pmath 6 | 7 | pause 8 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/control/flow/internal-abortmessage.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | 6 | pmath_t builtin_internal_abortmessage(pmath_expr_t expr) { 7 | _pmath_abort_message(pmath_expr_get_item(expr, 1)); 8 | 9 | pmath_unref(expr); 10 | return PMATH_NULL; 11 | } 12 | -------------------------------------------------------------------------------- /debugging/windbg/inspect.wds: -------------------------------------------------------------------------------- 1 | $$ Inspect a pmath object, given its pmath_t 2 | 3 | .if (${/d:$arg1} == 0) { 4 | .printf /oe "ERROR: pmath_t value expected\n" 5 | } 6 | .else { 7 | r? $t1 = @@c++(${$arg1}.as_bits) 8 | 9 | aS ${/v:pmath-var-last-inspect-head} ${$arg1} ${$arg1} 10 | $$ .printf "\n${$arg1} =" 11 | ${pmath-inspect-object-bits} @$t1 ${$arg1} 12 | } -------------------------------------------------------------------------------- /library/scripts/auto/core/surd.pmath: -------------------------------------------------------------------------------- 1 | % CubeRoot, Surd functions 2 | 3 | BeginPackage("System`") 4 | 5 | <True) 10 | MakeBoxes(Surd(~x, ~n))::= RadicalBox(MakeBoxes(x), MakeBoxes(n), SurdForm->True) 11 | 12 | End() 13 | 14 | EndPackage() 15 | -------------------------------------------------------------------------------- /library/scripts/auto/core/thisthat.pmath: -------------------------------------------------------------------------------- 1 | 2 | BeginPackage("System`") 3 | 4 | AbsArg 5 | ReIm 6 | TakeDrop 7 | 8 | Begin("System`Private`") 9 | 10 | AbsArg(~z)::= {Abs(z), Arg(z)} 11 | ReIm(~z)::= {Re(z), Im(z)} 12 | TakeDrop(~list, ~~ns)::= With({t:= Take(list, ns), d:= Drop(list, ns)}, {t,d} /? Head(t) =!= Take && Head(d) =!= Drop) 13 | 14 | End() 15 | 16 | EndPackage() -------------------------------------------------------------------------------- /library/console/src/console.h: -------------------------------------------------------------------------------- 1 | #ifndef __CONSOLE_H__ 2 | #define __CONSOLE_H__ 3 | 4 | #include 5 | 6 | extern pmath_threadlock_t read_lock; 7 | 8 | pmath_string_t readline_pmath( 9 | const char *prompt, 10 | pmath_bool_t with_completion, 11 | pmath_string_t previous_input); 12 | 13 | void cleanup_input_cache(void); 14 | 15 | 16 | #endif // __CONSOLE_H__ 17 | -------------------------------------------------------------------------------- /richmath/scripts/auto/frontend/dialogs.pmath: -------------------------------------------------------------------------------- 1 | Begin("FE`Private`") 2 | 3 | 4 | FE`FontDialog(~~~opts)::= FE`CallFrontEnd(FrontEnd`FontDialog(opts)) 5 | 6 | FE`ColorDialog()::= FE`CallFrontEnd(FrontEnd`ColorDialog()) 7 | FE`ColorDialog(~c)::= FE`CallFrontEnd(FrontEnd`ColorDialog(c)) 8 | FE`ColorDialog(~~~args)::= 1 /? (IsValidArgumentCount(FE`ColorDialog, Length@{args}, 1, 1);False) 9 | 10 | 11 | End() -------------------------------------------------------------------------------- /.vscode/astylerc: -------------------------------------------------------------------------------- 1 | # indentation options ... 2 | --indent=spaces=2 3 | --indent-cases 4 | --indent-classes 5 | --indent-labels 6 | --indent-namespaces 7 | --indent-switches 8 | --min-conditional-indent=2 9 | --max-instatement-indent=40 10 | 11 | # formatting options ... 12 | --keep-one-line-blocks 13 | --keep-one-line-statements 14 | --convert-tabs 15 | 16 | # padding options ... 17 | --pad-oper 18 | --fill-empty-lines -------------------------------------------------------------------------------- /richmath/src/gui/win32/ole/combase.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace richmath; 4 | 5 | IUnknown *richmath::get_canonical_iunknown(IUnknown *punk) { 6 | IUnknown *punkCanonical; 7 | if(punk && SUCCEEDED(punk->QueryInterface(IID_IUnknown, (void**)&punkCanonical))) 8 | punkCanonical->Release(); 9 | else 10 | punkCanonical = punk; 11 | 12 | return punkCanonical; 13 | } 14 | -------------------------------------------------------------------------------- /richmath/include/gui/edit-helper.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__EDIT_HELPER_H__INCLUDED 2 | #define RICHMATH__GUI__EDIT_HELPER_H__INCLUDED 3 | 4 | namespace richmath { 5 | class EditHelper { 6 | public: 7 | static bool insert_new_table_into_current_document(); 8 | static bool insert_new_table_into_current_document(int num_rows, int num_cols); 9 | }; 10 | } 11 | 12 | #endif // RICHMATH__GUI__EDIT_HELPER_H__INCLUDED 13 | -------------------------------------------------------------------------------- /library/include/pmath-builtins/datetime-private.h: -------------------------------------------------------------------------------- 1 | #ifndef __PMATH_BUILTINS__DATETIME_PRIVATE_H__ 2 | #define __PMATH_BUILTINS__DATETIME_PRIVATE_H__ 3 | 4 | #ifndef BUILDING_PMATH 5 | # error This header file is not part of the public pMath API 6 | #endif 7 | 8 | /* This header exports definitions of the sources in 9 | src/pmath-builtins/datetime/ 10 | */ 11 | 12 | 13 | 14 | #endif // __PMATH_BUILTINS__DATETIME_PRIVATE_H__ 15 | -------------------------------------------------------------------------------- /library/include/pmath-builtins/manipulate-private.h: -------------------------------------------------------------------------------- 1 | #ifndef __PMATH_BUILTINS__MANIPULATE_PRIVATE_H__ 2 | #define __PMATH_BUILTINS__MANIPULATE_PRIVATE_H__ 3 | 4 | #ifndef BUILDING_PMATH 5 | #error This header file is not part of the public pMath API 6 | #endif 7 | 8 | /* This header exports all definitions of the sources in 9 | src/pmath-builtins/manipulate/ 10 | */ 11 | 12 | #endif /* __PMATH_BUILTINS__MANIPULATE_PRIVATE_H__ */ 13 | -------------------------------------------------------------------------------- /debugging/windbg/inspect-object-bits.wds: -------------------------------------------------------------------------------- 1 | $$ Inspect a pmath object, given its pmath_t::as_bits 2 | 3 | .if (${/d:$arg1} == 0) { 4 | .printf /oe "ERROR: uint64_t value expected\n" 5 | } 6 | .else { 7 | .if(${/d:$arg2}) { 8 | .printf "\n${$arg2} =\n" 9 | } 10 | .else { 11 | .printf "\n" 12 | } 13 | 14 | ${pmath-print-object-link} ${$arg1} ${/f:$arg2} 15 | .printf " =\n " 16 | 17 | ${pmath-print-expr} ${$arg1} ${/f:$arg2} 18 | .printf "\n\n" 19 | } -------------------------------------------------------------------------------- /library/test/Makefile: -------------------------------------------------------------------------------- 1 | PROGRAM = bin/linux/test 2 | OBJPATH = obj/linux 3 | LIBS = -lpmath -lrt 4 | CFLAGS = -s -O3 -I ../library/include 5 | CC = gcc 6 | RM = rm -fr 7 | 8 | all: $(PROGRAM) 9 | 10 | $(PROGRAM): $(OBJPATH)/main.o 11 | $(CC) $(LIBS) $(OBJPATH)/main.o -o $(PROGRAM) 12 | 13 | $(OBJPATH)/main.o: main.c 14 | $(CC) $(CFLAGS) -c -o $(OBJPATH)/main.o main.c 15 | 16 | clean: 17 | $(RM) $(OBJPATH)/*.o $(PROGRAM) 18 | 19 | run: $(PROGRAM) 20 | ./$(PROGRAM) -------------------------------------------------------------------------------- /modules/System/QuantityUnits/powers.pmath: -------------------------------------------------------------------------------- 1 | BeginPackage("System`QuantityUnits`") 2 | 3 | Begin("System`QuantityUnits`Private`") 4 | 5 | 6 | QuantityPower(~~~):= $Failed 7 | Function QuantityPower(HoldPattern(Quantity(~mag, ~unit)), y: (~:Integer | ~:Rational | ~:Real)) { 8 | With(newUnit:= unit^y |> ReplaceRepeated({(~a^~b)^~c :> a^(b c), (~a * ~b)^~c :> a^c * b^c})) 9 | 10 | newValidQuanitity(mag^y, newUnit) 11 | } 12 | 13 | 14 | End() 15 | 16 | EndPackage() 17 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/parallel/threadidle.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | 7 | PMATH_PRIVATE pmath_t builtin_internal_threadidle(pmath_expr_t expr) { 8 | if(pmath_expr_length(expr) != 0) { 9 | pmath_message_argxxx(pmath_expr_length(expr), 0, 0); 10 | return expr; 11 | } 12 | 13 | pmath_unref(expr); 14 | pmath_thread_sleep(); 15 | return PMATH_NULL; 16 | } 17 | -------------------------------------------------------------------------------- /richmath/scripts/auto/frontend/menu-message-formatter.pmath: -------------------------------------------------------------------------------- 1 | Begin("FE`") 2 | 3 | Begin("FE`Private`") 4 | 5 | Function FE`MenuMessageFormatter(~heldname,~msg){ 6 | With(stack:= Stack()) 7 | 8 | ColonForm(Row({ 9 | RawBoxes(TemplateBox({ 10 | MessageName -> heldname, 11 | Message -> msg, 12 | Stack -> stack[..-2]}, 13 | "MessageMenuButton")), 14 | heldname}), 15 | msg) 16 | } 17 | 18 | End() 19 | 20 | End() 21 | -------------------------------------------------------------------------------- /richmath/include/eval/interpolation.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__EVAL__INTERPOLATION_H__INCLUDED 2 | #define RICHMATH__EVAL__INTERPOLATION_H__INCLUDED 3 | 4 | #include 5 | 6 | namespace richmath { 7 | class Interpolation { 8 | public: 9 | static float interpolation_index(const Array &values, float val, bool clip); 10 | //static float interpolation_value(const Array &values, float index); 11 | }; 12 | } 13 | 14 | #endif // RICHMATH__EVAL__INTERPOLATION_H__INCLUDED 15 | -------------------------------------------------------------------------------- /library/include/pmath-core/custom-private.h: -------------------------------------------------------------------------------- 1 | #ifndef __PMATH_CORE__CUSTOM_PRIVATE_H__ 2 | #define __PMATH_CORE__CUSTOM_PRIVATE_H__ 3 | 4 | #ifndef BUILDING_PMATH 5 | # error This header file is not part of the public pMath API 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | 12 | PMATH_PRIVATE pmath_bool_t _pmath_custom_objects_init(void); 13 | PMATH_PRIVATE void _pmath_custom_objects_done(void); 14 | 15 | #endif /* __PMATH_CORE__CUSTOM_PRIVATE_H__ */ 16 | -------------------------------------------------------------------------------- /library/include/pmath-util/hash/incremental-hash-private.h: -------------------------------------------------------------------------------- 1 | #ifndef PMATH_UTIL__HASH__INCREMENTAL_HASH_PRIVATE_H__INCLUDED 2 | #define PMATH_UTIL__HASH__INCREMENTAL_HASH_PRIVATE_H__INCLUDED 3 | 4 | #ifndef BUILDING_PMATH 5 | # error This header file is not part of the public pMath API 6 | #endif 7 | 8 | #include 9 | 10 | #include 11 | 12 | 13 | PMATH_PRIVATE 14 | unsigned int _pmath_incremental_hash( 15 | const void *data, 16 | size_t len, 17 | unsigned int hash); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /modules/Java/classpath/pmath/util/NoExitSecurityManager.java: -------------------------------------------------------------------------------- 1 | package pmath.util; 2 | 3 | import java.security.Permission; 4 | 5 | /** A security manager that gives every permission but disallows exit. 6 | */ 7 | public class NoExitSecurityManager extends SecurityManager { 8 | @Override 9 | public void checkExit(int status) { 10 | throw new SecurityException("exit not allowed"); 11 | } 12 | 13 | @Override 14 | public void checkPermission(Permission perm) { 15 | /* allow everything else */ 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /richmath/include/gui/messagebox.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__MESSAGEBOX_H__INCLUDED 2 | #define RICHMATH__GUI__MESSAGEBOX_H__INCLUDED 3 | 4 | #include 5 | 6 | namespace richmath { 7 | enum class YesNoCancel { 8 | No, 9 | Yes, 10 | Cancel 11 | }; 12 | 13 | YesNoCancel ask_save(Document *doc); 14 | YesNoCancel ask_remove_private_style_definitions(Document *doc); 15 | bool ask_open_suspicious_system_file(String path); 16 | Expr ask_interrupt(Expr stack); 17 | } 18 | 19 | #endif // RICHMATH__GUI__MESSAGEBOX_H__INCLUDED 20 | -------------------------------------------------------------------------------- /library/test-suite/tests/integer-roots.pmath: -------------------------------------------------------------------------------- 1 | 2 | AssertEqual( 27^(1/3) , 3 ) 3 | 4 | AssertEqual( 4^(1/6) , 2^(1/3) ) 5 | 6 | AssertEqual( (4 * 27)^(1/6) , 2^(1/3) Sqrt(3) ) 7 | 8 | AssertEqual( (4 * 27)^(7/6) , 108 * 2^(1/3) Sqrt(3) ) 9 | 10 | AssertEqual( (5*5*3)^(1/3) , 3^(1/3) * 5^(2/3) ) 11 | AssertHead( (5*5*3)^(1/3), Times ) % simplifies to 3^(1/3) * 5^(2/3) 12 | 13 | AssertEqual( (5*3)^(1/3) , 3^(1/3) * 5^(1/3) ) 14 | AssertHead( (5*3)^(1/3), Power ) % remains 15^(1/3) 15 | AssertHead( 5^(1/3) * 3^(1/3), Power ) % simplifies to 15^(1/3) 16 | -------------------------------------------------------------------------------- /richmath/include/gui/gtk/mgtk-colordialog.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__GTK__MGTK_COLORDIALOG_H__INCLUDED 2 | #define RICHMATH__GUI__GTK__MGTK_COLORDIALOG_H__INCLUDED 3 | 4 | #ifndef RICHMATH_USE_GTK_GUI 5 | # error this header is gtk specific 6 | #endif 7 | 8 | #include 9 | 10 | 11 | namespace richmath { 12 | class MathGtkColorDialog { 13 | public: 14 | MathGtkColorDialog() = delete; 15 | 16 | static pmath::Expr show(Color initialcolor); 17 | }; 18 | } 19 | 20 | 21 | #endif // RICHMATH__GUI__GTK__MGTK_COLORDIALOG_H__INCLUDED 22 | -------------------------------------------------------------------------------- /richmath/include/eval/simple-evaluator.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__SIMPLE_EVALUATOR_H__INCLUDED 2 | #define RICHMATH__SIMPLE_EVALUATOR_H__INCLUDED 3 | 4 | #include 5 | 6 | namespace richmath { 7 | class FrontEndObject; 8 | class SimpleEvaluator { 9 | class Impl; 10 | public: 11 | static bool try_eval(FrontEndObject *scope, Expr *result, Expr call); 12 | 13 | static Expr expand_compressed_data(Expr expr); 14 | 15 | static void done(); 16 | }; 17 | } 18 | 19 | #endif // RICHMATH__SIMPLE_EVALUATOR_H__INCLUDED 20 | -------------------------------------------------------------------------------- /richmath/include/gui/win32/win32-colordialog.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__WIN32__WIN32_COLORDIALOG_H__INCLUDED 2 | #define RICHMATH__GUI__WIN32__WIN32_COLORDIALOG_H__INCLUDED 3 | 4 | #ifndef RICHMATH_USE_WIN32_GUI 5 | # error this header is win32 specific 6 | #endif 7 | 8 | #include 9 | 10 | 11 | namespace richmath { 12 | class Win32ColorDialog { 13 | public: 14 | Win32ColorDialog() = delete; 15 | 16 | static Expr show(Color initialcolor); 17 | }; 18 | } 19 | 20 | 21 | #endif // RICHMATH__GUI__WIN32__WIN32_COLORDIALOG_H__INCLUDED 22 | -------------------------------------------------------------------------------- /richmath/src/graphics/syntax-styles.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | 6 | using namespace richmath; 7 | 8 | 9 | //{ class GeneralSyntaxInfo ... 10 | 11 | SharedPtr GeneralSyntaxInfo::std; 12 | 13 | GeneralSyntaxInfo::GeneralSyntaxInfo() 14 | : Shareable() 15 | { 16 | SET_BASE_DEBUG_TAG(typeid(*this).name()); 17 | 18 | for(auto &c : glyph_style_colors) 19 | c = Color::None; 20 | } 21 | 22 | GeneralSyntaxInfo::~GeneralSyntaxInfo() { 23 | } 24 | 25 | //} ... class GeneralSyntaxInfo 26 | -------------------------------------------------------------------------------- /library/test-suite/tests/SetPrecision.pmath: -------------------------------------------------------------------------------- 1 | 2 | x:= 1.5`10 3 | x20:= 1.5`20 4 | xMachine:= 1.5 5 | xRational:= 3/2 6 | 7 | % comparing ToString(FullForm(...)) in order to also consider precision, which === ignores. 8 | AssertEqual(x.SetPrecision(MachinePrecision).FullForm.ToString, xMachine.FullForm.ToString) 9 | 10 | AssertUnequal(x.SetPrecision(20).FullForm.ToString, xMachine.FullForm.ToString) 11 | 12 | AssertEqual(x.SetPrecision(20).FullForm.ToString, x20.FullForm.ToString) 13 | 14 | AssertEqual(x.SetPrecision(Infinity).FullForm.ToString, xRational.FullForm.ToString) 15 | -------------------------------------------------------------------------------- /library/include/pmath-builtins/parallel-private.h: -------------------------------------------------------------------------------- 1 | #ifndef __PMATH_BUILTINS__PARALLEL_PRIVATE_H__ 2 | #define __PMATH_BUILTINS__PARALLEL_PRIVATE_H__ 3 | 4 | #ifndef BUILDING_PMATH 5 | #error This header file is not part of the public pMath API 6 | #endif 7 | 8 | #include 9 | 10 | /* This header exports all definitions of the sources in 11 | src/pmath-builtins/parallel/ 12 | */ 13 | 14 | // for pmath_custom_t where data is pmath_task_t: 15 | PMATH_PRIVATE void _pmath_custom_task_destroy(void *data); 16 | 17 | #endif // __PMATH_BUILTINS__PARALLEL_PRIVATE_H__ 18 | -------------------------------------------------------------------------------- /modules/Java/library/src/pmath_Core.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class pmath_Core */ 4 | 5 | #ifndef _Included_pmath_Core 6 | #define _Included_pmath_Core 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: pmath_Core 12 | * Method: execute 13 | * Signature: (Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/Object; 14 | */ 15 | JNIEXPORT jobject JNICALL Java_pmath_Core_execute 16 | (JNIEnv *, jclass, jstring, jobjectArray); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /richmath/include/gui/win32/win32-fontdialog.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__WIN32__WIN32_FONTDIALOG_H__INCLUDED 2 | #define RICHMATH__GUI__WIN32__WIN32_FONTDIALOG_H__INCLUDED 3 | 4 | #ifndef RICHMATH_USE_WIN32_GUI 5 | # error this header is win32 specific 6 | #endif 7 | 8 | #include 9 | 10 | 11 | namespace richmath { 12 | class Win32FontDialog { 13 | public: 14 | Win32FontDialog() = delete; 15 | 16 | static pmath::Expr show(Style initial_style = nullptr); 17 | }; 18 | } 19 | 20 | 21 | #endif // RICHMATH__GUI__WIN32__WIN32_FONTDIALOG_H__INCLUDED 22 | -------------------------------------------------------------------------------- /richmath/include/util/selection-tracking.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__UTIL__SELECTION_TRACKING_H__INCLUDED 2 | #define RICHMATH__UTIL__SELECTION_TRACKING_H__INCLUDED 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace richmath { 9 | class Section; 10 | 11 | bool toggle_edit_section( 12 | Section *section, 13 | ArrayView old_locations, 14 | Hashtable &found_locations); 15 | } 16 | 17 | #endif // RICHMATH__UTIL__SELECTION_TRACKING_H__INCLUDED 18 | -------------------------------------------------------------------------------- /richmath/post-build-windows.ps1: -------------------------------------------------------------------------------- 1 | 2 | [CmdletBinding()] 3 | param( 4 | [string] 5 | $TargetExe, 6 | 7 | [string] 8 | $DllSearchPath 9 | ) 10 | 11 | If( -not (Test-Path $TargetExe -PathType Leaf)) { 12 | throw "Executable $TargetExe not found." 13 | } 14 | 15 | $scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition 16 | 17 | $targetDirectory = (Get-Item -Path $TargetExe).Directory.FullName 18 | 19 | Copy-Item -Path "$scriptDir\dependencies\default\*" -Destination $targetDirectory -Force 20 | 21 | . "$scriptDir\..\util\collect-dlls.ps1" $TargetExe $DllSearchPath 22 | -------------------------------------------------------------------------------- /modules/Java/library/src/pmath_ParserArguments.h: -------------------------------------------------------------------------------- 1 | /* DO NOT EDIT THIS FILE - it is machine generated */ 2 | #include 3 | /* Header for class pmath_ParserArguments */ 4 | 5 | #ifndef _Included_pmath_ParserArguments 6 | #define _Included_pmath_ParserArguments 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | /* 11 | * Class: pmath_ParserArguments 12 | * Method: execute 13 | * Signature: ()Ljava/lang/Object; 14 | */ 15 | JNIEXPORT jobject JNICALL Java_pmath_ParserArguments_execute 16 | (JNIEnv *, jobject); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | #endif 22 | -------------------------------------------------------------------------------- /richmath/include/gui/gtk/mgtk-fontdialog.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__GTK__MGTK_FONTDIALOG_H__INCLUDED 2 | #define RICHMATH__GUI__GTK__MGTK_FONTDIALOG_H__INCLUDED 3 | 4 | #ifndef RICHMATH_USE_GTK_GUI 5 | # error this header is gtk specific 6 | #endif 7 | 8 | #include 9 | 10 | 11 | namespace richmath { 12 | class MathGtkFontDialog { 13 | public: 14 | MathGtkFontDialog() = delete; 15 | 16 | static pmath::Expr show(Style initial_style = nullptr); 17 | }; 18 | } 19 | 20 | 21 | #endif // RICHMATH__GUI__GTK__MGTK_FONTDIALOG_H__INCLUDED 22 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/control/hash.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | PMATH_PRIVATE pmath_t builtin_hash(pmath_expr_t expr){ 7 | pmath_t obj; 8 | unsigned int hash; 9 | 10 | if(pmath_expr_length(expr) != 1){ 11 | pmath_message_argxxx(pmath_expr_length(expr), 1, 1); 12 | return expr; 13 | } 14 | 15 | obj = pmath_expr_get_item(expr, 1); 16 | pmath_unref(expr); 17 | 18 | hash = pmath_hash(obj); 19 | pmath_unref(obj); 20 | 21 | return pmath_integer_new_ui32(hash); 22 | } 23 | -------------------------------------------------------------------------------- /pmath.workspace: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /library/build-all.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION 4 | 5 | set "searchPath=%ProgramFiles%" 6 | 7 | if defined ProgramFiles(x86) ( 8 | set "searchPath=%searchPath%;%ProgramFiles(x86)%" 9 | ) 10 | 11 | for %%X in (CodeBlocks\codeblocks.exe) do set codeblocks.exe="%%~$searchPath:X" 12 | 13 | if not defined codeblocks.exe ( 14 | echo "CodeBlocks not found" 15 | pause 16 | goto end 17 | ) 18 | 19 | pushd %~dp0 20 | 21 | %codeblocks.exe% /na /nd /ns --debug-log --no-batch-window-close --target=All-Windows --build pmath.cbp 22 | 23 | popd 24 | 25 | :end 26 | endlocal 27 | -------------------------------------------------------------------------------- /library/include/pmath-util/concurrency/threadlocks-private.h: -------------------------------------------------------------------------------- 1 | #ifndef __PMATH_UTIL__CONCURRENCY__THREADLOCKS_PRIVATE_H__ 2 | #define __PMATH_UTIL__CONCURRENCY__THREADLOCKS_PRIVATE_H__ 3 | 4 | #ifndef BUILDING_PMATH 5 | #error This header file is not part of the public pMath API 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | PMATH_PRIVATE void _pmath_threadlocks_memory_panic(void); 12 | 13 | PMATH_PRIVATE pmath_bool_t _pmath_threadlocks_init(void); 14 | PMATH_PRIVATE void _pmath_threadlocks_done(void); 15 | 16 | #endif /* __PMATH_UTIL__CONCURRENCY__THREADLOCKS_PRIVATE_H__ */ 17 | -------------------------------------------------------------------------------- /richmath/src/gui/color-dialog.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include 6 | 7 | 8 | using namespace richmath; 9 | 10 | 11 | Expr richmath_eval_FrontEnd_ColorDialog(Expr expr) { 12 | return ColorDialog::run(PMATH_CPP_MOVE(expr)); 13 | } 14 | 15 | //{ class ColorDialog ... 16 | 17 | Expr ColorDialog::run(Expr expr) { 18 | Color initcolor = Color::None; 19 | 20 | if(expr.expr_length() >= 1) 21 | initcolor = Color::from_pmath(expr[1]); 22 | 23 | AutoGuiWait timer; 24 | return show(initcolor); 25 | } 26 | 27 | //} ... class ColorDialog 28 | -------------------------------------------------------------------------------- /richmath/include/gui/gtk/mgtk-cursors.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__GTK__MGTK_CURSORS_H__INCLUDED 2 | #define RICHMATH__GUI__GTK__MGTK_CURSORS_H__INCLUDED 3 | 4 | #ifndef RICHMATH_USE_GTK_GUI 5 | # error this header is gtk specific 6 | #endif 7 | 8 | #include 9 | 10 | #include 11 | 12 | 13 | namespace richmath { 14 | class MathGtkCursors: public Base { 15 | public: 16 | MathGtkCursors(); 17 | ~MathGtkCursors(); 18 | 19 | GdkCursor *get_gdk_cursor(CursorType type); // caller must gdk_cursor_unref it 20 | }; 21 | } 22 | 23 | #endif // RICHMATH__GUI__GTK__MGTK_CURSORS_H__INCLUDED 24 | -------------------------------------------------------------------------------- /library/test-suite/tests/serialization.pmath: -------------------------------------------------------------------------------- 1 | 2 | AssertEqual(Uncompress @ Compress(-1337), -1337) 3 | 4 | AssertEqual(Uncompress @ Compress(-2^100+5), -2^100+5) 5 | 6 | AssertEqual(Uncompress @ Compress({1,2,3}), {1,2,3}) 7 | 8 | AssertEqual(Uncompress @ Compress("Hello\[Pi]"), "Hello\[Pi]") 9 | 10 | AssertEqual(Uncompress @ Compress(1.5), 1.5) 11 | 12 | % use ToString(FullForm(...)) to also compare working precision 13 | AssertEqual(Uncompress @ Compress(1.5`10) // FullForm // ToString, 1.5`10 // FullForm // ToString) 14 | 15 | AssertEqual(Uncompress @ Compress(1.5[+/-0.5]`10) // FullForm // ToString, 1.5[+/-0.5]`10 // FullForm // ToString) 16 | -------------------------------------------------------------------------------- /richmath/include/gui/gtk/mgtk-recent-documents.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__GTK__MGTK_RECENT_DOCUMENTS_H__INCLUDED 2 | #define RICHMATH__GUI__GTK__MGTK_RECENT_DOCUMENTS_H__INCLUDED 3 | 4 | 5 | #ifndef RICHMATH_USE_GTK_GUI 6 | # error this header is gtk specific 7 | #endif 8 | 9 | #include 10 | 11 | namespace richmath { 12 | struct MathGtkRecentDocuments { 13 | static void add(String path); 14 | static Expr as_menu_list(); 15 | static bool remove(String path); 16 | static void init(); 17 | static void done(); 18 | }; 19 | } 20 | 21 | 22 | #endif // RICHMATH__GUI__GTK__MGTK_RECENT_DOCUMENTS_H__INCLUDED 23 | -------------------------------------------------------------------------------- /richmath/include/gui/win32/win32-messagebox.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__WIN32__WIN32_MESSAGEBOX_H__INCLUDED 2 | #define RICHMATH__GUI__WIN32__WIN32_MESSAGEBOX_H__INCLUDED 3 | 4 | #ifndef RICHMATH_USE_WIN32_GUI 5 | # error this header is win32 specific 6 | #endif 7 | 8 | #include 9 | 10 | 11 | namespace richmath { 12 | YesNoCancel win32_ask_save(Document *doc, String question); 13 | YesNoCancel win32_ask_remove_private_style_definitions(Document *doc); 14 | bool win32_ask_open_suspicious_system_file(String path); 15 | Expr win32_ask_interrupt(Expr stack); 16 | } 17 | 18 | #endif // RICHMATH__GUI__WIN32__WIN32_MESSAGEBOX_H__INCLUDED 19 | -------------------------------------------------------------------------------- /richmath/include/gui/font-dialog.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__FONT_DIALOG_H__INCLUDED 2 | #define RICHMATH__GUI__FONT_DIALOG_H__INCLUDED 3 | 4 | 5 | #ifdef RICHMATH_USE_GTK_GUI 6 | # include 7 | #endif 8 | 9 | #ifdef RICHMATH_USE_WIN32_GUI 10 | # include 11 | #endif 12 | 13 | 14 | namespace richmath { 15 | struct FontDialog : 16 | #if RICHMATH_USE_GTK_GUI 17 | private MathGtkFontDialog 18 | #elif RICHMATH_USE_WIN32_GUI 19 | private Win32FontDialog 20 | #endif 21 | { 22 | static Expr run(Expr style_expr); 23 | }; 24 | } 25 | 26 | #endif // RICHMATH__GUI__FONT_DIALOG_H__INCLUDED 27 | -------------------------------------------------------------------------------- /library/include/pmath-util/garbage-collection-private.h: -------------------------------------------------------------------------------- 1 | #ifndef PMATH_UTIL__GARBAGE_COLLECTION_PRIVATE_H__INCLUDED 2 | #define PMATH_UTIL__GARBAGE_COLLECTION_PRIVATE_H__INCLUDED 3 | 4 | #ifndef BUILDING_PMATH 5 | # error This header file is not part of the public pMath API 6 | #endif 7 | 8 | 9 | #include 10 | 11 | 12 | /** Run the garbage collector. 13 | 14 | This function is not thread-safe. It must only be called from the garbage-collection thread. 15 | 16 | \see pmath_collect_temporary_symbols 17 | */ 18 | PMATH_PRIVATE 19 | void _pmath_unsafe_run_gc(void); 20 | 21 | 22 | #endif // PMATH_UTIL__GARBAGE_COLLECTION_PRIVATE_H__INCLUDED 23 | -------------------------------------------------------------------------------- /library/include/pmath-util/user-format-private.h: -------------------------------------------------------------------------------- 1 | #ifndef __PMATH_UTIL__FORMATTING_PRIVATE_H__ 2 | #define __PMATH_UTIL__FORMATTING_PRIVATE_H__ 3 | 4 | 5 | #include 6 | 7 | 8 | /**\brief get the associated Format rule for obj. 9 | 10 | \param obj A pMath object. It won't be freed. 11 | \return The associated Format definition or PMATH_UNDEFINED. 12 | */ 13 | PMATH_PRIVATE 14 | PMATH_ATTRIBUTE_USE_RESULT 15 | pmath_t _pmath_get_user_format(pmath_t obj); 16 | 17 | 18 | PMATH_PRIVATE 19 | pmath_bool_t _pmath_write_user_format(struct pmath_write_ex_t *info, pmath_t obj); 20 | 21 | 22 | #endif // __PMATH_UTIL__FORMATTING_PRIVATE_H__ 23 | -------------------------------------------------------------------------------- /modules/Java/library/src/pj-threads.h: -------------------------------------------------------------------------------- 1 | #ifndef __PJ_THREADS_H__ 2 | #define __PJ_THREADS_H__ 3 | 4 | #include 5 | #include 6 | 7 | PMATH_PRIVATE void pj_thread_message( 8 | pmath_messages_t mq, // wont be freed 9 | pmath_symbol_t sym, // wont be freed 10 | const char *tag, 11 | size_t argcount, 12 | ...); // pmath_t[argcount] will all be freed 13 | 14 | PMATH_PRIVATE 15 | PMATH_ATTRIBUTE_USE_RESULT 16 | pmath_messages_t pj_thread_get_companion(jthread *out_jthread); 17 | 18 | PMATH_PRIVATE pmath_bool_t pj_threads_init(void); 19 | PMATH_PRIVATE void pj_threads_done(void); 20 | 21 | #endif // __PJ_THREADS_H__ 22 | -------------------------------------------------------------------------------- /debugging/gdb/readme.txt: -------------------------------------------------------------------------------- 1 | GDB Python scripts 2 | ================== 3 | 4 | The Code::Blocks projects in pmath.workspace already contain required GDB startup customizations. 5 | When starting GDB, the following GDB macro lines are run in principle: 6 | 7 | python import sys 8 | python sys.path.insert(0, '/full/path/to/pmath/debugging/gdb') 9 | python import pmath_gdb 10 | python pmath_gdb.printers.register_pmath_printers(None) 11 | 12 | You can use the GDB command `pmath`, see `help pmath`. 13 | To show the managed stack, use `pmath bt`. 14 | To print a pmath_t variable VAR, use `pmath p VAR`. 15 | The output can be customized with `pmath set depth N` and `pmath set maxlen N`. 16 | -------------------------------------------------------------------------------- /richmath/include/eval/binding.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__EVAL__BINDING_H__INCLUDED 2 | #define RICHMATH__EVAL__BINDING_H__INCLUDED 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | extern pmath_symbol_t richmath_FE_KeyEvent; 9 | extern pmath_symbol_t richmath_FE_KeyAlt; 10 | extern pmath_symbol_t richmath_FE_KeyControl; 11 | extern pmath_symbol_t richmath_FE_KeyShift; 12 | extern pmath_symbol_t richmath_FE_ScopedCommand; 13 | 14 | namespace richmath { 15 | class Document; 16 | 17 | bool init_bindings(); 18 | void done_bindings(); 19 | } 20 | 21 | #endif // RICHMATH__EVAL__BINDING_H__INCLUDED 22 | -------------------------------------------------------------------------------- /modules/System/InputOutput/library/src/stdafx.h: -------------------------------------------------------------------------------- 1 | #ifndef PMATH_MODULE_INOUT_STDAFX_H_INCLUDED 2 | #define PMATH_MODULE_INOUT_STDAFX_H_INCLUDED 3 | 4 | #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) 5 | # define _WIN32_WINNT 0x0600 /* Vista and above */ 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | #ifdef PMATH_OS_WIN32 15 | # include 16 | #else 17 | # include 18 | # include 19 | # include 20 | # include 21 | # include 22 | # include 23 | #endif 24 | 25 | 26 | #endif // PMATH_MODULE_INOUT_STDAFX_H_INCLUDED 27 | -------------------------------------------------------------------------------- /library/include/pmath-util/files/filesystem.h: -------------------------------------------------------------------------------- 1 | #ifndef PMATH_UTIL_FILES_FILESYSTEM_H_INCLUDED 2 | #define PMATH_UTIL_FILES_FILESYSTEM_H_INCLUDED 3 | 4 | #include 5 | 6 | /** \brief Convert an absolute or relative file path to an absolute file path if possible. 7 | \param relname The relative or absolute path. It will be freed. 8 | \return An absolute file path or PMATH_NULL. You must free it. 9 | 10 | This function does not attempt to canonicalize the resulting path. 11 | */ 12 | PMATH_API 13 | PMATH_ATTRIBUTE_USE_RESULT 14 | pmath_string_t pmath_to_absolute_file_name(pmath_string_t relname); 15 | 16 | #endif // PMATH_UTIL_FILES_FILESYSTEM_H_INCLUDED 17 | -------------------------------------------------------------------------------- /library/src/pmath-core/packed-arrays-errdef-pack_from_to.inc: -------------------------------------------------------------------------------- 1 | #ifndef FROM_TYPE 2 | # error FROM_TYPE not defined 3 | #endif 4 | 5 | #ifndef TO_TYPE 6 | # error TO_TYPE not defined 7 | #endif 8 | 9 | #ifndef NAME_pack_array_from_to 10 | # error NAME_pack_array_from_to not defined 11 | #endif 12 | 13 | static void NAME_pack_array_from_to(FROM_TYPE, TO_TYPE) 14 | ( struct _pmath_packed_array_t *array, 15 | size_t level, 16 | const FROM_TYPE *array_data, 17 | TO_TYPE **location 18 | ) { 19 | assert(0 && "invalid conversion"); 20 | } 21 | -------------------------------------------------------------------------------- /modules/Windows/library/src/registry.h: -------------------------------------------------------------------------------- 1 | #ifndef __PMATH_WINDOWS__REGISTRY_H__ 2 | #define __PMATH_WINDOWS__REGISTRY_H__ 3 | 4 | #include 5 | #include 6 | 7 | /** \brief Extract the base and subkey path from a full registry path 8 | \param out_base Receives the base key upon return. It must not be closed. 9 | \param fullname The full key path. 10 | \return The subkey path on success or PMATH_NULL on error. 11 | */ 12 | extern pmath_string_t registry_split_subkey(HKEY *out_base, pmath_string_t fullname); 13 | 14 | extern pmath_bool_t registry_set_wow64_access_option(REGSAM *inout_acces_rights, pmath_t options); 15 | 16 | #endif // __PMATH_WINDOWS__REGISTRY_H__ 17 | -------------------------------------------------------------------------------- /richmath/scripts/resources/StyleSheets/Palette.pmathdoc: -------------------------------------------------------------------------------- 1 | /* pMath Document */ 2 | 3 | Document({ 4 | SectionGroup({Section(StyleData(StyleDefinitions -> "Core.pmathdoc")), 5 | SectionGroup({Section("Palette stylesheet", "Title"), 6 | Section( 7 | "This file contains default style definitions to apply to palette \ 8 | windows.", "Text"), 9 | SectionGroup({Section("Document styles", "Section"), 10 | Section(StyleData("Document"), Background -> None, Saveable -> False, 11 | Selectable -> False, ShowSectionBracket -> False, 12 | WindowFrame -> "Palette")}, All)}, All)}, All)}, 13 | StyleDefinitions -> "Stylesheets.pmathdoc", Visible -> True) -------------------------------------------------------------------------------- /library/scripts/auto/core/format/accents.pmath: -------------------------------------------------------------------------------- 1 | /* Parsing Transpose/... in traditional form 2 | */ 3 | 4 | Begin("System`Private`") 5 | 6 | Unprotect(System`Private`MakeScriptsExpression) 7 | 8 | System`Private`MakeScriptsExpression({~x, SuperscriptBox("\[DownTee]")})::= 9 | MakeExpression({"System`Transpose", "(", x, ")"}) 10 | 11 | Protect(System`Private`MakeScriptsExpression) 12 | 13 | 14 | Unprotect(Transpose) 15 | 16 | /* this is also defined/redefined in linalg.pmath */ 17 | MakeBoxes(Transpose(~x))::= {ParenthesizeBoxes(MakeBoxes(x), Power, "Postfix"), SuperscriptBox("\[DownTee]")} 18 | 19 | SetAttributes(Transpose, {Protected, ReadProtected}); 20 | 21 | End() 22 | -------------------------------------------------------------------------------- /library/scripts/auto/core/format/griditems.pmath: -------------------------------------------------------------------------------- 1 | Begin("System`Private`Format`GridItems`") 2 | 3 | MakeBoxes(SpanFromAbove):= "\[SpanFromAbove]" 4 | MakeBoxes(SpanFromBoth):= "\[SpanFromBoth]" 5 | MakeBoxes(SpanFromLeft):= "\[SpanFromLeft]" 6 | 7 | MakeBoxes(Spacer(~size ? isLength))::= TemplateBox({size}, "Spacer") 8 | MakeBoxes(Spacer(size: {~ ? isLength, ~ ? isLength}))::= TemplateBox({size}, "Spacer") 9 | 10 | SetAttributes(isLength, {HoldAllComplete}) 11 | isLength(Automatic)::= True 12 | isLength(Scaled(~s))::= IsNumeric(Unevaluated(s)) && (s >= 0) === True 13 | isLength(Dynamic(~~))::= True 14 | isLength(~len)::= IsNumeric(Unevaluated(len)) && (len >= 0) === True 15 | 16 | End() -------------------------------------------------------------------------------- /richmath/include/gui/color-dialog.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__COLOR_DIALOG_H__INCLUDED 2 | #define RICHMATH__GUI__COLOR_DIALOG_H__INCLUDED 3 | 4 | 5 | #ifdef RICHMATH_USE_GTK_GUI 6 | # include 7 | #endif 8 | 9 | #ifdef RICHMATH_USE_WIN32_GUI 10 | # include 11 | #endif 12 | 13 | #include 14 | 15 | 16 | namespace richmath { 17 | struct ColorDialog : 18 | #if RICHMATH_USE_GTK_GUI 19 | private MathGtkColorDialog 20 | #elif RICHMATH_USE_WIN32_GUI 21 | private Win32ColorDialog 22 | #endif 23 | { 24 | static Expr run(Expr expr); 25 | }; 26 | } 27 | 28 | #endif // RICHMATH__GUI__COLOR_DIALOG_H__INCLUDED 29 | -------------------------------------------------------------------------------- /richmath/scripts/auto/frontend/showdefinition.pmath: -------------------------------------------------------------------------------- 1 | Begin("FE`Private`") 2 | 3 | 4 | Unprotect(ShowDefinition) 5 | 6 | ShowDefinition(~s:String)::= With({n:= Names(s)}, 7 | SectionPrint("PrintUsage", 8 | Style( 9 | Grid(n.Sort.Map(RawBoxes({ButtonBox(ToBoxes(#))," "}) &).Partition( 10 | Ceiling(Length(n)/2), Ceiling(Length(n)/2), {1,1}, {}).PadRight({2, Ceiling(Length(n)/2)}, "").Transpose), 11 | ButtonBoxOptions -> { 12 | ButtonFrame -> "Frameless", 13 | ButtonFunction -> (With({s:= ToExpression(First(#))}, ShowDefinition(s)) &)}, 14 | GridBoxRowSpacing -> 0.2, 15 | GridBoxColumnSpacing -> 2 16 | )) /? Length(n) > 1) 17 | 18 | Protect(ShowDefinition) 19 | 20 | 21 | End() -------------------------------------------------------------------------------- /library/src/pmath-builtins/language/frompackedarray.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | 6 | PMATH_PRIVATE pmath_t builtin_developer_frompackedarray(pmath_expr_t expr) { 7 | /* Developer`FromPackedArray(expr) 8 | */ 9 | pmath_t array; 10 | 11 | if(pmath_expr_length(expr) != 1) { 12 | pmath_message_argxxx(pmath_expr_length(expr), 1, 1); 13 | return expr; 14 | } 15 | 16 | array = pmath_expr_get_item(expr, 1); 17 | pmath_unref(expr); 18 | 19 | if(!pmath_is_packed_array(array)) 20 | return array; 21 | 22 | array = _pmath_expr_unpack_array(array, TRUE); 23 | 24 | return array; 25 | } 26 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/language/getrefcount.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | 6 | extern pmath_symbol_t pmath_System_Infinity; 7 | 8 | PMATH_PRIVATE pmath_t builtin_private_getrefcount(pmath_expr_t expr) { 9 | pmath_t item; 10 | 11 | if(pmath_expr_length(expr) != 1) 12 | return expr; 13 | 14 | item = pmath_expr_get_item(expr, 1); 15 | pmath_unref(expr); 16 | if(pmath_is_pointer(item)) 17 | expr = pmath_integer_new_siptr(pmath_refcount(item)); 18 | else 19 | expr = pmath_ref(_pmath_object_pos_infinity); 20 | 21 | pmath_unref(item); 22 | return expr; 23 | } 24 | -------------------------------------------------------------------------------- /richmath/src/gui/font-dialog.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | using namespace richmath; 6 | 7 | extern pmath_symbol_t richmath_System_List; 8 | 9 | 10 | Expr richmath_eval_FrontEnd_FontDialog(Expr expr) { 11 | return FontDialog::run(PMATH_CPP_MOVE(expr)); 12 | } 13 | 14 | //{ class FontDialog ... 15 | 16 | Expr FontDialog::run(Expr style_expr) { 17 | Style initial_style; 18 | 19 | if(style_expr.expr_length() > 0) { 20 | style_expr.set(0, Symbol(richmath_System_List)); 21 | initial_style = Style(PMATH_CPP_MOVE(style_expr)); 22 | } 23 | 24 | AutoGuiWait timer; 25 | return show(initial_style); 26 | } 27 | 28 | //} ... class FontDialog 29 | -------------------------------------------------------------------------------- /editors/pmath-vscode/language-configuration.json: -------------------------------------------------------------------------------- 1 | { 2 | "comments": { 3 | "lineComment": "%", 4 | "blockComment": [ "/*", "*/" ] 5 | }, 6 | "brackets": [ 7 | [ "(", ")" ], 8 | [ "[[", "]]" ], 9 | [ "[", "]" ], 10 | [ "{", "}" ] 11 | ], 12 | "autoClosingPairs": [ 13 | { "open": "{", "close": "}" }, 14 | { "open": "[", "close": "]" }, 15 | { "open": "(", "close": ")" }, 16 | { "open": "\"", "close": "\"", "notIn": ["string", "comment"] }, 17 | { "open": "/*", "close": " */", "notIn": ["string", "comment"] } 18 | ], 19 | "surroundingPairs": [ 20 | ["{", "}"], 21 | ["[", "]"], 22 | ["(", ")"], 23 | ["\"", "\""] 24 | ] 25 | } -------------------------------------------------------------------------------- /library/src/pmath-builtins/lists/append.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | 6 | PMATH_PRIVATE pmath_t builtin_append(pmath_expr_t expr) { 7 | pmath_t list, elem; 8 | 9 | if(pmath_expr_length(expr) != 2) { 10 | pmath_message_argxxx(pmath_expr_length(expr), 2, 2); 11 | return expr; 12 | } 13 | 14 | list = pmath_expr_get_item(expr, 1); 15 | if(!pmath_is_expr(list)) { 16 | pmath_unref(list); 17 | pmath_message(PMATH_NULL, "nexprat", 2, PMATH_FROM_INT32(1), pmath_ref(expr)); 18 | return expr; 19 | } 20 | 21 | elem = pmath_expr_get_item(expr, 2); 22 | pmath_unref(expr); 23 | return pmath_expr_append(list, 1, elem); 24 | } 25 | -------------------------------------------------------------------------------- /library/scripts/auto/core/format/brackets.pmath: -------------------------------------------------------------------------------- 1 | % Ceiling/Floor/... in traditional form 2 | 3 | Begin("System`Private`") 4 | 5 | Unprotect(Ceiling, Floor, BracketingBar, DoubleBracketingBar) 6 | 7 | MakeBoxes(Ceiling(~x))::= {"\[LeftCeiling]", MakeBoxes(x), "\[RightCeiling]"} 8 | MakeBoxes(Floor(~x))::= {"\[LeftFloor]", MakeBoxes(x), "\[RightFloor]"} 9 | MakeBoxes(BracketingBar(~~~x))::= {"\[LeftBracketingBar]", MakeBoxes({x})[2], "\[RightBracketingBar]"} 10 | MakeBoxes(DoubleBracketingBar(~~~x))::= {"\[LeftDoubleBracketingBar]", MakeBoxes({x})[2], "\[RightDoubleBracketingBar]"} 11 | 12 | SetAttributes({Ceiling, Floor, BracketingBar, DoubleBracketingBar}, {Protected, ReadProtected}); 13 | 14 | End() 15 | -------------------------------------------------------------------------------- /modules/System/Numerics/library/src/zeta-impl.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | extern pmath_symbol_t pmath_System_Private_AutoSimplifyZeta; 4 | 5 | #define SIMPLIFY_SYMBOL pmath_System_Private_AutoSimplifyZeta 6 | 7 | PMATH_PRIVATE pmath_t eval_System_Zeta(pmath_expr_t expr) { 8 | if(pmath_expr_length(expr) == 1) { 9 | # define ACB_FUNCTION acb_zeta 10 | # include "acb-impl-onearg.inc" 11 | # undef ACB_FUNCTION 12 | } 13 | else if(pmath_expr_length(expr) == 2) { 14 | # define ACB_FUNCTION acb_hurwitz_zeta 15 | # include "acb-impl-twoarg.inc" 16 | # undef ACB_FUNCTION 17 | } 18 | else { 19 | pmath_message_argxxx(pmath_expr_length(expr), 1, 2); 20 | return expr; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /modules/System/Numerics/simplify-hypgeom.pmath: -------------------------------------------------------------------------------- 1 | BeginPackage("System`Numerics`HypGeom`") 2 | 3 | System`Private`AutoSimplifyHypGeom 4 | 5 | Begin("System`Numerics`HypGeom`Private`") 6 | 7 | % 8 | % If direct (numerical) calculation of Hypergeometric2F1(a1, a2, b, x), etc. is not possible 9 | % (because x is an expression or an exact number), 10 | % System`Private`AutoSimplifyHypGeom(Hypergeometric2F1, {a1, a2}, {b}, x) 11 | % etc. get called. 12 | % If that returns $Failed, the original expression Hypergeometric2F1(...) etc. remains unevaluated. 13 | % Otherwise, the result of AutoSimplifyHypGeom will be returned. 14 | % 15 | System`Private`AutoSimplifyHypGeom(~, ~, ~, ~):= $Failed 16 | 17 | 18 | 19 | End() 20 | 21 | EndPackage() 22 | -------------------------------------------------------------------------------- /library/include/pmath-util/modules-private.h: -------------------------------------------------------------------------------- 1 | #ifndef __PMATH_UTIL__MODULES_PRIVATE_H__ 2 | #define __PMATH_UTIL__MODULES_PRIVATE_H__ 3 | 4 | #ifndef BUILDING_PMATH 5 | #error This header file is not part of the public pMath API 6 | #endif 7 | 8 | #include 9 | 10 | // initialized in pmath_init(): 11 | PMATH_PRIVATE extern pmath_t _pmath_object_loadlibrary_load_message; 12 | PMATH_PRIVATE extern pmath_t _pmath_object_get_load_message; 13 | 14 | PMATH_PRIVATE pmath_bool_t _pmath_module_load(pmath_string_t filename); // filename will be freed 15 | 16 | PMATH_PRIVATE pmath_bool_t _pmath_modules_init(void); 17 | PMATH_PRIVATE void _pmath_modules_done(void); 18 | 19 | #endif /* __PMATH_UTIL__MODULES_PRIVATE_H__ */ 20 | -------------------------------------------------------------------------------- /modules/System/Numerics/simplify-ortho-poly.pmath: -------------------------------------------------------------------------------- 1 | BeginPackage("System`Numerics`OrthogonalPolynomials`") 2 | 3 | System`Private`AutoSimplifyOrthoPoly 4 | 5 | Begin("System`Numerics`OrthogonalPolynomials`Private`") 6 | 7 | % 8 | % If direct (numerical) calculation of ChebychevU(nu, x), HermiteH(nu, x), etc. is not possible (because 9 | % x is an expression or an exact number), System`Private`AutoSimplifyOrthoPoly(HermiteH, nu, x) 10 | % etc. get called. 11 | % If that returns $Failed, the original expression HermiteH(nu, x) etc. remains unevaluated. 12 | % Otherwise, the result of AutoSimplifyOrthoPoly will be returned. 13 | % 14 | System`Private`AutoSimplifyOrthoPoly(~, ~, ~):= $Failed 15 | 16 | 17 | 18 | End() 19 | 20 | EndPackage() 21 | -------------------------------------------------------------------------------- /richmath/include/gui/dragdrophandler.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__DRAGDROPHANDLER_H__INCLUDED 2 | #define RICHMATH__GUI__DRAGDROPHANDLER_H__INCLUDED 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace richmath { 9 | enum class DropAction { 10 | Copy, 11 | Move, 12 | Link, 13 | }; 14 | 15 | class DragDropHandler: public Shareable { 16 | private: 17 | class Impl; 18 | public: 19 | DragDropHandler(); 20 | virtual ~DragDropHandler(); 21 | 22 | virtual MenuCommandStatus can_drop(DropAction action) = 0; 23 | virtual bool do_drop(DropAction action) = 0; 24 | }; 25 | } 26 | 27 | #endif // RICHMATH__GUI__DRAGDROPHANDLER_H__INCLUDED 28 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/control/definitions/update.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | PMATH_PRIVATE pmath_t builtin_update(pmath_expr_t expr) { 6 | pmath_t sym; 7 | 8 | if(pmath_expr_length(expr) != 1) { 9 | pmath_message_argxxx(pmath_expr_length(expr), 1, 1); 10 | return expr; 11 | } 12 | 13 | sym = pmath_expr_get_item(expr, 1); 14 | if(pmath_is_string(sym)) { 15 | sym = pmath_symbol_find(sym, FALSE); 16 | } 17 | 18 | if(!pmath_is_symbol(sym)) { 19 | pmath_message(PMATH_NULL, "ssym", 1, sym); 20 | return expr; 21 | } 22 | 23 | pmath_unref(expr); 24 | 25 | pmath_symbol_update(sym); 26 | pmath_unref(sym); 27 | return PMATH_NULL; 28 | } 29 | -------------------------------------------------------------------------------- /modules/System/Numerics/library/src/util.h: -------------------------------------------------------------------------------- 1 | #ifndef __MODULE__PMATH_NUMERICS__UTIL_H__ 2 | #define __MODULE__PMATH_NUMERICS__UTIL_H__ 3 | 4 | #ifndef __MODULE__PMATH_NUMERICS__STDAFX_H__ 5 | # error include "stdafx.h" first 6 | #endif 7 | 8 | // If *z == x * ImaginaryI => *z:= x 9 | PMATH_PRIVATE pmath_bool_t pnum_is_imaginary(pmath_t *z); 10 | 11 | PMATH_PRIVATE pmath_bool_t pnum_equals_quotient(pmath_t obj, int32_t num, int32_t den); 12 | PMATH_PRIVATE pmath_bool_t pnum_get_small_rational(pmath_t obj, int32_t *num, int32_t *den); 13 | 14 | // basically a copy of _pmath_contains_symbol 15 | PMATH_PRIVATE 16 | pmath_bool_t pnum_contains_nonhead_symbol(pmath_t obj, pmath_symbol_t sub); 17 | 18 | 19 | #endif // __MODULE__PMATH_NUMERICS__UTIL_H__ 20 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/control/memoryusage.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | 9 | extern pmath_symbol_t pmath_System_List; 10 | 11 | PMATH_PRIVATE pmath_t builtin_memoryusage(pmath_expr_t expr){ 12 | size_t current, max;; 13 | 14 | if(pmath_expr_length(expr) != 0){ 15 | pmath_message_argxxx(pmath_expr_length(expr), 0, 0); 16 | return expr; 17 | } 18 | 19 | pmath_mem_usage(¤t, &max); 20 | pmath_unref(expr); 21 | 22 | return pmath_expr_new_extended( 23 | pmath_ref(pmath_System_List), 2, 24 | pmath_integer_new_uiptr(current), 25 | pmath_integer_new_uiptr(max)); 26 | } 27 | -------------------------------------------------------------------------------- /richmath/include/boxes/box-factory.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__BOXES__BOX_FACTORY_H__INCLUDED 2 | #define RICHMATH__BOXES__BOX_FACTORY_H__INCLUDED 3 | 4 | #include 5 | #include 6 | 7 | 8 | namespace richmath { 9 | struct BoxFactory { 10 | static Box *create_empty_box(LayoutKind layout_kind, Expr expr); 11 | static AbstractSequence *create_sequence(LayoutKind kind); 12 | static Section *create_empty_section(Expr expr) { return create_empty_section(kind_of_section(expr)); } 13 | static Section *create_empty_section(SectionKind kind); 14 | 15 | static SectionKind kind_of_section(Expr expr); 16 | }; 17 | } 18 | 19 | #endif // RICHMATH__BOXES__BOX_FACTORY_H__INCLUDED 20 | -------------------------------------------------------------------------------- /richmath/include/gui/win32/win32-recent-documents.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__WIN32__WIN32_RECENT_DOCUMENTS_H__INCLUDED 2 | #define RICHMATH__GUI__WIN32__WIN32_RECENT_DOCUMENTS_H__INCLUDED 3 | 4 | #ifndef RICHMATH_USE_WIN32_GUI 5 | # error this header is win32 specific 6 | #endif 7 | 8 | 9 | #include 10 | #include 11 | 12 | 13 | namespace richmath { 14 | struct Win32RecentDocuments { 15 | static void add(String path); 16 | static Expr as_menu_list(); 17 | static bool remove(String path); 18 | static void init(); 19 | static void done(); 20 | 21 | static void set_window_app_user_model_id(HWND hwnd); 22 | }; 23 | } 24 | 25 | 26 | #endif // RICHMATH__GUI__WIN32__WIN32_RECENT_DOCUMENTS_H__INCLUDED 27 | -------------------------------------------------------------------------------- /richmath/include/boxes/sectionornament.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__BOXES__SECTIONORNAMENT_H__INCLUDED 2 | #define RICHMATH__BOXES__SECTIONORNAMENT_H__INCLUDED 3 | 4 | #include 5 | 6 | namespace richmath { 7 | class SectionOrnament final : public Base { 8 | public: 9 | SectionOrnament(); 10 | ~SectionOrnament(); 11 | 12 | bool has_index(int i) const { return _box && _box->index() == i; } 13 | bool reload_if_necessary(BoxAdopter owner, Expr expr, BoxInputFlags flags); 14 | 15 | Box *box_or_null() const { return _box; } 16 | Expr to_pmath() const { return _expr; } 17 | 18 | private: 19 | Box *_box; 20 | Expr _expr; 21 | }; 22 | } 23 | 24 | #endif // RICHMATH__BOXES__SECTIONORNAMENT_H__INCLUDED 25 | -------------------------------------------------------------------------------- /modules/Java/classpath/pmath/util/WrappedException.java: -------------------------------------------------------------------------------- 1 | package pmath.util; 2 | 3 | /** Wraps a native pMath exception. 4 | */ 5 | public class WrappedException extends RuntimeException { 6 | private Expr expr; 7 | 8 | /** Get the wrapped pMath exception expression. 9 | * 10 | * @return An arbitrary expression. 11 | */ 12 | public Expr getExpr() { 13 | return expr; 14 | } 15 | 16 | /** Create a new wrapped pMath exception 17 | * 18 | * @param expr The pMath representation of the expression. 19 | */ 20 | public WrappedException(Expr expr) { 21 | super("wrapped pMath exception: " + expr); 22 | this.expr = expr; 23 | } 24 | 25 | @java.io.Serial 26 | private static final long serialVersionUID = 3637246794112472621L; 27 | } 28 | -------------------------------------------------------------------------------- /library/include/pmath-builtins/control/messages-private.h: -------------------------------------------------------------------------------- 1 | #ifndef __PMATH_BUILTINS__CONTROL__MESSAGES_PRIVATE_H__ 2 | #define __PMATH_BUILTINS__CONTROL__MESSAGES_PRIVATE_H__ 3 | 4 | #ifndef BUILDING_PMATH 5 | #error This header file is not part of the public pMath API 6 | #endif 7 | 8 | /* This header exports all definitions of the sources in 9 | src/pmath-builtins/control/messages/ 10 | */ 11 | 12 | PMATH_PRIVATE pmath_t _pmath_messages_in_group(pmath_string_t group); // group will be freed 13 | 14 | PMATH_PRIVATE pmath_bool_t _pmath_is_valid_messagename(pmath_t msg); 15 | PMATH_PRIVATE pmath_bool_t _pmath_message_is_default_off(pmath_t msg); 16 | 17 | PMATH_PRIVATE pmath_bool_t _pmath_message_is_on(pmath_t msg); 18 | 19 | #endif // __PMATH_BUILTINS__CONTROL__MESSAGES_PRIVATE_H__ 20 | -------------------------------------------------------------------------------- /modules/Java/example/Gui/using-awt.pmath: -------------------------------------------------------------------------------- 1 | 2 | BeginPackage("UsingAwt`") 3 | 4 | Begin("UsingAwt`Private`") 5 | 6 | < onClosing}) 21 | frm @ addWindowListener(adapter) 22 | 23 | onClosing(~this, ~windowEvent)::= windowEvent @ getWindow() @ dispose() 24 | 25 | label @ setText("Hi there.") 26 | frm @ setEnabled(True) 27 | 28 | End() 29 | 30 | EndPackage() 31 | -------------------------------------------------------------------------------- /library/include/pmath-builtins/language-private.h: -------------------------------------------------------------------------------- 1 | #ifndef __PMATH_BUILTINS__LANGUAGE_PRIVATE_H__ 2 | #define __PMATH_BUILTINS__LANGUAGE_PRIVATE_H__ 3 | 4 | #ifndef BUILDING_PMATH 5 | #error This header file is not part of the public pMath API 6 | #endif 7 | 8 | #include 9 | 10 | /* This header exports definitions of the sources in 11 | src/pmath-builtins/language/ 12 | */ 13 | 14 | PMATH_PRIVATE extern pmath_t _pmath_object_makeexpression_key_auto_uncompress; 15 | 16 | // evaluates MakeExpression(box) but also retains debug metadata 17 | PMATH_PRIVATE pmath_t _pmath_makeexpression_with_debugmetadata(pmath_t box); 18 | 19 | PMATH_PRIVATE pmath_bool_t _pmath_is_machinenumber(pmath_t x); 20 | 21 | #endif /* __PMATH_BUILTINS__LANGUAGE_PRIVATE_H__ */ 22 | -------------------------------------------------------------------------------- /modules/Java/example/Interrupt/Test1.java: -------------------------------------------------------------------------------- 1 | public class Test1{ 2 | public static int add(int a, int b){ 3 | return a + b; 4 | } 5 | 6 | public static int div(int a, int b){ 7 | return a / b; 8 | } 9 | 10 | public static Object identity(Object src){ 11 | return src; 12 | } 13 | 14 | public static Object[] identity2(Object... src){ 15 | return src; 16 | } 17 | 18 | public Object self(){ 19 | return this; 20 | } 21 | 22 | public static int recursiveCall(int depth){ 23 | if(depth > 0) 24 | return 1 + recursiveCall(depth - 1); 25 | return 0; 26 | } 27 | 28 | public static void endlessLoop(){ 29 | while(true){ 30 | } 31 | } 32 | 33 | public static void interruptableLoop(){ 34 | while(!java.lang.Thread.currentThread().isInterrupted()){ 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /modules/System/Numerics/library/src/stdafx.h: -------------------------------------------------------------------------------- 1 | #ifndef __MODULE__PMATH_NUMERICS__STDAFX_H__ 2 | #define __MODULE__PMATH_NUMERICS__STDAFX_H__ 3 | 4 | 5 | #include 6 | #include 7 | 8 | #ifdef _MSC_VER 9 | // Needed by mpir/gmp to use dllimport declarations 10 | # define MSC_USE_DLL 11 | 12 | # pragma warning(push) 13 | // In mpz_get_ui(): Converting 'mp_limb_t' to 'unsigned long': possible data loss. 14 | # pragma warning(disable: 4244) 15 | # include 16 | # include 17 | # include 18 | # pragma warning(pop) 19 | #else 20 | # include 21 | # include 22 | # include 23 | #endif // _MSC_VER 24 | 25 | #include 26 | 27 | #include 28 | 29 | 30 | #endif // __MODULE__PMATH_NUMERICS__STDAFX_H__ 31 | -------------------------------------------------------------------------------- /richmath/include/util/autovaluereset.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__UTIL__AUTOVALUERESET_H__INCLUDED 2 | #define RICHMATH__UTIL__AUTOVALUERESET_H__INCLUDED 3 | 4 | namespace richmath { 5 | template 6 | class AutoValueReset { 7 | public: 8 | AutoValueReset(T &_reference) 9 | : reference(_reference), 10 | old_value(_reference) 11 | { 12 | } 13 | 14 | ~AutoValueReset() { 15 | reference = old_value; 16 | } 17 | 18 | private: 19 | AutoValueReset(const AutoValueReset &) = delete; 20 | const AutoValueReset &operator=(const AutoValueReset &) = delete; 21 | 22 | private: 23 | T &reference; 24 | T old_value; 25 | }; 26 | } 27 | 28 | #endif // RICHMATH__UTIL__AUTOVALUERESET_H__INCLUDED 29 | -------------------------------------------------------------------------------- /richmath/include/util/text-gathering.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__UTIL__TEXT_GATHERING_H__INCLUDED 2 | #define RICHMATH__UTIL__TEXT_GATHERING_H__INCLUDED 3 | 4 | #include 5 | 6 | #include 7 | 8 | namespace richmath { 9 | class SimpleTextGather { 10 | class Impl; 11 | public: 12 | explicit SimpleTextGather(int maxlen); 13 | 14 | void append(Box *box); 15 | void append(const VolatileSelection &sel); 16 | 17 | void append_space(); 18 | void append_text(String str); 19 | void append_text(const char *str); 20 | 21 | public: 22 | String text; 23 | int max_length; 24 | bool skip_string_characters_in_math : 1; 25 | }; 26 | } 27 | 28 | #endif // RICHMATH__UTIL__TEXT_GATHERING_H__INCLUDED 29 | -------------------------------------------------------------------------------- /library/include/pmath-util/stacks-private.h: -------------------------------------------------------------------------------- 1 | #ifndef __PMATH_UTIL__STACKS_PRIVATE_H__ 2 | #define __PMATH_UTIL__STACKS_PRIVATE_H__ 3 | 4 | #ifndef BUILDING_PMATH 5 | # error This header file is not part of the public pMath API 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | struct _pmath_stack_item_t { 14 | struct _pmath_stack_item_t *next; 15 | }; 16 | 17 | struct _pmath_stack_t { 18 | union { 19 | struct { 20 | struct _pmath_stack_item_t *top; 21 | intptr_t operation_counter_or_spinlock; 22 | } s; 23 | 24 | pmath_atomic2_t as_atomic2; 25 | } u; 26 | }; 27 | 28 | PMATH_PRIVATE pmath_bool_t _pmath_stacks_init(void); 29 | 30 | #endif /* __PMATH_UTIL__STACKS_PRIVATE_H__ */ 31 | -------------------------------------------------------------------------------- /modules/Java/library/src/pj-objects.h: -------------------------------------------------------------------------------- 1 | #ifndef __PJ_OBJECTS_H__ 2 | #define __PJ_OBJECTS_H__ 3 | 4 | #include 5 | #include 6 | 7 | 8 | PMATH_PRIVATE 9 | PMATH_ATTRIBUTE_USE_RESULT 10 | pmath_t pj_object_from_java(JNIEnv *env, jobject jobj); 11 | 12 | PMATH_PRIVATE 13 | PMATH_ATTRIBUTE_USE_RESULT 14 | jobject pj_object_to_java(JNIEnv *env, pmath_t obj); // obj will be freed; returns new local reference 15 | 16 | PMATH_PRIVATE pmath_bool_t pj_object_is_java(JNIEnv *env, pmath_t obj); // obj wont be freed 17 | 18 | PMATH_PRIVATE void pj_objects_clear_cache(void); 19 | 20 | PMATH_PRIVATE pmath_t pj_eval_upcall_Java_JavaField(pmath_expr_t expr); 21 | 22 | PMATH_PRIVATE pmath_bool_t pj_objects_init(void); 23 | PMATH_PRIVATE void pj_objects_done(void); 24 | 25 | #endif // __PJ_OBJECTS_H__ 26 | -------------------------------------------------------------------------------- /library/include/pmath-util/version.h: -------------------------------------------------------------------------------- 1 | #ifndef __PMATH_UTIL__VERSION_H__ 2 | #define __PMATH_UTIL__VERSION_H__ 3 | 4 | #include 5 | 6 | /**\defgroup version Version Information 7 | 8 | @{ 9 | */ 10 | 11 | /**\brief Get the date and time when pMath was compiled. 12 | */ 13 | PMATH_API 14 | void pmath_version_datetime( 15 | int *year, 16 | int *month, 17 | int *day, 18 | int *hour, 19 | int *minute, 20 | int *second); 21 | 22 | /**\brief Get version number (major + minor/100) 23 | */ 24 | PMATH_API 25 | double pmath_version_number(void); 26 | 27 | /**\brief Get version number part. 28 | \param index The number index. Major=1, Minor=2, Revision=3 29 | */ 30 | PMATH_API 31 | long pmath_version_number_part(int index); 32 | 33 | /** @} */ 34 | 35 | #endif // __PMATH_UTIL__VERSION_H__ 36 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/formating/baseform.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | 6 | extern pmath_symbol_t pmath_System_Automatic; 7 | 8 | PMATH_PRIVATE pmath_t builtin_baseform(pmath_expr_t expr) { 9 | pmath_t base; 10 | 11 | if(pmath_expr_length(expr) != 2) { 12 | pmath_message_argxxx(pmath_expr_length(expr), 2, 2); 13 | return expr; 14 | } 15 | 16 | base = pmath_expr_get_item(expr, 2); 17 | if(pmath_same(base, pmath_System_Automatic)) { 18 | pmath_unref(base); 19 | } 20 | else if( !pmath_is_int32(base) || 21 | PMATH_AS_INT32(base) < 2 || 22 | PMATH_AS_INT32(base) > 36) 23 | { 24 | pmath_message(PMATH_NULL, "basf", 2, base, PMATH_FROM_INT32(36)); 25 | return expr; 26 | } 27 | 28 | return expr; 29 | } 30 | -------------------------------------------------------------------------------- /modules/Java/library/run-java-32.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION 4 | 5 | if "%PROCESSOR_ARCHITECTURE%" == "x86" ( 6 | set "JAVA_REG_KEY=HKLM\Software\JavaSoft\Java Runtime Environment" 7 | ) else ( 8 | set "JAVA_REG_KEY=HKLM\Software\Wow6432Node\JavaSoft\Java Runtime Environment" 9 | ) 10 | 11 | for /F "usebackq skip=2 tokens=2*" %%A in (`reg.exe query "%JAVA_REG_KEY%" /v CurrentVersion 2^>NUL`) DO ( 12 | set "JRE_VERSION=%%B" 13 | ) 14 | if not defined JRE_VERSION ( 15 | echo "Java Runtime Environment (32-bit) not found." 16 | goto end 17 | ) 18 | 19 | for /F "usebackq skip=2 tokens=2*" %%A in (`reg.exe query "%JAVA_REG_KEY%\%JRE_VERSION%" /v JavaHome 2^>NUL`) DO ( 20 | set "JRE_HOME=%%B" 21 | ) 22 | 23 | "%JRE_HOME%\bin\java.exe" %* 24 | 25 | 26 | :end 27 | endlocal 28 | -------------------------------------------------------------------------------- /modules/System/Numerics/library/src/ortho-poly-impl.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | extern pmath_symbol_t pmath_System_Private_AutoSimplifyOrthoPoly; 4 | 5 | #define SIMPLIFY_SYMBOL pmath_System_Private_AutoSimplifyOrthoPoly 6 | 7 | PMATH_PRIVATE pmath_t eval_System_ChebyshevT(pmath_expr_t expr) { 8 | # define ACB_FUNCTION acb_hypgeom_chebyshev_t 9 | # include "acb-impl-twoarg.inc" 10 | # undef ACB_FUNCTION 11 | } 12 | 13 | PMATH_PRIVATE pmath_t eval_System_ChebyshevU(pmath_expr_t expr) { 14 | # define ACB_FUNCTION acb_hypgeom_chebyshev_u 15 | # include "acb-impl-twoarg.inc" 16 | # undef ACB_FUNCTION 17 | } 18 | 19 | PMATH_PRIVATE pmath_t eval_System_HermiteH(pmath_expr_t expr) { 20 | # define ACB_FUNCTION acb_hypgeom_hermite_h 21 | # include "acb-impl-twoarg.inc" 22 | # undef ACB_FUNCTION 23 | } 24 | -------------------------------------------------------------------------------- /richmath/resources/resources.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__RESOURCES_H__INCLUDED 2 | #define RICHMATH__RESOURCES_H__INCLUDED 3 | 4 | #define ICO_APP_MAIN 1 5 | #define ICO_FILE 2 6 | 7 | // same values as CursorType: 8 | #define CUR_TEXT_SE 101 9 | #define CUR_TEXT_E 102 10 | #define CUR_TEXT_NE 103 11 | #define CUR_TEXT_N 104 12 | #define CUR_TEXT_NW 105 13 | #define CUR_TEXT_W 106 14 | #define CUR_TEXT_SW 107 15 | #define CUR_TEXT_S 108 16 | #define CUR_SECTION 109 17 | #define CUR_DOCUMENT 110 18 | #define CUR_NOSELECT 111 19 | #define CUR_GRAB 112 20 | #define CUR_GRABBING 113 21 | 22 | 23 | #define BMP_PIN16 201 24 | #define BMP_PIN24 202 25 | #define BMP_PIN32 203 26 | 27 | 28 | #endif // RICHMATH__RESOURCES_H__INCLUDED 29 | -------------------------------------------------------------------------------- /richmath/include/gui/gtk/mgtk-messagebox.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__GTK__MGTK_MESSAGEBOX_H__INCLUDED 2 | #define RICHMATH__GUI__GTK__MGTK_MESSAGEBOX_H__INCLUDED 3 | 4 | #ifndef RICHMATH_USE_GTK_GUI 5 | # error this header is gtk specific 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | namespace richmath { 12 | class ControlContext; 13 | 14 | YesNoCancel mgtk_ask_save(Document *doc, String question); 15 | YesNoCancel mgtk_ask_remove_private_style_definitions(Document *doc); 16 | bool mgtk_ask_open_suspicious_system_file(String path); 17 | Expr mgtk_ask_interrupt(Expr stack); 18 | 19 | int mgtk_themed_dialog_run(ControlContext &ctx, GtkDialog *dialog); 20 | int mgtk_themed_dialog_run(GtkDialog *dialog); 21 | } 22 | 23 | #endif // RICHMATH__GUI__GTK__MGTK_MESSAGEBOX_H__INCLUDED 24 | -------------------------------------------------------------------------------- /richmath/include/gui/recent-documents.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__RECENT_DOCUMENTS_H__INCLUDED 2 | #define RICHMATH__GUI__RECENT_DOCUMENTS_H__INCLUDED 3 | 4 | 5 | #ifdef RICHMATH_USE_GTK_GUI 6 | # include 7 | #endif 8 | 9 | #ifdef RICHMATH_USE_WIN32_GUI 10 | # include 11 | #endif 12 | 13 | 14 | namespace richmath { 15 | struct RecentDocuments : 16 | #if defined(RICHMATH_USE_GTK_GUI) 17 | public MathGtkRecentDocuments 18 | #elif defined(RICHMATH_USE_WIN32_GUI) 19 | public Win32RecentDocuments 20 | #endif 21 | { 22 | static Expr open_document_menu_item(Expr label, Expr path); 23 | static Expr open_document_menu_item(Expr label, Expr path, bool add_to_recent); 24 | }; 25 | } 26 | 27 | #endif // RICHMATH__GUI__RECENT_DOCUMENTS_H__INCLUDED 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.cbTemp 3 | *.chm 4 | *.chw 5 | *.layout 6 | *.depend 7 | *.pdb 8 | *.cbp.mak 9 | /library/.idea 10 | /library/bin 11 | /library/obj 12 | /library/tmp 13 | /library/Makefile 14 | /library/dependencies 15 | /library/console/bin 16 | /library/console/obj 17 | /library/test/bin 18 | /library/test/obj 19 | /library/doxygen/doc 20 | /library/doxygen/html 21 | /library/doxygen/latex 22 | /library/doxygen/xml 23 | /modules/Eigen/bin 24 | /modules/Eigen/obj 25 | /modules/hello/bin 26 | /modules/hello/obj 27 | /modules/hello/Makefile 28 | /richmath/dependencies/linux 29 | /richmath/dependencies/windows 30 | /richmath/bin 31 | /richmath/obj 32 | /richmath/Makefile 33 | /Makefile 34 | 35 | /richmath/WINDOWSTEMPDIR_FONTCONFIG_CACHE 36 | 37 | /richmath/*.cscope_file_list 38 | *.bmarks 39 | .directory 40 | /.VSCodeCounter/ 41 | *.srctrl* 42 | -------------------------------------------------------------------------------- /richmath/include/gui/control-glow.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__CONTROL_GLOW_H__INCLUDED 2 | #define RICHMATH__GUI__CONTROL_GLOW_H__INCLUDED 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace richmath { 9 | class ControlGlowHook : public PaintHook { 10 | public: 11 | ControlGlowHook(Box *destination, ContainerType type, ControlState state); 12 | 13 | virtual void run(Box *box, Context &context) override; 14 | 15 | public: 16 | static bool all_disabled; 17 | 18 | public: 19 | Box *destination; 20 | ContainerType type; 21 | ControlState state; 22 | Margins outside; 23 | Margins inside; 24 | }; 25 | } 26 | 27 | #endif // RICHMATH__GUI__CONTROL_GLOW_H__INCLUDED 28 | -------------------------------------------------------------------------------- /library/include/pmath-util/files/mixed-buffer.h: -------------------------------------------------------------------------------- 1 | #ifndef __PMATH_UTIL__FILES__MIXED_BUFFER_H__ 2 | #define __PMATH_UTIL__FILES__MIXED_BUFFER_H__ 3 | 4 | #include 5 | 6 | /**\addtogroup file_api 7 | @{ 8 | */ 9 | 10 | /**\brief Creates a mixed binary/text file double ended queue. 11 | \param encoding The encoding name. Possible values are "latin1", and 12 | "base85" 13 | \param out_textfile Will be set to the readable/writable text end. 14 | \param out_binfile Will be set to the readable/writable binary end. 15 | */ 16 | PMATH_API 17 | PMATH_ATTRIBUTE_NONNULL(1) 18 | void pmath_file_create_mixed_buffer( 19 | const char *encoding, 20 | pmath_symbol_t *out_textfile, 21 | pmath_symbol_t *out_binfile); 22 | 23 | /** @} */ 24 | 25 | #endif // __PMATH_UTIL__FILES__MIXED_BUFFER_H__ 26 | -------------------------------------------------------------------------------- /library/scripts/auto/core/Developer/OpenTextFile.pmath: -------------------------------------------------------------------------------- 1 | 2 | BeginPackage("Developer`") 3 | 4 | Developer`OpenTextFile 5 | Developer`SourceLocationOpenerFunction 6 | 7 | Begin("Developer`Private`") 8 | 9 | Options(OpenTextFile):= {Line->Automatic, Column->Automatic} 10 | Function OpenTextFile(~filename:String, opts:OptionsPattern()) { 11 | If($SystemID === "Windows") { 12 | With(path:= $NamespacePath) 13 | Block({$NamespacePath:= path}, Get("Windows`")) 14 | Return(Windows`Editors`OpenTextFile(filename, opts)) 15 | } 16 | $Failed 17 | } 18 | 19 | SourceLocationOpenerFunction(~)::= None 20 | Function SourceLocationOpenerFunction(Language`SourceLocation(~path, {~l1, ~c1} .. {~l2, ~c2})) { 21 | If(FileInformation(path) =!= {}) { 22 | Return(OpenTextFile(path, Line->l1, Column->c1) &) 23 | } 24 | Return(None) 25 | } 26 | 27 | End() 28 | 29 | EndPackage() 30 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/logic/xor.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | 6 | extern pmath_symbol_t pmath_System_False; 7 | extern pmath_symbol_t pmath_System_True; 8 | 9 | PMATH_PRIVATE pmath_t builtin_xor(pmath_expr_t expr) { 10 | pmath_bool_t result = FALSE; 11 | size_t i; 12 | 13 | for(i = pmath_expr_length(expr); i > 0; --i) { 14 | pmath_t item = pmath_expr_get_item(expr, i); 15 | pmath_unref(item); 16 | 17 | if(pmath_same(item, pmath_System_True)) { 18 | result = (result != FALSE); 19 | } 20 | else if(pmath_same(item, pmath_System_False)) { 21 | result = (result == FALSE); 22 | } 23 | else 24 | return expr; 25 | } 26 | 27 | pmath_unref(expr); 28 | return pmath_ref(result ? pmath_System_True : pmath_System_False); 29 | } 30 | -------------------------------------------------------------------------------- /library/scripts/auto/core/format/syntax.pmath: -------------------------------------------------------------------------------- 1 | 2 | Begin("System`Private`") 3 | 4 | System`Private`MakeLimitsExpression 5 | System`Private`MakeScriptsExpression 6 | System`Private`MakeJuxtapositionExpression 7 | 8 | Options(SqrtBox):= Options(RadicalBox):= { SurdForm -> False } 9 | Options(OverscriptBox):= Options(UnderoverscriptBox):= Options(UnderscriptBox):= { LimitsPositioning -> Automatic } 10 | 11 | Unprotect( 12 | System`Private`MakeLimitsExpression, 13 | System`Private`MakeScriptsExpression, 14 | System`Private`MakeJuxtapositionExpression) 15 | 16 | MakeLimitsExpression(~~~):= Default 17 | MakeScriptsExpression(~~~):= Default 18 | MakeJuxtapositionExpression(~~~):= Default 19 | 20 | Protect( 21 | System`Private`MakeLimitsExpression, 22 | System`Private`MakeScriptsExpression, 23 | System`Private`MakeJuxtapositionExpression) 24 | 25 | End() 26 | -------------------------------------------------------------------------------- /richmath/include/syntax/scope-colorizer.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__SYNTAX__SCOPE_COLORIZER_H__INCLUDED 2 | #define RICHMATH__SYNTAX__SCOPE_COLORIZER_H__INCLUDED 3 | 4 | #include 5 | #include 6 | 7 | 8 | namespace richmath { 9 | class MathSequence; 10 | class SpanExpr; 11 | 12 | class ScopeColorizer: public Base { 13 | public: 14 | explicit ScopeColorizer(MathSequence &sequence); 15 | 16 | void scope_colorize_spanexpr(SyntaxState &state, SpanExpr *se); 17 | 18 | void comments_colorize(); 19 | 20 | void syntax_colorize_spanexpr(SpanExpr *se); 21 | 22 | void arglist_errors_colorize_spanexpr(SpanExpr *se, float error_indicator_height); 23 | 24 | private: 25 | MathSequence &sequence; 26 | }; 27 | } 28 | 29 | #endif // RICHMATH__SYNTAX__SCOPE_COLORIZER_H__INCLUDED 30 | -------------------------------------------------------------------------------- /richmath/include/util/filesystem.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__UTIL__FILESYSTEM_H__INCLUDED 2 | #define RICHMATH__UTIL__FILESYSTEM_H__INCLUDED 3 | 4 | #include 5 | 6 | namespace richmath { 7 | struct FileSystem { 8 | static String to_existing_absolute_file_name(String filename); 9 | static String to_possibly_nonexisting_absolute_file_name(String filename); 10 | 11 | static String file_name_join(String dir, String name); 12 | static bool is_filename_without_directory(String filename); 13 | 14 | static String extract_directory_path(String *filename); 15 | 16 | static String get_directory_path(String filename) { return extract_directory_path(&filename); } 17 | 18 | static String get_uri_scheme(String uri); 19 | static String get_local_path_from_uri(String uri); 20 | }; 21 | } 22 | 23 | #endif // RICHMATH__UTIL__FILESYSTEM_H__INCLUDED 24 | -------------------------------------------------------------------------------- /editors/pmath-vscode/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pmath", 3 | "version": "0.2.0", 4 | "engines": { 5 | "vscode": "*" 6 | }, 7 | "publisher": "Peter Frentrup", 8 | "contributes": { 9 | "languages": [ 10 | { 11 | "id": "pMath", 12 | "aliases": [ "pMath", "pmath" ], 13 | "extensions": [ ".pmath" ], 14 | "configuration": "./language-configuration.json" 15 | } 16 | ], 17 | "grammars": [ 18 | { 19 | "language": "pMath", 20 | "scopeName": "source.pmath", 21 | "path": "./syntaxes/pmath.tmLanguage" 22 | } 23 | ], 24 | "snippets": [ 25 | { 26 | "language": "pMath", 27 | "path": "./snippets/pmath.json" 28 | } 29 | ] 30 | } 31 | } -------------------------------------------------------------------------------- /library/src/pmath-builtins/lists/total.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include 6 | 7 | 8 | extern pmath_symbol_t pmath_System_Plus; 9 | 10 | pmath_t builtin_total(pmath_expr_t expr) { 11 | /* Total(list) = Plus @@ list 12 | 13 | 14 | TODO: see Kahan summation algorithm for higher accuracy 15 | */ 16 | pmath_t item; 17 | 18 | if(pmath_expr_length(expr) != 1) { 19 | pmath_message_argxxx(pmath_expr_length(expr), 1, 1); 20 | return expr; 21 | } 22 | 23 | item = pmath_expr_get_item(expr, 1); 24 | if(!pmath_is_expr(item)) { 25 | pmath_unref(item); 26 | pmath_message(PMATH_NULL, "nexprat", 2, PMATH_FROM_INT32(1), pmath_ref(expr)); 27 | return expr; 28 | } 29 | 30 | pmath_unref(expr); 31 | return pmath_expr_set_item(item, 0, pmath_ref(pmath_System_Plus)); 32 | } 33 | -------------------------------------------------------------------------------- /richmath/include/gui/win32/menus/win32-menu-gutter-slider.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__WIN32__MENUS__WIN32_MENU_GUTTER_SLIDER_H__INCLUDED 2 | #define RICHMATH__GUI__WIN32__MENUS__WIN32_MENU_GUTTER_SLIDER_H__INCLUDED 3 | 4 | #ifndef RICHMATH_USE_WIN32_GUI 5 | # error this header is win32 specific 6 | #endif 7 | 8 | #include 9 | 10 | namespace richmath { 11 | class Win32MenuGutterSlider : public Win32MenuItemOverlay { 12 | class Impl; 13 | public: 14 | virtual void update_rect(HWND hwnd, HMENU menu) override; 15 | virtual void initialize(HWND hwnd, HMENU menu) override; 16 | virtual bool handle_mouse_message(UINT msg, WPARAM wParam, const POINT &pt, HMENU menu) override; 17 | 18 | public: 19 | Expr lhs; 20 | Expr scope; 21 | }; 22 | } 23 | 24 | #endif // RICHMATH__GUI__WIN32__MENUS__WIN32_MENU_GUTTER_SLIDER_H__INCLUDED 25 | -------------------------------------------------------------------------------- /modules/Java/library/src/pj-values.h: -------------------------------------------------------------------------------- 1 | #ifndef __PJ_VALUES_H__ 2 | #define __PJ_VALUES_H__ 3 | 4 | #include 5 | #include 6 | 7 | 8 | PMATH_PRIVATE pmath_string_t pj_string_from_java(JNIEnv *env, jstring jstr); 9 | PMATH_PRIVATE jstring pj_string_to_java( JNIEnv *env, pmath_string_t str); // str will be freed; returns local ref 10 | 11 | // obj will be freed 12 | PMATH_PRIVATE jobject pj_value_to_java_object(JNIEnv *env, pmath_t obj, jclass type); 13 | 14 | // obj will be freed; type wont be freed 15 | PMATH_PRIVATE pmath_bool_t pj_value_to_java( JNIEnv *env, pmath_t obj, pmath_t type, jvalue *value); 16 | PMATH_PRIVATE pmath_t pj_value_from_java(JNIEnv *env, char type, const jvalue *value); 17 | 18 | // args and types wont be freed 19 | PMATH_PRIVATE pmath_bool_t pj_value_fill_args(JNIEnv *env, pmath_expr_t types, pmath_expr_t args, jvalue *jargs); 20 | 21 | 22 | #endif // __PJ_VALUES_H__ 23 | -------------------------------------------------------------------------------- /richmath/resources/richmath.rc: -------------------------------------------------------------------------------- 1 | #define _WIN32_WINNT 0x600 2 | 3 | #include 4 | #include "resources.h" 5 | 6 | 1 24 "Windows.manifest" 7 | 8 | 9 | ICO_APP_MAIN ICON "app-icon.ico" 10 | ICO_FILE ICON "file-icon.ico" 11 | 12 | 13 | CUR_TEXT_N CURSOR "text_beam_n.cur" 14 | CUR_TEXT_NW CURSOR "text_beam_nw.cur" 15 | CUR_TEXT_W CURSOR "text_beam_w.cur" 16 | CUR_TEXT_SW CURSOR "text_beam_sw.cur" 17 | CUR_TEXT_S CURSOR "text_beam_s.cur" 18 | CUR_TEXT_SE CURSOR "text_beam_se.cur" 19 | CUR_TEXT_E CURSOR "text_beam_e.cur" 20 | CUR_TEXT_NE CURSOR "text_beam_ne.cur" 21 | CUR_SECTION CURSOR "section_beam.cur" 22 | CUR_DOCUMENT CURSOR "document_beam.cur" 23 | CUR_NOSELECT CURSOR "no_select.cur" 24 | CUR_GRAB CURSOR "grab_hand.cur" 25 | CUR_GRABBING CURSOR "grabbing.cur" 26 | 27 | 28 | BMP_PIN16 BITMAP "pin16.bmp" 29 | BMP_PIN24 BITMAP "pin24.bmp" 30 | BMP_PIN32 BITMAP "pin32.bmp" 31 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/datetime/timing.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | 10 | extern pmath_symbol_t pmath_System_List; 11 | 12 | PMATH_PRIVATE pmath_t builtin_timing(pmath_expr_t expr) { 13 | pmath_t obj; 14 | double start, end; 15 | 16 | if(pmath_expr_length(expr) != 1) { 17 | pmath_message_argxxx(pmath_expr_length(expr), 1, 1); 18 | return expr; 19 | } 20 | 21 | start = pmath_tickcount(); 22 | 23 | obj = pmath_expr_get_item(expr, 1); 24 | pmath_unref(expr); 25 | obj = pmath_evaluate(obj); 26 | 27 | end = pmath_tickcount(); 28 | 29 | return pmath_expr_new_extended( 30 | pmath_ref(pmath_System_List), 2, 31 | PMATH_FROM_DOUBLE(end - start), 32 | obj); 33 | } 34 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/language/symbolname.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | 6 | PMATH_PRIVATE pmath_t builtin_symbolname(pmath_expr_t expr) { 7 | pmath_t sym; 8 | 9 | if(pmath_expr_length(expr) != 1) { 10 | pmath_message_argxxx(pmath_expr_length(expr), 1, 1); 11 | return expr; 12 | } 13 | 14 | sym = pmath_expr_get_item(expr, 1); 15 | if(pmath_is_symbol(sym)) { 16 | pmath_string_t name = pmath_symbol_name(sym); 17 | const uint16_t *buf = pmath_string_buffer(&name); 18 | int len = pmath_string_length(name); 19 | 20 | pmath_unref(expr); 21 | pmath_unref(sym); 22 | 23 | --len; 24 | while(len > 0 && buf[len] != '`') 25 | --len; 26 | 27 | return pmath_string_part(name, len + 1, -1); 28 | } 29 | 30 | pmath_message(PMATH_NULL, "sym", 2, sym, PMATH_FROM_INT32(1)); 31 | return expr; 32 | } 33 | -------------------------------------------------------------------------------- /richmath/include/gui/gtk/mgtk-dragdrophandler.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__GTK__MGTK_DRAGDROPHANDLER_H__INCLUDED 2 | #define RICHMATH__GUI__GTK__MGTK_DRAGDROPHANDLER_H__INCLUDED 3 | 4 | #ifndef RICHMATH_USE_GTK_GUI 5 | # error this header is gtk specific 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | 12 | namespace richmath { 13 | class MathGtkDragDropHandler final : public DragDropHandler { 14 | public: 15 | explicit MathGtkDragDropHandler(GdkDragContext *context); 16 | virtual ~MathGtkDragDropHandler(); 17 | 18 | virtual MenuCommandStatus can_drop(DropAction action) override; 19 | virtual bool do_drop(DropAction action) override; 20 | 21 | static GdkDragAction native_action(DropAction action); 22 | 23 | private: 24 | GdkDragContext *_context; 25 | }; 26 | } 27 | 28 | #endif // RICHMATH__GUI__GTK__MGTK_DRAGDROPHANDLER_H__INCLUDED 29 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/number-theory/bitnot.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | 7 | pmath_t builtin_bitnot(pmath_expr_t expr) { 8 | pmath_mpint_t item; 9 | 10 | if(pmath_expr_length(expr) != 1) { 11 | pmath_message_argxxx(pmath_expr_length(expr), 1, 1); 12 | return expr; 13 | } 14 | 15 | item = pmath_expr_get_item(expr, 1); 16 | if(pmath_is_int32(item)) 17 | item = _pmath_create_mp_int(PMATH_AS_INT32(item)); 18 | 19 | if(pmath_is_mpint(item)) { 20 | pmath_mpint_t result = _pmath_create_mp_int(0); 21 | 22 | if(!pmath_is_null(result)) { 23 | pmath_unref(expr); 24 | 25 | mpz_com(PMATH_AS_MPZ(result), PMATH_AS_MPZ(item)); 26 | 27 | pmath_unref(item); 28 | return _pmath_mp_int_normalize(result); 29 | } 30 | } 31 | 32 | pmath_unref(item); 33 | return expr; 34 | } 35 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/parallel/getthreadid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #if PMATH_USE_PTHREAD 5 | # include 6 | 7 | # include 8 | #elif PMATH_USE_WINDOWS_THREADS 9 | # include 10 | #endif 11 | 12 | 13 | PMATH_PRIVATE pmath_t builtin_getthreadid(pmath_expr_t expr) { 14 | pmath_unref(expr); 15 | 16 | #if PMATH_USE_PTHREAD 17 | { 18 | pmath_integer_t result = _pmath_create_mp_int(0); 19 | pthread_t thread = pthread_self(); 20 | 21 | if(!pmath_is_null(result)) { 22 | mpz_import( 23 | PMATH_AS_MPZ(result), 24 | sizeof(pthread_t), 25 | 1, 26 | 1, 27 | 0, 28 | 0, 29 | &thread); 30 | } 31 | 32 | return result; 33 | } 34 | #elif PMATH_USE_WINDOWS_THREADS 35 | return pmath_integer_new_ulong((unsigned long)GetCurrentThreadId()); 36 | #endif 37 | } 38 | -------------------------------------------------------------------------------- /modules/System/QuantityUnits/sums.pmath: -------------------------------------------------------------------------------- 1 | BeginPackage("System`QuantityUnits`") 2 | 3 | Begin("System`QuantityUnits`Private`") 4 | 5 | 6 | QuantityPlus(~~~)::= $Failed 7 | QuantityPlus(HoldPattern(Quantity(~mag1, ~unit)), HoldPattern(Quantity(~mag2, ~unit))) ::= newValidQuanitity(mag1 + mag2, unit) 8 | Function QuantityPlus(HoldPattern(Quantity(~mag1, ~unit1)), HoldPattern(Quantity(~mag2, ~unit2))) { 9 | With(fund1 := unit1 |> Replace(~s:String :> $AllUnits[s, "FundamentalUnitValue"], 0..)) 10 | With(fund2 := unit2 |> Replace(~s:String :> $AllUnits[s, "FundamentalUnitValue"], 0..)) 11 | 12 | With(ratio:= fund2 / fund1) 13 | 14 | If(ratio.IsReal =!= True) { 15 | Message(Quantity::compat, unit1, unit2) 16 | Return($Failed) 17 | } 18 | 19 | %newValidQuanitity(mag1 + mag2 * ratio, unit1) 20 | ConsolidateValidQuantityUnits(mag1 + mag2 * ratio, unit1, unit2) 21 | } 22 | 23 | 24 | End() 25 | 26 | EndPackage() 27 | -------------------------------------------------------------------------------- /richmath/post-build-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | # 3 | # argument $1 is pmath library build name ( ../library/bin/linux/$1/* ) 4 | # argument $2 is dependency architecture ( dependencies/linux/$2/* ) 5 | # argument $3 is target build name ( bin/linux/$3/* ) 6 | 7 | 8 | 9 | function ln-copy { 10 | ln -sf "$1" "$2" 11 | if [ "$?" != "0" ]; then 12 | cp "$1" "$2" 13 | fi 14 | } 15 | 16 | mkdir -p dependencies/linux/$2 17 | 18 | cp ../library/bin/linux/$1/*.so.0.1 bin/linux/$3/ 19 | cp -r dependencies/default/. bin/linux/$3/ 20 | cp -r dependencies/linux/$2/. bin/linux/$3/ 21 | 22 | function ln-copy-all { 23 | ln-copy $(pwd)/libpmath.so.0.1 libpmath.so.0 24 | ln-copy $(pwd)/libpmath.so.0 libpmath.so 25 | } 26 | 27 | pushd bin/linux/$3 28 | ln-copy-all 29 | 30 | # add $ORIGIN to the rpath. Due to the $ sign, this cannot reliably be done through Code::Blocks IDE 31 | chrpath -r '$ORIGIN' ./richmath 32 | 33 | popd 34 | 35 | -------------------------------------------------------------------------------- /debugging/windbg/init.wds: -------------------------------------------------------------------------------- 1 | $$ initialize script aliases 2 | 3 | .echo "init pmath aliases" 4 | aS ${/v:pmath-init-dbg} $$>a<"${$arg0}" 5 | aS ${/v:pmath-dbg-path} ${$arg0}\.. 6 | 7 | .block { 8 | aS ${/v:pmath-print-object-link} $$>a<"${pmath-dbg-path}\print-object-link.wds" 9 | aS ${/v:pmath-print-object-simple} $$>a<"${pmath-dbg-path}\print-object-simple.wds" 10 | aS ${/v:pmath-print-string-buffer} $$>a<"${pmath-dbg-path}\print-string-buffer.wds" 11 | aS ${/v:pmath-print-escape-char} $$>a<"${pmath-dbg-path}\print-escape-char.wds" 12 | aS ${/v:pmath-print-expr} $$>a<"${pmath-dbg-path}\print-expr.wds" 13 | aS ${/v:pmath-inspect-object-bits} $$>a<"${pmath-dbg-path}\inspect-object-bits.wds" 14 | aS ${/v:pmath-inspect} $$>a<"${pmath-dbg-path}\inspect.wds" 15 | 16 | aS ${/v:debugpmath} $$>a<"${pmath-dbg-path}\debugpmath.wds" 17 | 18 | .nvload "${pmath-dbg-path}\pmath.natvis" 19 | .nvload "${pmath-dbg-path}\richmath.natvis" 20 | } 21 | -------------------------------------------------------------------------------- /library/test-suite/tests/ToCharacterCode.pmath: -------------------------------------------------------------------------------- 1 | 2 | AssertEqual(ToCharacterCode("abc"), {97, 98, 99}) 3 | 4 | AssertEqual(ToCharacterCode("XYZ"), {88, 89, 90}) 5 | 6 | AssertEqual(ToCharacterCode("\[Alpha]\[Beta]"), {16^^3b1, 16^^3b2}) 7 | 8 | AssertEqual(ToCharacterCode("\[Alpha]\[Beta]", "UTF-8"), {16^^ce, 16^^B1, 16^^ce, 16^^b2}) 9 | 10 | AssertEqual(ToCharacterCode("\[Sum]"), {16^^2211}) 11 | 12 | AssertEqual(ToCharacterCode("\[Sum]", "UTF-8"), {16^^E2, 16^^88, 16^^91}) 13 | 14 | AssertEqual(ToCharacterCode("\[U+1234]\[U+0000]\[U+FFFF]"), {16^^1234, 0, 16^^ffff}) 15 | 16 | AssertEqual(ToCharacterCode("\[U+12345]", "Unicode"), {16^^12345}) 17 | AssertEqual(ToCharacterCode("\[U+12345]", "UTF-32"), {16^^12345}) 18 | AssertEqual(ToCharacterCode("\[U+12345]"), {16^^D808, 16^^DF45}) 19 | AssertEqual(ToCharacterCode("\[U+12345]", "UTF-16"), {16^^D808, 16^^DF45}) 20 | AssertEqual(ToCharacterCode("\[U+12345]", "UTF-8"), {16^^F0, 16^^92, 16^^8D, 16^^85}) 21 | -------------------------------------------------------------------------------- /modules/System/Numerics/simplify-airy.pmath: -------------------------------------------------------------------------------- 1 | BeginPackage("System`Numerics`Airy`") 2 | 3 | System`Private`AutoSimplifyAiry 4 | 5 | Begin("System`Numerics`Airy`Private`") 6 | 7 | % 8 | % If direct (numerical) calculation of AiryAi(x), AiryAiPrime(x), etc. is not possible (because 9 | % x is an expression or an exact number), System`Private`AutoSimplifyAiry(AiryAi, x) 10 | % etc. get called. 11 | % If that returns $Failed, the original expression AiryAi(x) etc. remains unevaluated. 12 | % Otherwise, the result of AutoSimplifyAiry will be returned. 13 | % 14 | System`Private`AutoSimplifyAiry(~, ~):= $Failed 15 | 16 | System`Private`AutoSimplifyAiry(AiryAi, 0):= 1/(3^(2/3) Gamma(2/3)) 17 | System`Private`AutoSimplifyAiry(AiryAiPrime, 0):= -1/(3^(1/3) Gamma(1/3)) 18 | System`Private`AutoSimplifyAiry(AiryBi, 0):= 1/(3^(1/6) Gamma(2/3)) 19 | System`Private`AutoSimplifyAiry(AiryBiPrime, 0):= 3^(1/6) / Gamma(1/3) 20 | 21 | 22 | End() 23 | 24 | EndPackage() 25 | -------------------------------------------------------------------------------- /richmath/include/graphics/callout-triangle.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GRAPHICS__CALLOUT_TRIANGLE_H__INCLUDED 2 | #define RICHMATH__GRAPHICS__CALLOUT_TRIANGLE_H__INCLUDED 3 | 4 | 5 | #include 6 | #include 7 | 8 | namespace richmath { 9 | struct CalloutTriangle { 10 | float x_base_from; 11 | float x_base_to; 12 | float x_tip_projection; 13 | float y_tip_height; 14 | 15 | static CalloutTriangle ForBasePointingToTarget(const Interval &base, const Interval &target, float tip_size); 16 | static CalloutTriangle ForSideOfBasePointingToTarget(const RectangleF &base, Side side, const RectangleF &target, float tip_size, bool relative); 17 | 18 | void offset_x(float dx); 19 | void swap_x_base(); 20 | 21 | void get_triangle_points(Point out_points[3], const RectangleF &base, Side side) const; 22 | }; 23 | } 24 | 25 | #endif // RICHMATH__GRAPHICS__CALLOUT_TRIANGLE_H__INCLUDED 26 | -------------------------------------------------------------------------------- /richmath/include/eval/partial-dynamic.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__EVAL__PARTIAL_DYNAMIC_H__INCLUDED 2 | #define RICHMATH__EVAL__PARTIAL_DYNAMIC_H__INCLUDED 3 | 4 | #include 5 | 6 | namespace richmath { 7 | class StyledObject; 8 | 9 | class PartialDynamic { 10 | class Impl; 11 | public: 12 | PartialDynamic(); 13 | PartialDynamic(StyledObject *owner, Expr expr); 14 | 15 | void operator=(Expr expr); 16 | 17 | StyledObject *owner() { return _owner; } 18 | Expr expr() const { return _held_expr[1]; } 19 | 20 | Expr get_value_now(); 21 | void get_value_later(Expr job_info); 22 | bool get_value(Expr *result, Expr job_info); 23 | Expr finish_dynamic(Expr dyn_eval_result); 24 | 25 | private: 26 | Expr _dyn_eval_template; 27 | Expr _held_expr; 28 | StyledObject *_owner; 29 | }; 30 | } 31 | 32 | #endif // RICHMATH__EVAL__PARTIAL_DYNAMIC_H__INCLUDED 33 | -------------------------------------------------------------------------------- /library/scripts/auto/core/streams.pmath: -------------------------------------------------------------------------------- 1 | Begin("System`Private`") 2 | 3 | Unprotect(InputStream, OutputStream) 4 | 5 | % TODO: warn when trying to change BinaryFormat or CharacterEncoding options 6 | InputStream/: SetOptions(InputStream(~obj:Symbol), ~rules)::= SetOptions(obj, rules) 7 | OutputStream/: SetOptions(OutputStream(~obj:Symbol), ~rules)::= SetOptions(obj, rules) 8 | 9 | MakeBoxes(InputStream(~obj:Symbol))::= TemplateBox({MakeBoxes(LongForm(obj))}, "InputStream") 10 | MakeBoxes(OutputStream(~obj:Symbol))::= TemplateBox({MakeBoxes(LongForm(obj))}, "OutputStream") 11 | 12 | Function Format(InputStream(~obj:Symbol,~~~)) { 13 | With(opts:= Options(Unevaluated(obj))) 14 | 15 | "InputStream"(Skeleton(Lookup(opts, File, ""))) 16 | } 17 | Function Format(OutputStream(~obj:Symbol,~~~)) { 18 | With(opts:= Options(Unevaluated(obj))) 19 | 20 | "OutputStream"(Skeleton(Lookup(opts, File, ""))) 21 | } 22 | 23 | 24 | Protect(InputStream, OutputStream) 25 | 26 | End() 27 | -------------------------------------------------------------------------------- /richmath/src/gui/win32/api/win32-version.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | using namespace richmath; 5 | 6 | //{ class Win32Version ... 7 | 8 | void Win32Version::init() { 9 | static Win32Version w; 10 | } 11 | 12 | Win32Version::Win32Version() { 13 | } 14 | 15 | Win32Version::~Win32Version() { 16 | } 17 | 18 | bool Win32Version::check_osversion(int min_major, int min_minor, int min_build) { 19 | OSVERSIONINFO osvi; 20 | memset(&osvi, 0, sizeof(osvi)); 21 | osvi.dwOSVersionInfoSize = sizeof(osvi); 22 | GetVersionEx(&osvi); 23 | 24 | if((int)osvi.dwMajorVersion > min_major) 25 | return true; 26 | 27 | if((int)osvi.dwMajorVersion < min_major) 28 | return false; 29 | 30 | if((int)osvi.dwMinorVersion > min_minor) 31 | return true; 32 | 33 | if((int)osvi.dwMinorVersion < min_minor) 34 | return false; 35 | 36 | return (int)osvi.dwBuildNumber >= min_build; 37 | } 38 | 39 | //} ... class Win32Version 40 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/control/match.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include 6 | 7 | 8 | extern pmath_symbol_t pmath_System_False; 9 | extern pmath_symbol_t pmath_System_True; 10 | 11 | PMATH_PRIVATE pmath_t builtin_match(pmath_expr_t expr){ 12 | /* Match(obj, pattern) 13 | */ 14 | pmath_t obj, pat; 15 | 16 | if(pmath_expr_length(expr) != 2){ 17 | pmath_message_argxxx(pmath_expr_length(expr), 2, 2); 18 | return expr; 19 | } 20 | 21 | obj = pmath_expr_get_item(expr, 1); 22 | pat = pmath_expr_get_item(expr, 2); 23 | if(!_pmath_pattern_validate(pat)) { 24 | pmath_unref(obj); 25 | pmath_unref(pat); 26 | return expr; 27 | } 28 | 29 | pmath_unref(expr); 30 | 31 | if(_pmath_pattern_match(obj, pat, NULL)){ 32 | pmath_unref(obj); 33 | return pmath_ref(pmath_System_True); 34 | } 35 | 36 | pmath_unref(obj); 37 | return pmath_ref(pmath_System_False); 38 | } 39 | -------------------------------------------------------------------------------- /library/scripts/auto/core/format/rawboxes.pmath: -------------------------------------------------------------------------------- 1 | /* RawBoxes 2 | System`BoxForm`$UseTextFormatting 3 | System`BoxForm`MakeCallBoxes 4 | */ 5 | 6 | Begin("System`BoxForm`Private`") 7 | 8 | System`BoxForm`$UseTextFormatting:= False 9 | Attributes(System`BoxForm`$UseTextFormatting):= {ThreadLocal} 10 | 11 | 12 | SetAttributes(System`BoxForm`MakeCallBoxes, {HoldAllComplete}); 13 | 14 | System`BoxForm`MakeCallBoxes(~h())::= {MakeBoxes(h), "(", ")"} 15 | System`BoxForm`MakeCallBoxes(~h(~x))::= {MakeBoxes(h), "(", MakeBoxes(x), ")"} 16 | System`BoxForm`MakeCallBoxes(~h(~~xs))::= {MakeBoxes(h), "(", {xs}.Unevaluated.Map(MakeBoxes).Riffle(","), ")"} 17 | 18 | Protect(System`BoxForm`MakeCallBoxes) 19 | 20 | 21 | Unprotect(RawBoxes) 22 | 23 | MakeBoxes(r: RawBoxes(~x))::= 24 | If(Refresh(System`BoxForm`$UseTextFormatting === True, None), 25 | System`BoxForm`MakeCallBoxes(r) 26 | , 27 | x 28 | ) 29 | 30 | SetAttributes(RawBoxes, {Protected, ReadProtected}); 31 | 32 | End() 33 | -------------------------------------------------------------------------------- /library/scripts/auto/hyper-console/init.pmath: -------------------------------------------------------------------------------- 1 | 2 | BeginPackage("System`Con`") 3 | 4 | PrintWelcomeMessage 5 | PrintHelpMessage 6 | 7 | Begin("System`Con`Private`") 8 | 9 | Unprotect($HyperlinksSupported) 10 | $HyperlinksSupported:= True 11 | Protect($HyperlinksSupported) 12 | 13 | Unprotect(ShowDefinition) 14 | Function ShowDefinition(~s:String) { 15 | With(n:= Names(s)) 16 | SectionPrint("PrintUsage", n.Sort.Map(Button(#, ShowDefinition(#)) &).Row("\n")) /? Length(n) > 1 17 | } 18 | Protect(ShowDefinition) 19 | 20 | 21 | Function PrintWelcomeMessage() { 22 | Print("Welcome to pMath."); 23 | 24 | PrintHelpMessage(); 25 | } 26 | 27 | Function PrintHelpMessage() { 28 | With(names:= Names("System`*")) 29 | With(i:= RandomInteger(1..Length(names))) 30 | With(randomName:= names[i]) 31 | 32 | Print( 33 | "Type `", 34 | Button("??symbol", ShowDefinition(randomName)), 35 | "` to get help about a symbol. Exit with `", 36 | Button("Quit()", Quit()), 37 | "`.") 38 | } 39 | 40 | End() 41 | 42 | EndPackage() 43 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/control/loadlibrary.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | 7 | extern pmath_symbol_t pmath_System_DollarFailed; 8 | 9 | PMATH_PRIVATE pmath_t builtin_loadlibrary(pmath_expr_t expr){ 10 | /* LoadLibrary(filename) 11 | */ 12 | pmath_t filename; 13 | 14 | if(pmath_expr_length(expr) != 1){ 15 | pmath_message_argxxx(pmath_expr_length(expr), 1, 1); 16 | } 17 | 18 | filename = pmath_expr_get_item(expr, 1); 19 | pmath_unref(expr); 20 | 21 | if(!pmath_is_string(filename) 22 | || pmath_string_length(filename) == 0){ 23 | pmath_message(PMATH_NULL, "fstr", 1, filename); 24 | return pmath_ref(pmath_System_DollarFailed); 25 | } 26 | 27 | if(!_pmath_module_load(pmath_ref(filename))){ 28 | pmath_message(PMATH_NULL, "fail", 1, filename); 29 | return pmath_ref(pmath_System_DollarFailed); 30 | } 31 | 32 | pmath_unref(filename); 33 | return PMATH_NULL; 34 | } 35 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/io/characters.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | 6 | extern pmath_symbol_t pmath_System_List; 7 | 8 | PMATH_PRIVATE pmath_t builtin_characters(pmath_expr_t expr) { 9 | /* Characters(string) 10 | */ 11 | pmath_string_t string; 12 | 13 | if(pmath_expr_length(expr) != 1) { 14 | pmath_message_argxxx(pmath_expr_length(expr), 1, 1); 15 | return expr; 16 | } 17 | 18 | string = pmath_expr_get_item(expr, 1); 19 | 20 | if(pmath_is_string(string)) { 21 | size_t i; 22 | 23 | pmath_unref(expr); 24 | expr = pmath_expr_new( 25 | pmath_ref(pmath_System_List), 26 | (size_t)pmath_string_length(string)); 27 | 28 | for(i = pmath_expr_length(expr); i > 0; --i) 29 | expr = pmath_expr_set_item( 30 | expr, i, 31 | pmath_string_part(pmath_ref(string), (int)i - 1, 1)); 32 | } 33 | 34 | pmath_unref(string); 35 | return expr; 36 | } 37 | -------------------------------------------------------------------------------- /library/include/pmath-builtins/io-private.h: -------------------------------------------------------------------------------- 1 | #ifndef __PMATH_BUILTINS__IO_PRIVATE_H__ 2 | #define __PMATH_BUILTINS__IO_PRIVATE_H__ 3 | 4 | #ifndef BUILDING_PMATH 5 | # error This header file is not part of the public pMath API 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | /* This header exports all definitions of the sources in 12 | src/pmath-builtins/io/ 13 | */ 14 | 15 | // 0 = invalid, -1 = LE, 1 = BE 16 | PMATH_PRIVATE int _pmath_get_byte_ordering(pmath_t head, pmath_expr_t options); 17 | 18 | PMATH_PRIVATE pmath_bool_t _pmath_file_check(pmath_t file, int properties); 19 | 20 | PMATH_PRIVATE 21 | PMATH_ATTRIBUTE_USE_RESULT 22 | pmath_string_t _pmath_get_directory(void); 23 | 24 | 25 | PMATH_PRIVATE void _init_pmath_native_encoding(void); // called from _pmath_strings_init() 26 | 27 | extern PMATH_PRIVATE const char *_pmath_native_encoding; 28 | extern PMATH_PRIVATE pmath_bool_t _pmath_native_encoding_is_utf8; 29 | 30 | #endif /* __PMATH_BUILTINS__IO_PRIVATE_H__ */ 31 | -------------------------------------------------------------------------------- /richmath/include/gui/win32/win32-filedialog.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__WIN32__WIN32_FILEDIALOG_H__INCLUDED 2 | #define RICHMATH__GUI__WIN32__WIN32_FILEDIALOG_H__INCLUDED 3 | 4 | #ifndef RICHMATH_USE_WIN32_GUI 5 | # error this header is win32 specific 6 | #endif 7 | 8 | #include 9 | #include 10 | 11 | 12 | namespace richmath { 13 | class Win32FileDialog: public Base { 14 | class Impl; 15 | public: 16 | Win32FileDialog(bool to_save); 17 | ~Win32FileDialog(); 18 | 19 | void set_title(pmath::String title); 20 | void set_filter(pmath::Expr filter); 21 | void set_initial_file(pmath::String initialfile); 22 | 23 | pmath::Expr show_dialog(); 24 | 25 | private: 26 | pmath::String _title_z; 27 | pmath::String _filters_z; 28 | pmath::String _default_extension_z; 29 | pmath::String _initialfile; 30 | bool _to_save; 31 | }; 32 | } 33 | 34 | 35 | #endif // RICHMATH__GUI__WIN32__WIN32_FILEDIALOG_H__INCLUDED 36 | -------------------------------------------------------------------------------- /library/include/pmath-util/files/text-from-binary.h: -------------------------------------------------------------------------------- 1 | #ifndef __PMATH_UTIL__FILES__TEXT_FROM_BINARY_FILE_H__ 2 | #define __PMATH_UTIL__FILES__TEXT_FROM_BINARY_FILE_H__ 3 | 4 | #include 5 | 6 | /**\addtogroup file_api 7 | @{ 8 | */ 9 | 10 | /**\brief Create a text file object operating on a binary file. 11 | \param binfile A binary file. It will be freed. 12 | \param encoding A text encoding that the iconv library knows. 13 | \return A newly created text file object. You can destroy and close it with 14 | pmath_file_close() or pmath_unref(). 15 | 16 | If \a binfile is readable, the resulting textfile will be readable. 17 | If \a binfile is writable, the resulting textfile will be writable. 18 | */ 19 | PMATH_API 20 | PMATH_ATTRIBUTE_USE_RESULT 21 | PMATH_ATTRIBUTE_NONNULL(2) 22 | pmath_symbol_t pmath_file_create_text_from_binary( 23 | pmath_t binfile, 24 | const char *encoding); 25 | 26 | /** @} */ 27 | 28 | #endif // __PMATH_UTIL__FILES__TEXT_FROM_BINARY_FILE_H__ 29 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/gui/button.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | 6 | PMATH_PRIVATE pmath_t builtin_button(pmath_expr_t expr) { 7 | size_t i; 8 | 9 | size_t exprlen = pmath_expr_length(expr); 10 | if(exprlen < 1) { 11 | pmath_message_argxxx(pmath_expr_length(expr), 1, 2); 12 | return expr; 13 | } 14 | 15 | if(exprlen >= 2) { 16 | pmath_t item; 17 | 18 | for(i = exprlen; i > 2; --i) { 19 | expr = pmath_expr_set_item( 20 | expr, i, 21 | pmath_evaluate( 22 | pmath_expr_get_item(expr, i))); 23 | } 24 | 25 | item = pmath_expr_get_item(expr, 2); 26 | if(pmath_is_rule(item)) { 27 | item = pmath_evaluate(item); 28 | expr = pmath_expr_set_item(expr, 2, item); 29 | } 30 | else 31 | pmath_unref(item); 32 | } 33 | 34 | if(exprlen > 2) 35 | pmath_unref(pmath_options_extract(expr, 2)); 36 | 37 | return expr; 38 | } 39 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/logic/boole.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | #include 6 | 7 | 8 | extern pmath_symbol_t pmath_System_False; 9 | extern pmath_symbol_t pmath_System_True; 10 | extern pmath_symbol_t pmath_System_Undefined; 11 | 12 | PMATH_PRIVATE pmath_t builtin_boole(pmath_expr_t expr) { 13 | pmath_t obj; 14 | 15 | if(pmath_expr_length(expr) != 1) { 16 | pmath_message_argxxx(pmath_expr_length(expr), 1, 1); 17 | return expr; 18 | } 19 | 20 | obj = pmath_expr_get_item(expr, 1); 21 | pmath_unref(obj); 22 | if(pmath_same(obj, pmath_System_True)) { 23 | pmath_unref(expr); 24 | return PMATH_FROM_INT32(1); 25 | } 26 | 27 | if(pmath_same(obj, pmath_System_False)) { 28 | pmath_unref(expr); 29 | return PMATH_FROM_INT32(0); 30 | } 31 | 32 | if(pmath_same(obj, pmath_System_Undefined)) { 33 | pmath_unref(expr); 34 | return pmath_ref(pmath_System_Undefined); 35 | } 36 | 37 | return expr; 38 | } 39 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/number-theory/bitget.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | 7 | pmath_t builtin_bitget(pmath_expr_t expr) { 8 | pmath_mpint_t num; 9 | pmath_integer_t bit; 10 | 11 | if(pmath_expr_length(expr) != 2) { 12 | pmath_message_argxxx(pmath_expr_length(expr), 2, 2); 13 | return expr; 14 | } 15 | 16 | num = pmath_expr_get_item(expr, 1); 17 | bit = pmath_expr_get_item(expr, 2); 18 | 19 | if(!pmath_is_int32(bit) || PMATH_AS_INT32(bit) < 0) { 20 | pmath_unref(num); 21 | pmath_unref(bit); 22 | return expr; 23 | } 24 | 25 | if(pmath_is_int32(num)) 26 | num = _pmath_create_mp_int(PMATH_AS_INT32(num)); 27 | 28 | if(pmath_is_mpint(num)) { 29 | int b = mpz_tstbit(PMATH_AS_MPZ(num), (unsigned)PMATH_AS_INT32(bit)); 30 | 31 | pmath_unref(expr); 32 | pmath_unref(num); 33 | 34 | return PMATH_FROM_INT32(b); 35 | } 36 | 37 | pmath_unref(num); 38 | return expr; 39 | } 40 | -------------------------------------------------------------------------------- /library/post-build-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | function ln-copy { 4 | ln -sf "$1" "$2" 5 | if [ "$?" != "0" ]; then 6 | cp "$1" "$2" 7 | fi 8 | } 9 | 10 | mkdir -p dependencies/linux/$2 11 | mkdir -p console/dependencies/linux/$2 12 | 13 | mkdir -p test/$1 14 | cp -r dependencies/linux/$2/. test/$1/ 15 | cp scripts/maininit.5.txt test/$1/maininit.pmath 16 | #echo "Get(ToFileName({DirectoryName($""Input, 5), \"scripts\"}, \"maininit.pmath\"))" > test/$1/maininit.pmath 17 | cp $1/libpmath.so.0.1 test/$1/ 18 | 19 | mkdir -p console/$1 20 | cp -r console/dependencies/linux/$2/. console/$1/ 21 | cp scripts/maininit.5.txt console/$1/maininit.pmath 22 | cp $1/libpmath.so.0.1 console/$1/ 23 | 24 | function ln-copy-all { 25 | ln-copy "$(pwd)/libpmath.so.0.1" libpmath.so.0 26 | ln-copy "$(pwd)/libpmath.so.0" libpmath.so 27 | } 28 | 29 | pushd $1 30 | ln-copy-all 31 | popd 32 | 33 | pushd test/$1 34 | ln-copy-all 35 | popd 36 | 37 | pushd console/$1 38 | ln-copy-all 39 | popd 40 | -------------------------------------------------------------------------------- /library/scripts/auto/core/text/maketextboxes.pmath: -------------------------------------------------------------------------------- 1 | 2 | BeginPackage("System`Text`") 3 | 4 | MakeTextBoxes 5 | 6 | Begin("System`Text`Private`") 7 | 8 | MakeTextBoxes(~other)::= BoxData(MakeBoxes(other)) 9 | MakeTextBoxes(~s:String)::= s 10 | MakeTextBoxes(RawBoxes(~box))::= box 11 | 12 | Attributes(makeSimpleTextBox):= {HoldAllComplete} 13 | makeSimpleTextBox(orig: ~h(~inner, ~~~opts), ~expectedHead) ::= 14 | MakeBoxes(h(0, opts)) |> { 15 | expectedHead(~, ~~~boxopts) :> expectedHead(MakeTextBoxes(inner), boxopts), 16 | ~ :> BoxData(MakeBoxes(orig)) 17 | } 18 | makeSimpleTextBox(~other)::= BoxData(MakeBoxes(other)) 19 | 20 | MakeTextBoxes(~expr:Button)::= makeSimpleTextBox(expr, ButtonBox) 21 | MakeTextBoxes(~expr:Graphics)::= MakeBoxes(expr) 22 | MakeTextBoxes(~expr:Interpretation)::= makeSimpleTextBox(expr, InterpretationBox) 23 | MakeTextBoxes(~expr:Panel)::= makeSimpleTextBox(expr, PanelBox) 24 | MakeTextBoxes(~expr:Style)::= makeSimpleTextBox(expr, StyleBox) 25 | 26 | End() 27 | 28 | EndPackage() 29 | -------------------------------------------------------------------------------- /modules/System/Numerics/library/src/agm-impl.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | extern pmath_symbol_t pmath_System_Private_AutoSimplifyArithmeticGeometricMean; 4 | 5 | #define SIMPLIFY_SYMBOL pmath_System_Private_AutoSimplifyArithmeticGeometricMean 6 | 7 | static void acb_agm_2(acb_t res, const acb_t a, const acb_t b, slong prec) { 8 | acb_t ba; 9 | acb_t agm1_ba; 10 | 11 | if(acb_is_one(a)) { 12 | acb_agm1(res, b, prec); 13 | return; 14 | } 15 | if(acb_is_one(b)) { 16 | acb_agm1(res, a, prec); 17 | return; 18 | } 19 | 20 | // agm(a,b) = a agm(1, b/a) 21 | acb_init(ba); 22 | acb_init(agm1_ba); 23 | acb_div(ba, b, a, prec); 24 | acb_agm1(agm1_ba, ba, prec); 25 | /* acb_mul() does not allow aliasing output wiht input arguments */ 26 | acb_mul(res, agm1_ba, a, prec); 27 | acb_clear(agm1_ba); 28 | acb_clear(ba); 29 | } 30 | 31 | PMATH_PRIVATE pmath_t eval_System_ArithmeticGeometricMean(pmath_expr_t expr) { 32 | # define ACB_FUNCTION acb_agm_2 33 | # include "acb-impl-twoarg.inc" 34 | # undef ACB_FUNCTION 35 | } 36 | -------------------------------------------------------------------------------- /richmath/include/gui/gtk/mgtk-filedialog.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__GTK__MGTK_FILEDIALOG_H__INCLUDED 2 | #define RICHMATH__GUI__GTK__MGTK_FILEDIALOG_H__INCLUDED 3 | 4 | #ifndef RICHMATH_USE_GTK_GUI 5 | # error this header is gtk specific 6 | #endif 7 | 8 | #include 9 | #include 10 | //#include 11 | 12 | typedef struct _GtkFileChooserDialog GtkFileChooserDialog; 13 | typedef struct _GtkFileChooser GtkFileChooser; 14 | 15 | namespace richmath { 16 | class MathGtkFileDialog: public Base { 17 | class Impl; 18 | public: 19 | MathGtkFileDialog(bool to_save); 20 | ~MathGtkFileDialog(); 21 | 22 | void set_title(pmath::String title); 23 | void set_filter(pmath::Expr filter); 24 | void set_initial_file(pmath::String initialfile); 25 | 26 | pmath::Expr show_dialog(); 27 | 28 | private: 29 | GtkFileChooserDialog *_dialog; 30 | GtkFileChooser *_chooser; 31 | }; 32 | } 33 | 34 | 35 | #endif // RICHMATH__GUI__GTK__MGTK_FILEDIALOG_H__INCLUDED 36 | -------------------------------------------------------------------------------- /richmath/include/gui/win32/api/stylusutil.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__WIN32__API__STYLUSUTIL_H__INCLUDED 2 | #define RICHMATH__GUI__WIN32__API__STYLUSUTIL_H__INCLUDED 3 | 4 | #ifndef RICHMATH_USE_WIN32_GUI 5 | # error this header is win32 specific 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace richmath { 13 | class StylusUtil { 14 | public: 15 | static ComBase create_stylus_for_window(HWND hwnd); 16 | 17 | static ULONG get_stylus_sync_plugin_count(IRealTimeStylus *stylus); 18 | static ULONG get_stylus_sync_plugin_count(const ComBase &stylus) { 19 | return get_stylus_sync_plugin_count(stylus.get()); 20 | } 21 | 22 | static void debug_describe_packet_data_definition(IRealTimeStylus *stylus, TABLET_CONTEXT_ID tcid); 23 | static void debug_describe_packet_data(IRealTimeStylus *stylus, TABLET_CONTEXT_ID tcid, LONG *data); 24 | }; 25 | } 26 | 27 | #endif // RICHMATH__GUI__WIN32__API__STYLUSUTIL_H__INCLUDED 28 | -------------------------------------------------------------------------------- /richmath/include/gui/win32/win32-dragdrophandler.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__WIN32__WIN32_DRAGDROPHANDLER_H__INCLUDED 2 | #define RICHMATH__GUI__WIN32__WIN32_DRAGDROPHANDLER_H__INCLUDED 3 | 4 | #ifndef RICHMATH_USE_WIN32_GUI 5 | # error this header is win32 specific 6 | #endif 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace richmath { 13 | class Win32DragDropHandler final : public DragDropHandler { 14 | public: 15 | explicit Win32DragDropHandler(ComBase data, DWORD allowed_effects); 16 | 17 | virtual MenuCommandStatus can_drop(DropAction action) override; 18 | virtual bool do_drop(DropAction action) override; 19 | 20 | static DWORD effect_from_action(DropAction action); 21 | 22 | public: 23 | DWORD *used_effect_ptr; 24 | private: 25 | ComBase _data; 26 | DWORD _allowed_effects; 27 | }; 28 | } 29 | 30 | #endif // RICHMATH__GUI__WIN32__WIN32_DRAGDROPHANDLER_H__INCLUDED 31 | -------------------------------------------------------------------------------- /richmath/include/gui/win32/api/win32-hd-trackpad.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__WIN32__API__HIGH_DEFINITION_TRACKPAD_H__INCLUDED 2 | #define RICHMATH__GUI__WIN32__API__HIGH_DEFINITION_TRACKPAD_H__INCLUDED 3 | 4 | #ifndef RICHMATH_USE_WIN32_GUI 5 | # error this header is win32 specific 6 | #endif 7 | 8 | #include 9 | 10 | class IDirectManipulationViewportEventHandler; 11 | 12 | namespace richmath { 13 | class HiDefTrackpadHandlerImpl; 14 | class NativeWidget; 15 | 16 | class HiDefTrackpadHandler { 17 | friend class HiDefTrackpadHandlerImpl; 18 | public: 19 | HiDefTrackpadHandler(); 20 | ~HiDefTrackpadHandler(); 21 | 22 | void init(HWND hwnd, NativeWidget *destination); 23 | void detach(); 24 | 25 | void on_pointer_hit_test(WPARAM wParam); 26 | void on_timer(); 27 | 28 | public: 29 | static struct TimerIdType {} TimerId; 30 | 31 | private: 32 | HiDefTrackpadHandlerImpl *_data; 33 | }; 34 | } 35 | 36 | #endif // RICHMATH__GUI__WIN32__API__HIGH_DEFINITION_TRACKPAD_H__INCLUDED 37 | -------------------------------------------------------------------------------- /richmath/info/format2.txt: -------------------------------------------------------------------------------- 1 | 2+a 2 | n 3 | .---. 2 1 4 | > a = 1 + --- 5 | '---' i x 6 | i=1 7 | 8 | ___________________________________ 9 | parsed (pmath expression): 10 | {{UnderoverscriptBox("\[Sum]", {"i", "=", "1"}, SuperscriptBox("n", {"2", "+", "a"})), SubsuperscriptBox("a", "i", "2")}, "=", {"1", "+", FractionBox("1", "X")}} 11 | 12 | ___________________________________ 13 | pmath representation (string): 14 | "\(\[Sum]\+\(i=1\)\%\(n\^\(2+a\)\)a\_i\%2=1+1\/x\)" 15 | 16 | ___________________________________ 17 | internal representation (richmath classes): 18 | Sequence( 19 | "\[UnderoverscriptBoxPlaceholder]a\[SubsuperscriptBoxPlaceholder]=1+\[BoxPlaceholder]", 20 | { 21 | UnderoverscriptBox( 22 | Sequence("\[Sum]", {}), 23 | Sequence("i=1", {}), 24 | Sequence( 25 | "n\[SubsuperscriptBoxPlaceholder]", 26 | SubsuperscriptBox( 27 | NULL, 28 | Sequence("2+a", {})), 29 | {})), 30 | FractionBox( 31 | Sequence("1", {}), 32 | Sequence("x", {})) 33 | }) 34 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/lists/nest.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | PMATH_PRIVATE pmath_t builtin_nest(pmath_expr_t expr) { 9 | /* Nest(f, x, n) 10 | */ 11 | pmath_t obj, func; 12 | size_t n; 13 | 14 | if(pmath_expr_length(expr) != 3) { 15 | pmath_message_argxxx(pmath_expr_length(expr), 3, 3); 16 | return expr; 17 | } 18 | 19 | obj = pmath_expr_get_item(expr, 3); 20 | if(!pmath_is_int32(obj) || PMATH_AS_INT32(obj) < 0) { 21 | pmath_unref(obj); 22 | pmath_message(PMATH_NULL, "intnm", 2, PMATH_FROM_INT32(3), pmath_ref(expr)); 23 | return expr; 24 | } 25 | 26 | n = (unsigned)PMATH_AS_INT32(obj); 27 | 28 | func = pmath_expr_get_item(expr, 1); 29 | obj = pmath_expr_get_item(expr, 2); 30 | pmath_unref(expr); 31 | while(n-- > 0 && !pmath_aborting()) 32 | obj = pmath_evaluate(pmath_expr_new_extended(pmath_ref(func), 1, obj)); 33 | 34 | pmath_unref(func); 35 | return obj; 36 | } 37 | -------------------------------------------------------------------------------- /richmath/info/format.txt: -------------------------------------------------------------------------------- 1 | 2 | _________________________________________________________ 3 | b 4 | .---. 5 | > f[i] 6 | '---' 7 | i=a 8 | 9 | pMath: 10 | \(UnderoverBox\,\[sum]\,i=a\,b\)f[i] 11 | 12 | C: 13 | BOX_START "UnderoverBox" BOX_NEXT 14 | UTF8_SUM BOX_NEXT 15 | "i=a" BOX_NEXT 16 | "b" 17 | BOX_END 18 | 19 | _________________________________________________________ 20 | /------\ 21 | | Ok | 22 | \------/ 23 | 24 | pMath: 25 | \(ButtonBox\,Ok\) 26 | 27 | C: 28 | BOX_START "ButtonBox" BOX_NEXT 29 | "Ok" BOX_NEXT 30 | BOX_END 31 | 32 | _________________________________________________________ 33 | /------\ 34 | | Ok | 35 | \------/ [with Background 0xFF0080] 36 | 37 | pMath: 38 | \(ButtonBox\,Ok\,Background\=0xff0080\) 39 | 40 | C: 41 | BOX_START "ButtonBox" BOX_NEXT 42 | "Ok" BOX_NEXT 43 | "Background" BOX_OPTION_SET "0xff0080" 44 | BOX_END 45 | 46 | _________________________________________________________ 47 | Options for Buttons: 48 | OnClick 49 | Background, 50 | Active, 51 | Baseline, 52 | Enabled -------------------------------------------------------------------------------- /library/scripts/auto/core/text/init.pmath: -------------------------------------------------------------------------------- 1 | BeginPackage("System`Text`") 2 | 3 | System`Text`MakeTextBoxes 4 | System`Text`MakeTextExpression 5 | 6 | Begin("System`Text`Private`") 7 | 8 | Attributes(MakeTextBoxes):= {HoldAllComplete, Protected} 9 | Attributes(MakeTextExpression):= {HoldAllComplete, Protected} 10 | 11 | Unprotect(Text) 12 | Attributes(Text):= {ReadProtected} 13 | MakeBoxes(Text({~~~elems}))::= TextData @ List @@ HoldComplete(elems).Map(MakeTextBoxes) 14 | MakeBoxes(Text(~other))::= TextData(MakeTextBoxes(other)) 15 | Protect(Text) 16 | 17 | Unprotect(TextData) 18 | SetAttributes(TextData, {ReadProtected}) 19 | TextData/: MakeExpression(TextData(~elements))::= 20 | MakeTextExpression(elements) |> { 21 | HoldComplete(~~~data) :> HoldComplete(Text(data)), 22 | ~ :> $Failed 23 | } 24 | Protect(TextData) 25 | 26 | AutoLoad(Hold(MakeTextBoxes), 27 | ToFileName(DirectoryName($Input), "maketextboxes.pmath")) 28 | AutoLoad(Hold(MakeTextExpression), 29 | ToFileName(DirectoryName($Input), "maketextexpression.pmath")) 30 | 31 | End() 32 | 33 | EndPackage() 34 | -------------------------------------------------------------------------------- /modules/Eigen/src/classification.h: -------------------------------------------------------------------------------- 1 | #ifndef __P4E__CLASSIFICATION_H__ 2 | #define __P4E__CLASSIFICATION_H__ 3 | 4 | #include "arithmetic-expr.h" 5 | #include 6 | 7 | #ifdef _MSC_VER 8 | # define __func__ __FUNCTION__ 9 | #endif 10 | 11 | 12 | namespace pmath4eigen { 13 | 14 | class MatrixKind { 15 | public: 16 | 17 | typedef enum { 18 | General, 19 | MachineReal, 20 | MachineComplex 21 | } Type; 22 | 23 | static bool get_matrix_dimensions( 24 | const pmath::Expr &matrix, 25 | size_t &rows, 26 | size_t &cols); 27 | 28 | static Type classify(const pmath::Expr &matrix); 29 | 30 | static bool is_symbolic_matrix(const pmath::Expr &matrix); 31 | 32 | template 33 | static bool is_hermetian_matrix(const Eigen::MatrixBase &m) { 34 | return Eigen::internal::isApprox( 35 | (m.conjugate() - m.transpose()).cwiseAbs().maxCoeff(), 0); 36 | } 37 | }; 38 | 39 | } 40 | 41 | 42 | #endif // __P4E__CLASSIFICATION_H__ 43 | -------------------------------------------------------------------------------- /richmath/include/boxes/tooltipbox.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__BOXES__TOOLTIPBOX_H__INCLUDED 2 | #define RICHMATH__BOXES__TOOLTIPBOX_H__INCLUDED 3 | 4 | #include 5 | 6 | 7 | namespace richmath { 8 | class TooltipBox final : public AbstractStyleBox { 9 | using base = AbstractStyleBox; 10 | public: 11 | explicit TooltipBox(AbstractSequence *content); 12 | 13 | // Box::try_create(expr, opts); 14 | virtual bool try_load_from_object(Expr expr, BoxInputFlags opts) override; 15 | 16 | virtual Expr to_pmath_symbol() override; 17 | 18 | virtual Box *mouse_sensitive() override { return this; } 19 | virtual void on_mouse_enter() override; 20 | virtual void on_mouse_exit() override; 21 | 22 | Expr tooltip_boxes() const { return _tooltip_boxes; } 23 | 24 | protected: 25 | Expr _tooltip_boxes; 26 | 27 | virtual Expr to_pmath_impl(BoxOutputFlags flags) override; 28 | }; 29 | } 30 | 31 | #endif // RICHMATH__BOXES__TOOLTIPBOX_H__INCLUDED 32 | -------------------------------------------------------------------------------- /modules/Java/start-jshell.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | 4 | setlocal ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION 5 | 6 | set PMATH_JAVA_DIR=%~dp0 7 | set PMATH_JAVA_CLASSPATH=%PMATH_JAVA_DIR%\classpath 8 | set PMATH_JAVA_BINDING_DLL=%PMATH_JAVA_DIR%\bin\Windows\x86-64\pmath-java.dll 9 | set PMATH_CORE_BASE_DIR=%PMATH_JAVA_DIR%\..\..\library\scripts 10 | set PMATH_CORE_DLL_DIR=%PMATH_JAVA_DIR%\..\..\library\bin\windows\msvc-debug-x64 11 | set PMATH_CORE_DLL=%PMATH_CORE_DLL_DIR%\pmath.dll 12 | 13 | for %%X in (jshell.exe) do ( 14 | set jshell_exe="%%~$PATH:X" 15 | ) 16 | 17 | if not defined jshell_exe ( 18 | echo jshell.exe not found. 19 | goto end 20 | ) 21 | 22 | set PATH=%PMATH_CORE_DLL_DIR%;%PATH% 23 | 24 | rem TODO: also set pmath.core.base_directory or %PMATH_BASEDIRECTORY% 25 | %jshell_exe% --class-path "%PMATH_JAVA_CLASSPATH%" "-R-Dpmath.core.dll=%PMATH_CORE_DLL%" "-R-Dpmath.core.base_directory=%PMATH_CORE_BASE_DIR%" "-R-Dpmath.binding.dll=%PMATH_JAVA_BINDING_DLL%" 26 | 27 | 28 | :end 29 | rem (((echo."%cmdcmdline%")|find /I "%~0")>nul) 30 | rem if %errorlevel% equ 0 pause 31 | 32 | endlocal 33 | -------------------------------------------------------------------------------- /modules/System/Numerics/library/src/acb-impl-onearg.inc: -------------------------------------------------------------------------------- 1 | /* Implement unary functions F(x) of a single complex argument. 2 | First try ACB_FUNCTION(x) in C and then fall back to SIMPLIFY_SYMBOL(F, x) 3 | in pMath, returning unevaluated if that gives $Failed. 4 | */ 5 | #ifndef ACB_FUNCTION 6 | # error ACB_FUNCTION not defined 7 | #endif 8 | #ifndef SIMPLIFY_SYMBOL 9 | # error SIMPLIFY_SYMBOL not defined 10 | #endif 11 | 12 | extern pmath_symbol_t pmath_System_DollarFailed; 13 | 14 | pmath_t x; 15 | 16 | if(pmath_expr_length(expr) != 1) { 17 | pmath_message_argxxx(pmath_expr_length(expr), 1, 1); 18 | return expr; 19 | } 20 | 21 | x = pmath_expr_get_item(expr, 1); 22 | if(pmath_complex_try_evaluate_acb(&expr, x, ACB_FUNCTION)) { 23 | pmath_unref(x); 24 | return expr; 25 | } 26 | 27 | x = pmath_expr_new_extended( 28 | pmath_ref(SIMPLIFY_SYMBOL), 2, 29 | pmath_expr_get_item(expr, 0), 30 | x); 31 | 32 | x = pmath_evaluate(x); 33 | if(!pmath_same(x, pmath_System_DollarFailed)) { 34 | pmath_unref(expr); 35 | return x; 36 | } 37 | 38 | pmath_unref(x); 39 | return expr; 40 | -------------------------------------------------------------------------------- /modules/Windows/library/src/string-util.c: -------------------------------------------------------------------------------- 1 | #include "util.h" 2 | 3 | 4 | BSTR string_to_bstr_free(pmath_string_t str) { 5 | int length = pmath_string_length(str); 6 | const uint16_t *buf = pmath_string_buffer(&str); 7 | BSTR bstr = SysAllocStringLen(buf, (UINT)length); 8 | pmath_unref(str); 9 | return bstr; 10 | } 11 | 12 | pmath_string_t bstr_to_string(BSTR bstr) { 13 | return pmath_string_insert_ucs2(PMATH_NULL, 0, bstr, SysStringLen(bstr)); 14 | } 15 | 16 | pmath_bool_t string_to_guid(pmath_string_t string, GUID *guid) { 17 | BSTR bstr = string_to_bstr_free(pmath_ref(string)); 18 | if(!SUCCEEDED(IIDFromString(bstr, guid))) { 19 | SysFreeString(bstr); 20 | return FALSE; 21 | } 22 | SysFreeString(bstr); 23 | return TRUE; 24 | } 25 | 26 | pmath_string_t guid_to_string(const GUID *guid) { 27 | LPOLESTR guid_string = NULL; 28 | if(SUCCEEDED(StringFromIID(guid, &guid_string))) { 29 | pmath_string_t result = pmath_string_insert_ucs2(PMATH_NULL, 0, guid_string, -1); 30 | CoTaskMemFree(guid_string); 31 | return result; 32 | } 33 | return PMATH_NULL; 34 | } 35 | -------------------------------------------------------------------------------- /library/test-suite/tests/number-idenity.pmath: -------------------------------------------------------------------------------- 1 | % Maybe it would be better to testC function _pmath_numbers_equal() directly. 2 | 3 | xArb:= 1.5`10 4 | xArbCopy:= 1.5`10 5 | xArb2:= 1.5`22 6 | xArb2Copy:= 1.5`22 7 | xArbRadius:= 1.5[+/-1*^-20]`33 8 | xArbRadiusCopy:= 1.5[+/-1*^-20]`33 9 | xArbRadius2:= 1.5[+/-5*^-20]`33 10 | xMachine:= 1.5` 11 | xRat:= 3/2 12 | xRatCopy:= 3/2 13 | 14 | 15 | AssertEqual(xArb, xArbCopy) 16 | AssertEqual(xArb2, xArb2Copy) 17 | AssertEqual(xArbRadius, xArbRadiusCopy) 18 | AssertEqual(xMachine, xMachine) 19 | AssertEqual(xRat, xRatCopy) 20 | 21 | 22 | % different types: float, rational 23 | AssertUnequal(xArb, xRat) 24 | AssertUnequal(xMachine, xRat) 25 | 26 | 27 | % ignoring working precision 28 | AssertUnequal(xArb, xMachine) 29 | AssertUnequal(xArb2, xMachine) 30 | AssertUnequal(xArbRadius, xMachine) 31 | 32 | AssertEqual(xArb, xArb2) 33 | 34 | 35 | % non-matching radius 36 | AssertUnequal(xArb, xArbRadius) 37 | AssertUnequal(xArb2, xArbRadius) 38 | AssertUnequal(xMachine, xArbRadius) 39 | AssertUnequal(xArbRadius2, xArbRadius) 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /richmath/include/eval/server.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__EVAL__SERVER_H__INCLUDED 2 | #define RICHMATH__EVAL__SERVER_H__INCLUDED 3 | 4 | #include 5 | #include 6 | 7 | 8 | namespace richmath { 9 | Expr evaluate_to_boxes(Expr obj); 10 | Expr generate_section(String style, Expr boxes); 11 | 12 | class Server: public Shareable { 13 | public: 14 | virtual void run_boxes(Expr boxes) = 0; 15 | 16 | virtual void run(Expr obj) = 0; 17 | 18 | virtual Expr interrupt_wait( 19 | Expr expr, 20 | double timeout_seconds, 21 | pmath_bool_t (*idle_function)(double *end_tick,void *idle_data), 22 | void *idle_data) = 0; 23 | virtual void async_interrupt(Expr expr) = 0; 24 | 25 | virtual void abort_all() = 0; 26 | 27 | virtual bool is_accessable() = 0; 28 | 29 | static bool init_local_server(); 30 | static SharedPtr local_server; 31 | }; 32 | } 33 | 34 | #endif // RICHMATH__EVAL__SERVER_H__INCLUDED 35 | -------------------------------------------------------------------------------- /richmath/scripts/resources/StyleSheets/Default.pmathdoc: -------------------------------------------------------------------------------- 1 | /* pMath Document */ 2 | 3 | Document({ 4 | SectionGroup({Section(StyleData(StyleDefinitions -> "Core.pmathdoc")), 5 | SectionGroup({Section("Default stylesheet", "Title"), 6 | Section( 7 | "This file contains default style definitions to apply to new \ 8 | documents.", "Text"), 9 | SectionGroup({Section("Document styles", "Section"), 10 | Section(StyleData("Document"), Background -> GrayLevel(1), 11 | FontColor -> GrayLevel(0))}, All), 12 | SectionGroup({Section("Section styles", "Section"), 13 | SectionGroup({Section("Formulas", "Subsection"), 14 | Section(StyleData("DisplayFormula"), AutoNumberFormating -> False, 15 | AutoSpacing -> True, Evaluatable -> False, FontSize -> 12, 16 | LanguageCategory -> "Formula", MenuSortingValue -> 1700, 17 | ScriptLevel -> 0, SectionMargins -> {{50, Inherited}, {7, 7}}, 18 | ShowAutoStyles -> False)}, All)}, All)}, All)}, All)}, 19 | StyleDefinitions -> "Stylesheets.pmathdoc", Visible -> True) -------------------------------------------------------------------------------- /richmath/src/gui/recent-documents.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | using namespace pmath; 5 | using namespace richmath; 6 | 7 | 8 | 9 | extern pmath_symbol_t richmath_System_False; 10 | extern pmath_symbol_t richmath_System_MenuItem; 11 | extern pmath_symbol_t richmath_System_True; 12 | extern pmath_symbol_t richmath_FrontEnd_DocumentOpen; 13 | 14 | Expr RecentDocuments::open_document_menu_item(Expr label, Expr path) { 15 | return Call( 16 | Symbol(richmath_System_MenuItem), 17 | PMATH_CPP_MOVE(label), 18 | Call( 19 | Symbol(richmath_FrontEnd_DocumentOpen), 20 | PMATH_CPP_MOVE(path))); 21 | } 22 | 23 | Expr RecentDocuments::open_document_menu_item(Expr label, Expr path, bool add_to_recent) { 24 | return Call( 25 | Symbol(richmath_System_MenuItem), 26 | PMATH_CPP_MOVE(label), 27 | Call( 28 | Symbol(richmath_FrontEnd_DocumentOpen), 29 | PMATH_CPP_MOVE(path), 30 | add_to_recent ? Symbol(richmath_System_True) : Symbol(richmath_System_False))); 31 | } 32 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/control/flow/tryevaluatesecured.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | 8 | extern pmath_symbol_t pmath_System_HoldComplete; 9 | 10 | PMATH_PRIVATE pmath_t builtin_internal_tryevaluatesecured(pmath_expr_t expr) { 11 | /* Internal`TryEvaluateSecured(expr, level) 12 | */ 13 | pmath_t obj; 14 | pmath_security_level_t level; 15 | 16 | if(pmath_expr_length(expr) != 2) { 17 | pmath_message_argxxx(pmath_expr_length(expr), 2, 2); 18 | return expr; 19 | } 20 | 21 | obj = pmath_evaluate(pmath_expr_get_item(expr, 2)); 22 | if(!_pmath_security_level_from_expr(&level, obj)) { 23 | pmath_message(PMATH_NULL, "seclvl", 1, obj); 24 | return expr; 25 | } 26 | pmath_unref(obj); 27 | 28 | obj = pmath_expr_extract_item(expr, 1); 29 | pmath_unref(expr); 30 | 31 | obj = pmath_evaluate_secured(obj, level); 32 | 33 | obj = pmath_expr_new_extended(pmath_ref(pmath_System_HoldComplete), 1, obj); 34 | return obj; 35 | } 36 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/number-theory/jacobisymbol-and-kroneckersymbol.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | 7 | pmath_t builtin_jacobisymbol_and_kroneckersymbol(pmath_expr_t expr) { 8 | /** The Kronecker symbol is a generalization of Jacobi symbol. 9 | */ 10 | pmath_mpint_t a, b; 11 | 12 | if(pmath_expr_length(expr) != 2) { 13 | pmath_message_argxxx(pmath_expr_length(expr), 2, 2); 14 | return expr; 15 | } 16 | 17 | a = pmath_expr_get_item(expr, 1); 18 | b = pmath_expr_get_item(expr, 2); 19 | 20 | if(pmath_is_int32(a)) 21 | a = _pmath_create_mp_int(PMATH_AS_INT32(a)); 22 | 23 | if(pmath_is_int32(b)) 24 | b = _pmath_create_mp_int(PMATH_AS_INT32(b)); 25 | 26 | if(!pmath_is_mpint(a) || !pmath_is_mpint(b)) { 27 | pmath_unref(a); 28 | pmath_unref(b); 29 | return expr; 30 | } 31 | 32 | pmath_unref(expr); 33 | expr = PMATH_FROM_INT32(mpz_kronecker(PMATH_AS_MPZ(a), PMATH_AS_MPZ(b))); 34 | 35 | pmath_unref(a); 36 | pmath_unref(b); 37 | return expr; 38 | } 39 | -------------------------------------------------------------------------------- /library/scripts/auto/core/echo.pmath: -------------------------------------------------------------------------------- 1 | 2 | Begin("System`Echo`") 3 | 4 | Echo(~expr)::= (SectionPrint("Echo", Unevaluated(expr)); expr) 5 | Echo(~expr, ~label)::= (SectionPrint("Echo", label, Unevaluated(expr)); expr) 6 | Echo(~expr, ~label, ~f)::= (SectionPrint("Echo", label, f(expr)); expr) 7 | Echo(~~~args)::= $Failed /? IsValidArgumentCount(Echo, Length @ {args}, 1, 3) 8 | 9 | EchoFunction()(~expr)::= (SectionPrint("Echo", Unevaluated(expr)); expr) 10 | EchoFunction(~f)(~expr)::= (SectionPrint("Echo", f(expr)); expr) 11 | EchoFunction(~label, ~f)(~expr)::= (SectionPrint("Echo", label, f(expr)); expr) 12 | EchoFunction( )(~~~args)::= $Failed /? IsValidArgumentCount(EchoFunction( ), Length @ {args}, 1, 1) 13 | EchoFunction( ~f)(~~~args)::= $Failed /? IsValidArgumentCount(EchoFunction( f), Length @ {args}, 1, 1) 14 | EchoFunction(~label, ~f)(~~~args)::= $Failed /? IsValidArgumentCount(EchoFunction(label, f), Length @ {args}, 1, 1) 15 | EchoFunction(~~~args)::= $Failed /? (IsValidArgumentCount(EchoFunction, Length @ {args}, 0, 2);False) 16 | 17 | End() 18 | -------------------------------------------------------------------------------- /modules/System/QuantityUnits/products.pmath: -------------------------------------------------------------------------------- 1 | BeginPackage("System`QuantityUnits`") 2 | 3 | Begin("System`QuantityUnits`Private`") 4 | 5 | 6 | % Returns $Failed insetad of Times @@ factorList if it cannot simplify the product. 7 | Function QuantityProduct(~factorList) { 8 | With({{{null, units}, magnitudes}, others}:= factorList |> 9 | Scan({ 10 | HoldPattern(Quantity(~mag, ~unit)) ? IsValidQuantity :> (Emit(unit, UNIT); Emit(mag, MAGNITUDE)), 11 | ~x ? IsNumeric :> Emit(x, MAGNITUDE), 12 | ~x :> Emit(x, OTHER) 13 | }) |> 14 | Gather(UNIT) |> 15 | Gather(MAGNITUDE) |> 16 | Gather(OTHER)) 17 | 18 | If(units === {}) { 19 | Return($Failed) 20 | } 21 | 22 | If(Length(units) === 1) { 23 | If(Length(magnitudes) <= 1) { 24 | Return($Failed) 25 | } 26 | Return((Times @@ others) * newValidQuanitity(Times @@ magnitudes, units.First)) 27 | } 28 | 29 | (Times @@ others) * ConsolidateValidQuantityUnits(Times @@ magnitudes, Times @@ units) 30 | } 31 | 32 | 33 | End() 34 | 35 | EndPackage() 36 | -------------------------------------------------------------------------------- /richmath/include/eval/eval-contexts.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__EVAL__EVAL_CONTEXT_H__INCLUDED 2 | #define RICHMATH__EVAL__EVAL_CONTEXT_H__INCLUDED 3 | 4 | #include 5 | 6 | namespace richmath { 7 | class Section; 8 | 9 | class EvaluationContexts { 10 | class Impl; 11 | public: 12 | static void init(); 13 | static void done(); 14 | 15 | static void context_source_deleted(StyledObject *obj); 16 | static void set_context(String context); 17 | static Expr prepare_set_context(String context); 18 | static Expr make_context_block(Expr expr, String context); 19 | 20 | static Section *find_section_group_header(Section *section); 21 | static String resolve_context(StyledObject *obj); 22 | 23 | static Expr prepare_namespace_for_current_context(Expr expr); 24 | static Expr prepare_namespace_for(Expr expr, StyledObject *obj); 25 | 26 | static String current(); 27 | static Expr replace_symbol_namespace(Expr expr, String old_ns, String new_ns); 28 | }; 29 | } 30 | 31 | #endif // RICHMATH__EVAL__EVAL_CONTEXT_H__INCLUDED 32 | -------------------------------------------------------------------------------- /richmath/scripts/auto/frontend/import.pmath: -------------------------------------------------------------------------------- 1 | /* Helper functions for GraphicsBox */ 2 | 3 | BeginPackage("FE`Import`") 4 | 5 | FE`Import`PasteFileNameContentBoxes 6 | FE`Import`FileNamesDropDescription 7 | 8 | Begin("FE`Import`Private`") 9 | 10 | Function PasteFileNameContentBoxes(~fname:String) { 11 | If(fname.StringMatch(~~~ ++ ".pmathdoc")) { 12 | DocumentOpen(fname) 13 | Return(/\/); 14 | } 15 | 16 | $Failed 17 | } 18 | 19 | PasteFileNameContentBoxes(~~~):= $Failed 20 | 21 | Function FileNamesDropDescription({~fname:String, ~~~rest}) { 22 | If(fname.StringMatch(~~~ ++ ".pmathdoc")) { 23 | Return({ 24 | "Image" -> "Copy", 25 | "Message" -> "Open %1", 26 | "Insert" -> If({rest} === {}, "Document", "Documents")}) 27 | } 28 | Return({ 29 | "Image" -> "Warning", % "Copy", "Move", "Link", "No", "Label", "Warning", "NoImage" 30 | "Message" -> "Insert %1 (not yet implemented)", 31 | "Insert" -> If({rest} === {}, "File", "Files")}) 32 | } 33 | 34 | FileNamesDropDescription(~~~):= $Failed 35 | 36 | End() 37 | 38 | EndPackage() 39 | -------------------------------------------------------------------------------- /richmath/include/util/double-point.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GRAPHICS__DOUBLE_POINT_H__INCLUDED 2 | #define RICHMATH__GRAPHICS__DOUBLE_POINT_H__INCLUDED 3 | 4 | #include 5 | #include 6 | 7 | namespace richmath { 8 | class DoublePoint { 9 | public: 10 | DoublePoint() 11 | : x(0), y(0) 12 | { 13 | } 14 | 15 | DoublePoint(double _x, double _y) 16 | : x(_x), y(_y) 17 | { 18 | } 19 | 20 | double operator[](int i) const { switch(i) { case 0: return x; case 1: return y; default: RICHMATH_ASSERT(!"bad index"); return x; }} 21 | 22 | public: 23 | static bool load_point( DoublePoint &point, Expr coords); 24 | static bool load_point_or_points(DoubleMatrix &points, Expr coords); 25 | 26 | static bool load_line( DoubleMatrix &line, Expr coords); 27 | static bool load_line_or_lines(Array &lines, Expr coords); 28 | 29 | public: 30 | double x; 31 | double y; 32 | }; 33 | 34 | } 35 | 36 | #endif // RICHMATH__GRAPHICS__DOUBLE_POINT_H__INCLUDED 37 | -------------------------------------------------------------------------------- /richmath/include/boxes/graphics/pointbox.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__BOXES__GRAPHICS__POINTBOX_H__INCLUDED 2 | #define RICHMATH__BOXES__GRAPHICS__POINTBOX_H__INCLUDED 3 | 4 | #include 5 | #include 6 | 7 | 8 | namespace richmath { 9 | class PointBox final : public GraphicsElement { 10 | protected: 11 | virtual ~PointBox(); 12 | public: 13 | static GraphicsElement *create(Expr expr, BoxInputFlags opts) = delete; 14 | static PointBox *try_create(Expr expr, BoxInputFlags opts); 15 | 16 | virtual bool try_load_from_object(Expr expr, BoxInputFlags opts) override; 17 | 18 | virtual void find_extends(GraphicsBounds &bounds) override; 19 | virtual void paint(GraphicsDrawingContext &gc) override; 20 | 21 | protected: 22 | Expr _uncompressed_expr; 23 | DoubleMatrix _points; 24 | 25 | protected: 26 | PointBox(); 27 | 28 | virtual Expr to_pmath_impl(BoxOutputFlags flags) override; 29 | }; 30 | } 31 | 32 | 33 | #endif // RICHMATH__BOXES__GRAPHICS__POINTBOX_H__INCLUDED 34 | -------------------------------------------------------------------------------- /richmath/include/boxes/graphics/linebox.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__BOXES__GRAPHICS__LINEBOX_H__INCLUDED 2 | #define RICHMATH__BOXES__GRAPHICS__LINEBOX_H__INCLUDED 3 | 4 | #include 5 | #include 6 | 7 | 8 | namespace richmath { 9 | class LineBox final : public GraphicsElement { 10 | protected: 11 | virtual ~LineBox(); 12 | public: 13 | static GraphicsElement *create(Expr expr, BoxInputFlags opts) = delete; 14 | static LineBox *try_create(Expr expr, BoxInputFlags opts); 15 | 16 | virtual bool try_load_from_object(Expr expr, BoxInputFlags opts) override; 17 | 18 | virtual void find_extends(GraphicsBounds &bounds) override; 19 | virtual void paint(GraphicsDrawingContext &gc) override; 20 | 21 | protected: 22 | Expr _uncompressed_expr; 23 | Array _lines; 24 | 25 | protected: 26 | LineBox(); 27 | 28 | virtual Expr to_pmath_impl(BoxOutputFlags flags) override; 29 | }; 30 | } 31 | 32 | 33 | #endif // RICHMATH__BOXES__GRAPHICS__LINEBOX_H__INCLUDED 34 | -------------------------------------------------------------------------------- /richmath/include/gui/win32/menus/win32-custom-menu-overlay.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__WIN32__MENUS__WIN32_CUSTOM_MENU_OVERLAY_H__INCLUDED 2 | #define RICHMATH__GUI__WIN32__MENUS__WIN32_CUSTOM_MENU_OVERLAY_H__INCLUDED 3 | 4 | #ifndef RICHMATH_USE_WIN32_GUI 5 | # error this header is win32 specific 6 | #endif 7 | 8 | #include 9 | 10 | namespace richmath { 11 | class Win32CustomMenuOverlay : public Win32MenuItemOverlay { 12 | class Impl; 13 | public: 14 | ~Win32CustomMenuOverlay(); 15 | 16 | virtual void update_rect(HWND hwnd, HMENU menu) override; 17 | 18 | virtual bool calc_rect(RECT &rect, HWND hwnd, HMENU menu); 19 | 20 | String text(); 21 | void text(String str); 22 | 23 | protected: 24 | virtual bool on_create(CREATESTRUCTW *args); 25 | virtual void on_paint(HDC hdc) {} 26 | virtual bool on_timer(UINT_PTR id, TIMERPROC proc) { return false; } 27 | virtual LPARAM on_wndproc(UINT message, WPARAM wParam, LPARAM lParam); 28 | }; 29 | } 30 | 31 | #endif // RICHMATH__GUI__WIN32__MENUS__WIN32_CUSTOM_MENU_OVERLAY_H__INCLUDED 32 | -------------------------------------------------------------------------------- /richmath/scripts/resources/Palettes/Memory Usage.pmathdoc: -------------------------------------------------------------------------------- 1 | /* pMath Document */ 2 | 3 | Document({ 4 | Section( 5 | TextData({ 6 | BoxData(DynamicLocalBox({FE`Private`hist}, 7 | DynamicBox( 8 | ToBoxes(Refresh(With({FE`Private`memUsage$:= MemoryUsage()}, 9 | FE`Private`hist:= 10 | Take(Append(FE`Private`hist, First(FE`Private`memUsage$)), 11 | UpTo(-100)); 12 | Column({ 13 | Text({RawBoxes(TemplateBox({"MemoryUsage", "In use"}, 14 | "ShowMoreDocumentationHyperlink2")), ": ", 15 | First(FE`Private`memUsage$), "\[RawTab]Max: ", 16 | Last(FE`Private`memUsage$)}), ListLinePlot(FE`Private`hist, 17 | FrameTicks -> {{Automatic, None}, None}, Frame -> True, 18 | Axes -> False, ImageSize -> Medium)})), None, 19 | UpdateInterval -> 1.5))), DynamicLocalValues -> {}, 20 | Initialization :> (FE`Private`hist:= {}), 21 | UnsavedVariables :> {FE`Private`hist}))}), "ControlStyle")}, 22 | StyleDefinitions -> "Palette.pmathdoc", Visible -> True, 23 | WindowTitle -> "Memory Usage") -------------------------------------------------------------------------------- /richmath/include/gui/gtk/mgtk-css.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__GTK__MGTK_CSS_H__INCLUDED 2 | #define RICHMATH__GUI__GTK__MGTK_CSS_H__INCLUDED 3 | 4 | #ifndef RICHMATH_USE_GTK_GUI 5 | # error this header is gtk specific 6 | #endif 7 | 8 | #include 9 | 10 | #include 11 | 12 | 13 | namespace richmath { 14 | class CubicBezierEasingFunction; 15 | 16 | class MathGtkCss { 17 | public: 18 | static void init(); 19 | static void done(); 20 | 21 | # if GTK_MAJOR_VERSION >= 3 22 | static double parse_transition_delay(const char *css, double fallback = 0.0f); 23 | static double parse_transition_duration(const char *css, double fallback = 0.0f); 24 | static bool parse_transition_timing_function(CubicBezierEasingFunction &fun, const char *css); 25 | 26 | static Expr parse_text_shadow(const char *css); 27 | static Expr parse_text_shadow(GtkStyleContext *ctx); 28 | # endif 29 | }; 30 | 31 | #if GTK_MAJOR_VERSION < 3 32 | inline void MathGtkCss::init() {} 33 | inline void MathGtkCss::done() {} 34 | #endif 35 | } 36 | 37 | #endif // RICHMATH__GUI__GTK__MGTK_CSS_H__INCLUDED 38 | -------------------------------------------------------------------------------- /richmath/include/gui/event-handlers.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__EVENT_HANDLERS_H__INCLUDED 2 | #define RICHMATH__GUI__EVENT_HANDLERS_H__INCLUDED 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace richmath { 9 | enum class EventHandlerResult: uint8_t { 10 | Continue, 11 | StopPropagation, 12 | }; 13 | 14 | class EventHandlers { 15 | class Impl; 16 | public: 17 | static String key_name(SpecialKey key); 18 | 19 | static EventHandlerResult decode_handler_result(Expr result); 20 | 21 | static EventHandlerResult execute_key_down_handler(FrontEndObject *obj, const SpecialKeyEvent &event, Expr handler); 22 | static EventHandlerResult execute_key_down_handler(StyledObject *obj, ObjectStyleOptionName handlers, const SpecialKeyEvent &event); 23 | 24 | static EventHandlerResult execute_key_press_handler(FrontEndObject *obj, uint32_t ch, Expr handler); 25 | static EventHandlerResult execute_key_press_handler(StyledObject *obj, ObjectStyleOptionName handlers, uint32_t ch); 26 | }; 27 | } 28 | 29 | #endif // RICHMATH__GUI__EVENT_HANDLERS_H__INCLUDED 30 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/control/flow/finally.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | 6 | PMATH_PRIVATE pmath_t builtin_finally(pmath_expr_t expr) { 7 | pmath_thread_t current_thread; 8 | pmath_t exception, fst; 9 | intptr_t old_ignore_older_aborts; 10 | 11 | if(pmath_expr_length(expr) != 2) { 12 | pmath_message_argxxx(pmath_expr_length(expr), 2, 2); 13 | return expr; 14 | } 15 | 16 | current_thread = pmath_thread_get_current(); 17 | if(!current_thread) { 18 | pmath_unref(expr); 19 | return PMATH_NULL; 20 | } 21 | 22 | fst = pmath_evaluate(pmath_expr_get_item(expr, 1)); 23 | 24 | old_ignore_older_aborts = current_thread->ignore_older_aborts; 25 | current_thread->ignore_older_aborts = 1 + pmath_atomic_read_aquire(&_pmath_abort_timer); 26 | exception = _pmath_thread_catch(current_thread); 27 | 28 | pmath_unref(pmath_evaluate(pmath_expr_get_item(expr, 2))); 29 | 30 | pmath_throw(exception); 31 | current_thread->ignore_older_aborts = old_ignore_older_aborts; 32 | 33 | pmath_unref(expr); 34 | return fst; 35 | } 36 | -------------------------------------------------------------------------------- /richmath/include/boxes/interpretationbox.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__BOXES__INTERPRETATIONBOX_H__INCLUDED 2 | #define RICHMATH__BOXES__INTERPRETATIONBOX_H__INCLUDED 3 | 4 | #include 5 | 6 | 7 | namespace richmath { 8 | class InterpretationBox final : public AbstractStyleBox { 9 | using base = AbstractStyleBox; 10 | public: 11 | explicit InterpretationBox(AbstractSequence *content); 12 | explicit InterpretationBox(AbstractSequence *content, Expr _interpretation); 13 | 14 | virtual MathSequence *as_inline_span() override; 15 | virtual void reset_style() override; 16 | 17 | // Box::try_create(expr, opts); 18 | virtual bool try_load_from_object(Expr expr, BoxInputFlags opts) override; 19 | 20 | virtual Expr to_pmath_symbol() override; 21 | 22 | virtual bool edit_selection(SelectionReference &selection, EditAction action) override; 23 | 24 | protected: 25 | virtual Expr to_pmath_impl(BoxOutputFlags flags) override; 26 | 27 | public: 28 | Expr interpretation; 29 | }; 30 | } 31 | 32 | #endif // RICHMATH__BOXES__INTERPRETATIONBOX_H__INCLUDED 33 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/lists/mean.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | 9 | extern pmath_symbol_t pmath_System_List; 10 | extern pmath_symbol_t pmath_System_Plus; 11 | extern pmath_symbol_t pmath_System_Times; 12 | 13 | PMATH_PRIVATE pmath_t builtin_mean(pmath_expr_t expr) { 14 | /* Mean(list) = (Plus @@ list) / Length(list) 15 | */ 16 | pmath_t item; 17 | 18 | if(pmath_expr_length(expr) != 1) { 19 | pmath_message_argxxx(pmath_expr_length(expr), 1, 1); 20 | return expr; 21 | } 22 | 23 | item = pmath_expr_get_item(expr, 1); 24 | if( !pmath_is_expr_of(item, pmath_System_List) || 25 | pmath_expr_length(item) == 0) 26 | { 27 | pmath_unref(item); 28 | return expr; 29 | } 30 | 31 | pmath_unref(expr); 32 | return pmath_expr_new_extended( 33 | pmath_ref(pmath_System_Times), 2, 34 | pmath_rational_new( 35 | PMATH_FROM_INT32(1), 36 | pmath_integer_new_uiptr(pmath_expr_length(item))), 37 | pmath_expr_set_item(item, 0, pmath_ref(pmath_System_Plus))); 38 | } 39 | -------------------------------------------------------------------------------- /richmath/include/gui/gtk/mgtk-icons.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__GTK__MGTK_ICONS_H__INCLUDED 2 | #define RICHMATH__GUI__GTK__MGTK_ICONS_H__INCLUDED 3 | 4 | #ifndef RICHMATH_USE_GTK_GUI 5 | # error this header is gtk specific 6 | #endif 7 | 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | 14 | namespace richmath { 15 | class MathGtkIcons: public Base { 16 | public: 17 | enum Index { 18 | AppIcon16Index, 19 | AppIcon24Index, 20 | AppIcon32Index, 21 | AppIcon48Index, 22 | 23 | IconsCount 24 | }; 25 | 26 | public: 27 | MathGtkIcons(); 28 | ~MathGtkIcons(); 29 | 30 | GdkPixbuf *get_icon(Index idx); // you must free the result withn g_object_unref() 31 | 32 | GdkPixbuf *get_app_icon(GtkIconSize size); // you must free the result withn g_object_unref() 33 | 34 | static GdkPixbuf *new_pixbuf_from_image(cairo_surface_t *image); 35 | 36 | GList *get_app_icon_list(); // list of GdkPixbuf, you must free it 37 | }; 38 | } 39 | 40 | #endif // RICHMATH__GUI__GTK__MGTK_ICONS_H__INCLUDED 41 | -------------------------------------------------------------------------------- /modules/System/Numerics/library/src/acb-impl-twoarg.inc: -------------------------------------------------------------------------------- 1 | /* Implement functions F(x, y) of a two complex arguments. 2 | First try ACB_FUNCTION(x, y) in C and then fall back to SIMPLIFY_SYMBOL(F, x, y) 3 | in pMath, returning unevaluated if that gives $Failed. 4 | */ 5 | #ifndef ACB_FUNCTION 6 | # error ACB_FUNCTION not defined 7 | #endif 8 | #ifndef SIMPLIFY_SYMBOL 9 | # error SIMPLIFY_SYMBOL not defined 10 | #endif 11 | 12 | extern pmath_symbol_t pmath_System_DollarFailed; 13 | 14 | pmath_t x; 15 | pmath_t y; 16 | 17 | if(pmath_expr_length(expr) != 2) { 18 | pmath_message_argxxx(pmath_expr_length(expr), 2, 2); 19 | return expr; 20 | } 21 | 22 | x = pmath_expr_get_item(expr, 1); 23 | y = pmath_expr_get_item(expr, 2); 24 | if(pmath_complex_try_evaluate_acb_2(&expr, x, y, ACB_FUNCTION)) { 25 | pmath_unref(x); 26 | pmath_unref(y); 27 | return expr; 28 | } 29 | 30 | x = pmath_expr_new_extended( 31 | pmath_ref(SIMPLIFY_SYMBOL), 3, 32 | pmath_expr_get_item(expr, 0), 33 | x, 34 | y); 35 | 36 | x = pmath_evaluate(x); 37 | if(!pmath_same(x, pmath_System_DollarFailed)) { 38 | pmath_unref(expr); 39 | return x; 40 | } 41 | 42 | pmath_unref(x); 43 | return expr; 44 | -------------------------------------------------------------------------------- /richmath/include/util/alignment.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__UTIL__ALIGNMENT_H__INCLUDED 2 | #define RICHMATH__UTIL__ALIGNMENT_H__INCLUDED 3 | 4 | 5 | #include 6 | 7 | 8 | namespace richmath { 9 | class SimpleAlignment { 10 | class Impl; 11 | public: 12 | float horizontal; // 0 = left .. 1 = right 13 | float vertical; // 0 = bottom .. 1 = top 14 | 15 | static const SimpleAlignment TopLeft; 16 | static const SimpleAlignment Center; 17 | 18 | float interpolate_left_to_right(float left, float right) { return left + horizontal * (right - left); } 19 | float interpolate_bottom_to_top(float bottom, float top) { return bottom + vertical * (top - bottom); } 20 | 21 | static SimpleAlignment from_pmath(Expr expr, SimpleAlignment fallback); 22 | }; 23 | 24 | class SimpleBoxBaselinePositioning { 25 | public: 26 | float ascent; 27 | float descent; 28 | float cy; 29 | 30 | float scaled_baseline(double scale) const { return (float)(-(double)descent + scale * (ascent + descent)); } 31 | float calculate_baseline(float em, Expr baseline_pos) const; 32 | }; 33 | } 34 | 35 | #endif // RICHMATH__UTIL__ALIGNMENT_H__INCLUDED 36 | -------------------------------------------------------------------------------- /library/include/pmath-util/hash/sha1.h: -------------------------------------------------------------------------------- 1 | #ifndef PMATH_UTIL__HASH__SHA1_H__INCLUDED 2 | #define PMATH_UTIL__HASH__SHA1_H__INCLUDED 3 | 4 | 5 | #ifndef BUILDING_PMATH 6 | # error This header file is not part of the public pMath API 7 | #endif 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | 15 | /* SHA-1 in C 16 | By Steve Reid 17 | Public Domain 18 | */ 19 | struct _pmath_sha1_context_t { 20 | uint32_t state[5]; 21 | uint32_t count[2]; 22 | uint8_t buffer[64]; 23 | }; 24 | 25 | struct _pmath_sha1_digest_t { 26 | uint8_t digest[20]; 27 | }; 28 | 29 | PMATH_PRIVATE 30 | void _pmath_sha1_transform(uint32_t state[5], const uint8_t buffer[64]); 31 | 32 | PMATH_PRIVATE 33 | void _pmath_sha1_init(struct _pmath_sha1_context_t *context); 34 | 35 | PMATH_PRIVATE 36 | void _pmath_sha1_update(struct _pmath_sha1_context_t *context, const uint8_t *data, uint32_t len); 37 | 38 | PMATH_PRIVATE 39 | void _pmath_sha1_final(struct _pmath_sha1_digest_t hash_out[1], struct _pmath_sha1_context_t *context); 40 | 41 | PMATH_PRIVATE 42 | void _pmath_sha1(struct _pmath_sha1_digest_t hash_out[1], const uint8_t *buf, size_t len); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/arithmetic/fractionalpart.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | 14 | extern pmath_symbol_t pmath_System_IntegerPart; 15 | extern pmath_symbol_t pmath_System_Plus; 16 | extern pmath_symbol_t pmath_System_Times; 17 | 18 | PMATH_PRIVATE pmath_t builtin_fractionalpart(pmath_expr_t expr) { 19 | pmath_t x, ix; 20 | 21 | if(pmath_expr_length(expr) != 1){ 22 | pmath_message_argxxx(pmath_expr_length(expr), 1, 1); 23 | return expr; 24 | } 25 | 26 | x = pmath_expr_get_item(expr, 1); 27 | 28 | ix = FUNC(pmath_ref(pmath_System_IntegerPart), pmath_ref(x)); 29 | ix = pmath_evaluate(ix); 30 | if(!pmath_is_expr_of_len(ix, pmath_System_IntegerPart, 1)){ 31 | pmath_unref(expr); 32 | return MINUS(x, ix); 33 | } 34 | 35 | pmath_unref(x); 36 | pmath_unref(ix); 37 | return expr; 38 | } 39 | -------------------------------------------------------------------------------- /richmath/include/boxes/framebox.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__BOXES__FRAMEBOX_H__INCLUDED 2 | #define RICHMATH__BOXES__FRAMEBOX_H__INCLUDED 3 | 4 | #include 5 | 6 | 7 | namespace richmath { 8 | class FrameBox final : public ExpandableOwnerBox { 9 | using base = ExpandableOwnerBox; 10 | class Impl; 11 | public: 12 | explicit FrameBox(AbstractSequence *content = nullptr); 13 | 14 | // Box::try_create(expr, opts); 15 | virtual bool try_load_from_object(Expr expr, BoxInputFlags options) override; 16 | 17 | virtual void paint(Context &context) override; 18 | 19 | virtual void reset_style() override; 20 | 21 | virtual Expr to_pmath_symbol() override; 22 | 23 | protected: 24 | virtual Expr to_pmath_impl(BoxOutputFlags flags) override; 25 | virtual void resize_default_baseline(Context &context) override; 26 | 27 | virtual DefaultStyleOptionOffsets get_default_styles_offset() override { return DefaultStyleOptionOffsets::FrameBox; } 28 | 29 | protected: 30 | float em; 31 | }; 32 | } 33 | 34 | #endif // RICHMATH__BOXES__FRAMEBOX_H__INCLUDED 35 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/lists/flatten.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | 6 | PMATH_PRIVATE pmath_t builtin_flatten(pmath_expr_t expr) { 7 | /* Flatten(list) 8 | Flatten(list, tolevel) 9 | Flatten(list, tolevel, head) 10 | */ 11 | pmath_expr_t list; 12 | pmath_t head; 13 | size_t depth, exprlen; 14 | 15 | exprlen = pmath_expr_length(expr); 16 | if(exprlen < 1 || exprlen > 3) { 17 | pmath_message_argxxx(exprlen, 1, 3); 18 | return expr; 19 | } 20 | 21 | list = pmath_expr_get_item(expr, 1); 22 | if(!pmath_is_expr(list)) { 23 | pmath_unref(list); 24 | return expr; 25 | } 26 | 27 | depth = SIZE_MAX; 28 | if(exprlen >= 2) { 29 | pmath_t depth_arg = pmath_expr_get_item(expr, 2); 30 | if(!extract_number(depth_arg, SIZE_MAX, &depth)) { 31 | pmath_unref(list); 32 | pmath_unref(depth_arg); 33 | return expr; 34 | } 35 | pmath_unref(depth_arg); 36 | } 37 | 38 | if(exprlen == 3) 39 | head = pmath_expr_get_item(expr, 3); 40 | else 41 | head = pmath_expr_get_item(list, 0); 42 | 43 | pmath_unref(expr); 44 | return pmath_expr_flatten(list, head, depth); 45 | } 46 | -------------------------------------------------------------------------------- /modules/Java/library/src/pjvm.h: -------------------------------------------------------------------------------- 1 | #ifndef PJVM_H__INCLUDED 2 | #define PJVM_H__INCLUDED 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | extern pmath_t pjvm_dll_filename; 10 | extern pmath_t pjvm_auto_detach_key; 11 | extern jthrowable pjvm_internal_exception; 12 | 13 | PMATH_PRIVATE pmath_bool_t pjvm_register_external(JavaVM *jvm); 14 | 15 | PMATH_PRIVATE pmath_bool_t pjvm_java_is_running(void); 16 | 17 | PMATH_PRIVATE 18 | PMATH_ATTRIBUTE_USE_RESULT 19 | pmath_t pjvm_try_get(void); // must be freed 20 | 21 | PMATH_PRIVATE JavaVM *pjvm_get_java(pmath_t pjvm); 22 | PMATH_PRIVATE jvmtiEnv *pjvm_get_jvmti(pmath_t pjvm); 23 | 24 | PMATH_PRIVATE JNIEnv *pjvm_try_get_env(void); 25 | PMATH_PRIVATE JNIEnv *pjvm_get_env(void); 26 | 27 | PMATH_PRIVATE pmath_bool_t pj_exception_to_pmath(JNIEnv *env); 28 | PMATH_PRIVATE pmath_bool_t pj_exception_to_java(JNIEnv *env); 29 | PMATH_PRIVATE pmath_bool_t pj_exception_throw_new(JNIEnv *env, jclass clazz, pmath_string_t message); // message will be freed 30 | 31 | PMATH_PRIVATE void pjvm_ensure_started(void); 32 | 33 | PMATH_PRIVATE pmath_bool_t pjvm_init(void); 34 | PMATH_PRIVATE void pjvm_done(void); 35 | 36 | #endif // PJVM_H__INCLUDED 37 | -------------------------------------------------------------------------------- /richmath/include/boxes/panebox.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__BOXES__PANEBOX_H__INCLUDED 2 | #define RICHMATH__BOXES__PANEBOX_H__INCLUDED 3 | 4 | #include 5 | 6 | namespace richmath { 7 | class PaneBox : public AbstractTransformationBox { 8 | using base = AbstractTransformationBox; 9 | class Impl; 10 | protected: 11 | virtual ~PaneBox(); 12 | public: 13 | explicit PaneBox(AbstractSequence *content); 14 | 15 | virtual void reset_style() override; 16 | 17 | virtual bool try_load_from_object(Expr expr, BoxInputFlags opts) override; 18 | 19 | virtual Expr to_pmath_symbol() override; 20 | 21 | virtual void paint_content(Context &context) override; 22 | 23 | protected: 24 | virtual Expr to_pmath_impl(BoxOutputFlags flags) override; 25 | 26 | virtual void resize_default_baseline(Context &context) override; 27 | virtual float allowed_content_width(const Context &context) override; 28 | 29 | virtual DefaultStyleOptionOffsets get_default_styles_offset() override { return DefaultStyleOptionOffsets::PaneBox; } 30 | }; 31 | } 32 | 33 | #endif // RICHMATH__BOXES__PANEBOX_H__INCLUDED 34 | -------------------------------------------------------------------------------- /richmath/include/gui/common-tooltips.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__TOOLTIPS_H__INCLUDED 2 | #define RICHMATH__GUI__TOOLTIPS_H__INCLUDED 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace pmath { 9 | class Expr; 10 | } 11 | 12 | namespace richmath { 13 | class Document; 14 | class Stylesheet; 15 | 16 | extern Side control_placement_side(ControlPlacementKind cpk); 17 | 18 | namespace CommonTooltips { 19 | void load_content(Document *doc, const pmath::Expr &boxes, SharedPtr stylesheet); 20 | 21 | Interval popup_placement_before(Interval target, float size, Interval outer); 22 | Interval popup_placement_after( Interval target, float size, Interval outer); 23 | Interval popup_placement_at( Interval target, float size, Interval outer); 24 | 25 | RectangleF popup_placement(const RectangleF &target_rect, Vector2F size, ControlPlacementKind cpk, const RectangleF &monitor); 26 | RectangleF popup_placement(const RectangleF &target_rect, Vector2F size, ControlPlacementKind cpk); 27 | } 28 | } 29 | 30 | #endif // RICHMATH__GUI__TOOLTIPS_H__INCLUDED 31 | -------------------------------------------------------------------------------- /modules/Windows/library/src/util.h: -------------------------------------------------------------------------------- 1 | #ifndef __PMATH_WINDOWS__ERROR_UTIL_H__ 2 | #define __PMATH_WINDOWS__ERROR_UTIL_H__ 3 | 4 | #include 5 | #include 6 | 7 | /** Convert a pMath string to a BSTR and free the pMath string. 8 | */ 9 | extern BSTR string_to_bstr_free(pmath_string_t str); 10 | 11 | /** Convert a BSTR to a pMath string. The BSTR is not freed. 12 | */ 13 | extern pmath_string_t bstr_to_string(BSTR bstr); 14 | 15 | 16 | /** Convert a pMath string to a GUID. The string will not be freed. 17 | */ 18 | extern pmath_bool_t string_to_guid(pmath_string_t string, GUID *guid); 19 | 20 | /** Convert a GUID to a pMath string. 21 | */ 22 | extern pmath_string_t guid_to_string(const GUID *guid); 23 | 24 | /** Test whether a HRESULT indicates success and print a message if not. 25 | */ 26 | extern pmath_bool_t check_succeeded(HRESULT hr); 27 | 28 | /** Test whether a win32 error code indicates success and print a message if not. 29 | */ 30 | extern pmath_bool_t check_succeeded_win32(DWORD error_code); 31 | 32 | 33 | /** The inverse of CommandLineToArgvW. The list will be freed. 34 | */ 35 | extern pmath_t try_compose_arguments(pmath_expr_t list); 36 | 37 | #endif // __PMATH_WINDOWS__ERROR_UTIL_H__ 38 | -------------------------------------------------------------------------------- /richmath/include/boxes/graphics/circleordiskbox.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__BOXES__GRAPHICS__CIRCLEBOX_H__INCLUDED 2 | #define RICHMATH__BOXES__GRAPHICS__CIRCLEBOX_H__INCLUDED 3 | 4 | #include 5 | #include 6 | 7 | namespace richmath { 8 | class CircleOrDiskBox final : public GraphicsElement { 9 | class Impl; 10 | protected: 11 | virtual ~CircleOrDiskBox(); 12 | public: 13 | static GraphicsElement *create(Expr expr, BoxInputFlags opts) = delete; 14 | static CircleOrDiskBox *try_create(Expr expr, BoxInputFlags opts); 15 | 16 | virtual bool try_load_from_object(Expr expr, BoxInputFlags opts) override; 17 | 18 | virtual void find_extends(GraphicsBounds &bounds) override; 19 | virtual void paint(GraphicsDrawingContext &gc) override; 20 | 21 | protected: 22 | Expr _expr; 23 | double cx; 24 | double cy; 25 | double rx; 26 | double ry; 27 | Interval angles; 28 | 29 | protected: 30 | CircleOrDiskBox(); 31 | 32 | virtual Expr to_pmath_impl(BoxOutputFlags flags) override; 33 | }; 34 | } 35 | 36 | #endif // RICHMATH__BOXES__GRAPHICS__CIRCLEBOX_H__INCLUDED 37 | -------------------------------------------------------------------------------- /library/test-suite/tests/FromCharacterCode.pmath: -------------------------------------------------------------------------------- 1 | 2 | AssertEqual("abc", FromCharacterCode({97, 98, 99})) 3 | AssertEqual("abc", FromCharacterCode({97, 98, 99}, "ASCII")) 4 | AssertEqual("abc", FromCharacterCode({97, 98, 99}, "UTF-8")) 5 | AssertEqual("abc", FromCharacterCode({97, 98, 99}, "UTF-16")) 6 | AssertEqual("abc", FromCharacterCode({97, 98, 99}, "UTF-32")) 7 | 8 | AssertEqual("XYZ", FromCharacterCode @ {88, 89, 90}) 9 | 10 | AssertEqual("\[Alpha]\[Beta]", FromCharacterCode @ {16^^3b1, 16^^3b2}) 11 | 12 | AssertEqual("\[Alpha]\[Beta]", FromCharacterCode({16^^ce, 16^^B1, 16^^ce, 16^^b2}, "UTF-8")) 13 | 14 | AssertEqual("\[Sum]", FromCharacterCode @ {16^^2211}) 15 | 16 | AssertEqual("\[Sum]", FromCharacterCode({16^^E2, 16^^88, 16^^91}, "UTF-8")) 17 | 18 | AssertEqual("\[U+1234]\[U+0000]\[U+FFFF]", FromCharacterCode @ {16^^1234, 0, 16^^ffff}) 19 | 20 | AssertEqual("\[U+12345]", FromCharacterCode({16^^12345}, "Unicode")) 21 | AssertEqual("\[U+12345]", FromCharacterCode({16^^12345}, "UTF-32")) 22 | AssertEqual("\[U+12345]", FromCharacterCode({16^^D808, 16^^DF45})) 23 | AssertEqual("\[U+12345]", FromCharacterCode({16^^D808, 16^^DF45}, "UTF-16")) 24 | AssertEqual("\[U+12345]", FromCharacterCode({16^^F0, 16^^92, 16^^8D, 16^^85}, "UTF-8")) 25 | -------------------------------------------------------------------------------- /library/scripts/auto/core/text/maketextexpression.pmath: -------------------------------------------------------------------------------- 1 | 2 | BeginPackage("System`Text`") 3 | 4 | MakeTextExpression 5 | 6 | Begin("System`Text`Private`") 7 | 8 | Attributes(makeSimpleTextExpression):= {HoldAllComplete} 9 | makeSimpleTextExpression(box: ~h(~innerbox, ~~~boxopts), ~expectedHead) ::= 10 | MakeExpression(h(0, boxopts)) |> { 11 | HoldComplete(expectedHead(~, ~~~opts)) :> MakeTextExpression(innerbox) |> { 12 | HoldComplete(~inner) :> HoldComplete(expectedHead(inner, opts)), 13 | ~ :> MakeExpression(box) 14 | }, 15 | ~ :> MakeExpression(box) 16 | } 17 | MakeTextExpression(~other)::= MakeExpression(other) 18 | MakeTextExpression(~s:String)::= HoldComplete(s) 19 | MakeTextExpression(BoxData(~boxes))::= MakeExpression(boxes) 20 | MakeTextExpression({~~~items})::= HoldComplete(items) |> 21 | Map(MakeTextExpression) |> 22 | Flatten(1) |> 23 | Replace(HoldComplete(~~~objs):>HoldComplete({objs})) 24 | 25 | MakeTextExpression(~box:ButtonBox)::= makeSimpleTextExpression(box, Button) 26 | MakeTextExpression(~box:PanelBox)::= makeSimpleTextExpression(box, Panel) 27 | MakeTextExpression(~box:StyleBox)::= makeSimpleTextExpression(box, Style) 28 | 29 | End() 30 | 31 | EndPackage() 32 | -------------------------------------------------------------------------------- /richmath/include/gui/documents.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__GUI__DOCUMENTS_H__INCLUDED 2 | #define RICHMATH__GUI__DOCUMENTS_H__INCLUDED 3 | 4 | 5 | #include 6 | 7 | #include 8 | 9 | 10 | namespace richmath { 11 | class Box; 12 | class Document; 13 | class DocumentsImpl; 14 | 15 | class Documents { 16 | friend class DocumentsImpl; 17 | using Impl = DocumentsImpl; 18 | public: 19 | static bool init(); 20 | static void done(); 21 | 22 | static ObservableValue focused_document_id; 23 | static ObservableValue selected_document_id; 24 | 25 | static Document *selected_document(); 26 | static void selected_document(Document *document); 27 | 28 | static Box *keyboard_input_box(); 29 | static Document *keyboard_input_document(); 30 | static Document *focused_document(); 31 | static void focus_gained(Document *document); 32 | static bool focus_lost(Document *old_focus_doc); 33 | 34 | static Expr make_section_boxes(Expr boxes, Document *doc); 35 | static bool locate_document_from_command(Expr item_cmd); 36 | }; 37 | 38 | } 39 | 40 | #endif // RICHMATH__GUI__DOCUMENTS_H__INCLUDED 41 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/lists/nestlist.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | PMATH_PRIVATE pmath_t builtin_nestlist(pmath_expr_t expr) { 10 | /* NestList(f, x, n) 11 | */ 12 | pmath_t obj, func; 13 | size_t n; 14 | 15 | if(pmath_expr_length(expr) != 3) { 16 | pmath_message_argxxx(pmath_expr_length(expr), 3, 3); 17 | return expr; 18 | } 19 | 20 | obj = pmath_expr_get_item(expr, 3); 21 | if(!pmath_is_int32(obj) || PMATH_AS_INT32(obj) < 0) { 22 | pmath_unref(obj); 23 | pmath_message(PMATH_NULL, "intnm", 2, PMATH_FROM_INT32(3), pmath_ref(expr)); 24 | return expr; 25 | } 26 | 27 | n = (unsigned)PMATH_AS_INT32(obj); 28 | 29 | pmath_gather_begin(PMATH_NULL); 30 | func = pmath_expr_get_item(expr, 1); 31 | obj = pmath_expr_get_item(expr, 2); 32 | pmath_unref(expr); 33 | while(n-- > 0 && !pmath_aborting()) { 34 | pmath_emit(pmath_ref(obj), PMATH_NULL); 35 | obj = pmath_evaluate(pmath_expr_new_extended(pmath_ref(func), 1, obj)); 36 | } 37 | 38 | pmath_emit(obj, PMATH_NULL); 39 | pmath_unref(func); 40 | return pmath_gather_end(); 41 | } 42 | -------------------------------------------------------------------------------- /library/include/pmath-util/security-private.h: -------------------------------------------------------------------------------- 1 | #ifndef PMATH_UTIL__SECURITY_PRIVATE_H__INCLUDED 2 | #define PMATH_UTIL__SECURITY_PRIVATE_H__INCLUDED 3 | 4 | 5 | #ifndef BUILDING_PMATH 6 | # error This header file is not part of the public pMath API 7 | #endif 8 | 9 | 10 | #include 11 | 12 | 13 | PMATH_PRIVATE 14 | pmath_bool_t _pmath_security_check_builtin( 15 | void *func, // A pmath_builtin_func_t or pmath_approx_func_t 16 | pmath_expr_t expr, 17 | pmath_symbol_t src_sym, // The symbol that defines `func`. Wont be freed. 18 | pmath_symbol_t kind, // How `func` is bound to `src_sym`, e.g. pmath_System_DownRules. Wont be freed. 19 | pmath_security_level_t current_level); // must be pmath_thread_get_current()->security_level 20 | 21 | 22 | PMATH_PRIVATE 23 | pmath_t _pmath_security_level_to_expr(pmath_security_level_t level); 24 | 25 | 26 | // expr wont be freed 27 | PMATH_PRIVATE 28 | pmath_bool_t _pmath_security_level_from_expr(pmath_security_level_t *level, pmath_expr_t expr); 29 | 30 | PMATH_PRIVATE 31 | pmath_bool_t _pmath_security_init(void); 32 | 33 | PMATH_PRIVATE 34 | void _pmath_security_done(); 35 | 36 | 37 | #endif // PMATH_UTIL__SECURITY_PRIVATE_H__INCLUDED 38 | -------------------------------------------------------------------------------- /richmath/include/eval/current-value.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__EVAL__CURRENT_VALUE_H__INCLUDED 2 | #define RICHMATH__EVAL__CURRENT_VALUE_H__INCLUDED 3 | 4 | 5 | #include 6 | 7 | namespace richmath { 8 | class FrontEndObject; 9 | 10 | class CurrentValueImpl; 11 | class CurrentValue final { 12 | friend class CurrentValueImpl; 13 | using Impl = CurrentValueImpl; 14 | public: 15 | static void init(); 16 | static void done(); 17 | 18 | static Expr get( Expr item); 19 | static Expr get(Expr obj, Expr item); 20 | static Expr get(FrontEndObject *obj, Expr item); 21 | static bool put(FrontEndObject *obj, Expr item, Expr rhs); 22 | 23 | static bool register_provider( 24 | Expr item, 25 | Expr (*get)(FrontEndObject *obj, Expr item), 26 | bool (*put)(FrontEndObject *obj, Expr item, Expr rhs) = nullptr); 27 | static bool register_provider( 28 | Expr item, 29 | FrontEndObject *(*get)(FrontEndObject *obj, Expr item)); 30 | 31 | private: 32 | CurrentValue() = delete; 33 | CurrentValue(const CurrentValue&) = delete; 34 | 35 | }; 36 | } 37 | 38 | #endif // RICHMATH__EVAL__CURRENT_VALUE_H__INCLUDED 39 | -------------------------------------------------------------------------------- /richmath/include/syntax/autocompletion.h: -------------------------------------------------------------------------------- 1 | #ifndef RICHMATH__SYNTAX__AUTOCOMPLETION_H__INCLUDED 2 | #define RICHMATH__SYNTAX__AUTOCOMPLETION_H__INCLUDED 3 | 4 | #include 5 | #include 6 | 7 | 8 | namespace richmath { 9 | class Document; 10 | 11 | class AutoCompletion { 12 | public: 13 | explicit AutoCompletion(Document *_document); 14 | ~AutoCompletion(); 15 | 16 | AutoCompletion(const AutoCompletion &) = delete; 17 | 18 | bool is_active() const; 19 | bool has_popup() const; 20 | bool has_popup(FrontEndReference id) const; 21 | 22 | bool handle_key_backspace(); 23 | bool handle_key_escape(); 24 | bool handle_key_press(uint32_t unichar); 25 | bool handle_key_tab(LogicalDirection direction); 26 | bool handle_key_up_down(LogicalDirection direction); 27 | void stop(); 28 | 29 | public: 30 | SelectionReference range; 31 | 32 | private: 33 | class Private; 34 | Private *priv; 35 | 36 | public: 37 | class AccessToken final { 38 | friend class AutoCompletion; 39 | 40 | explicit AccessToken() = default; 41 | }; 42 | }; 43 | } 44 | 45 | #endif // RICHMATH__SYNTAX__AUTOCOMPLETION_H__INCLUDED 46 | -------------------------------------------------------------------------------- /library/include/pmath-util/version-private.h: -------------------------------------------------------------------------------- 1 | #ifndef __PMATH_UTIL__VERSION_PRIVATE_H__ 2 | #define __PMATH_UTIL__VERSION_PRIVATE_H__ 3 | 4 | //Date Version Types 5 | static const char _PMATH_VERSION_DATE[] = "29"; 6 | static const char _PMATH_VERSION_MONTH[] = "03"; 7 | static const char _PMATH_VERSION_YEAR[] = "2025"; 8 | static const char _PMATH_VERSION_UBUNTU_VERSION_STYLE[] = "25.03"; 9 | 10 | //Software Status 11 | static const char _PMATH_VERSION_STATUS[] = "Alpha"; 12 | static const char _PMATH_VERSION_STATUS_SHORT[] = "a"; 13 | 14 | //Standard Version Type 15 | static const long _PMATH_VERSION_MAJOR = 0; 16 | static const long _PMATH_VERSION_MINOR = 5; 17 | static const long _PMATH_VERSION_BUILD = 1023; 18 | static const long _PMATH_VERSION_REVISION = 1431; 19 | 20 | //Miscellaneous Version Types 21 | static const long _PMATH_VERSION_BUILDS_COUNT = 1290; 22 | #define _PMATH_VERSION_RC_FILEVERSION 0,5,1023,1431 23 | #define _PMATH_VERSION_RC_FILEVERSION_STRING "0, 5, 1023, 1431\0" 24 | static const char _PMATH_VERSION_FULLVERSION_STRING [] = "0.5.1023.1431"; 25 | 26 | //These values are to keep track of your versioning state, don't modify them. 27 | static const long _PMATH_VERSION_BUILD_HISTORY = 0; 28 | 29 | 30 | #endif //__PMATH_UTIL__VERSION_PRIVATE_H__ 31 | -------------------------------------------------------------------------------- /library/include/pmath-builtins/control/flow-private.h: -------------------------------------------------------------------------------- 1 | #ifndef __PMATH_BUILTINS__CONTROL__FLOW_PRIVATE_H__ 2 | #define __PMATH_BUILTINS__CONTROL__FLOW_PRIVATE_H__ 3 | 4 | #ifndef BUILDING_PMATH 5 | #error This header file is not part of the public pMath API 6 | #endif 7 | 8 | /* This header exports all definitions of the sources in 9 | src/pmath-builtins/control/flow/ 10 | */ 11 | 12 | PMATH_PRIVATE pmath_bool_t _pmath_run(pmath_t *in_out); // return = stop? (break/return/...) 13 | 14 | PMATH_PRIVATE 15 | PMATH_ATTRIBUTE_NONNULL(2, 3) 16 | void _pmath_iterate( 17 | pmath_t iter, // will be freed 18 | void (*init)(size_t, pmath_symbol_t, void*), // symbol must not be freed 19 | pmath_bool_t (*next)(void*), 20 | void *data); 21 | /* iter = n 22 | i->n 23 | i->a..b 24 | i->a..b..d 25 | i->{x1,x2,...} 26 | 27 | messages: 28 | General::iter 29 | General::iterb 30 | 31 | _count_ is determined by iter. 32 | init(_count_, data) is called iff there is no error (no message). 33 | next(data) is called at most _count_ times. The return value specifies 34 | whether to go on. 35 | */ 36 | 37 | #endif // __PMATH_BUILTINS__CONTROL__FLOW_PRIVATE_H__ 38 | -------------------------------------------------------------------------------- /richmath/src/eval/interpolation.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | #ifdef _MSC_VER 9 | namespace std { 10 | static bool isnan(double d) {return _isnan(d);} 11 | } 12 | #endif 13 | 14 | #ifndef NAN 15 | # define NAN (std::numeric_limits::quiet_NaN()) 16 | #endif 17 | 18 | 19 | using namespace richmath; 20 | 21 | //{ class Interpolation ... 22 | 23 | 24 | float Interpolation::interpolation_index(const Array &values, float val, bool clip) { 25 | float prev = NAN; 26 | for(int i = 0; i < values.length(); ++i) { 27 | float cur = values[i]; 28 | if(val == cur) 29 | return i; 30 | 31 | float rel = (cur - val) / (cur - prev); 32 | if(0 <= rel && rel <= 1) 33 | return i - rel; 34 | 35 | prev = cur; 36 | } 37 | 38 | if(clip) { 39 | if(values.length() >= 2) { 40 | if(values[0] < values[1]) { 41 | if(val < values[0]) 42 | return 0; 43 | else 44 | return values.length() - 1; 45 | } 46 | else { 47 | if(val > values[0]) 48 | return values.length() - 1; 49 | else 50 | return 0; 51 | } 52 | } 53 | } 54 | return NAN; 55 | } 56 | 57 | //} ... class Interpolation 58 | -------------------------------------------------------------------------------- /modules/hello/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | static pmath_symbol_t HELLO_SYMBOL_GREET = PMATH_STATIC_NULL; 6 | 7 | static pmath_t hello_func_greet(pmath_expr_t expr){ 8 | pmath_unref(expr); 9 | return PMATH_C_STRING("Hi there."); 10 | } 11 | 12 | PMATH_MODULE 13 | pmath_bool_t pmath_module_init(pmath_string_t filename){ 14 | #define VERIFY(x) do{ if(pmath_is_null(x)) goto FAIL; }while(0) 15 | #define NEW_SYMBOL(name) pmath_symbol_get(PMATH_C_STRING((name)), TRUE) 16 | 17 | #define BIND(sym, func, use) do{ if(!pmath_register_code((sym), (func), (use))) goto FAIL; }while(0) 18 | #define BIND_DOWN(sym, func) BIND((sym), (func), PMATH_CODE_USAGE_DOWNCALL) 19 | 20 | #define PROTECT(sym) pmath_symbol_set_attributes((sym), pmath_symbol_get_attributes((sym)) | PMATH_SYMBOL_ATTRIBUTE_PROTECTED) 21 | 22 | VERIFY(HELLO_SYMBOL_GREET = NEW_SYMBOL("Hello`Greet")); 23 | 24 | BIND_DOWN(HELLO_SYMBOL_GREET, hello_func_greet); 25 | 26 | PROTECT(HELLO_SYMBOL_GREET); 27 | 28 | return TRUE; 29 | 30 | FAIL: 31 | return FALSE; 32 | 33 | #undef VERIFY 34 | #undef NEW_SYMBOL 35 | #undef BIND 36 | #undef BIND_DOWN 37 | #undef PROTECT 38 | } 39 | 40 | PMATH_MODULE 41 | void pmath_module_done(void){ 42 | pmath_unref(HELLO_SYMBOL_GREET); 43 | } 44 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/arithmetic/minus-and-subtract.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | 10 | extern pmath_symbol_t pmath_System_Times; 11 | extern pmath_symbol_t pmath_System_Plus; 12 | 13 | 14 | PMATH_PRIVATE pmath_t builtin_minus(pmath_expr_t expr) { 15 | /* Minux(x) 16 | */ 17 | if(pmath_expr_length(expr) != 1) { 18 | pmath_message_argxxx(pmath_expr_length(expr), 1, 1); 19 | return expr; 20 | } 21 | 22 | pmath_t x = pmath_expr_get_item(expr, 1); 23 | pmath_unref(expr); 24 | if(pmath_is_number(x)) 25 | return pmath_number_neg(x); 26 | return NEG(x); 27 | } 28 | 29 | PMATH_PRIVATE pmath_t builtin_subtract(pmath_expr_t expr) { 30 | /* Subtract(x, y) 31 | */ 32 | if(pmath_expr_length(expr) != 2) { 33 | pmath_message_argxxx(pmath_expr_length(expr), 2, 2); 34 | return expr; 35 | } 36 | 37 | pmath_t y = pmath_expr_extract_item(expr, 2); 38 | if(pmath_is_number(y)) 39 | y = pmath_number_neg(y); 40 | else 41 | y = NEG(y); 42 | expr = pmath_expr_set_item(expr, 2, y); 43 | expr = pmath_expr_set_item(expr, 0, pmath_ref(pmath_System_Plus)); 44 | return expr; 45 | } 46 | -------------------------------------------------------------------------------- /library/src/pmath-builtins/lists/leafcount.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | 7 | static size_t leafcount(pmath_t obj) { // obj will be freed 8 | if(pmath_is_packed_array(obj)) { 9 | size_t dims = pmath_packed_array_get_dimensions(obj); 10 | const size_t *sizes = pmath_packed_array_get_sizes(obj); 11 | 12 | size_t i, total; 13 | total = 1; 14 | i = dims; 15 | while(i-- > 0) { 16 | total = sizes[i] * total + 1; 17 | } 18 | 19 | pmath_unref(obj); 20 | return total; 21 | } 22 | 23 | if(pmath_is_expr(obj)) { 24 | size_t result = 0; 25 | size_t i; 26 | 27 | for(i = 0; i <= pmath_expr_length(obj); ++i) 28 | result += leafcount(pmath_expr_get_item(obj, i)); 29 | 30 | pmath_unref(obj); 31 | return result; 32 | } 33 | 34 | pmath_unref(obj); 35 | return 1; 36 | } 37 | 38 | PMATH_PRIVATE pmath_t builtin_leafcount(pmath_expr_t expr) { 39 | pmath_t obj; 40 | 41 | if(pmath_expr_length(expr) != 1) { 42 | pmath_message_argxxx(pmath_expr_length(expr), 1, 1); 43 | return expr; 44 | } 45 | 46 | obj = pmath_expr_get_item(expr, 1); 47 | pmath_unref(expr); 48 | 49 | return pmath_integer_new_uiptr(leafcount(obj)); 50 | } 51 | --------------------------------------------------------------------------------