Skip to content

ajpgarner/moment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Moment

(c) 2022-2024 Austrian Academy of Sciences

Author: Andrew J. P. Garner

Moment a set of tools designed to aid in the generation and manipulation of operator matrices, for use in the context of convex optimization problems. In particular, it aids in the generation of hierarchies of moment matrices and localizing matrices, such as arise in the NPA and PNA hierarchies. Can also generate matrices for inflated causal-compatibility scenarios.

Minimum tested versions

MATLAB 2018a (9.4)

For compiling C++ library

On Windows:
Clang 14.0.0 (via clang-cl), GCC 12.1.0, or Visual Studio 2022
CMAKE 3.22

On GNU/Linux:
GCC 12.3.0
CMAKE 3.22

On Mac:
GCC 12.3.0
CMAKE 3.22

Installation Instructions

GNU/Linux

To download and compile the library use the following commands:

git clone --recursive https://github.com/ajpgarner/moment.git
cd moment
cmake . -DCMAKE_BUILD_TYPE=Release
cmake --build .

Once the build is complete, the binary mtk.mexa64 will be automatically copied into the moment/matlab folder.

To use from MATLAB, add the following folders to the matlab path: moment/matlab, moment/matlab/classes, and moment/matlab/functions. This can be done automatically by running the script mtk_install from the moment/matlab folder, and then restarting MATLAB. If everything is correctly installed, calling function mtk (from any folder) should display the version information of Moment.

Mac

Only tested on Intel-based Macs. You first need the compilation tools if you don't already have:

brew install git
brew install gcc@12
brew install cmake

It is vital to use GCC 12, it will not work with the native clang. After that the commands are the same as in GNU/Linux:

git clone --recursive https://github.com/ajpgarner/moment.git
cd moment
cmake . -DCMAKE_BUILD_TYPE=Release
cmake --build .

Once the build is complete, the binary mtk.mexmaci64 will be automatically copied into the moment/matlab folder.

To use from MATLAB, add the following folders to the matlab path: moment/matlab, moment/matlab/classes, and moment/matlab/functions. This can be done automatically by running the script mtk_install from the moment/matlab folder, and then restarting MATLAB. If everything is correctly installed, calling function mtk (from any folder) should display the version information of Moment.

Windows: CLion

Clone the repository (e.g. with GitHub desktop).

Open CLion, and from the File > Open menu, navigate to the cloned repository root directory.

To build the MATLAB binary, select the target moment_mex in the Build Configurations drop down, then press the build button. Alternatively, select Build Project from the Build menu.

Once the build is complete, the binary mtk.mexw64 will have been copied to the moment/matlab folder.

To use from MATLAB, add the following folders to the matlab path: moment/matlab, moment/matlab/classes, and moment/matlab/functions. This can be done automatically by running the script mtk_install from the moment/matlab folder, and then restarting MATLAB. If everything is correctly installed, calling function mtk (from any folder) should display the version information of Moment.

Windows: Visual Studio

Clone the repository (e.g. with GitHub desktop).

Open Visual Studio 2022, and select "Open a local folder". Navigate to the root of the cloned repository and click 'Select folder'. Visual Studio will accordingly parse the CMakeList files. The project can then be built by selecting "Build All" from Visual Studio's Build menu, or pressing F7.

Once the build is complete, the binary mtk.mexw64 will have been copied to the moment/matlab folder.

To use from MATLAB, add the following folders to the matlab path: moment/matlab, moment/matlab/classes, and moment/matlab/functions. This can be done automatically by running the script mtk_install from the moment/matlab folder, and then restarting MATLAB. If everything is correctly installed, calling function mtk (from any folder) should display the version information of Moment.

Dependencies

Googletest: C++ unit test suite.

Eigen: Linear algebra template library for C++.

Both dependencies are included as git submodules (and hence will be pulled by using the above installation instructions).

If using a pre-compiled binary (and not requiring C++ unit tests), it is not necessary to pull these dependencies.

Directory outline

\: Root of Moment.

\cpp: Root of the C++ source code.

\cpp\eigen: Inclusion of Eigen subproject.

\cpp\googletest: Inclusion of googletest subproject.

\cpp\lib_moment: Toolkit algorithms agnostic of MATLAB. Builds lib_moment.

\cpp\mex_functions: Root for MATLAB/C++ interface code (i.e. building mtk mex library).

\cpp\stress_tests: Stand-alone benchmarking / CPU profiling tests.

\cpp\tests: C++ unit tests for lib_moment (build using googletest).

\matlab: Root of Moment MATLAB package

\matlab\classes: Object-oriented interface for moment.

\matlab\examples: Example scripts making use of the Moment library.

\matlab\functions: MATLAB functional interface for Moment.

\matlab\tests: MATLAB unit tests for moment mex library, and other matlab classes.

Releases

No releases published

Packages

No packages published

Languages