public Spins GenSpin(StdMt19937 randomNumderEngine) { if (randomNumderEngine == null) { throw new ArgumentNullException(nameof(randomNumderEngine)); } randomNumderEngine.ThrowIfDisposed(); this.ThrowIfDisposed(); var spins = NativeMethods.graph_Graph_gen_spin_mt19937(this.NativePtr, randomNumderEngine.NativePtr); using (var vector = new StdVector <int>(spins)) return(new Spins(vector.ToArray().Select(v => new Spin(v)))); }
public static void Run(Ising system, StdMt19937 randomNumberEngine, ScheduleList scheduleList) { if (system == null) { throw new ArgumentNullException(nameof(system)); } if (randomNumberEngine == null) { throw new ArgumentNullException(nameof(randomNumberEngine)); } if (scheduleList == null) { throw new ArgumentNullException(nameof(scheduleList)); } system.ThrowIfDisposed(); randomNumberEngine.ThrowIfDisposed(); scheduleList.ThrowIfDisposed(); if (!UpdaterElementTypesRepository.SupportTypes.TryGetValue(typeof(T), out var types)) { throw new NotSupportedException($"{typeof(T).Name} does not support"); } if (types.Item2 != system.IsingType) { throw new NotSupportedException($"{typeof(T).Name} supports only {system.IsingType}"); } if (types.Item3 != system.GraphType) { throw new NotSupportedException($"{typeof(T).Name} supports only {system.GraphType}"); } if (types.Item4 != system.FloatType) { throw new NotSupportedException($"{typeof(T).Name} supports only {system.FloatType}"); } var updaterType = types.Item1; var ret = NativeMethods.algorithm_Algorithm_run(updaterType, system.NativePtr, system.IsingType, system.GraphType, system.FloatType, randomNumberEngine.NativePtr, scheduleList.NativePtr); }