• What Do You Need Help With? V6
    7,544 replies, posted
[QUOTE=blacksam;45158398] So I'm trying to do a recursive flood fill algorithm, but I keep running into a stack overflow error and I don't know why that is. 0's are meant to be filled and 1's are the "walls".[/QUOTE] I think you are infinitely recursing on positions with value 1. You're flood algorithm shouldn't recurse (or do anything) if the grid value is 1. Otherwise it will pass through the walls and infinitely recurse. Check for a valid row and column, and return if grid[row][col] == 1 If grid[row][col] == 0, then set it to 3 and call flood on the neighbors.
I have another question about SDL C++ Visual studio. I can't get it to load an image with this code: [code]SDL_Surface* image = IMG_Load("Assets/Images/Player/player_sheet1.png")[/code] returns NULL.
[QUOTE=Pat.Lithium;45161640]I have another question about SDL C++ Visual studio. I can't get it to load an image with this code: [code]SDL_Surface* image = IMG_Load("Assets/Images/Player/player_sheet1.png")[/code] returns NULL.[/QUOTE] IMG_GetError() should tell you what's wrong in that case.
oops forgot to put some dll files in the project directory
Anyone have any good resources on writing VSTs? I am getting back into music, and I would like to write my own mini software-synths.
I'm having trouble getting sdl2 to work with Xcode. I also have vs12 on windows 8 using bootcamp, but I would rather program c++ in macos. here's the error: [code] linker command failed with exit code 1 (use -v to see invocation)[/code]
-snip-
If the fish eye is your own choice and the point of the project is to just add some filters of your own choosing, I suggest you start with easier filters first, i.e. convolution filters, as they encompass Gaussian blur, edge, motion blur ( I think) and stuff like that. Basically if you are able to implement the convolution of an image with a kernel you can immediately add a dozen of filters to your project with the implementation of only a single tool (i.e. a convolution). Now if you really have to implement a fish eye, you better start reading up: [url]http://paulbourke.net/dome/fisheye/[/url] But those are a whole different type of filters based on projections. I suspect that the convolution is easier to implement than projection and shit like that.
-snip-
What keeps you from switching to the simple filters, given that you haven't implemented the fish eye yet?
-snip-
You should talk to the "good coder" and tell him you're having difficulties.
Wait, so has there been done enough effort on the fish eye that change is simply not possible anymore, or does the project hinge on the fact that there's a fish eye? Are other parts dependent on it? If not then a change would just hurt the feelings of the guy who had the idea of the fish eye in the first place, but it's not that good of an idea :v: More fish eye sources (concrete code examples) [url]http://stackoverflow.com/questions/2477774/correcting-fisheye-distortion-programmatically[/url] this one seems nice [url]http://popscan.blogspot.be/2012/04/fisheye-lens-equation-simple-fisheye.html[/url] It's really a clear example of people ignoring the theory behind a tool, thinking their programming skills are all they need.
-snip-
Ok, so I'm using CUDAfy.Net, and I have the following 3 structs: [code] [Cudafy] public struct Collider { public int Index; public int Type; public Sphere Sphere; public Plane Plane; public Material Material; } [Cudafy] public struct Material { public Color Color; public Texture Texture; public float Shininess; } [Cudafy] public struct Texture { public int Width, Height; public byte[ ] Data; } [/code] Now, as soon as I send over an array of Collider objects to the GPU, using [code] CopyToDevice<GPU.Collider>( ColliderArray ); [/code] I get the following error: An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll Additional information: Object contains non-primitive or non-blittable data. Does anyone with any experience with either CUDAfy.Net, or OpenCL ( since it basically compiles down into OpenCL ), have any idea how I could accomplish this? The whole problem lies in the byte array of Texture, since everything worked just fine when I didn't have a Texture struct.
[QUOTE=Pelf;45146786]Why do division operations take much longer than addition, subtraction, or multiplication? (see [url=http://msdn.microsoft.com/en-us/library/ms973852.aspx]here[/url]) If I want to divide a number by 10, should I instead multiply by 0.1?[/QUOTE] Note that everything said below is as far as I understand, and may [b]not[/b] be entirely accurate. If I am misinformed on any one part, please feel free to point it out. This is something I am curious in myself, but finding information on it is a bit difficult, at least when I tried. To actually answer your question fully, the core of the answer is in commutativity. There are various algorithms for [url=http://en.wikipedia.org/wiki/Multiplication_algorithm]multiplication[/url] and [url=http://en.wikipedia.org/wiki/Division_algorithm]division[/url] - in general, modern ALUs (Arithmetic Logic Units) use the faster algorithms those pages describe. However, you'll find that they are iterative solutions. Modern CPUs / ALUs take full advantage of parallelization, which, for arithmetic, generally exploits commutativity. Multiplication algorithms generally apply addition and multiplication, which are both commutative ((1 + 2) + 3 = 1 + (2 + 3)), whereas division algorithms generally apply subtraction and division, neither of which are commutative ((1 - 2) - 3 =/= 1 - (2 - 3)). The commutativity of addition and multiplication in multiplication algorithms means that the ALU can run several operations at the same time, because the order they are done in does not matter - in the end, they'll equal the same thing, no matter how they're put together. The parallelization that the ALU can achieve for division algorithms, however, is very much restricted compared to multiplication algorithms, which results in a stricter bottleneck, and thusly more cycles to complete. That being said, modern CPUs / ALUs are chock full of tricks, and don't use one algorithm for all instances. For example, division and multiplication by powers of two (2, 4, 8, 16, etc) can be done exceptionally cheaply by doing a bit-shift - the binary representation of 5 is 101, and the binary representation of 10 (5 * 2 ) is 1010. By simply pushing all the bits over to the left one position, and slamming a zero into the 1's place, you multiply by two. Similarly, pushing all the bits over to the right one position gives you division by two. I am certain other tricks exist for other common operations, such as multiplication and division by 10. As Fredo said, for something like division by 10, it'd be cheaper to divide by 10 rather than multiply by 0.1 and cast. For more complex divisions, though (like, say, dividing a large floating-point number by a small floating-point number - EG 13254657.4598 / 657.2535), it becomes a more contextual basis on whether or not multiplication with inverses (keep in mind floating-point errors! x/y =/= x*(1/y)!) is more beneficial to use than division.
[QUOTE=Gmod4ever;45177760]That being said, modern CPUs / ALUs are chock full of tricks, and don't use one algorithm for all instances. For example, division and multiplication by powers of two (2, 4, 8, 16, etc) can be done exceptionally cheaply by doing a bit-shift - the binary representation of 5 is 101, and the binary representation of 10 (5 * 2 ) is 1010. By simply pushing all the bits over to the left one position, and slamming a zero into the 1's place, you multiply by two. Similarly, pushing all the bits over to the right one position gives you division by two.[/QUOTE] Does the ALU actually do this? I was under the impression that compilers make the optimization, even when not multiplying by powers of 2. For example, if you want to compute x*18, the compiler would optimize it to compute (x<<4) + (x<<1), which is equivalent to x*16+x*2. Because you are using powers of 2, the single expensive multiplication would turn into 2 bit shifts and an addition. x*15 would become x*16-x, and so on. Of course at some point it's quicker to do the single multiplication than several bit shifts and additions.
[QUOTE=Fredo;45183089]Does the ALU actually do this? I was under the impression that compilers make the optimization, even when not multiplying by powers of 2. For example, if you want to compute x*18, the compiler would optimize it to compute (x<<4) + (x<<1), which is equivalent to x*16+x*2. Because you are using powers of 2, the single expensive multiplication would turn into 2 bit shifts and an addition. x*15 would become x*16-x, and so on. Of course at some point it's quicker to do the single multiplication than several bit shifts and additions.[/QUOTE] It may be the compiler, now that I think on it. The point is, though, that the expression gets simplified so that the ALU has significantly less work to do.
I made some WPF controls. Specifically a custom window (made custom borders and whatnot) and a button (so far). What would be the best way to package it up into a dll so you can just us the new window class and buttons? (instead of copying over the styles from app.xaml and such)
Not sure if this is the right thread but whatever. I'm starting an Intro to Computer Programming class tomorrow as a requirement for my Bioinformatics major (made a thread about it a while ago: [url]http://facepunch.com/showthread.php?t=1391443[/url]). We're using this textbook in class: [url]http://www.wiley.com/WileyCDA/WileyTitle/productCd-EHEP001707.html[/url] Is there anything important I should know/do beforehand, for someone who has never done programming beyond some basic HTML?
Well first of all HTML is not programming :v: Apart from that it might help a tiny tiny bit, if it's intro then yeah, there's not much you need to know beforehand I guess?
[QUOTE=Number-41;45187420]Well first of all HTML is not programming :v: Apart from that it might help a tiny tiny bit, if it's intro then yeah, there's not much you need to know beforehand I guess?[/QUOTE] HTML was the closest thing I could think of, but yeah I can see how they're very different. Guess I'll just see how it goes tomorrow then. Is C++ a good language to learn for Intro?
[QUOTE=TerrorShield;45188760]Is C++ a good language to learn for Intro?[/QUOTE] A lot of people would say it is, but I'd say it's not. It doesn't teach programming as much as it teaches systems programming.
Honestly if I could start over, I'd start with C#. Not having to deal with a lot of the nuances of C++ would be great, but I've become so engrained in it the way things work and are written that it's become natural to me. So if you can, learn C#.
Ah ok. Well I guess there's not much I can do about it then. Hopefully it gets taught better in higher level classes? As programming is probably going to be an important skill in Bioinformatics if there's so many prereq classes in CS.
So many people go to Uni(or college depending where you are) to do computer science or related degrees without ever having done any programming. I'd say it's the vast majority. I really don't understand why, there are so many people that drop out because they don't enjoy it. [editline]23rd June 2014[/editline] Hopefully you enjoy it!
I've always been interested in programming but never really got into it. Thanks for the support though! I'll see how it goes for now, still early enough to change my major and CS is only a portion of it.
Just for the record I have pretty much zero programming knowledge and very little bash/batch knowledge, but I am trying to challenge myself and thought this would be the right place to post my question. So I'm trying to make a Youtube-dl batch script that acts somewhat similar to the bash script in [URL="https://www.youtube.com/watch?v=G7uztVbg7CQ"] this video. [/URL] Here is what I am having trouble with, [CODE] @echo off ::copy NUL video.mp4 ::copy NUL audio.m4a cls set /p URL=Paste YouTube URL: if "%URL%"=="https://www.youtube.com/watch?v=" goto dl if "%URL%"=="http://www.youtube.com/watch?v=" goto dl if NOT "%URL%"=="https://www.youtube.com/watch?v=" goto bad if NOT "%URL%"=="http://www.youtube.com/watch?v=" goto bad :bad echo "URL is not valid" pause exit :dl echo temp > temp.txt pause del temp.txt pause [/CODE] I have the inputted url go set to the "URL" variable that I will use later on, what I want to do is for the [U]if[/U] command to be able to ignore anything after "watch?v=", just so it can check if it is a valid YouTube url, right now if I just copy/paste the url into the input so it matches it creates a temporary temp.txt. What can I do to make it essentially look for "https://www.youtube.com/watch?v=[B][U]*[/U][/B]", I hope that makes sense.
This guy on SO has the answer i think: [url]http://stackoverflow.com/questions/2027070/how-to-concatenate-strings-in-a-windows-batch-file[/url] Also, if video's are not downloading today. My current job needs youtube download extraction too, but can't use youtube-dl directly. I used it as reference for the url decryption part. And it seems, today youtube updated their player, making the current cipher useless. youtube-dl has not been updated as far as i can tell.
[QUOTE='[ J ] Man;45189348']batch file stuff[/QUOTE] Sounds like you're looking for substrings: [URL]http://ss64.com/nt/syntax-substring.html[/URL] Use %URL:~0,32% for https and 0,31 for http. The find command also has some basic regular expression functionality too I think, if you need pattern matching (eg. to get the video ID - I assume it's variable length).
Sorry, you need to Log In to post a reply to this thread.