« first day (491 days earlier)      last day (4448 days later) » 

5:00 PM
or directory_filename.obj or something
 
Would anyone happen to know of a way to check if a file exists or not without using the windows or linux system dependent libs or opening the file for reading !
 
user784668
Does anyone know a good monospaced font that does not look like U+1F4A9 under Linux?
 
user784668
@angryInsomniac What do you need that for?
 
@Fanael You made yourself high now, didn't you? Bravo for you and your moment of self divine.
 
@angryInsomniac No, of course not.
 
5:02 PM
@angryInsomniac huh? Impossible, file access depends on the OS
 
there is no way to perform any file operation without asking the operating system
 
You'd need glibc or kernel32.lib or something.
 
@Fanael Huffman encoder that I'm making , I dont really want to make it system dependent , but figured there has to be a better way than opening the file for reading !
 
@angryInsomniac there are of course cross platform ways to do this
 
user784668
@DzekTrek I've never touched this shit. I don't know why you're thinking I'm high.
 
5:03 PM
I happen to have one lying around using stat
 
@DeadMG That's off topic. Just because the OS is used in some way doesn't mean you do it against the OS API.
 
user784668
@angryInsomniac Checking for existence will then cause a race condition, is that what you want?
 
@Fanael How so ?
 
@Fanael Don't act like a you don't know what I am talking about here, 'cause it is clear to all of us. How low can you go?
 
@LucDanton It does, however, mean that it is impossible to use libraries which are not dependent on the OS API
 
5:04 PM
@angryInsomniac Assuming C++, Boost.Filesystem is one such portable library to accomplish what you want do.
 
user784668
@angryInsomniac You check if file exists, it does. Someone removes it. Now you try to open it, thinking it exists => boom.
 
@DzekTrek Wait, what?
 
@LucDanton Hmm , shall look into Boost.Filesystem , thanks
 
assumes input is UTF8
 
1 message moved to bin
pastebin for code blocks please
 
5:06 PM
@DeadMG gotcha
 
@DeadMG lol it was pastebin (gist)
 
So we can't post ideone links, but github, which inevitably will be hosting an entire source file, gets oneboxed??
 
@Fanael The program runs for less than 5 seconds in most cases and its not a production level software, just an assignment , so I think I can ignore that case
 
@DzekTrek Woa, woa, woa, don't get so angry about it.
 
@DzekTrek I'd expect anything someone does is based on some thinking of their own. By definition.
 
5:06 PM
@Potatoswatter Why can't you post ideone links?
I see them in here all the time
 
@angryInsomniac pastebin.com/mMtXsG8V
 
@rubenvb Thanks @rubenvb , I'll check the code out !
 
@LucDanton Yes, but that doesn't give him a right to conclude dirty actions against someone else.
 
user784668
@angryInsomniac Better not to ignore it.
 
@EtiennedeMartel well some people do.
 
5:07 PM
^ Not oneboxed
 
that's why you can post them
 
lol
 
so that we don't get Wall'O'Texted every time you want to post code
 
someone fails to see the point :P
 
user784668
@EtiennedeMartel Do you understand what he's up to?
 
5:08 PM
@Fanael Yup , better not to :) But , tradeoffs , that's probably not as important in this context !
 
@Fanael I have no fucking idea what's happening.
 
ideone = small snippets. github = huge sources. Which one should get oneboxed?
 
@Potatoswatter Ideone, of course.
 
@Potatoswatter but Gist is like pastebin hosted on github, no "whole source files" meant to be posted on Gist really.
 
user784668
@Potatoswatter Neither.
 
5:08 PM
@Fanael I agree with neither
oh wait, that's confusing :)
 
user784668
@rubenvb Welcome to the wonderful world of ambiguities in English!
 
OK. It's out of my hands anyway. Will look at Gist when I'm not supposed to be going and doing stuff, as right now.
 
Tin
good afternoon guys! i hope you had a good weekend! i've been working in a function that given a range of two double numbers, it returns a random number in that interval. i'm not quite sure whether the generated numbers are equally spread. could you pls have a small look at the following code? pastebin.com/HAgGHvaF
 
