LeastSquaresWonderer

1

votes
2

answer
57

views

Configure ssh config file for certain command

My problem is the following. I wish to configure the .ssh/config as such, that when I write ssh exampleX It is the same as if I wrote ssh -i /path/to/key.pem [email protected] Note that the above command works. Following the answers here I tried to create the file as Host exampleX HostName address User u...
LeastSquaresWonderer
1

votes
0

answer
536

views

How to scroll with mouse in tmux (not history, but terminal output)

This seemingly simple question, is one I cannot find an answer to. The solutions suggesting adding setw -g mouse on into the config, do not work. Yes, the mouse works, but on history. Not on the shell output. I cannot understand the logic behind this... why is this the default? Lets say I issue an l...
1

votes
1

answer
48

views

Avoid <> with default template class/struct in C++

Suppose template struct S{ T x; a(T xx){x=xx;} }; and that we wish to ease the most common use by more than just a default specialization wishing to omit the empty angle brackets. One could reach for typedef typedef S defaut_S; default_S(1); but here the consistency is broken in a way, as default_S...
1

votes
2

answer
0

views

Array of indexes for each element alongs the first dimension in a 2D array (numpy., tensorflow)

indexes = np.array([[0,1,3],[1,2,4 ]]) data = np.random.rand(2,5) Now, i would like an array of shape (2,3), where result[0] = data[0,indexes[0]] result[1] = data[1,indexes[1]] What would be the proper way to achieve this? A numpy way that yould generalize to bigger arrays (perhaps even higher dime...
LeastSquaresWonderer
1

votes
1

answer
245

views

c++ -> template meta programming vs template functions

I am learning C++ template meta-programming. I want to know the difference between the following constructs. Suppose the classic example of the factorial. Example 1 template struct factorial { enum { fac = n*factorial::fac }; }; factorial ex; (where we omit the termination conditions for brevity.)...
LeastSquaresWonderer
2

votes
1

answer
108

views

Why the difference in the flow of universal reference and rvalue reference

Working from the Efficient Modern C++, Item 25. we have an example Case 1 class Widget { public: template void setName(T&& newName) { name = std::forward(newName); } ... }; Case 2 class Widget { public: void setName(const std::string& newName) { name = newName; } void setName(std::string&& newName)...
LeastSquaresWonderer
2

votes
3

answer
79

views

How to properly announce/perform an update of GitHub repo

Suppose there is a repository named Repo, and there have been some forks made from other people. Suppose Repo is some library or an API. As people use the library/API, the owner continues development and in some time has added features and improved on the existing ones. What is the proper procedure...
LeastSquaresWonderer
2

votes
4

answer
71

views

Calling subclass (virtual) function (late binding), when not dealing with pointers

Looking at the answer Why do we need virtual functions in C++, they show that virtual functions allow late binding, which results in being able to call subclass functions, when being downcasted. For completness, I include the code in question. class Animal { public: virtual void eat() { std::cout
LeastSquaresWonderer
8

votes
2

answer
134

views

Returning a member from an rvalue object

Lets take two structs/classes struct C1{ C1(){}; C1(C1&){std::cout
LeastSquaresWonderer
1

votes
1

answer
36

views

Why does constructor work with wrong parameters?

I have a constructor T(someClass o); The class someClass is initialized by double* x. That is someClass(double * X); Why does the following work? double * X=new X[10]; T obj(X); Why does this work, even though that there is no constructor for T, that takes double * as an argument (it should get an i...
LeastSquaresWonderer
3

votes
1

answer
105

views

Behavior of std::map iterators and insertions

As a simple start Map map1=//filled up in some way; Map map2; map2.insert(map1.begin(),map1.end()); We know that map::insert is O(log(n)), with no hint provided. Does this mean that the above runs in O(nlog(n)), or does it use the fact that map1 is already sorted and simply inserts at correct positi...