intersection

Calculate if two infinite regex solution sets don't intersect

落爺英雄遲暮 提交于 2019-12-18 15:35:24
问题 In calculate if two arbitrary regular expressions have any overlapping solutions (assuming it's possible). For example these two regular expressions can be shown to have no intersections by brute force because the two solution sets are calculable because it's finite. ^1(11){0,1000}$ ∩ ^(11){0,1000}$ = {} {1,111, ..., ..111} ∩ {11,1111, ..., ...11} = {} {} = {} But replacing the {0,1000} by * remove the possibility for a brute force solution, so a smarter algorithm must be created. ^1(11)*$ ∩

How to find an intersection of curve and circle?

家住魔仙堡 提交于 2019-12-18 12:55:29
问题 I have a curve, derived from empirical data, and I can obtain a reasonable model of it. I need to identify a point (x, y) where the curve intersects a circle of known center and radius. The following code illustrates the question. x <- c(0.05, 0.20, 0.35, 0.50, 0.65, 0.80, 0.95, 1.10, 1.25, 1.40, 1.55, 1.70, 1.85, 2.00, 2.15, 2.30, 2.45, 2.60, 2.75, 2.90, 3.05) y <- c(1.52, 1.44, 1.38, 1.31, 1.23, 1.15, 1.06, 0.96, 0.86, 0.76, 0.68, 0.61, 0.54, 0.47, 0.41, 0.36, 0.32, 0.29, 0.27, 0.26, 0.26)

How to find an intersection of curve and circle?

允我心安 提交于 2019-12-18 12:55:11
问题 I have a curve, derived from empirical data, and I can obtain a reasonable model of it. I need to identify a point (x, y) where the curve intersects a circle of known center and radius. The following code illustrates the question. x <- c(0.05, 0.20, 0.35, 0.50, 0.65, 0.80, 0.95, 1.10, 1.25, 1.40, 1.55, 1.70, 1.85, 2.00, 2.15, 2.30, 2.45, 2.60, 2.75, 2.90, 3.05) y <- c(1.52, 1.44, 1.38, 1.31, 1.23, 1.15, 1.06, 0.96, 0.86, 0.76, 0.68, 0.61, 0.54, 0.47, 0.41, 0.36, 0.32, 0.29, 0.27, 0.26, 0.26)

Fast intersection of sets: C++ vs C#

心不动则不痛 提交于 2019-12-18 11:12:36
问题 On my machine (Quad core, 8gb ram), running Vista x64 Business, with Visual Studio 2008 SP1, I am trying to intersect two sets of numbers very quickly. I've implemented two approaches in C++, and one in C#. The C# approach is faster so far, I'd like to improve the C++ approach so its faster than C#, which I expect C++ can do. Here is the C# output: (Release build) Found the intersection 1000 times, in 4741.407 ms Here is the initial C++ output, for two different approaches (Release x64 build)

Python intersection and difference sum doesn't give me the actual number of the original set

血红的双手。 提交于 2019-12-18 09:31:05
问题 I have two lists, one with old IDs and one with new IDs. I want to get items in common and items not common. The new_Items list has all new ones. The old_Items has the old ones. I suppose that when I calculate the ones in common plus the in new items list but not in old items list, I get the actual number of new items. Here is the code and the output. print(old_Items) print(new_Items) common = set(new_Items) & set(old_Items) not_common = set(new_Items) - set(old_Items) print(len(old_Items))

Intersection of 2d and 1d Numpy array

房东的猫 提交于 2019-12-18 08:39:52
问题 For every element in array A[:,3:] that is also in array B , I want to set the value to 0, which creates the array result import numpy as np A = np.array([[1, 1, 10, 101, 102, 103, 0, 0], [2, 2, 10, 102, 108, 0, 0, 0], [3, 3, 11, 101, 102, 106, 107, 108]]) B = np.array([101, 106, 108]) result = np.array([[1, 1, 10, 0, 102, 103, 0, 0], [2, 2, 10, 102, 0, 0, 0, 0], [3, 3, 11, 0, 102, 0, 107, 0]]) I know there is a way to do this using in1d and broadcasting A as a 1D array, but I have no idea

Python - Intersection of two lists of lists [duplicate]

岁酱吖の 提交于 2019-12-18 08:23:46
问题 This question already has answers here : Removing duplicates from a list of lists (10 answers) Closed 3 years ago . These are my two lists; k = [[1, 2], [4], [5, 6, 2], [1, 2], [3], [4], [5,9]] kDash = [[1, 2], [4], [5, 6, 2], [1, 2], [3], [4], [5,6], [1,2]] My output should be the following; [[1, 2], [4], [5, 6, 2], [1, 2], [3], [4]] how can I get to this output? thank you in advance 回答1: You will have to convert the lists to list of tuples, and then use the intersection. Note that below

Connecting two WPF canvas elements by a line, without using anchors?

拈花ヽ惹草 提交于 2019-12-18 07:12:22
问题 I have a canvas for diagramming, and want to join nodes in the diagram by directed lines (arrow ends). I tried the anchor approach, where lines only attach at specific points on the nodes but that did not work for me, it looked like crap. I simply want a line from the centre of each object to the other, and stop the line at the nodes' edge in order for the arrow end to show properly. But finding the edge of a canvas element to test intersections against has proven difficult. Any ideas? 回答1: I

intersection of n lists via JS

冷暖自知 提交于 2019-12-18 07:06:47
问题 I am working on an algorithm and trying to figure out how to solve it given the following information: I would like to find the intersection between n number of lists assume that I have a (properly working) intersection(a, b) function assume that the intersection() only takes two lists as input So the problem would look something like this: var a = {1, 2, 'b'}; var b = {2, 'b', 'b'}; var c = {2, 'b', 'c'}; var d = {'a', 'b', 'c'}; //this is the part that does not work, of course: function

Intersect two arrays

半世苍凉 提交于 2019-12-18 04:34:42
问题 How can I find the intersecttion between 2 arrays in C#, in a fast way? 回答1: There's the Intersect extension method on Enumerable. It works on any IEnumerable<T> including arrays. 回答2: Here is an example use of Linq Intersect. // Assign two arrays. int[] array1 = { 1, 2, 4 }; int[] array2 = { 2, 3, 4 }; // Call Intersect extension method. var intersect = array1.Intersect(array2); foreach (int value in intersect) { label1.Text += value + "\n"; } 来源: https://stackoverflow.com/questions/4248433