|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On November 18 2012 02:36 fabiano wrote: That site will come in handy, thanks
Note that apart from maybe some ISO 9001 companies, noone really uses UML. Most programmers that use diagrams use stuff that looks like UML except without all the formal parts, mostly scribbling together a rough outline and putting boxes around it with the occasional straight line between them.
Development in most companies is very fluid with stuff changing on a daily basis, so any time spent on a complete UML diagram ends up being wasted.
If you need it for your education, learn enough of it to get past the tests, then you can freely forget everything again.
|
On November 18 2012 05:10 Morfildur wrote:Show nested quote +On November 18 2012 02:36 fabiano wrote: That site will come in handy, thanks Note that apart from maybe some ISO 9001 companies, noone really uses UML. Most programmers that use diagrams use stuff that looks like UML except without all the formal parts, mostly scribbling together a rough outline and putting boxes around it with the occasional straight line between them. Development in most companies is very fluid with stuff changing on a daily basis, so any time spent on a complete UML diagram ends up being wasted. If you need it for your education, learn enough of it to get past the tests, then you can freely forget everything again.
Still a pretty good skill to have. Being able to follow a formal specification is important, and so is being able to diagram out designs and structures. In practice, you rarely have to follow a formal specification when doing diagrams, but its not a bad way to learn either of those skills.
|
Question for you programming experts!
I want to design a function which takes any generic function from a differential equation and performs RK2/RK4 or whatever integration method on it. Now I was thinking something like this:
Obviously I want this to be able to have a function as an input. I know that this can be done via a pointer, but I was wondering if there was some more elegant solution.
Suppose I am trying to integrate dy/dx = E^x
double Function(x) { return exp(x);}
double RK2Integration( double (*)Function(x), stepsize, etc... ) { /* RK2 Calculations here */
return y; }
I am just wondering if you guys have a more elegant solution to this problem. I am not a programmer; I just do things numerically when it takes to long to solve it out by hand ^^
|
Hey guys, I've got a question.
I'm in High School and I've got some extra free time on my hands now that football season is over.
A few years ago I started learning C++ and I got relatively far. The best thing I did was make a Pong game from scratch using SFML graphics library. I ended up stopping programming with C++ because after seeing how hard Pong was to make, I didn't feel like I could make any better games without a college education.
Now with my extra free time, I'd like to get back into programming but I don't want to go back to making only games, which is what I did with C++.
Can anyone recommend a complete walkthrough/guide/language that would allow me to really learn how to - for example - work with the windows operating system. Basically, I want to use programming to do something useful, not just make game after game after game. I also am looking for a looooong guide that will start out at the basics and continue through more complicated things.
Thanks!
|
On November 18 2012 05:44 dannystarcraft wrote: Question for you programming experts!
I want to design a function which takes any generic function from a differential equation and performs RK2/RK4 or whatever integration method on it. Now I was thinking something like this:
Obviously I want this to be able to have a function as an input. I know that this can be done via a pointer, but I was wondering if there was some more elegant solution.
Suppose I am trying to integrate dy/dx = E^x
double Function(x) { return exp(x);}
double RK2Integration( double (*)Function(x), stepsize, etc... ) { /* RK2 Calculations here */
return y; }
I am just wondering if you guys have a more elegant solution to this problem. I am not a programmer; I just do things numerically when it takes to long to solve it out by hand ^^
It's a good solution, it's basically functional programming which comes more and more into style these days.
The only real alternative is doing it in C++ with classes and inheritance, though your solution does basically the same in less code.
|
On November 18 2012 05:50 AegonC wrote: Hey guys, I've got a question.
I'm in High School and I've got some extra free time on my hands now that football season is over.
A few years ago I started learning C++ and I got relatively far. The best thing I did was make a Pong game from scratch using SFML graphics library. I ended up stopping programming with C++ because after seeing how hard Pong was to make, I didn't feel like I could make any better games without a college education.
Now with my extra free time, I'd like to get back into programming but I don't want to go back to making only games, which is what I did with C++.
Can anyone recommend a complete walkthrough/guide/language that would allow me to really learn how to - for example - work with the windows operating system. Basically, I want to use programming to do something useful, not just make game after game after game. I also am looking for a looooong guide that will start out at the basics and continue through more complicated things.
Thanks!
Generally people refer to long guides that start out at the basics and continue through more complicated things 'books' . I would recommend the Head First series on whatever language you want to learn. A lot of people write books about software engineering, but most of them are written with the intention of writing a book-- the Head First series intends to actually teach you the material in a way that is easy to understand and comprehensive.
I've gone back and began reading through Head First Java and I really wish I had learned to program with that book. I mean hell, I have a career in software engineering and I'm learning little subtle things from that book which is pretty awesome.
If you want to get into computer science as a career, read a lot and acquire a lot of books, they're excellent references in the future.
|
On November 18 2012 05:44 dannystarcraft wrote: Question for you programming experts!
I want to design a function which takes any generic function from a differential equation and performs RK2/RK4 or whatever integration method on it. Now I was thinking something like this:
Obviously I want this to be able to have a function as an input. I know that this can be done via a pointer, but I was wondering if there was some more elegant solution.
Suppose I am trying to integrate dy/dx = E^x
double Function(x) { return exp(x);}
double RK2Integration( double (*)Function(x), stepsize, etc... ) { /* RK2 Calculations here */
return y; }
I am just wondering if you guys have a more elegant solution to this problem. I am not a programmer; I just do things numerically when it takes to long to solve it out by hand ^^
Templates gives you a solution allowing you to plug in a real function, a functor, or a lambda function.
template <typename func_type> double RK2(func_type func, float dt, ...) { // ... func(...): }
class function1 { public: double operator()(double x) { return exp(x); } };
double function2(double x) { return exp(x); }
void main() { // Functor RK2(function1(), 0.05f, ... ); // Function pointer RK2(function2, 0.05f, ... ); // Lambda (C++11) RK2([](double x){return exp(x);}, 0.05f, ...); }
Even if you only integrate actual functions by function pointer, using a template argument makes things nicer by masking this type.
|
Hello. So, I'm doing some basic directx stuff and I'm somewhat confused in relation to vertexbuffer and how to use them and I need some general hints. My problem: say we have a world geometry and some models (e.g. the map and starcraft and units and buildings). How do I organize them in vertexbuffers? Everything gets its own vb or I should stuff everything - world and units in one big buffer? If we have one big buffer, how add the new vertices for - say - the new units?
|
Can anyone recommend me a C/C++ fixed point arithmetic library?
I've been googling a bit and found some already: http://sourceforge.net/projects/fixedptc/. Also apparently the gcc compiler has implemented it ( http://gcc.gnu.org/onlinedocs/gcc/Fixed_002dPoint.html ), so should I use that? (I'm using Code::Blocks which I believe uses gcc/g++). Third option would be to implement it myself in C++.
How much does this slow down the program compared to if I program like this:
int a, b, c; a = 100; // ~ 10.0 b = 105; // ~ 10.5 c = a * b / 10; // ~ 105.0
This way is obviously optimal, but when more complicated calculation comes in...
|
On November 18 2012 09:29 Mstring wrote:Show nested quote +On November 18 2012 05:44 dannystarcraft wrote: Question for you programming experts!
I want to design a function which takes any generic function from a differential equation and performs RK2/RK4 or whatever integration method on it. Now I was thinking something like this:
Obviously I want this to be able to have a function as an input. I know that this can be done via a pointer, but I was wondering if there was some more elegant solution.
Suppose I am trying to integrate dy/dx = E^x
double Function(x) { return exp(x);}
double RK2Integration( double (*)Function(x), stepsize, etc... ) { /* RK2 Calculations here */
return y; }
I am just wondering if you guys have a more elegant solution to this problem. I am not a programmer; I just do things numerically when it takes to long to solve it out by hand ^^ Templates gives you a solution allowing you to plug in a real function, a functor, or a lambda function. template <typename func_type> double RK2(func_type func, float dt, ...) { // ... func(...): }
class function1 { public: double operator()(double x) { return exp(x); } };
double function2(double x) { return exp(x); }
void main() { // Functor RK2(function1(), 0.05f, ... ); // Function pointer RK2(function2, 0.05f, ... ); // Lambda (C++11) RK2([](double x){return exp(x);}, 0.05f, ...); }
Even if you only integrate actual functions by function pointer, using a template argument makes things nicer by masking this type.
There shouldn't be a () behind function1.
If DannyStarcraft is using VS2012 or the latest GCC, it gets even more general, so he's not restricted to functions that take exactly one integral parameter type:
template <typename func_type, typename... args> double RK2(func_type function, args... arguments) { //do rk2 stuff function(arguments...); }
where args is your usual list of types (which can be completely different from each other). e.g. this is valid:
void func1(int a, complex b, vector<int> c) { }
//... somewhere else RK2(func1, 2,complex(1,2),somevector);
Note all the "..." are intentional. If you're interested, look up variadic templates.
In general, if you want to be able to do something with your code / make it more general, etc., there's always a way to do it, since C++ templates are a turing complete language. But if you want to accomplish bigger feats, it usually gets hard to do unless you're very experienced with templates.
|
On November 19 2012 06:08 heishe wrote: There shouldn't be a () behind function1.
Let me know which compiler you use that lets you do without
|
*sigh* I've studied and studied for my programming course but I still don't feel confident in taking the exam today. I did fine on my last one but when it comes to HW he gives us some real brainteasers to work with. He just sent an e-mail saying that it's fine for us to bring our books and notes which probably means that this exam is going hard as hell, making us write a program with some magical flare to it other wise we'll be writing a dumb program that takes too much time to write out.
Just simple stuff in Python, if elif else, booleans, loops with for and while... But depending on the problem he wants us to solve it might be a bitch, it's stressful to wrap my around a teaser because while the concepts we're learning right now aren't too complex, coming up with the numbers a program might need and how to bring it all together is a different story...
Sorry guys just a frustrated CS student letting off some steam, please sprinkle your magical powder over me so that I may be a wizard for this exam @_@.
|
Get plenty of sleep beforehand. If the exam only contains basic stuff, but you expect it to be tricky, the key thing is to be well rested and relaxed. Assuming you actually know the basics obviously.
|
On November 20 2012 01:32 Snuggles wrote: *sigh* I've studied and studied for my programming course but I still don't feel confident in taking the exam today. I did fine on my last one but when it comes to HW he gives us some real brainteasers to work with. He just sent an e-mail saying that it's fine for us to bring our books and notes which probably means that this exam is going hard as hell, making us write a program with some magical flare to it other wise we'll be writing a dumb program that takes too much time to write out.
Just simple stuff in Python, if elif else, booleans, loops with for and while... But depending on the problem he wants us to solve it might be a bitch, it's stressful to wrap my around a teaser because while the concepts we're learning right now aren't too complex, coming up with the numbers a program might need and how to bring it all together is a different story...
Sorry guys just a frustrated CS student letting off some steam, please sprinkle your magical powder over me so that I may be a wizard for this exam @_@.
Having books and such for programming tests is not unusual, they usually don't help much anyways. Most problems are a case of getting algorithms to work, you can't get that from books in the time of a test. Books only help if you can't remember some function names and such, which is the easiest and least useful part of such a test anyways.
I don't think he will ask you any brainteasers, those are HW questions. Most likely it will be some basic stuff, sorting and such.
|
On November 19 2012 01:13 Gesh wrote: Hello. So, I'm doing some basic directx stuff and I'm somewhat confused in relation to vertexbuffer and how to use them and I need some general hints. My problem: say we have a world geometry and some models (e.g. the map and starcraft and units and buildings). How do I organize them in vertexbuffers? Everything gets its own vb or I should stuff everything - world and units in one big buffer? If we have one big buffer, how add the new vertices for - say - the new units?
Look up ID3DXMesh, it's probably what you want.
To answer the question specifically, you want one vertexbuffer per material (or batch) per object. For example, your unit might be one ID3DXMesh, with several SubMeshes, and the level would be another mesh. When you render your scene you would do something like:
for each mesh in view: for each submesh in mesh: set material properties on d3dDevice (texture, shaders, etc) submesh.draw()
|
C++ right
using VS2012, my lambdas have weird return types. I try like
std::cout << [] () -> int {return 12;};
the right hand side gives me a return type of "lambda []int () -> int". Shouldn't that return a simple int or is there something I'm not grasping?
|
On November 20 2012 15:24 Fyodor wrote:C++ right using VS2012, my lambdas have weird return types. I try like std::cout << [] () -> int {return 12;}; the right hand side gives me a return type of "lambda []int () -> int". Shouldn't that return a simple int or is there something I'm not grasping?
I haven't worked with C++ lambdas but judging from the little that i know, it looks like you are passing the lambda function itself, you don't execute it and pass the result.
|
On November 20 2012 15:43 Morfildur wrote:Show nested quote +On November 20 2012 15:24 Fyodor wrote:C++ right using VS2012, my lambdas have weird return types. I try like std::cout << [] () -> int {return 12;}; the right hand side gives me a return type of "lambda []int () -> int". Shouldn't that return a simple int or is there something I'm not grasping? I haven't worked with C++ lambdas but judging from the little that i know, it looks like you are passing the lambda function itself, you don't execute it and pass the result. oh so that's why this works?
auto f = [] () {return 12;}; std::cout << f();
|
In C++11 you can define all your return types using (a form of) this syntax. You don't have to declare them in Lambdas if the return type is deductible by the compiler.
From wikipedia:
[](int x, int y) { return x + y; } The return type is implicit; it returns the type of the return expression (decltype(x+y)). The return type of a lambda can be omitted as long as all return expressions return the same type.
The other kind mostly has its uses in template functions I guess...
template<class Lhs, class Rhs> auto adding_func(const Lhs &lhs, const Rhs &rhs) -> decltype(lhs+rhs) {return lhs + rhs;}
On November 20 2012 15:48 Fyodor wrote:Show nested quote +On November 20 2012 15:43 Morfildur wrote:On November 20 2012 15:24 Fyodor wrote:C++ right using VS2012, my lambdas have weird return types. I try like std::cout << [] () -> int {return 12;}; the right hand side gives me a return type of "lambda []int () -> int". Shouldn't that return a simple int or is there something I'm not grasping? I haven't worked with C++ lambdas but judging from the little that i know, it looks like you are passing the lambda function itself, you don't execute it and pass the result. oh so that's why this works? auto f = [] () {return 12;}; std::cout << f();
^ in this case f is of function type (std::function<int> in this case). The compiler actually turns this into a function which will end up in your binary - even if you use it just once. So using _many_ lambdas will increase your binary size... but then if this really matters to you, you probably won't be using C++ in the first place ;-)
|
On November 20 2012 17:36 Schokomuesli wrote:In C++11 you can define all your return types using (a form of) this syntax. You don't have to declare them in Lambdas if the return type is deductible by the compiler. From wikipedia: Show nested quote +[](int x, int y) { return x + y; } The return type is implicit; it returns the type of the return expression (decltype(x+y)). The return type of a lambda can be omitted as long as all return expressions return the same type. The other kind mostly has its uses in template functions I guess... template<class Lhs, class Rhs> auto adding_func(const Lhs &lhs, const Rhs &rhs) -> decltype(lhs+rhs) {return lhs + rhs;}
Show nested quote +On November 20 2012 15:48 Fyodor wrote:On November 20 2012 15:43 Morfildur wrote:On November 20 2012 15:24 Fyodor wrote:C++ right using VS2012, my lambdas have weird return types. I try like std::cout << [] () -> int {return 12;}; the right hand side gives me a return type of "lambda []int () -> int". Shouldn't that return a simple int or is there something I'm not grasping? I haven't worked with C++ lambdas but judging from the little that i know, it looks like you are passing the lambda function itself, you don't execute it and pass the result. oh so that's why this works? auto f = [] () {return 12;}; std::cout << f();
^ in this case f is of function type (std::function<int> in this case). The compiler actually turns this into a function which will end up in your binary - even if you use it just once. So using _many_ lambdas will increase your binary size... but then if this really matters to you, you probably won't be using C++ in the first place ;-) So how do I use lambdas without making them function types? I've seen them tossed in as the third element in a for loop but it won't return me an int that I can print.
Also are big binaries much of a problem really? I thought there was no strong relation between code size and performance.
|
|
|
|