| Title: | An Example R Package that Uses 'mojo' Through the .Call Interface |
|---|---|
| Description: | This package demonstrates how to use the 'mojo' by calling shared library builds from R through its .Call interface. |
| Authors: | Sounkou Mahamane Toure [aut, cre] |
| Maintainer: | Sounkou Mahamane Toure <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.0.1.9000 |
| Built: | 2026-05-23 09:24:43 UTC |
| Source: | https://github.com/sounkou-bioinfo/hellomojo |
Hello from Mojo Call the native 'hello' function from the Mojo shared library
hellomojo()hellomojo()
Add two numbers using the native 'add' function from the Mojo shared library
hellomojo_add(a, b)hellomojo_add(a, b)
a |
A numeric value |
b |
A numeric value |
The sum of a and b
1D convolution using the native Mojo function
hellomojo_convolve(signal, kernel)hellomojo_convolve(signal, kernel)
signal |
Numeric vector (signal) |
kernel |
Numeric vector (kernel) |
Numeric vector (convolution result)
Get system and GPU device information using Mojo Shows both CPU and GPU information when available
hellomojo_device_info(device_id = 0L, api_name = "cuda")hellomojo_device_info(device_id = 0L, api_name = "cuda")
device_id |
Integer device ID (default: 0) |
api_name |
Character string specifying the GPU API ("cuda" or "hip", default: "cuda") |
Prints system and device information to console
Compiles the Mojo source and installs it to inst/libs
mojo_build_package( venv = ".venv/mojo", source = "inst/mojo/hellomojo/hellomojo.mojo" )mojo_build_package( venv = ".venv/mojo", source = "inst/mojo/hellomojo/hellomojo.mojo" )
venv |
Path to virtual environment with Mojo |
source |
Path to Mojo source file |
Check if system requirements for Mojo compilation are available
mojo_check_python_requirements()mojo_check_python_requirements()
Named logical vector with availability of requirements
Similar to callme::compile() but for Mojo code.
Parses Mojo files, extracts export functions, compiles to shared library,
generates C wrappers, compiles those, and creates R functions.
mojo_compile( mojo_file, venv = NULL, PKG_LIBS = NULL, env = parent.frame(), verbosity = 0 )mojo_compile( mojo_file, venv = NULL, PKG_LIBS = NULL, env = parent.frame(), verbosity = 0 )
mojo_file |
Path to mojo file |
venv |
Path to Python virtual environment with Mojo installed |
PKG_LIBS |
Additional linker flags (e.g., for external libraries) |
env |
Environment to assign wrapper functions. Default: parent.frame() |
verbosity |
Level of output (0-4). Default: 0 |
Invisibly returns named list of R wrapper functions
Find Mojo binary in virtual environment or system
mojo_find(venv = NULL)mojo_find(venv = NULL)
venv |
Path to virtual environment. If NULL, searches system PATH. |
Path to mojo binary, or NULL if not found
Get information about Mojo installation
mojo_info(venv = NULL)mojo_info(venv = NULL)
venv |
Path to virtual environment |
Create a Python virtual environment and install Mojo
mojo_install(venv = ".venv/mojo", nightly = TRUE, python = "python3")mojo_install(venv = ".venv/mojo", nightly = TRUE, python = "python3")
venv |
Path where to create the virtual environment |
nightly |
If TRUE, install nightly build. If FALSE, install stable. |
python |
Python executable to use. Default is "python3". |