Skip to content

Latest commit

 

History

53 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Capacity functions for MATLAB

capacity_functions_mex is a portable MATLAB MEX gateway for the numerical algorithms in src/capacity_functions.c. It evaluates mutual information and log-likelihood ratios for PAM and QAM constellations. The MEX binary is built locally and is not committed to the repository.

Requirements

  • MATLAB R2026a or later with a configured C compiler (mex -setup C).
  • A C99 compiler. On Windows, select MathWorks-supported MinGW-w64 (MinGW 14.2 is supported in R2026a). On Linux, use a supported GCC toolchain. On macOS, use Xcode on Apple silicon; MATLAB R2026a does not support Intel Macs.

See MathWorks' supported compiler list and platform roadmap.

Build and test

From the repository root in MATLAB:

mexFile = build;
results = runtests('tests');

build writes the platform-specific file to build/ and adds that directory to the MATLAB path. The default build is serial and has no OpenMP dependency.

To request OpenMP, use a compiler that accepts GCC-compatible -fopenmp flags:

mexFile = build(UseOpenMP=true);

The OpenMP option is supported with MinGW-w64 on Windows and is intended for a toolchain where OpenMP is already installed and configured. A serial build is the portable supported baseline.

API

All operations use one command dispatcher:

[gmi, mi] = capacity_functions_mex('qam_gmi', C, SNR, Pk);
llr = capacity_functions_mex('qam_llr', C, sigma2, y, Pk);
Command Inputs after command Output
qam_gmi C, SNR, Pk gmi or [gmi, mi]
pam_gmi C, SNR, Pk gmi or [gmi, mi]
qam_llr C, sigma2, y, Pk bit LLRs
pam_llr C, sigma2, y, Pk bit LLRs
qam_llr_maxlog C, sigma2, y, Pk max-log bit LLRs
qam_llr_pn C, Kn, Kp, y, Pk phase-noise bit LLRs
qam_llr_pn_maxlog C, Kn, Kp, y, Pk max-log phase-noise bit LLRs
qam_symbllr C, sigma2, y, Pk symbol metrics
qam_mi_montecarlo C, sigma2, y, Pk MI estimate
pam_mi_montecarlo C, sigma2, y, Pk MI estimate

C, Pk, SNR, and y must be full double column vectors. QAM inputs can be real or complex; PAM inputs must be real. sigma2 is a positive scalar for Monte-Carlo MI and symbol metrics, and a positive M-element column vector for the AWGN LLR commands. Kn and Kp are positive real scalars. M = numel(C) must be a power of two, and Pk must be strictly positive and sum to one within 1e-12. LLR outputs are numel(y) * log2(M)-by-1; symbol metrics are numel(y) * M-by-1.

The constellation ordering defines the bit labels. Use Gray order when that is the desired mapping.

Layout

  • src/capacity_functions.c and .h: preserved numerical implementation.
  • src/capacity_functions_mex.c: validated MEX dispatcher.
  • build.m: local serial/OpenMP build entry point.
  • tests/: MATLAB unit tests.

License

MIT. See LICENSE.

About

C / MATLAB functions to evaluate mutual information for optical communications

Topics

Resources

Stars

10 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages