pub unsafe extern "C" fn createPauliHamilFromFile(
fn_: *mut c_char,
) -> PauliHamilExpand description
Creates a \p PauliHamil instance, a real-weighted sum of products of Pauli operators, populated with the data in filename \p fn.
Each line in the plaintext file is interpreted as a separate product of Pauli operators in the total sum. Each line must be a space-separated list with format
c p1 p2 p3 ... pNwhere \p c is the real coefficient of the term, and \p p1 … \p pN are numbers in {0,1,2,3} to indicate ::PAULI_I, ::PAULI_X, ::PAULI_Y, ::PAULI_Z operators respectively, which act on qubits \p 0 through \p N-1 (all qubits).
For example, the file containing
0.31 1 0 1 2
-0.2 3 2 0 0encodes a two-term four-qubit Hamiltonian \f[ 0.31 , X_0 , X_2 , Y_3 -0.2 , Z_0 , Y_1 ,. \f]
The initialised ::PauliHamil can be previewed with reportPauliHamil().
The number of qubits and terms are inferred from the file. The created Hamiltonian can be used just like one created via createPauliHamil(). It can be modified directly (see ::PauliHamil), or through initPauliHamil().
The returned dynamic \p PauliHamil instance must later be freed via destroyPauliHamil().
@see
- reportPauliHamil()
- destroyPauliHamil()
- createPauliHamil()
- initPauliHamil()
- createDiagonalOpFromPauliHamilFile()
@ingroup type @param[in] fn filename of the plaintext file specifying the pauli operators and coefficients @returns a dynamic ::PauliHamil struct @throws invalidQuESTInputError()
- if the file with name \p fn cannot be read
- if the file is not correctly formatted as described above @author Tyson Jones