Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: read a Pauli-sum-product file #47

Open
TysonRayJones opened this issue Jun 24, 2019 · 2 comments
Open

Enhancement: read a Pauli-sum-product file #47

TysonRayJones opened this issue Jun 24, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@TysonRayJones
Copy link
Member

and convert to a structure which can be read by CalcExpectedValue

@TysonRayJones TysonRayJones added the enhancement New feature or request label Jun 24, 2019
@TysonRayJones
Copy link
Member Author

This code...

filename = "hamil.txt";
Plus @@ (#[[1]] Times @@ 
        MapThread[(Subscript[
            Switch[#2, 0, Null, 1, X, 2, Y, 3, Z], #1 - 1] /. 
            Subscript[Null, _] -> Sequence[] &), {Range@
           Length@#[[2 ;;]], #[[2 ;;]]}] &) /@ 
    ReadList[filename, Number, RecordLists -> True];

converts format (coeff, pauli-on-each-qubit) e.g.

0.4435314 0 0 1 0 1 2 2 
0.1991123 0 0 0 0 1 2 3 
...

into the form

0.4435314 X_2 X_4 Y_5 Y_6 + 0.1991123 X_4 Y_5 Z_6

which is accepted by the new CalcExpecPauliSum added in 9bcb519

but the inner QuEST-core function calcExpecPauliSum needlessly converts this back into a format akin to the original final format.
A more direct parse is the simple

{coeffs, paulicodes} = With[
 	{rows = ReadList["chemHamil6qb.txt", Number, RecordLists -> True]},
 	{rows[[All, 1]], Flatten @ rows[[All, 2 ;;]]}
 ]

I'm not sure which if any of these should be added to the library

@TysonRayJones
Copy link
Member Author

GetPauliSumFromCoeffs[] added in 35903fe, although the aforementioned overhead of casting back to a non-symbolic form in the backend still exists

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant