GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - njpipeorgan/MathCompile: Compile Wolfram Language functions into C++ code and binary

BranchesTags
Open more actions menu

Latest commit

 

History

349 Commits
349 Commits

Folders and files

NameName
Last commit message
Last commit date
IncludeFiles
IncludeFiles
 
 
LibraryResources
LibraryResources
 
 
SourceFiles
SourceFiles
 
 
compiler_explorer
compiler_explorer
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
MathCompile.wl
MathCompile.wl
 
 
PacletInfo.wl
PacletInfo.wl
 
 
README.md
README.md
 
 

Repository files navigation

MathCompile is a package that translates Wolfram Language functions into C++ code and generate dynamic libraries that can be called in Wolfram Language.

MathCompile is focused on improving the availability of functional programming and covering the functionalities provided by the built-in compiler. Currently, MathCompile supports over 300 functions and over 20 constants; see the wiki page for the full list.

Prerequisites

To compile Wolfram Language functions to C++ code, Wolfram Mathematica 12 is required. An alternative to Mathematica is Wolfram Engine, which is freely available to developers.

To compile functions to binary, a C++ compiler supporting C++17 standard is required. See this wiki page for the list of all supported C++ compilers, their availabilities, and how to use them.

MathCompile supports linking with external BLAS and LAPACK libraries as an alternative to Eigen. See this wiki page for how to do this.

Documentation

To know more about MathCompile, see the Wiki.

To learn about how to install and use MathCompile, see the Guide.

Basic usage

First, load the package:

<<MathCompile`

If you have a supported C++ compiler, compile a function to binary using CompileToBinary:

cf=CompileToBinary[
  Function[{Typed[x,{Integer,1}]},Apply[Times,x]]
]

Use this compiled function just like a normal Wolfram Language funcion:

cf[{1,2,3,4}]    (* gives 24 *)

Without a C++ compiler, you can still check the intermediate C++ code using CompileToCode:

CompileToCode[
  Function[{Typed[x,{Integer,1}]},Apply[Times,x]]
]

The result is a C++ function named main_function:

auto main_function(const wl::ndarray<int64_t, 1>& v35) {
    return wl::val(wl::apply(WL_FUNCTION(wl::times), WL_PASS(v35)));
}

The disassembly generated by GCC 7.4 and Clang 5.0 for this function is available through Compiler Explorer.

About

Compile Wolfram Language functions into C++ code and binary

Topics

c-plus-pluscompilermathematicawolfram-language

Resources

Readme
Apache-2.0 license
Activity

Stars

130 stars

Watchers

12 watching

Forks

11 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.