By the way , has anyone implemented a Huffman encoder before ? I am trying to gauge weather mine is excessively slow , it takes 4-5 seconds for a 12 Mb file
 
Gists are oneboxed?
 
5:11 PM
@Tin C++11 has that prepackaged…
 
@Tin srand should be called only once per process. So put it in the main. Also, rand is not a good choice for a uniform distribution.
 
@CatPlusPlus apparently.
 
rand sucks.
 
user784668
@CatPlusPlus Not if you want a sucky generator, because in this case it's quite good.
 
Tin
@EtiennedeMartel, thaht's why I use this static bool didSeeding; variable
@Potatoswatter, i didn't get that. is there a c++11 function for that?
 
user784668
5:12 PM
@EtiennedeMartel Depending on the C library, it may be "once per thread".
 
Where are those homophone cartoons anyways? (for stuff like its <->it's and their, they're there etcetera)?
 
@Tin You're using an int as the initial random number. It's likely to have just 32 bits of randomness, whereas double needs 53 (if memory serves).
 
Tin
@CatPlusPlus, what do you usually use instead of rand?
 
@Tin std::mersenne_twister!
 
std::uniform_int_distribution<int> d(1, 6); std::linear_congruential_engine rnd; int random_number = d(rnd);
 
5:13 PM
nooo, not the lce random number generator. It sucks!
 
Or whatever.
 
sheesh
 
rand48 is nice.
 
You guys are still just posting integral generators. Hold on…
 
man
 
Tin
5:14 PM
@rubenvb, thanks for the link!
 
I went and designed my nice windows/rendering API and now it turns out I might jut have to re-work the whole thing
 
It's more lightweight than MT if you don't need that large a period.
 
@CatPlusPlus I compared libstdc++'s mersenne twister to msvcrt's rand. It was only a ~20% performance difference...
 
user784668
MT19937 sucks. It's enormous, and 624 is not a power of 2.
 
user784668
@rubenvb That's because rand is thread-safe.
 
5:15 PM
I'm not talking about performance, though rand48 is usually bit faster than MT.
 
std::uniform_real_distribution. Then you pass it a generator such as mersenne_twister at generation time.
 
Oh, he wanted real distribution? Didn't notice.
 
Tin
@CatPlusPlus, yes a real distribution
 
not a fake one
obviously
 
I thought that was the core of the question… so many pitfalls with floating arithmetic.
 
5:16 PM
I usually use uniform01 or uniform_int.
But whatever, the point is it's already implemented in standard library, or Boost.
 
user784668
@rubenvb Try comparing libstdc++'s mersenne twister to libstdc++'s linear congruential.
 
@Fanael yeah, could've done that too, I'm guessing my first comparison sucked ass :P
 
user784668
Ohfuck?
 
user784668
mersenne_twister_engine has 14 (fourteen) template parameters?
 
Tin
@Potatoswatter, do you mind in giving an illustration? (using both std::uniform_real_distribution and mersenne_twister)
 
5:19 PM
@Fanael MT19937 is specialisation of that. There are different sets of starting parameters.
 
@rubenvb Hey , I just looked at your code, what are the include files and namespaces used for "convert_to_utf16" ?
 
user784668
@CatPlusPlus Yeah, I know. But 14 is hell of a lot of parameters.
 
@angryInsomniac oh, hold on, let me dig that up (it uses the Win32 API for that)
 
@Fanael And now you're making me wonder what's the most template parameters I have in my code.
 
@Fanael Well, you don't use it directly, so.
 
Tin
5:21 PM
 
user784668
typedef mersenne_twister_engine<
    uint_fast32_t,
    32, 624, 397, 31,
    0x9908b0dfUL, 11,
    0xffffffffUL, 7,
    0x9d2c5680UL, 15,
    0xefc60000UL, 18, 1812433253UL> mt19937;
 
Mersenne Twister is the shit.
 
Multiline markdown fail! Again!
 
Tin
more specifically, in the loop, why does std::uniform_real_distribution<> dis(1, 2); is not called there
 
