Package 'hellomojo'

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

Help Index


Hello from Mojo Call the native 'hello' function from the Mojo shared library

Description

Hello from Mojo Call the native 'hello' function from the Mojo shared library

Usage

hellomojo()

Add two numbers using the native 'add' function from the Mojo shared library

Description

Add two numbers using the native 'add' function from the Mojo shared library

Usage

hellomojo_add(a, b)

Arguments

a

A numeric value

b

A numeric value

Value

The sum of a and b


1D convolution using the native Mojo function

Description

1D convolution using the native Mojo function

Usage

hellomojo_convolve(signal, kernel)

Arguments

signal

Numeric vector (signal)

kernel

Numeric vector (kernel)

Value

Numeric vector (convolution result)


Get system and GPU device information using Mojo Shows both CPU and GPU information when available

Description

Get system and GPU device information using Mojo Shows both CPU and GPU information when available

Usage

hellomojo_device_info(device_id = 0L, api_name = "cuda")

Arguments

device_id

Integer device ID (default: 0)

api_name

Character string specifying the GPU API ("cuda" or "hip", default: "cuda")

Value

Prints system and device information to console


Build Mojo library for this package

Description

Compiles the Mojo source and installs it to inst/libs

Usage

mojo_build_package(
  venv = ".venv/mojo",
  source = "inst/mojo/hellomojo/hellomojo.mojo"
)

Arguments

venv

Path to virtual environment with Mojo

source

Path to Mojo source file


Check if system requirements for Mojo compilation are available

Description

Check if system requirements for Mojo compilation are available

Usage

mojo_check_python_requirements()

Value

Named logical vector with availability of requirements


Compile Mojo code and create R wrapper functions

Description

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.

Usage

mojo_compile(
  mojo_file,
  venv = NULL,
  PKG_LIBS = NULL,
  env = parent.frame(),
  verbosity = 0
)

Arguments

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

Value

Invisibly returns named list of R wrapper functions


Find Mojo binary in virtual environment or system

Description

Find Mojo binary in virtual environment or system

Usage

mojo_find(venv = NULL)

Arguments

venv

Path to virtual environment. If NULL, searches system PATH.

Value

Path to mojo binary, or NULL if not found


Get information about Mojo installation

Description

Get information about Mojo installation

Usage

mojo_info(venv = NULL)

Arguments

venv

Path to virtual environment


Create a Python virtual environment and install Mojo

Description

Create a Python virtual environment and install Mojo

Usage

mojo_install(venv = ".venv/mojo", nightly = TRUE, python = "python3")

Arguments

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".