LOSC C library


The LOSC library provides a C interface to perform calculations of LOSC, including the construction of LOSC curvature matrix, LOSC localization, local occupation number and LOSC corrections. The C interface is developed by wrapping the C++ interface in C-style.


Not sure about how to let C code handle the exceptions that may be thrown in the C++ code.

The provided C interface (C header files) includes




provide the C interface for the matrix objects that are used in the LOSC library.


for the LOSC curvature matrix.


for the LOSC localization.


for the LOSC local occupation.


for the LOSC corrections.


A convenient header that includes everything you need.

In order to use the C interface of the LOSC library, following the steps of installation. Then all you need to do is to include the corresponding headers in your project to use the LOSC C library.

Data Structure

The LOSC C library defines matrix object with struct losc_matrix that is declared in <losc/matrix.h> header. You can call the constructor function losc_matrix_create to create a struct losc_matrix with any size, or you can pass a C pointer double * that points to an array to generate a struct losc_matrix, which does not own the data. Remember the storage of the matrix is ALWAYS interpreted in row-wise (C-style) major. See <losc/matrix.h> for more details.

Detailed References for the API

Please refer this section for the full documentation of C interface of the LOSC library.