std::uniform_real_distribution<> distro( low_bound, high_bound );
std::mt19937 engine;
while ( need_randomness ) {
    std::cout << distro( engine );
}
 
Tin
5:21 PM
but dis(gen)
 
@angryInsomniac Here is the implementation: github.com/rubenvb/Ambrosia/blob/master/libAmbrosia/Source/…
 
user784668
@EtiennedeMartel No, MT19937 is the shit.
 
@Tin You construct distribution object once, and then use its operator() to get random number out of a generator.
 
@Tin dis takes gen and calls it internally.
 
@Tin a distribution is a stateless adaptor object. You only need one
 
Tin
5:23 PM
ok, a now assume that my interval changes each time a function gets called
 
@rubenvb Thanks , I'll check that out
 
@Tin Then you can construct the object as a temporary…
 
@angryInsomniac there's also directory scans and time_t conversions in there. In the same folder, in unix.cpp, there's the Linux implementation (of course not for the UTF conversions, which I deemed unnecessary).
 
std::mt19937 engine;
while ( need_randomness ) {
    std::cout << std::uniform_real_distribution<>( low_bound, high_bound )
                   ( engine ); // call temporary functor once and destroy it
}
 
user784668
@CatPlusPlus Unless I do, because I want a MT with different params.
 
5:24 PM
You need one uniform_real_distribution per interval.
@Fanael Well, then you're in crazy land.
 
@rubenvb :) My system does not need to be anywhere near that comprehensive
 
Well, I'm proud of that code. It represents my first fight with OS APIs.
At the end of the windows.cpp is also a workaround to open fstreams with UTF16 filenames for libstdc++.
 
@rubenvb :D Nice ! btw , what is the library for ? Ambrosia ?
 
MSVC++ provides wstring overloads
 
I do reach 9 template parameters but three of those are 'dummy' parameters to disambiguate definitions, so I don't think it counts.
 
5:27 PM
@angryInsomniac it is the beginnings of a build system (check out the half-finished wiki). It's far from complete though and I've shifted to writing something with LLVM, so Ambrosia is kind of cold now.
 
I do have a specialization with 8 parameters.
 
@rubenvb "It hopefully never will be finished" ? :P
 
Tin
@Potatoswatter, here's an example on how do I need to use the random numbers pastebin.com/pXcsm4UZ
 
If I have a vector<int> $a=(a_0, a_1,\dots, a_n)$ and want $b = (a_0+1, a_1+1,\dots, a_n+1)$, is there some nice way of expressing this using initialization lists, or do I need to loop the loop?
 
@angryInsomniac uh, "hopefully" sounds kind of morbid, no? Or do you mean continued development :P?
 
5:28 PM
LaTeX doesn't work here.
 
Tin
@Potatoswatter, more specifically line 25
 
Damn, I hoped this thing would support LaTeX notation.
 
Well, TeX, but let's not get pedantic.
 
@angryInsomniac oh crap, I see it now.
 
@rubenvb Hoping for something to never be done ? :)
 
5:29 PM
@Tin Yeah, I got lost somewhere around Bag End.
 
@FaheemMitha What are a_0 and friends? Values?
 
@angryInsomniac I wonder what I meant when I wrote that.
 
@FaheemMitha Why $a? That's a terrible name.
 
@LucDanton : Yes. Just elements of the vector.
 
C++ identifiers don't need or require $ and probably benefit from not having it
 
5:30 PM
@DeadMG it's php
 
@DeadMG It's TeX math notation. It's called a, not $a.
 
perhaps "continued development" and "new features" and all that.
 
@rubenvb We tend to get preachy when we start stuff :)
 
$$ are delimiters.
 
oh
 
5:30 PM
@DeadMG No, $'s are for a local LaTeX math environment.
 
@rubenvb I'm pretty sure it was more personal than that !
 
@Abyx With vector<int>?
 
@FaheemMitha there is std::transform (or boost::transform)
 
It's std::vector<int> as = { a0, a1, ..., an };
 
Let me try again.
 
5:30 PM
@FaheemMitha std::vector<int> b(a.begin() + 1, a.begin() + n + 1); then?
 
