// Parses MCF wavefunction. internal static SparseMultiCFWavefunction <SpinOrbital> ToSparseMultiCFWavefunction(List <List <string> > superposition) { var outputState = new SparseMultiCFWavefunction <SpinOrbital>(); // Todo: modify broombridge to have explicit reference state. foreach (var element in superposition) { // First item is the amplitude. double amplitude = double.Parse(element.First().ToString(), System.Globalization.CultureInfo.InvariantCulture); // Second to Second-last are fermion operators. IEnumerable <LadderOperator <SpinOrbital> > operators = element .Take(element.Count() - 1) .Skip(1) .Select(o => V0_1.ParsePolishNotation(o.ToString())); var ladderSequence = new LadderSequence <SpinOrbital>(operators); // Sort operators to index order. IEnumerable <IndexOrderedSequence <SpinOrbital> > sortedOperators = ladderSequence.ToIndexOrder(); // Only select the shortest term with no repeated indices. IndexOrderedSequence <SpinOrbital> sortedOperator = sortedOperators.ToList().OrderBy(o => o.UniqueIndices()).First(); outputState.Set(sortedOperator, new Complex(amplitude, 0.0)); } return(outputState); }
/// <summary> /// Translate initial state specified by a superposition of <see cref="FermionTerm"/> acting on /// the vacuum state to a format consumable by Q# /// </summary> /// /// <param name="term">List of sequences of creation operations acting on vacuum state and their coefficients.</param> /// <returns>Q# description of initial state</returns> public static QArray <JordanWignerInputState> InitialStateSparseMultiConfigural( SparseMultiCFWavefunction <int> wavefunction) { return(new QArray <JordanWignerInputState>( wavefunction.Excitations.Select(o => InitialStatePrep(o.Value, o.Key, checkAnnihilation: true)) // Todo add reference wavefunction when that functionality is implemented. )); }