Пример #1
0
        public static Gate Add(IEnumerable <Gate> gates)
        {
            IEnumerator <Gate> iterator = gates.GetEnumerator();

            if (!iterator.MoveNext())
            {
                return(null);
            }

            int nbEntriesRef = iterator.Current.NbEntries;

            while (iterator.MoveNext())
            {
                if (iterator.Current.NbEntries != nbEntriesRef)
                {
                    throw new ArgumentException("cannot add gates of different lengths");
                }
            }

            return(new Gate("(" + String.Join("+", FuncTools.Map((Gate gate) => gate.Name, gates)) + ")", nbEntriesRef, LinearAlgebra.Mult(FuncTools.Map((Gate a) => a.Matrix, gates))));
        }
Пример #2
0
 public static State operator +(State a, Gate b)
 {
     return(new State(LinearAlgebra.Mult(a.Vector, b.Matrix)));
 }
Пример #3
0
        /// <summary>
        /// Evalue partiellement le circuit jusquà la ligne de numéro spécifié
        /// </summary>
        /// <param name="till_row"></param>
        /// <returns>State</returns>
        public State Evaluate(int till_row)
        {
            State entry = GetEntryState();

            return(new State(LinearAlgebra.Mult(entry.Vector, Gate.Add(FuncTools.Map(GetRowGate, FuncTools.Take(till_row + 1, rows))).Matrix)));
        }