@DeadMG clever question - clever answer
 
If you already have b then b.assign(a.begin() + 1, a.begin() + n + 1); I think.
 
It looks like std::transform(as.begin(), as.end(), bs.begin(), [](int a) { return a + 1; }); to me.
 
damn
 
For those interested, "Hello world" in my toy language:
entry
{
  std::io::print "Hello world!"
}
 
5:31 PM
I am an official moron
 
@Tin: Ah, none of the identifiers in line 25 appear anywhere else. So all that other code provides no context.
 
:: sucks as a scope operator.
 
@CatPlusPlus have an alternative?
 
@rubenvb Slash!
 
5:32 PM
@CatPlusPlus std::back_inserter(bs), with fresh bs!
 
@Potatoswatter Lol.
 
dot is fine
 
@LucDanton Details.
 
I'm also planning on user-defined operators (to an extent)
what about class member functions?
also dot?
 
Imperative languages are boring.
 
5:33 PM
yes
 
Tin
@Potatoswatter, I created a new post, sorry, I just wanted to copy the relevant part of the code, so I forgot some variables, here it's: pastebin.com/dhavUykG
 
@CatPlusPlus Not going boom due to bs not having the right size is a detail? :(
 
Tin
@Potatoswatter and it's the call to curThreshold = randomDouble(treshmin, treshmax);
 
that's so Java-ish...
 
anyone familiar with simplex noise?
 
user784668
@rubenvb If you're a hipster, use !
 
@Tin Sorry, I really gotta go. Just use my example as a one liner.
 
@LucDanton It's C++. Suffer, dammit!
 
@rubenvb You're going to ditch a good idea just because Java had it?
if you dropped every good idea just because Java had it, you'd be out like, one or two good ideas.
 
@DeadMG lol sounds kind of wrong, yet not entirely despicable huh?
 
5:34 PM
So, no classes, C-derived syntax, references, primitive types.
 
@CatPlusPlus I'm having the time of my life with C++! Just reimplemented Boost.Variant, but mine is better(ish)!
 
Tin
@Potatoswatter, ok, bue one short question, where shall I place the std::mt19937 engine;
 
Because Java has them.
Makes perfect sense.
 
@CatPlusPlus does Java have references?
 
Makes sense.
 
5:35 PM
@rubenvb Not references as we know them. It has pointers.
 
I thought everything was "pass-by-JIT-fu"
 
user784668
@LucDanton What makes your variant better?
 
All boxed values are accessed via references.
 
@sbi Oh, for fuck's sake. I stubled upon a workaround already. I turns out that Acroread will happily churn out 20 copies of 28 pages in duplex.... IFF...
 
Object x; is a reference.
 
5:35 PM
... IFF... you disable collation :)
 
So dots are the shit these days huh?
 
Tin
since, this function doSomething() is going to be called many times and inside of it, I call the uniform_real_distribution function, does the std::mt19937 engine; should come elsewhere? or would it be fine to place it inside doSomething() as well?
 
TRWTF is Acroread.
 
@Fanael Visitation is less painful as I don't require the StaticVisitor silliness. So visit(variant, make_overload(arg1 + foo, arg1)); just works for instance.
 
