Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
So I finally sorted out my hashing problems. After getting a proper hash function down it was still running 5x slower. It turned out my hash of a hash was causing a copy constructor to get kicked off. Basically when I did:

inner_hash_type var = *(outer_hash[key])

It was copying the whole thing. It went from taking 125 seconds to 6 seconds when I fixed that.

Now the underlaying operations are much faster than similar Java code, but oddly enough the mysql connector code is much slower. That's the code doing actual queries and such. Very odd.

Adbot
ADBOT LOVES YOU

TheGopher
Sep 7, 2009

mr_jim posted:

CoC doesn't help your ego, but it does help your programming. Have a thicker skin, you're getting some good advice here.

See I laugh at attitudes like this, because while maybe I am getting good advice ('go program more' isn't hard to type out) I shouldn't have to deal with elitist stand-offish attitudes to get an answer, no matter the quality of advice. I have plenty thick skin, more than most people but having thick skin doesn't mean you're immune to being annoyed at people being dicks just because they can.

For some reason, for most people on SA the concept of acting civil while maintaining a high level of posting quality doesn't exist. It seems I have to trade posting quality for good attitudes which is a drat shame, but preferable.

UberJumper
May 20, 2007
woop

ShoulderDaemon posted:

Yep. Declare node set A to be the set of all the points you have, and set B to be the empty set.

Edit: If it's not obvious, you need to better explain how you want to split the group, and consequently what problem you are actually trying to solve. Splitting a group of things into two groups of things is so trivial that you aren't likely to get a useful answer out of us without some more information.

Yeah im pretty brain dead :suicide:

Pretty much im trying to implement some weird obscure way of using multi cores + GA to solve the TSP (by weird / obscure i mean like its a completely stupid idea but hey i didn't choose).

For example:

We generate 64 different populations, or possible solutions to the TSP problem. Normally each population holds its own bitstring or datablob.

So instead we were thinking of basically Breaking them into n smaller problems, when once we find optimal we combine them. Now since we pretty much want to group smaller groups, i was thinking of picking a starting node, and slowly growing the pop bubbles.

Basically we generate Where you have an initial population and you group them into N clusters,

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
TheGopher you don't seem to "get" SA, you should have lurked more in CoC before making your posts. You've seriously gotten a lot a help and attention from some of the most experienced software developers on this board. Why did you come here expecting everyone to play nice with you?

Here is another valid answer to your questions.
Teach Yourself Programming in Ten Years

shrughes
Oct 11, 2008

(call/cc call/cc)

TheGopher posted:

See I laugh at attitudes like this, because while maybe I am getting good advice ('go program more' isn't hard to type out) I shouldn't have to deal with elitist stand-offish attitudes to get an answer, no matter the quality of advice. I have plenty thick skin, more than most people but having thick skin doesn't mean you're immune to being annoyed at people being dicks just because they can.

Nobody here is being elitist. There is nothing elitist about being mediocre at programming, which is how most people here view themselves. Everybody here got okay, or decent, or good, or however they rate themselves at programming, by doing it a lot. (One exception might be me, I got good at programming by playing with decks of cards when I was three years old.) If you want elitist, go read the articles on the double hump theory or some other educational tripe.

You can't get good at programming quickly or without doing it a lot. That's just the most important thing for you to do. Many of the people here learned programming with nothing more than the TI-83 manual and trial and error. I did my first programming with only the first MS Works help file to help me. And then the QBasic help file. And then the TI-83 manual. And then the TI-85 manual. And then the TI-89 manual. And then the HP-49G manual. And then Programming Perl, 3rd Edition, and then I didn't have a computer to run my Perl programs on. And then I had a lovely C++ book that my older sibling used in college.

And here you are, with all the resources the internet has to offer, and you're talking to people who built up text adventures and tetris games on top of the knowledge acquired in one small chapter in the back of the calculator manual that the internet is not holding your hand enough. And what's even more amazing is that when somebody who cares a lot about helping people with their problems gives you a description of their reactions when reading your post, you think it's offensive! And it's that kind of behavior which makes people assume that you have the attitude that the world should just revolve around you. And I suspect that's an accurate assumption. And moving on...

TheGopher posted:

For some reason, for most people on SA the concept of acting civil while maintaining a high level of posting quality doesn't exist. It seems I have to trade posting quality for good attitudes which is a drat shame, but preferable.

You're the one who asked a question badly, and even then people were repressing their inner flameswords to help you out. Look back in time at your posting and ask yourself how you might have asked a smarter question. You began your post with "So ".

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker

shrughes posted:

Many of the people here learned programming with nothing more than the TI-83 manual and trial and error.

How many of us are out there...

Mr.Hotkeys
Dec 27, 2008

you're just thinking too much

KARMA! posted:

How many of us are out there...

Reporting in. It wasn't my first language (that was either html or GameMaker), but drat did I waste so many hours in school making stupid little number guessing programs and screensavers.

e: Also it seems to me like he just needs some direction, in that maybe he understands practice will help immensely but doesn't know what to do. I've always wondered, and it would help here, if there are any sites that are basically like the problems in a textbook, that present challenges based on a user's skill level and offer the solutions and/or step-by-step methods or tutorials on how to do them. It sounds like a pretty great idea that I'll file away in the "cool stuff I though of that I'll never expound upon" file cabinet if it doesn't exist already.

Mr.Hotkeys fucked around with this message at 11:19 on Apr 19, 2010

yatagan
Aug 31, 2009

by Ozma
TI-89 here (you plebs).

mr_jim
Oct 30, 2006

OUT OF THE DARK

It was QBasic on a 286 about 20 years ago for me.


TheGopher, you're right that it isn't hard to type out "go program more". But it's really the best advice there is. Start a project that seems interesting to you and work on it. The result will be a pile of terrible code that you'll be embarrassed by in a few years, but that doesn't matter. Then start another project and keep working on that. Code yourself into a corner and rewrite the whole thing again. Repeat that process over and over again. After a few years of that, the code you write will stop being so embarrassing.

That's not to say you shouldn't do any reading as well. You've been learning about C, right? If you don't already own K&R's "The C Programming Language", get it and read it. Do some of the exercises. Then maybe pick up Kernighan and Pike's "The Practice of Programming" to learn about good style. Take a look at the Coding Horrors thread here in CoC to learn what not to do. You're interested in game development, so check out that megathread as well. Oh yeah, don't forget about data structures and algorithms. I don't have any specific book suggestions in that area, unfortunately.

Flamadiddle
May 9, 2004

Mr.Hotkeys posted:

I've always wondered, and it would help here, if there are any sites that are basically like the problems in a textbook, that present challenges based on a user's skill level and offer the solutions and/or step-by-step methods or tutorials on how to do them.

Not exactly what you're talking about (which sounds like a great idea), but JavaBat (now CodingBat: http://codingbat.com/) is a good timewaster. It won't teach you how to do things properly, but it lets you do some trial/error. It looks like they've added a whole Python section now, too.

covener
Jan 10, 2004

You know, for kids!

TheGopher posted:

I know basic C concepts. Stuff like pointers, arrays, defining classes, typecasting, etc. Basic stuff. I have no idea where to go from here. To be clear, C is the only language I'm familiar with. I could probably get to the same point with another language with minimal effort because I really understand what I've been taught.

TheGopher posted:

CarlH (the author of those tutorials) wrote some pretty comprehensive information about programming.

If you're about 8 hours into "learning C in 24 hours", you can't really make that call.

Lexical Unit
Sep 16, 2003

KARMA! posted:

How many of us are out there...

QBASIC and the help index, and then later a TI-83 and the manual. I once got in trouble for writing a program to solve a bunch of busy work in geography class that was supposed to take all class to finish, but I finished it in about 10 minutes and then slept for the rest of class.

Learn by doing. The harder it is what you try to do, the more you can potentially learn.

BigRedDot
Mar 6, 2008

I never programmed a calculator. Started with LOGO on a TRaSh-80, then Commodore BASIC. :)

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

I didn't start programming a calculator, but did once do mandelbrot on one. I think I only had the patience to wait for it to finish once, it took absolutely ages. Eventually had to wipe it before going into an exam once :(

csammis
Aug 26, 2003

Mental Institution
Commodore BASIC then TI-BASIC leading directly to Z-80 asm :whatup:

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"
Apple and TI computer BASIC in early grade school, then Commodore 64 BASIC, then C64 assembly, then AmigaBASIC, various random Amiga programming languages (AMOS, and I remember one called E fairly well), then Amiga 680x0 assembly, then I FINALLY got a Windows machine and started C++ (Turbo, then Visual).

:c00lbert:

I would have loved to learn C on the Amiga, but the only compilers I had access to were gimped commercial trials that wouldn't compile more than 4 functions. But the assembler I got was fully functional, so you make do with what you've got :v:

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Atari Basic is where it's at bitches.

Jonnty
Aug 2, 2007

The enemy has become a flaming star!

My dad tried to teach me C when I was 8 or something. I eventually settled on this, lots and lots of years ago: http://www.libertybasic.com/. The experience put me off programming till I was 13. Whoops!

Chocolate America
Nov 5, 2008

by garbage day
XML/DTD question:

Can you link to a DTD within another DTD? If so, how do you do it? I haven't been able to find anything reliable on google and the W3C site is way too technical.

Thanks.

edit: More specifically, I have 2 DTDs that I want to use for an "html" doctype. One of them is a W3C standard, and another one is a custom proprietary DTD.

Chocolate America fucked around with this message at 01:00 on Apr 20, 2010

Rabbi
Nov 20, 2002

mr_jim posted:

It was QBasic on a 286 about 20 years ago for me.
QBasic, on my dad's 386, 15 years ago

:cool:

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I have a question about boolean search languages or anything that's generally suited for searching. I am working on something for screening stocks and I want to be able to write out something that knows to take an incoming pile of stocks, apply the rules, and leave me with just the ones that satisfy the rules. Initially I imagine I could just code something to do all that but I like the idea of being able to flexibly apply criteria and watch them plop out.

Before I go about writing up some BNF or something for this I wondered if there wasn't a robust grammar out there already to follow that might include some things I wouldn't have originally thought about. All I have in my mind right now are basically things with AND, OR, and NOT with maybe parentheses.



I have a separate question about FLTK. It sure seems easy to crank out something with it, but I wonder how well it handles layout and resizing. From what I can tell you just set groups as resizable and hope for the best. Is there anything like layout management?

shrughes
Oct 11, 2008

(call/cc call/cc)

Rocko Bonaparte posted:

Before I go about writing up some BNF or something for this I wondered if there wasn't a robust grammar out there already to follow that might include some things I wouldn't have originally thought about. All I have in my mind right now are basically things with AND, OR, and NOT with maybe parentheses.

I would just pick a language that lets you run stuff from the command prompt (and pick one that lets you define your own operators or override them). I would use Haskell and end up saying things like

code:
> :t isTechStock
isTechStock :: Stock -> Bool
> stocks (isBig <&> isTechStock)
["MSFT", "GOOG", "APPL"]
The implementation of (<&>) would be very simple:
code:
x <&> y = \stock -> x stock && y stock
So maybe use Ruby or Scala or Haskell or F# or something, and make some class for which you can define operators like "and" and "or" that takes two boolean predicates that take a stock as input and returns another such predicate. This is more convenient than writing your own minilanguage.

KingEup
Nov 18, 2004
I am a REAL ADDICT
(to threadshitting)


Please ask me for my google inspired wisdom on shit I know nothing about. Actually, you don't even have to ask.
Edit: I found a better thread for my question.

KingEup fucked around with this message at 09:03 on Apr 20, 2010

yatagan
Aug 31, 2009

by Ozma
What's the purpose of offsetting a UDP packet by a certain number of bytes? I see this function in http://java.sun.com/j2se/1.4.2/docs/api/java/net/DatagramPacket.html , but I'm not sure why anyone would use it?

Standish
May 21, 2001

yatagan posted:

What's the purpose of offsetting a UDP packet by a certain number of bytes? I see this function in http://java.sun.com/j2se/1.4.2/docs/api/java/net/DatagramPacket.html , but I'm not sure why anyone would use it?
avoiding data copying I guess?

yatagan
Aug 31, 2009

by Ozma
I guess I don't really get what the offset even means here, google's not being too helpful.

shrughes
Oct 11, 2008

(call/cc call/cc)
It's just giving offset and length into the byte[] array, isn't it? This is pretty standard when dealing with arrays. For example, String(byte[] bytes, int offset, int length)

yatagan
Aug 31, 2009

by Ozma

shrughes posted:

It's just giving offset and length into the byte[] array, isn't it? This is pretty standard when dealing with arrays. For example, String(byte[] bytes, int offset, int length)

Oh duh, it's marking where to start reading the byte array from. Thanks.

DrBouvenstein
Feb 28, 2007

I think I'm a doctor, but that doesn't make me a doctor. This fancy avatar does.
In MATLAB, how would I check that a string doesn't contain any characters other than ones from a set list (the list isn't a variable or anything like that.)

I have a program where the user enters an equation and MATLAB evaluates it, but first it has to check that the user only inputed numbers, or mathematical symbols. So I have to find a way for MATLAB to look it over and if it has anything other than 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, +, -, *, or /, give an error message (yeah, it's just a simple integer calculator with four functions right now.)

Nippashish
Nov 2, 2005

Let me see you dance!

DrBouvenstein posted:

In MATLAB, how would I check that a string doesn't contain any characters other than ones from a set list (the list isn't a variable or anything like that.)

I have a program where the user enters an equation and MATLAB evaluates it, but first it has to check that the user only inputed numbers, or mathematical symbols. So I have to find a way for MATLAB to look it over and if it has anything other than 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, +, -, *, or /, give an error message (yeah, it's just a simple integer calculator with four functions right now.)

You can use
code:
if all(ismember(input_string, string_of_valid_characters))
    % everything is ok
else
    % everything is not ok
end

Secx
Mar 1, 2003


Hippopotamus retardus
I have a database table with 155,000 names. We want to do some clean-up and find names which are not spelled exactly the same, but may be duplicates.

Example: "Johnson & Johnson incorporated" and "Johnson and Johnson inc." would return a very high score.

How should I go towards solving this problem ?

I did some research and found an algorithm that would fit my needs. I used it in a Ruby script, but the problem is speed. Comparing one name against 155,000 others to find those with a score of > 0.8 took 70 seconds on my laptop. It would take 4 months to compare all 155,000 at that rate.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

Secx posted:

I did some research and found an algorithm that would fit my needs. I used it in a Ruby script, but the problem is speed. Comparing one name against 155,000 others to find those with a score of > 0.8 took 70 seconds on my laptop. It would take 4 months to compare all 155,000 at that rate.

If the function is symmetric, it's 2 months, not four. And why would you do this in Ruby instead of a language suited for numeric processing (e.g. C)? Ruby is slow, and depending on the problem being solved (and the quality of the code), C can be up to 1000 times as fast: http://shootout.alioth.debian.org/u32/benchmark.php?test=all&lang=ruby&lang2=gcc

Secx
Mar 1, 2003


Hippopotamus retardus

Secx posted:

I have a database table with 155,000 names. We want to do some clean-up and find names which are not spelled exactly the same, but may be duplicates.

Example: "Johnson & Johnson incorporated" and "Johnson and Johnson inc." would return a very high score.

How should I go towards solving this problem ?

I did some research and found an algorithm that would fit my needs. I used it in a Ruby script, but the problem is speed. Comparing one name against 155,000 others to find those with a score of > 0.8 took 70 seconds on my laptop. It would take 4 months to compare all 155,000 at that rate.

Welp, it turns out that I was reinventing the wheel. MS SQL Server 2005 and up offer an integration service called Fuzzy Lookup Transform and it does exactly what I wanted to do.

http://www.sqlteam.com/article/using-fuzzy-lookup-transformations-in-sql-server-integration-services

DrBouvenstein
Feb 28, 2007

I think I'm a doctor, but that doesn't make me a doctor. This fancy avatar does.

Nippashish posted:

You can use
code:
if all(ismember(input_string, string_of_valid_characters))
    % everything is ok
else
    % everything is not ok
end

Thanks!

But now I got a new problem...

same scenario, but now I have to check and make sure that even if they only entered the right characters, they still wrote a valid equation...ie, I have to check to make sure they didn't do something like:

"5+7--6"
or
"/6+3"

etc...

Oisin
Jul 22, 2009
How do you extract "data" from audio files?

I'd like to mess around with a music visualizer of sorts, and the first step is actually reading the music file. I've read this but it really only talks about transforming the data once you already possess it:

http://stackoverflow.com/questions/153712/creating-music-visualizer

I assume (not an audio person) that "data" refers to the pitch of the song?

yatagan
Aug 31, 2009

by Ozma

Oisin posted:

How do you extract "data" from audio files?

I'd like to mess around with a music visualizer of sorts, and the first step is actually reading the music file. I've read this but it really only talks about transforming the data once you already possess it:

http://stackoverflow.com/questions/153712/creating-music-visualizer

I assume (not an audio person) that "data" refers to the pitch of the song?

Your audio will be encoded to a particular specification. Here's the WAVE specification (uncompressed audio):

http://www-mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html

Edit: I want to add that, depending on your language, there are probably pre-existing libraries that will do the grunt work.

yatagan fucked around with this message at 05:05 on Apr 21, 2010

schnarf
Jun 1, 2002
I WIN.

Oisin posted:

How do you extract "data" from audio files?

I'd like to mess around with a music visualizer of sorts, and the first step is actually reading the music file. I've read this but it really only talks about transforming the data once you already possess it:

http://stackoverflow.com/questions/153712/creating-music-visualizer

I assume (not an audio person) that "data" refers to the pitch of the song?

Check out libsndfile. The data is usually "amplitude," sometimes as 8-, 16-, 24- or 32-byte integers, and also possibly in floating point. You can imagine the amplitude as representing some voltage, or displacement of a speaker cone, or compression/rarefaction of air. The audio is at some sampling rate, like 48 Kilohertz, which means that 48000 samples in that file correspond to a single second, and they are uniformly spaced at 1/48000 of a second apart. The audio file can represent frequencies between 0 Hz (DC), and half the sampling rate, also known as Nyquist frequency, i.e. for 48k, the highest frequency is going to be 24k.

You can extract audio spectrum data using the Discrete Fourier Transform (DFT), if that's what you want to do. You dont' want to do a DFT directly (like, using the formula for it), you want to use a Fast Fourier Transform (FFT), which is a nlogn algorithm for computing the DFT. FFTW has some really great FFT implementations. For something like this, you'd do a Short-Time Fourier Transform (STFT), which means that rather than taking the DFT of the entire sequence of audio data, you apply a windowing function (i.e. Hann, Hamming, etc) to some short portion of the data (on the order of a few ms), and take the DFT of that. Then generally these windows will overlap a bit, i.e. the windows will be 20 ms long and the stride from window to window is 10 ms.

You're probably going to want to learn some DSP. You can wiki a lot of this stuff if you don't know it. There's also some stuff at http://www.dspguide.com/ and https://ccrma.stanford.edu/~jos/ . You can also check out the music-dsp mailing list.

chocojosh
Jun 9, 2007

D00D.
In my .NET programs I've been increasingly using "helpers" to handle part of the code that goes into code behind. For example, our WPF application supports a "flick", such as that you find in the iPhone. To do a "flick" requires some code on mouse down, mose mouve, mouse up. Instead of storing that code inside the control itself, I create a "FlickHelper".

The difference between "helpers" and a standard business layer, is that "helpers" are allowed to take UI controls as parameters and operate on them, whereas a business layer should not have any knowledge of the UI.

Is there an official pattern or name for this? I want to push my coworkers (and the new interns we have for the summer) to use this more often. The advantages I see to using "helpers":

  1. Reduces the total # of lines in the code behind class, which makes it easier to read the code behind class.
  2. Lowers the total number of member variables in the code behind class
  3. Allows the same logic to be used in different UIs without having to modify each UI


At the same time, any references/resources on patterns in the past few years? I'm currently working on desktop/WPF applications. In school we studied PoEA and most of the GoF patterns.

Oisin
Jul 22, 2009

schnarf posted:

Yatagan and Schnarf

Thanks guys, that helped a lot. I found JLayer and I will be using that since I am a bit more comfortable with JAVA.

Adbot
ADBOT LOVES YOU

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I'll try to ask this question I crammed into the end of an earlier post again: does anybody here understand FLTK layout and how resizing affects components? I see something about a resizable bit that affects thing, but that only one component in a group can do it. So how does one cause, say, two text fields to both resize when a window is made larger? Does each field need a group to itself?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply