Esempio n. 1
0
        public bool Equals(PauliTerm x)
        {
            // If parameter is null, return false.
            if (ReferenceEquals(x, null))
            {
                return(false);
            }

            // Optimization for a common success case.
            if (ReferenceEquals(this, x))
            {
                return(true);
            }

            // If run-time types are not exactly the same, return false.
            if (GetType() != x.GetType())
            {
                return(false);
            }
            // Return true if the fields match.
            return(QubitIndices.SequenceEqual(x.QubitIndices) && TermType == x.TermType);
        }
Esempio n. 2
0
 bool IEquatable <PauliTerm> .Equals(PauliTerm other) =>
 other.TermType == this.TermType &&
 QubitIndices.SequenceEqual(other.QubitIndices);
Esempio n. 3
0
 /// <summary>
 /// Creates a copy of this instance.
 /// </summary>
 public PauliTerm Clone() => new PauliTerm(QubitIndices.ToArray().Clone <int>(), TermType);