analysis

Time complexity of a powerset generating function

試著忘記壹切 提交于 2019-12-01 09:35:16
I'm trying to figure out the time complexity of a function that I wrote (it generates a power set for a given string): public static HashSet<string> GeneratePowerSet(string input) { HashSet<string> powerSet = new HashSet<string>(); if (string.IsNullOrEmpty(input)) return powerSet; int powSetSize = (int)Math.Pow(2.0, (double)input.Length); // Start at 1 to skip the empty string case for (int i = 1; i < powSetSize; i++) { string str = Convert.ToString(i, 2); string pset = str; for (int k = str.Length; k < input.Length; k++) { pset = "0" + pset; } string set = string.Empty; for (int j = 0; j <

How to suppress code analysis on generated code?

会有一股神秘感。 提交于 2019-11-30 13:12:37
I have a Silverlight project with a generated Reference.cs file where the service reference is in. The class is attributed with [GeneratedCode] and in the project configuration the code analysis on generated code is disabled (Release and Debug). What have I done wrong? Maybe you should try the solutions that works for StyleCop: 1) Put ".Designer.cs" to the end of the name of the file you don’t want StyleCop to check. Or call the the class, and the file containing it, "NativeMethods". Make sure you also uncheck "Analyze designer files" in StyleCop settings. In this case the whole file will be

Algorithms for determining the key of an audio sample

烂漫一生 提交于 2019-11-30 10:14:08
问题 I am interested in determining the musical key of an audio sample. How would (or could) an algorithm go about trying to approximate the key of a musical audio sample? Antares Autotune and Melodyne are two pieces of software that do this sort of thing. Can anyone give a bit of a layman's explanation about how this would work? To mathematically deduce the key of a song by analysing the frequency spectrum for chord progressions etc. This topic interests me a lot! Edit - brilliant sources and a

Java image analysis - counting vertical lines

送分小仙女□ 提交于 2019-11-30 09:31:46
I need a little help on an image analysis algorithm in Java. I basically have images like this: So, as you might guessed, I need to count the lines. What approach do you think would be best? Thanks, Smaug A simple segmentation algorithm can help you out. Heres how the algorithm works: scan pixels from left to right and record the position of the first black (whatever the color of your line is) pixel. carry on this process unless you find one whole scan when you don't find the black pixel. Record this position as well. We are just interested in the Y positions here. Now using this Y position

Scraping text from file within HTML tags

人走茶凉 提交于 2019-11-30 08:53:04
问题 I have a file that I want to extract dates from, it's a HTML source file so it's full of code and phrases I don't need. I need to extract every instance of a date that's wrapped in a specific HTML tag: abbr title="((this is the text I need))" data-utime=" What's the easiest way to achieve this? 回答1: If you're using Excel VBA, set a reference (Tools - References) to the MSHTML library (entitled Microsoft HTML Object Library in the reference menu) Sub ScrapeDateAbbr() Dim hDoc As MSHTML

Check string indentation?

↘锁芯ラ 提交于 2019-11-30 08:50:33
问题 I'm building an analyzer for a series of strings. I need to check how much each line is indented (either by tabs or by spaces). Each line is just a string in a text editor. How do I check by how much a string is indented? Or rather, maybe I could check how much whitespace or \t are before a string, but I'm unsure of how. 回答1: To count the number of spaces at the beginning of a string you could do a comparison between the left stripped (whitespace removed) string and the original: a = "

How are exponents calculated?

≯℡__Kan透↙ 提交于 2019-11-30 07:05:55
问题 I'm trying to determine the asymptotic run-time of one of my algorithms, which uses exponents, but I'm not sure of how exponents are calculated programmatically. I'm specifically looking for the pow() algorithm used for double-precision, floating point numbers. 回答1: I've had a chance to look at fdlibm's implementation. The comments describe the algorithm used: * n * Method: Let x = 2 * (1+f) * 1. Compute and return log2(x) in two pieces: * log2(x) = w1 + w2, * where w1 has 53-24 = 29 bit

Ruby Text Analysis

邮差的信 提交于 2019-11-30 06:53:34
Is there any Ruby gem or else for text analysis? Word frequency, pattern detection and so forth (preferably with an understanding of french) Tilo the generalization of word frequencies are Language Models, e.g. uni-grams (= single word frequency), bi-grams (= frequency of word pairs), tri-grams (=frequency of world triples), ..., in general: n-grams You should look for an existing toolkit for Language Models — not a good idea to re-invent the wheel here. There are a few standard toolkits available, e.g. from the CMU Sphinx team, and also HTK. These toolkits are typically written in C (for

Search times for binary search tree

房东的猫 提交于 2019-11-30 06:32:18
问题 Does anyone know how to figure out search time for a binary search tree(i.e. worst-case, best-case, and average-case)? 回答1: For a non-self-balancing tree (possible but unusual for a search tree), worst case is O(n), which is for the degenerate binary tree (a linked list). In this case, you have to search, on average, half the list before finding your desired element. Best case is O(log 2 n) for a perfectly balanced tree, since you cut the search space in half for every tree level. Average

c++ FFT Beat detection library?

人走茶凉 提交于 2019-11-30 05:15:07
问题 I am currently looking around for a good allround beat detection library / source code in C++ since I found it really hard to achieve satisfying results with the beat detection code I wrote myself using this tutorial: http://www.gamedev.net/reference/programming/features/beatdetection/ It's especially really hard if you want to make it work with any kind of music so I was wondering if there is something usable out there allready? Thanks! 回答1: You could try Aubio: http://aubio.org/ It does not