Quantum object code

Sometimes it is useful to see what operations are actually performed by an algorithm. Therefore, libquantum can generate quantum object code (sometimes called ``quobcode''). The quobcode can then be analyzed, optimized or executed in a different program. Quobcode is very similar to ordinary machine code on classical computers. Note that the generated code may be machine-dependent under some circumstances.


extern int quantum_objcode_start();

By calling this function, the quobcode generation is activated. All subsequent operations will not be simulated, but recorded for later output as object code.


extern int quantum_objcode_write(char *file);

Write the recorded quobcode data to file. The object code gets written as binary data, so you will need to use quobprint to actually view it. The return value is 0 for success, 1 when the quobcode generation is currently inactive and -1 when filename could not be opened.


extern int quantum_objcode_stop();

This function stops the quobcode recording. All generated data is deleted from memory, so you should call quantum_objcode_write before quantum_objcode_stop.


extern void quantum_objcode_run(char *file, quantum_reg *reg);

Load the object code stored in file and execute it in the simulator. Currently, the quobcode interface cannot deal with different quantum registers, so a pointer to the quantum register to be used for the operations has to be given as the second argument.