@sbi I guess we'll have something to sort out (quite literally). I'm only glad it still appears to have printed doublesided correctly (I didn't endup with both sides identical).
 
5:36 PM
that would impede the existence of class io in some use namespace though
 
@Tin It should be passed along to that function.
 
@LucDanton : Does that work? With n the length of the vector? Wouldn't a.begin() a.end() be more natural?
 
Otherwise you'd be creating and seeding new engine every time.
 
@FaheemMitha I'm not sure what the a_0 + 1 notation meant. If you wanted to add one to the elements of a, see Cat's suggestion.
 
Tin
@CatPlusPlus, so the engine, needs to be initialized only once, right?
 
5:38 PM
Typically, yes.
 
as in:
import std.io
class io { somefunctionthatisdeclaredinsomewayIhaven'tthoughtofyet() }
entry{
io.bla // <- which io am I talking about?
}
 
user784668
Does anyone know a good monospaced font that does not look like U+1F4A9 under Linux?
 
@Fanael Actually I don't know how well that example works exactly, I'll have to try it.
 
@Fanael Unicode is awesome
 
@rubenvb Error: ambiguity. Or try guessing by checking imported modules first, and local names next.
But guessing is bad.
 
5:39 PM
@CatPlusPlus that's ugly.
both ways
 
@rubenvb That's ambiguous, and there's little you can do about it.
 
user784668
@rubenvb Yeah, because it has shit.
 
the user has a responsibility not to do stupid shit
 
Leading to ambiguities is always ugly.
 
and it's not your job to protect them from themselves
 
5:39 PM
but that increases the number of reserved identifiers depending on context and stuff. That's just evil
 
Eh?
Namespacing has been invented for a reason.
Identifier already used? Put it in a new namespace.
 
but I want the using std::io kind of stuff to be actually usable
 
@LucDanton So transform, then?
 
if namespaces and classes are accessed in the same way, it introduces many ambiguities
 
@rubenvb It is usable.
 
5:41 PM
Only if you're silly.
 
@FaheemMitha Maybe? I still don't know what you want to do :)
 
Also, make namespace into objects and poof, it's the same thing.
 
I like python where is no namespaces
 
In Python modules are namespaces.
 
not to mention operator. overloading
 
5:42 PM
@LucDanton Take a vector<int>. Add 1 to every element in the vector.
 
Tin
@CatPlusPlus, thanks, how could i place everything together inside of a function so that I only need to initialize the engine only once? here's a pseudo-code: pastebin.com/CYWj19wp in the example, i was not sure where to properly define the engine varible
 
Return the result.
 
@FaheemMitha That's transform alright.
 
that could really really mess stuff up bad
 
@LucDanton Ok, thanks.
 
5:43 PM
@CatPlusPlus in C# (F#, etc) there are both modules and namespaces, they are different things
 
@Abyx And in Python, modules are namespaces.
 
Think of std::initializer_list as a kind of literal rather than a way to programatically construct objects.
 
Which are not different things.
 
@Fanael I meant to say "Unicode is da shit!"
 
@Tin double randomDouble2(std::mt19973& engine, double a, double b) { return std::uniform_real_distribution<>(a, b)(engine); }
 
5:43 PM
In python one could do this using list comprehensions. C++ needs list comprehensions.
 
It's not responsibility of that function to seed the generator.
 
@LucDanton an initializer list can replace std::make_pair etc...
 
More generically, replace std::mt19973 with template argument.
 
@FaheemMitha in python list is embedded type
 
@rubenvb No, that would be list initialization. std::pair doesn't have an std::initializer_list constructor.
 
5:44 PM
@Abyx What's an embedded type?
 
@FaheemMitha Funnily enough, I tried to make a list comprehension EDSL for C++ just for laughs.
 
@FaheemMitha Don't count on it.
 
@LucDanton huh? I can do mymap.insert({"bla", 4}); for std::map<std::string,int> mymap;. What's the difference?
 
@CatPlusPlus I wasn't. :-)
 
@rubenvb This is list initialization, i.e. syntax.
 
Tin
5:45 PM
@CatPlusPlus, thanks and then to use it, it should be something like this void doSomething(){ std::mt19973 engine; while(need_randomness){ std::cout<< randomDouble2(engine, a, n) << std::endl; } , right?
 
auto foo = { 1, 2, 3}; is an std::initializer_list<int> object.
 
@Tin Yes.
 
One is at the level of the language, the other at the level of the library (although there's one language rule involved in overload resolution, but it isn't used in our snippets so far).
 
@LucDanton fair enough, but that does not take away the fact an initializer list can be used in place of std::make_pair
 
Tin
@CatPlusPlus, do you mind in giving an illustration of your last suggestion? i,.e. replace std::mt19973 with template argument., how does the randomDouble2 function would look like and how could I call it in the doSomething function?
 
5:47 PM
It can construct objects
 
@rubenvb There's no such thing as 'an initializer list'. There's 'list initialization syntax' and there's std::initializer_list<T>. You can't use std::initializer_list<T> in place of std::make_pair.
 
template <typename Generator> double randomDouble2(Generator& engine, double a, double b) { return std::uniform_real_distribution<>(a, b)(engine); }
 
So again, I carefully crafted my original comment to refer to std::initializer_list<T> (which has its problems), not to list initialization syntax (which is super-neato).
 
for now, C++ language knows only about std::begin and std::end, for list comprehensions it would need to know about resize or push_back
 
Tin
@CatPlusPlus, and also, why does the engine is passed as reference and not as const reference? isn't the idea that it should be initialized only once?
 
5:48 PM
how come float is slower than double type?
 
@LucDanton oh you are crafty
 
@Tin Because it's impure. Using generator mutates its internal state.
You can't use const generator.
 
without a state, how would it know which random number to generate next?
 
@LucDanton : But I want a way to programatically construct objects. :-)
 
You can have pure stateful generator.
 
5:50 PM
@FaheemMitha Give me time to get back to my list-comp EDSL :p
Disclaimer: it will be very silly.
 
nextRandom :: Generator -> (a, Generator)
 
Tin
@CatPlusPlus, ok, thanks! and also for the templated version of randomDouble2 and what if I then would like to use it inside, the void doSomething() function?
 
@Tin The same way. Argument will be deduced.
 
Tin
@CatPlusPlus, great! thanks a lot. I'll test it right away
 
@rubenvb I.e. return a generator with new state instead of mutating in-place.
Of course it's easier to just make it mutable in C++.
 
5:52 PM
@Rookie Why do you say that?
 
@FredOverflow i tested simplex noise generator with float and double types, double took 9.2 seconds, float took 10.8 seconds
 
Onoes.
 
Did you test in Debug or Release mode?
 
Incredible.
 
@FredOverflow release
 
5:53 PM
Inconceivable.
 
@Rookie Well, since your FPU calculates with doubles internally, anyway, maybe using double from the get go is faster than constantly converting between the two.
But, a huuuge array of floats is probably faster than a huuuge array of doubles (memory bottleneck and stuff).
 
@FredOverflow i converted everything to use floats, so it didnt use any float functions etc... i think, i used (float)1.0 everywhere
 
So? Your FPU probably uses doubles internally, or do you have a 32 bit FPU?
 
I don't know, what is with people and silly benchmarks.
 
In fact, x87 uses 80 bits internally if I'm not mistaken?
 
5:55 PM
i dont know how my cpu works, i tihnk its 64bit
 
Well, what CPU you got?
 
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz x86 Family 6 Model 15 Stepping 11
 
Then you've got an x86 FPU alright. There is no reason why it would be faster on floats.
 
oh, cool
 
user784668
@FredOverflow Depends on its control word.
 
5:57 PM
Unless you're processing millions of floats, then memory becomes the bottle neck.
 
Yeah, you can switch it into 32 or 64-bit mode.
 
@Fanael Right, one of those dark corners I seldomly visit :)
 
But who cares, nobody uses FPU when there's SSE available.
 
user784668
@CatPlusPlus Exactly!
 
But it's a bit harder to program SSE.
 
user784668
5:58 PM
@FredOverflow Not at all. Scalar operations are vastly easier.
 
I mean in a high-level language.
 
FPU is weird.
 
Tin
@CatPlusPlus, I called the randomDouble2 several times inside of a doSomething function, which is also in a loop, and the generated random numbers are always the same. here the code snippet: pastebin.com/ktkDMTdB
 
user784668
FPU registers form a stack, SSE registers are, well, normal registers.
 
x87 ist weird.
 
5:59 PM
i need to code differently to be able to use the powers of SSE? isnt it just one #define or osmething? :p
 
You don't program for the FPU, the compiler does that
lol
 
@Fanael Yes sure, but programming SSE in C++ is harder than programming with ordinary floats and doubles.
 
user784668
@FredOverflow How is double c = a + b; any harder than double c = a + b;?
 

« first day (491 days earlier)      last day (4448 days later) »