matching

indices of occurence of each row in MATLAB

…衆ロ難τιáo~ 提交于 2019-12-06 11:50:19
I have two matrices, A and B . ( B is continuous like 1:n ) I need to find all the occurrences of each individual row of B in A , and store those row indices accordingly in cell array C . See below for an example. A = [3,4,5;1,3,5;1,4,3;4,2,1] B = [1;2;3;4;5] Thus, C = {[2,3,4];[4];[1,2,3];[1,3,4];[1,2]} Note C does not need to be in a cell array for my application. I only suggest it because the row vectors of C are of unequal length. If you can suggest a work-around, this is fine too. I've tried using a loop running ismember for each row of B , but this is too slow when the matrices A and B

Maximum weighted bipartite matching _with_ directed edges

南楼画角 提交于 2019-12-06 11:11:24
I know various algorithms to compute the maximum weighted matching of weighted, undirected bipartite graphs (i.e. the assignment problem): For instance ... The Hungarian Algorithm, Bellman-Ford or even the Blossom algorithm (which works for general, i.e. not bipartite, graphs). However, how can I compute the maximum weighted matching if the edges of the bipartite graph are weighted and directed ? I would appreciate pointers to algorithms with polinomial complexity or prior transformations to make the graph undirected so that I could apply any of the aforementioned algorithms. Edit: note that

Oracle SQL Regexp_replace matching

家住魔仙堡 提交于 2019-12-06 09:58:23
问题 Here is a funky matching that I need to accomplish. A5.1.9.11.2 Needs to become: A05.01.09.11.02 The amount of DOT sections will vary from none to many. And the letter "A" will always be there and always be 1 character. I would like to use the regexp_replace() function in order to use this as a sorting mechanism. Thanks. 回答1: Oracle SQL doesn't support lookaround assertions, which would be useful for this case: s/([0-9](?<![0-9]))/0\1/g You'll have to use at least two replacements: REGEXP

OpenCV Template Matching Drawing Rectangle Around Match

不羁岁月 提交于 2019-12-06 09:07:46
I want to use template matching, i am utilizing a code that i found that does what i want where it keeps it in bitmap and get a return of bitmap, the problem is im not entirely sure how i can get to drawing in the rectangles. I am using only java, no native while creating an app for android. With the use of openCV which i am new at. I will get multiple matches so i would like to get drawn rectangles around those point and also be able to obtain a value for the locations of these matches. mFind=new Mat(256, 192, CvType.CV_8UC4); Input = new Mat(256, 192, CvType.CV_8UC4); Mat mResult8u = new Mat

Machine Vision problem - Photo matching. Is a solution possible / known, using OpenCV?

杀马特。学长 韩版系。学妹 提交于 2019-12-06 05:37:49
Having searched around on SO, and also checked on OpenCV list but not having found an answer, posting my query here. Problem: Match 2 photos of the same scene, shot from 2 slightly different camera angles, and with slightly different lens distortions, with slightly different zoom-levels, and shot under slightly different lighting conditions. Constraints: Slightly different in the above statements can be taken to mean max. of 10% in most cases. The scene in question is to be considered an indoor scene, or an outdoor seen with limited details. Matching accuracy of 75% would be acceptable. The

Match 2 lists of strings by ressemblance

为君一笑 提交于 2019-12-05 22:18:08
Problem I have 2 lists of strings. I want to find the best matching pairs from my lists. For example, I have those 2 lists: list1 = {"a1","b1","c1"} list2 = {"a2","b2","c2"} I want to get the following results: results = {{"a1,"a2"}, {"b1,"b2"}, {"c1,"c2"}} Additional Info To compare 2 strings together, I would like to use something similar to the Levenshtein distance . For example, when I compare "a1" with "a2" , it gives me a shorter distance than "a1" with "b2" , so "a1" + "a2" would be considered a better match. I gets complicated when different pairs gets the same distance results. You

find best subset from list of strings to match a given string

大憨熊 提交于 2019-12-05 17:59:38
I have a string s = "mouse" and a list of string sub_strings = ["m", "o", "se", "e"] I need to find out what is the best and shortest matching subset of sub_strings the list that matches s. What is the best way to do this? The ideal result would be ["m", "o", "se"] since together they spell mose You can use a regular expression: import re def matches(s, sub_strings): sub_strings = sorted(sub_strings, key=len, reverse=True) pattern = '|'.join(re.escape(substr) for substr in sub_strings) return re.findall(pattern, s) This is at least short and quick, but it will not necessarily find the best set

postgres find zip codes near specific zip code

独自空忆成欢 提交于 2019-12-05 17:42:44
Assuming a Postgres Table containing zip as varchar(10) I want to get either all results matching a specific zip or extend my results with entries close to the queried one in case there are not enough results. Say: A user searches for zip "56500" and my result-set returns 2 items running an exact match. In this case I want to perform a kind of like query that finds "565%" entries. Eventually I need to run this in one query. Any suggestions? Something like this might be what you want: SELECT … FROM atable WHERE zip = @zip UNION ALL SELECT … FROM atable WHERE NOT EXISTS ( SELECT * FROM atable

Maximum bipartite graph (1,n) “matching”

被刻印的时光 ゝ 提交于 2019-12-05 16:56:30
I have a bipartite graph. I am looking for a maximum (1,n) "matching", which means that each vertex from partitation A has n associated vertices from partition B. The following figure shows a maximum (1,3) matching in a graph. Edges selected for the matching are red and unselected edges are black. See figure http://www.freeimagehosting.net/uploads/9a8df2d97c.gif This differs from the standard bipartite matching problem where each vertex is associate with only one other vertex, which could be called (1,1) matching with this notation. If the matching cardinality (n) is not enforced but is an

How to perform complex multicolumn match in R /

。_饼干妹妹 提交于 2019-12-05 16:50:13
I wish to match two dataframes based on conditionals on more than one column but cannot figure out how. So if there are my data sets: df1 <- data.frame(lower=c(0,5,10,15,20), upper=c(4,9,14,19,24), x=c(12,45,67,89,10)) df2 <- data.frame(age=c(12, 14, 5, 2, 9, 19, 22, 18, 23)) I wish to match age from df2 that falls into the range between lower and upper in df1 with the aim to add an extra column to df2 containing the value of x in df1 where age lies between upper and lower. i.e. I want df2 to look like age x 12 67 14 67 5 45 ....etc. How can I achieve such a match ? I would go with a simple