/// <summary> /// Coinjoins the submapping into one single transaction. /// </summary> public Mapping Join() { var subSetInputs = SubSets.SelectMany(x => x.Inputs); var suSetOutputs = SubSets.SelectMany(x => x.Outputs); return(new Mapping(new SubSet(subSetInputs, suSetOutputs, Precision))); }
public void Set <VType>(VType[] vertices, int[] indices) where VType : struct { VertexBuffer = Buffer11.Create <VType>(Device.Device, BindFlags.VertexBuffer, vertices); IndexBuffer = Buffer11.Create(Device.Device, BindFlags.IndexBuffer, indices); VertexSize = SharpDX.Utilities.SizeOf <VType>(); SubSets.Add(new SharpSubSet() { DiffuseColor = new Vector4(1, 1, 1, 1), IndexCount = indices.Count() }); }
static void Main() // INCORRECT - subSEQUENCE NOT subSET { // input int arraySize = int.Parse(Console.ReadLine()); // fill the array int[] toSearch = new int[arraySize]; for (int i = 0; i < arraySize; i++) { toSearch[i] = int.Parse(Console.ReadLine()); } // get the sum int toFindSum = int.Parse(Console.ReadLine()); var currQuery = from toStart in Enumerable.Range(0, toSearch.Length) from Length in Enumerable.Range(0, toSearch.Length - toStart) let SubSets = toSearch.Skip(toStart).Take(Length) orderby SubSets.Count() descending where SubSets.Sum() == toFindSum select SubSets; if (currQuery.Count() > 0) { Console.WriteLine("yes"); } else { Console.WriteLine("no"); } // test foreach (var item in currQuery.First()) { Console.Write(item + " "); } }
/// <summary> /// Prepares a mesh for being used as a shadow Volume. /// </summary> /// <remarks>In fact the geometry is doubled and an FloatStream is added that contains 1.0f for /// vertices that are used for the near cap and 0.0f for the far cap.</remarks> /// <param name="mesh">The mesh to prepare.</param> public static void PrepareMesh(Mesh mesh) { SubSets subSets = mesh.SubSets; for (int iSubSet = 0; iSubSet < subSets.Count; iSubSet++) { VertexUnit vu = subSets[iSubSet].VertexUnit; IGraphicsStream[] streams = new IGraphicsStream[vu.StreamCount + 1]; for (int iStream = 0; iStream < vu.StreamCount; iStream++) { IGraphicsStream fromStream = vu[iStream]; IGraphicsStream toStream = null; using (Purple.Profiling.Profiler.Instance.Sample("Clone")) { toStream = fromStream.Clone(); } using (Purple.Profiling.Profiler.Instance.Sample("Resize")) { toStream.Resize(fromStream.Size * 2); } using (Purple.Profiling.Profiler.Instance.Sample("CopyTo")) { fromStream.Data.CopyTo(toStream.Data, fromStream.Size); } streams[iStream] = toStream; } using (Purple.Profiling.Profiler.Instance.Sample("FloatStream")) { FloatStream floatStream = new FloatStream(vu.Size * 2); for (int i = 0; i < vu.Size; i++) { floatStream[i] = 1.0f; floatStream[i + vu.Size] = 0.0f; } streams[vu.StreamCount] = floatStream; } vu = new VertexUnit(streams); subSets[iSubSet].VertexUnit = vu; } }
public override string ToString() { return(string.Join(" | ", SubSets.Select(x => $"{string.Join(',', x.Inputs)} -> {string.Join(',', x.Outputs)}"))); }
protected override void DoCommandAction() { Tile startTile = FPGA.FPGA.Instance.GetTile(StartLocation); Tile targetTile = FPGA.FPGA.Instance.GetTile(TargetLocation); List <List <Location> > m_paths = new List <List <Location> >(); string startPortRegexp = ""; foreach (string s in StartPortRegexps) { startPortRegexp += "(" + s + ")|"; } startPortRegexp = startPortRegexp.Remove(startPortRegexp.Length - 1); foreach (Port startPort in startTile.SwitchMatrix.GetAllDrivers().Where(p => Regex.IsMatch(p.Name, startPortRegexp)).OrderBy(p => p.Name)) { foreach (Port targetPort in targetTile.SwitchMatrix.GetDrivenPorts().Where(p => Regex.IsMatch(p.Name, TargetPortRegexp)).OrderBy(p => p.Name)) { PathSearchOnFPGA searchCmd = new PathSearchOnFPGA(); searchCmd.Forward = true; searchCmd.MaxDepth = MaxDepth; searchCmd.MaxSolutions = 1; searchCmd.SearchMode = "BFS"; searchCmd.StartLocation = startTile.Location; searchCmd.StartPort = startPort.Name; searchCmd.TargetLocation = targetTile.Location; searchCmd.TargetPort = targetPort.Name; searchCmd.PrintBanner = false; CommandExecuter.Instance.Execute(searchCmd); m_paths.AddRange(searchCmd.m_paths); // copy output if (searchCmd.OutputManager.HasOutput) { OutputManager.WriteWrapperOutput(searchCmd.OutputManager.GetOutput()); } } // one blank for readability OutputManager.WriteWrapperOutput(""); } return; List <Tuple <Tuple <Location, Location>, List <Location> > > solutionSet = new List <Tuple <Tuple <Location, Location>, List <Location> > >(); foreach (List <Location> p in m_paths) { solutionSet.Add(new Tuple <Tuple <Location, Location>, List <Location> >(new Tuple <Location, Location>(p[0], p[p.Count - 1]), p)); //solutionSet.Add(new Tuple<Location, Location>(p[0], p[p.Count - 1]), p); } List <Tuple <Tuple <Location, Location>, List <Location> > > west = solutionSet.Where(t => Regex.IsMatch(t.Item1.Item1.Pip.Name, StartPortRegexps[0])).Distinct().ToList(); List <Tuple <Tuple <Location, Location>, List <Location> > > east = solutionSet.Where(t => Regex.IsMatch(t.Item1.Item1.Pip.Name, StartPortRegexps[1])).Distinct().ToList(); SubSets subSets = new SubSets(); int tries = 0; int size = 4; foreach (IEnumerable <Tuple <Tuple <Location, Location>, List <Location> > > wc in subSets.GetAllSubSets(west, size).Where(s => IsUnique(s))) { var westImuxes = from t in wc select t.Item1.Item2; foreach (IEnumerable <Tuple <Tuple <Location, Location>, List <Location> > > ec in subSets.GetAllSubSets(east, size).Where(s => IsUnique(s))) { tries++; var eastImuxes = from t in ec select t.Item1.Item2; if (westImuxes.Equals(eastImuxes)) { Console.WriteLine(wc); Console.WriteLine(ec); } } } return; List <Tuple <Tuple <Location, Location>, List <Location> > > result = new List <Tuple <Tuple <Location, Location>, List <Location> > >(); foreach (IEnumerable <Tuple <Tuple <Location, Location>, List <Location> > > candidates in subSets.GetAllSubSets(solutionSet, 8)) { List <Location> startPointsAndEndPoints = new List <Location>(); foreach (Tuple <Tuple <Location, Location>, List <Location> > c in candidates) { startPointsAndEndPoints.Add(c.Item1.Item1); //startPointsAndEndPoints.Add(c.Item1.Item2); } int distinctCount = startPointsAndEndPoints.Distinct().Count(); if (distinctCount != candidates.Count()) { continue; } //List<Tuple<Tuple<Location, Location>, List<Location>>> west = candidates.Where(t => t.Item1.Item1.Pip.Name.StartsWith(this.StartPortRegexps[0])).Distinct().ToList(); //List<Tuple<Tuple<Location, Location>, List<Location>>> east = candidates.Where(t => t.Item1.Item1.Pip.Name.StartsWith(this.StartPortRegexps[1])).Distinct().ToList(); if (west.Count == east.Count) { var westImuxes = from t in west select t.Item1.Item2; var eastImuxes = from t in east select t.Item1.Item2; if (westImuxes.Equals(eastImuxes)) { } } // List<Location> westImuxes = west. } }