DEOptim keeps telling: NaN value of objective function
I've written a simulation program in C++ and like to find parameters in R, using DEoptim. Sometimes everything works well and sometimes DEoptim stops and tells:Error in DEoptim(simulate, lower = lb,...
View ArticleHow to split a std::string into a range (v3) of std::string_views?
I need to split a std::string at all spaces. The resulting range should however transform it's element to std::string_views. I'm struggling with the "element type" of the range. I guess, the type is...
View ArticleWould a template work for std::variant's visit?
Earlier I asked this question about std::variant. Considering that the types hold by the variant are all printable by std::cout, is there a simple way to implement a visitor?Here for example, all the...
View ArticleIs it possible to get the first type of a parameter pack in a one-liner?
I have a parameter pack given in a variadic class template and want to extract the first type.Currently I do this, which works fine but is somehow cumbersome. Is it possible to do the same thing...
View ArticleHow to convert a string of digits into a vector of digits?
I'm trying to store a string (or str) of digits, e.g. 12345 into a vector, such that the vector contains {1,2,3,4,5}.As I'm totally new to Rust, I'm having problems with the types (String, str, char,...
View ArticleConfusion about unit tests (googletest) and projects/folder/files
It's the first time I want to use unit tests in my c++ project. Hence I've many existing classes for which I will write tests (at least for some of them). Further, the application has of course a...
View ArticleHow can I mock object that is stored as a unique_ptr in gmock?
I inject a dependency in some class. This class stores the dependency with an std::unique_ptr and is therefore the only owner of the object.What is the right way to mock a method in this dependency? My...
View ArticleRegular expression for comma-separation except if the comma is within...
I need to separate a string like this:cat, dog , ant( elephant, lion(tiger)), birdinto this:catdogant( elephant, lion(tiger))birdMy current state is this: (\w+)(,\s*)*, but that also separates...
View ArticlePassing a class-member function to a global function as argument [duplicate]
I am trying to pass a member function of class A to a global function as parameter. What must I do to make this work? Also, is this a good idea? Context: I want to do this because (the synonym)...
View ArticleHow to generate a random String of alphanumeric chars?
The first part of the question is probably pretty common and there are enough code samples that explain how to generate a random string of alphanumerics. The piece of code I use is from here.use...
View ArticleWhat is `shuffle_order_engine` for?
I wanted to code a line that shuffles a vector. Auto completion suggested shuffle_order_engine, which made me curious what it is, since the name suggests it does what I want.Usually i shuffle a vector...
View ArticleWhy is the datatype of a column ` and not just `` after applying the identity...
I have a case where I need to apply a dynamically selected function onto a column of a tibble. In some cases, I don't want the values to change at all -- then I select the identity function I().After...
View ArticleCan I make a thread-safe std::atomic?
I'm having a function that needs to be executed n=1000 times. This functions does a Monte Carlo style simulation and returns an int as the result. I'd like to run nthreads=4 in parallel. Whenever a...
View ArticleHow to generate a massive amount of high quality Random Numbers?
I'm working on a random walk simulation of particles moving in a lattice. For that reason I must create a massive amount of random numbers, about 10^12 and above. Currently I'm using the possibilities...
View ArticleHow can I make `bquote` replace the greek letter stored in a variable with...
I want to label the axis on a plot dynamically. The labels come from a data frame and contain greek letters as well as super/sub scription.In a static case, where I would know the letters of my labels,...
View ArticleAnswer by dani for How to change facet labels?
I feel like I should add my answer to this because it took me quite long to make this work:This answer is for you if:you do not want to edit your original data if you need expressions (bquote) in your...
View ArticleWhat happens to a pointer that points to an element in a vector when I...
I have a std::vector<int> and a pointer int* that points to an element in the vector. Let’s say the pointer points to the third element: pointer=&vector.at(2). If I now shuffle the vector,...
View ArticleWeird behaviour of QToolTip when it should follow the mouse who is over a...
I've a QGraphicsView hows shows a QGraphicsScene which contains a QGraphicsItem. My Item implements the hoverMoveEvent(...) method that fires up a QToolTip.I want that the tool tip to follows the mouse...
View ArticleReturn type std::optional
I have a situation where a function must return a value taken from a table. A cell in this table (let's assume the table just works...) may contain a value, or it might not. This value can also be one...
View ArticleIs it possible to get rid of template specialisation to stop recursion?
I'm writing my own container class that also provides iterators. These iterators can be dereferenced and reveal then a sub-range of the original container, for which again an iterator can be obtained....
View Article