Sample Codes
g++ example.cpp -o example -O3 -std=c++11 -larmadillo -lnlopt -I PATH_TO_QIClib_INCLUDE_DIRECTORY
Note that -lnlopt flag is optional, see here.
Basic matrix operartions
#include <iostream> #include <armadillo> #include <QIClib> //make sure that your compiler can find the header
int main(int argc, char** argv) { using namespace std; using namespace arma; using namespace qic; mat A = randu<mat>(5,5); // 5x5 real matrix cx_mat B = randu<cx_mat>(4,4); // 4x4 complex matrix // Hermiticity check cout << is_Hermitian(A) << endl << is_Hermitian( B*B.t() ) << endl; cx_mat C = B; // check for equality cout << is_equal(A,B) << endl << is_equal(B,C) << endl; B *= B.t(); // B is now Hermitian B /= trace(B); // normalise B // check if the matrix is a valid state cout << is_valid_state(A) << endl << is_valid_state(B) << endl; // trace out first party cx_mat B2 = TrX(B,{1}); // B2 is 2x2 matrix return 0; }