« first day (498 days earlier)      last day (2338 days later) » 

12:04 AM
Is it possible to use Visual Studio libraries with MinGW?
 
12:32 AM
@MarfGamer If memory serves, it uses (at least part of) the VS library by default. Not sure it could process VS headers though, so trying to use (for example) VS' standard containers would probably be a lot more difficult (if even possible).
 
 
1 hour later…
1:49 AM
Does an iterator of an unordered_map ( which is not getting new insertions or deletes) provide the same order each time , provided that we modify just the second part of the map (first stays intact)
 
@AnnaK. Yes - provided you do not trigger a rehash any other way (e.g. by changing the load factor)
I'm not sure it's standard mandated, though. But you can bet a few pies that all implementations have deterministic iteration order
 
@sehe Load factor you mean if the iterator is called with reference , const , etc?
 
2:03 AM
 
@sehe Says number of elements , so size of elements is irrelevant? e.g. I modify the second of each element in the map so that each second element has (let's say) triple the size than before
 
@AnnaK. It's a hash table. Changing load factor may change number of buckets, which determines the implicit iterator order.
@AnnaK. Size of the mapped value is irrelevant in all cases. (It's a node based allocator and nodes are dynamically allocated. They don't get moved about even there's a rehash)
 
@sehe ok, only key (first) counts towards the load factor, not the second
 
Number of keys, that is
 
In case we have mulitple keys you mean , right?
 
2:12 AM
If you have only 1 key, why use a map :)
5
A: Does an iterator iterate through boost::unordered_set or boost::unordered_map in the same order as long as the set's unchanged?

Mark RansomSome implementations of a hash map will reorder the items that hash to the same bin, putting the most recently accessed item at the front of a list, as an optimization. This would change the order. I'm not aware that boost::unordered_map does this, but in the future you might end up substituting ...

That's a caveat
3
Q: Is the order of two same unordered_maps the same?

pmsIn other words, if I fill two unordered_map, or unordered_set, objects with exactly the same content and the same hashing function, will iterating over them give the same sequence of key/value pairs? If so, then what are the conditions for this to hold (e.g. same hashing function, same keys, not...

That's another.
@AnnaK. Really you have to wonder why you are interested in the order of an unordered map
 
It helps me hash and search with name value (string), but at this point of my program , ordering matters
i can't assign value A to key 1 then value B to key 2 one time and then the opposite, from now on each time i wan't to have an ordered access , I'm making a vector with the keys so order is 1000% guaranteed to stay the same
 
2:43 AM
That sounds like a better plan.
 
3:01 AM
@JerryCoffin Just saw this. I kind of understand the first situation, but what did you mean by "clear the mutex"? I took the first possibility as when the thread wakes up, a signal also occurs, and so the signal is taken care of before the wait() is run, and the thread goes back to wait()'ing, possibly forever because of that signal vs. wakeup contention
 
 
2 hours later…
4:52 AM
TL;DR: even if spurious wakes never existed, you'd still need to write all the code that makes spurious wakes a non-issue as a side effect
 
 
7 hours later…
12:00 PM
hi guys
question: can double value be assigned in one step? (see Asm MOVSD command)
and is it important to consider two-step assigning in concurrent programming?
 
1 message moved from Lounge<C++>
 
@Kiramm going by spec: any assignment that is not atomic must be considered multipart
 
@Kiramm Define what you mean by one step.
 
@wilx I'm assuming atomic assignment (though without the memory acquire/release semantics)
 
@wilx Yes, I mean that this assignment is atomic - it can't be interrupted in some kind of middle state.
 
nwp
12:05 PM
It can't be interrupted if you are on a sane platform, but it is still a bug and will break your program in interesting ways.
Even writing a single byte will break your program if you have a race condition.
 
Basically, if you have concurrent threads accessing same memory then you have to use either locks or atomic access methods.
 
and the compiler is allowed to make all kinds of changes based on the assignment not being atomic, including first writing garbage to that memory location
For example a compiler whose optimizer is set to assume that a memset + patch is faster than a memcpy for certain patterns of data. Which can be expressed when clearing structs to default values.
 
 
3 hours later…
3:20 PM
the code : throw std::runtime_error("error") will output the message "error". Should i use the std::cerr for this? arent they both for the same purpous? to output errors?
 
nwp
throw std::runtime_error("error"); throws an exception, it doesn't output anything.
Maybe your debugger or OS or some code catching the exception print that error message, but the exception throwing itself doesn't.
 
@nwp so if i do a throw std::runtime_error("error") and then i do a catch(error) {} ,will it enter the catch?
 
nwp
You need something like try { throw std::runtime_error("error"); } catch(std::runtime_error &e) { std::err << e.what() << '\n'; }.
The throw part can be inside a function that is being called, it doesn't need to be directly inside the try block.
You can put the try around the main function block so it catches all the std::runtime_errors that were thrown basically anywhere and have not already been caught.
 
@nwp so that code will output "error" , since it was the error i throwed, correct?
 
nwp
Correct, but only because of the std::cerr << e.what(); which I misspelled above. If you leave that out nothing will be printed.
 
3:28 PM
ohh ok i get it, thanks!
 
3:57 PM
Hello.
 
Oct 21 at 18:04, by milleniumbug
http://www.nohello.com/
 
Is there some minimal working example how to use outf on a single .cpp file, but using outf inside main function and also inside another user defined function?
 
what is "outf"
 
@milleniumbug to use as outf << to print on a file
 
you pass the file stream to another function through arguments
that function will accept a std::ostream& then
 
4:02 PM
as a reference
 
@milleniumbug I read about this, but I don't know how to pass it. Should I put std::ostream& as argument on my function?
 
as a parameter type, yes
 
This is my function:
void compute_pairs(std::vector<diameter_index_t>& columns_to_reduce, hash_map<index_t, index_t>& pivot_column_index,
index_t dim, index_t n, value_t threshold, coefficient_t modulus,
const std::vector<coefficient_t>& multiplicative_inverse, const DistanceMatrix& dist,
const ComparatorCofaces& comp, const Comparator& comp_prev,
const binomial_coeff_table& binomial_coeff) {
 
sounds more like you should return the result and print in a loop
 
and then, to call the function, what I use as argument?
 
4:05 PM
outf, what else
also: what ratchet freak said
 
@ratchetfreak I wish to print thousands of numbers from a loop.
Then, in main and/or in user function, should I use outf or std::outf ?
 
how have you declared outf
 
I am using ofstream outf("Output.dat"); in main
 
there you go then
 
Is it right?
 
4:11 PM
it's not in a namespace, then don't add one
 
@milleniumbug OK.
 
would you write "int x = 42; f(std::x);"? no? well then
 
Let me try. Thanks for a while.
I got some errors: the 1st one is:
error: ‘outf’ was not declared in this scope
from user function
 
how is a parameter named
 
Also, form main:
error: ‘ofstream’ was not declared in this scope
 
4:18 PM
have you included the necessary headers
 
I wrote
void compute_pairs(std::vector<diameter_index_t>& columns_to_reduce, hash_map<index_t, index_t>& pivot_column_index,
index_t dim, index_t n, value_t threshold, coefficient_t modulus,
const std::vector<coefficient_t>& multiplicative_inverse, const DistanceMatrix& dist,
const ComparatorCofaces& comp, const Comparator& comp_prev,
const binomial_coeff_table& binomial_coeff, std::ostream&) {
 
show some more code, you can use coliru.stacked-crooked.com to create a compilable example
 
I use
#include <fstream>
#include <iostream>
#include <sstream>
and others
 
4258
Q: The Definitive C++ Book Guide and List

grepsedawkThis question attempts to collect the few pearls among the dozens of bad C++ books that are published every year. Unlike many other programming languages, which are often picked up on the go from tutorials found on the Internet, few are able to quickly pick up C++ without studying a well-written...

 
4:20 PM
))
 
@ratchetfreak the program contains a single .cpp. I'll put there.
 
@Sigur it may pollute this conversation
 
put it on coliru
and then post a link here
 
Yes. Great.
http://coliru.stacked-crooked.com/a/5ce5820717c02233
@Kiramm I put there, not here.... lol thanks
 
it's std::ofstream
 
4:24 PM
@Sigur oh, sry, misread
 
@milleniumbug there could be some garbage code. I'm trying to print on file for one week ago.
 
@Sigur you definitely should divide it into files to make it more readable
 
not yet, for now, make it compile first
 
@Kiramm I agree, but as you can notice, I have no experience. I only need to edit some few lines. Sorry for my very pour knowledge.
More precisely, some lines printing on screen some intervals (which contains ' [ ' ) I want to print on file. Let me find the line numbers
 
you need to name the parameter to be able to use it
 
4:28 PM
line 651
dim diameter -1
should go to the dat file
line 665:
dim birth death
should go to the same dat file, append it.
 
in the param list change std::ostream& to std::ostream& outf
 
OK, Done! Now the next error is in main
‘ofstream’ was not declared in this scope
ofstream outf("Output.dat");
 
8 mins ago, by milleniumbug
it's std::ofstream
 
so, should I use
std::ofstream outf("Output.dat");
in main function? Let me try
So, some good news. Now the program compiles. No error on my terminal. But some error when I run the program.
 
time to learn debugging
 
4:37 PM
which error?
 
@ratchetfreak To run the program, I need some point cloud file. If you can, please, try to compile and run to compare. I'll send a link to file.
@Kiramm segmentation fault
 
time to learn valgrind
in Lounge<C++>, Mar 22 '16 at 20:12, by milleniumbug
@sehe I run process in valgrind with valgrind --vgdb=yes --vgdb-error=0 ./my_program and then I follow the instructions (as in, running gdb ./my_program and paste in target remote | /usr/lib64/valgrind/../../bin/vgdb --pid=PID)
 
Here is the input file pts.point_cloud
c++ -std=c++11 ripser.cpp -o ripser -Ofast -D NDEBUG
./ripser --format point-cloud --dim 2 pts.point_cloud
to compile and to run, I am doing as above.
Guys, sorry for garbage code. I commented all lines containing fopen and fclose and now the program compiles and run as expected. all outputs on screen are the same in the dat file.
I'm very happy for all who helped me.
I never heard about it. Thanks. I tried now.
==30086==
==30086== HEAP SUMMARY:
==30086== in use at exit: 72,704 bytes in 1 blocks
==30086== total heap usage: 8,918,903 allocs, 8,918,902 frees, 545,082,611 bytes allocated
==30086==
==30086== LEAK SUMMARY:
==30086== definitely lost: 0 bytes in 0 blocks
==30086== indirectly lost: 0 bytes in 0 blocks
==30086== possibly lost: 0 bytes in 0 blocks
==30086== still reachable: 72,704 bytes in 1 blocks
==30086== suppressed: 0 bytes in 0 blocks
 
it's ok
 
@milleniumbug Very nice. Thanks so much. Now I can continue my work. Best wishes.
 
5:12 PM
is std::pair only for C++ or does C also has that function option?
 
nwp
It's for C++ only. In C the best you can do is create a struct for each type combination.
 
@nwp ah ok, thanks
 
nwp
Actually that's what C++ does too, it's just that you don't need to type it.
 
ohhh ok makes sence
 

« first day (498 days earlier)      last day (2338 days later) »