And most of all, may other languages can generate very efficient code
some languages can generate more efficient code than C++, unless you're a C++ guru and are willing to spend absurd amounts of time optimizing your program
@AgainstASicilian My ego? I don't really see what my ego has to do with anything. I'm not the one acting butthurt when people tell me there might just be a better way to solve the problem I'm trying to solve
@EtiennedeMartel I don't care. I've solved enough PE problems to know that C++ implementations involving larger loop iterations tend to be loads faster. An implementation that will take 20 minutes in Python can take 10 in C++, for instance, based on the nature of the looping structures
@AgainstASicilian Yes. And it can also take 10 minutes in C# or Java. Or Fortran. Or a million other languages. I am not saying a C++ implementation of your program can't be faster than your Python program. I am saying that C++ is just one language out of many which can be used to generate fast code
@AgainstASicilian That's like saying that the space shuttle utterly smokes a bicycle.
@AgainstASicilian Yeah, sure. But what we're saying is that there might be better languages than C++ for that. As it is now, it looks to me like you're trying really hard to find some use for your golden hammer of choice.
Python was never designed to be fast. C++ was, sure, but so were dozens of other languages, which could be used to speed up your program without all the headaches adn struggles you're fighting with now
I don't know why you're reacting so strongly over this. I've never seen someone get bent out of shape just because someone else is trying to get GMP working in C++. Totally weird.
@AgainstASicilian I don't know why you are reacting so strongly over this. I've never seen someone get bent out of shape just because he's being given advice on how to better solve his problem
@AgainstASicilian .... You have such a good idea of what you need that you've had to ask for help here countless times in the last few hours. And you have such a good idea of what you need that you then disregard the answers people give you
@AgainstASicilian I'm not being sarcastic either. Go write your fast code in a language that's easier to grapple with than C++. I guarantee you it will change your mind.
@AgainstASicilian And why do you assume I haven't solved any of them?
Ratfor (short for Rational Fortran) is a programming language implemented as a preprocessor for Fortran 66. It provided modern control structures, unavailable in Fortran 66, to replace GOTOs and statement numbers.
Features
Ratfor provides the following kinds of flow-control statements, described by Kernighan and Plauger as "shamelessly stolen from the language C, developed for the UNIX operating system by D.M. Ritchie" ("Software Tools", p. 318):
* statement grouping with braces
* if-else, while, for, do, repeat-until, break, next
* "free-form" statements, i.e., not constrained...
Most of the problems are doable in under a second even in Python. I am talking about the seriously tough ones that take Python hours and hours to complete.
@AgainstASicilian It's ten minutes past eleven, and I need to get up earlyish tomorrow. And you have shown very clearly that you pay no attention to what anyone else are saying, and you still haven't even heard what it is we're telling you
Please listen this time. We have only said this 88 times, and I will happily repeat myself: "We are not saying C++ is a worse choice than Python when you want to write fast code"
Because you spend the better part of the day begging for help with extremely basic C++ problems, and you get angry when anyone actually tries to help you
@Mooing I declared an array of mpz_t's but apparently mpz_t's aren't what I need (unsure why specifically), so I am trying mpz_class. But it seems like a lot of the arithmetic operators mpz_t has are not present in mpz_class. Furthermore, I am trying to declare an array of these things but they're crashing at runtime
@AgainstASicilian as you've been told three times, mpz_t is a C-struct. Do not use it in C++ code. Use mpz_class instead. mpz_t doesn't have operators, because it's just a struct, whereas they are all automatically magically built into mpz_class
@AgainstASicilian use mpz_classexactly as if it were a float, but has infinite range.
@CheersandhthAlf I can get the examples working, but my code involves more complex examples that are not addressed in the docs (mainly arrays and having the bignums play nice with other datatypes. Also, apparently long longs have even more trouble)
@AgainstASicilian you can do the exact same thing with a vector. If you can use an array, you can use a vector. It's not more complicated, it's less complicated.
@AgainstASicilian not matter of opinion. Everything a dynamic array does, a vector does as well. Except you don't ahve to delete it. That's easier. Ergo, vector is objectively easier to use.
@MooingDuck It's harder in terms of syntax, for me. I have to quadruple check that I am typing everything in right before it works correctly. Arrays I rarely have that issue.
Also, sometimes arrays are faster than vectors (less overhead)
The following two criteria sets give me identical results using Lithium and MongoDB. Both are equally easy to read and write. Should I prefer one over the other for efficiency reasons, or is one just Lithium/MongoDB syntactic sugar for the other?
$criteria = array(
'fields' => array('_id'...
So, completely off topic, if i throw another network adaptor in my machine, can i use 2 ethernet connections to the interwebs? not at the same time of course but if one dies, enable the other etc?
@Timmy Yes, and with the right tools you can even load-balance stuff. Of course, how easy it is to setup depends on your OS and your networking knowledge
@EtiennedeMartel Not my point. I am saying in the past, for certain implementations, my array-based approach was more concise and faster in runtime compared to my vector one
@EtiennedeMartel Most people's "proof" is initializing an array where each data holds it's own index. A array can do that much faster than a vector, in every implementation I've ever seen.
@EtiennedeMartel The only thing I've been messing with is parallellised construction, but that's a real PITA to get right (virtually impossible generic due to exceptions).
@AgainstASicilian I'd really like to see some proof for that, I don't think vectors have more overhead then some counters, which are O(1) in terms of storage. And the reallocation issues you can solve with a call to resize or reserve.
@KillianDS I can't show proof without spoiling solutions unfortunately, but problem 344 is a good example. My C++ implementation for that one using vectors is slower than my array-based solution (dynamic programming solution using memoized combinatorics)
@MooingDuck One? Really? I mean, I have no idea what the question was, but I bet it's not the one that made me drop out of the discussion a while ago. And only about an hour ago, @jalf asked why he should even bother. And now the robot.
@AgainstASicilian Documentation on how to use the GMP C++ classes is here: http://gmplib.org/manual/C_002b_002b-Class-Interface.html#C_002b_002b-Class-Interface by the way
I've advertised my C++ skill as advanced and just realised it's been 10 months since I fired up VC2008 and 3 months since I used C++ without any standard libraries. I've an interview tomorrow.
@sbi I'm just trying to understand why my code wasn't working. I posted a question on SO and got some answers. For some reason, people here keep hammering on it?
@MooingDuck Apologies, what im interested in is what sort of techniques should i be using for the program to be less C-style, more C++ ...Im thinking lots of objects and little pointers
@AgainstASicilian If you ask the same question over and over, you are bound to get the same answer. — At least as long as the other side is patient enough.
@Timmy He already did exactly that the other day, after pissing everybody off by using the username "Feeds", and the real Feeds user's avatar — according to him accidentally.
@MooingDuck Well yes the problem is still there; it needs to be adjusted to work with long longs. I'm not confused about that, nor am I confused about using mpz_class vs. mpz_t. Again, I don't know why people are drudging this up over and over.