I have 2 std::vectors, one float, one integer: A and B.  A = [5,3,1,2]  B = [0.1, 0.2, 0.3, 0.4]  I want to sort A and maintain the same 1-1 in B. So the result should look like:  A = [1,2,3,5]  B = [0.3, 0.4, 0.2, 0.1]  I used python/js convention for convenience, but these are C++ std::vectors. I was considering just making a tuple struct and packing these into a std:vector of tuples, overloading the sort comparator. Is there more lazy way of doing this?
I have several std::vector, all of the same length. I want to sort one of these vectors, and apply the same transformation to all of the other vectors.  Is there a neat way of doing this? (preferably using the STL or Boost)?  Some of the vectors hold ints and some of them std::strings.  Pseudo code:  std::vector&lt;int&gt; Index = { 3, 1, 2 }; std::vector&lt;std::string&gt; Values = { "Third", "First", "Second" };  Transformation = sort(Index); Index is now { 1, 2, 3};  ... magic happens as Transformation is applied to Values ... Values are now { "First", "Second", "Third" };
Find probability using distribution function method Residue theorem with $\frac{1}{2\pi}\int_{0}^{2\pi}e^{\cos\theta}\cos(n\theta) d\theta$. The following integral should be doable using the residue theorum:     $$\frac1{2\pi}\int_{0}^{2\pi}e^{\cos\theta}\cos(n\theta) \,d\theta$$ On every boot up I get this:    For about 10 seconds (or more) before the "normal" Ubuntu Gnome loading screen and the login screen comes up.  I've read some questions and a bug report about this already, but this problem was dismissed as a minor inconvenience or there were no real solutions (that worked for me). For me, this problem leads to an unacceptable slow boot compared to Ubuntu (Unity) or Windows.  Does anybody know how to fix this or is this a "feature" of Ubuntu Gnome and not a bug? How to set tick label precision Let me know I have upvotes even after hitting the rep cap When you cap, you don't see any upvotes you get on your profile, therefore, you don't have any update on how your questions / answers are doing unless you look at them manually.   Capping the 200 daily rep is not a reason to stop posting here so could I get notified somehow that my posts are being voted on ? Maybe put a little +X in a different color letting me know that I got these votes but I won't get the reputation for it.   I can go and see in my reputation feed inside my profile and see it :    So I don't see why it wouldn't show up in the feed above.  Maybe putting the feed button green without any +X just like when you aquire a badge. LWC: Difference between "window" and "this" I am trying to understand what exactly is the difference between window and this in the context of a LWC component.  According to this  the Locker intercepts calls to the Window and uses Secured Window instead which acts as:     Secure wrapper for the window object, which represents a window containing a DOM document.   As for this what I  was:     To add an event listener to an element that a template doesn’t own,   call addEventListener directly: this.addEventListener()   What does salesforce mean by an element that a template doesn't own? Isn't window an element that the template doesn't own? Why are orbits elliptical? A Python module and package loading confusion Biblatex with Biber: Configuring my editor to avoid undefined citations Because of past conflicts, I don't believe my advisor will write me a good LOR for postdoc positions. What should I do? How essential is having my advisor's letter for post doc application?   I had a pretty bad relationship with my advisor for more than 4 years since I joined his lab and sometimes the relationship feels like slow inflammation that can easily flare up. We had very different opinion on how I want to approach my thesis and we argue very often on the experimental approach and the angle of attack. After that, he turned passive aggressive and completely hands-off. I noticed that he started slow to response to my email and given me very small amount time for meeting in comparison to other people in the lab. However, I proved to him that my approach was right and wrote the full paper myself and got published.   Recently, I got contact by a post doc employer who interested in my own work and request letter of recommendation. I asked my advisor for letter and he told me that I should write my own from which he can modify. I feel this is quite strange as he had wrote for all the other people in the lab, including a departing post doc who is currently interviewing for job. He told me he had done the same for other people but obviously he lied to me.   I further asked if he can provide me a copy of a completed version of the recommendation but he refused.   My question is should I still trust him to write my letter and is it essential? This post doc position is a great opportunity for me and either way I do is a big gamble.  Update: I decided to let my advisor wrote a letter for me and I think I may have made a big mistake. Since he wrote my letter, I asked the post doc lab head if my letter is completed and I no longer be able to hear back from him. Before that, he was quick to response to my email and showed great enthusiasm. As an insurance, I use one opportunity I have less desire to as bait to test the water and I still have one more shot at another position I really want.  Now, I'm thinking requesting open letter from advisor from now on for any future position or use letter service to check the letter.   Any suggestion? Thanks.  update: Great news! Got interviewed and offered at top ones! Thanks everyone! Determining functions from specifications... my high school teacher asked this question today, and I am struggling to find an answer that will work. The question is outlined below:  Give an example of a cubic polynomial, defined on the open interval (-3,3), which reaches both its maximum and minimum values. Me and my friend want to build a basic 101 mob farm, but we can't decide where to put it. He says it has got to be over an ocean, I say it can just be 128 blocks above ground and it will be just fine.  So the question is:    What is the absolute ideal place for a mob spawner?  If we build it 128 blocks above ground do we still need to light up caves? If we dig a 128x128 square straight to bedrock will that make a perfect environment?   Please advise! Validity of maximising log-likelihood for maximum likelihood estimation For reasons owing to mathematical convenience, when finding MLEs (maximum likelihood estimates), it is often the log-likelihood function---as opposed to the standard likelihood function---which is maximised.  From what I've gathered, this approach is deemed valid as a result of the monotonically increasing nature of the (natural) logarithm function.  My understanding of a monotonically increasing function is: for all $x$ and $y$ (defined on a subset of the reals), if $x \leq y$ then $f(x) \leq f(y)$.  This, however, does not appear to be the case for all log-likelihood functions; for example: for the log-likelihood $\text{Gamma}(3, 5)$ function, if $x = 0.15$ and $y = 0.46$, then $f(x) = -0.59$ and $f(y) = -1.19$.  Clearly, I've misunderstood this concept. Fundamentally, I guess I'm asking can somebody (preferably mathematically) demonstrate why:  $$ \hat{\theta} = \text{argmax} \text{ } L(\theta) = \text{argmax} \text{ } \text{log} \text{ } L(\theta) $$  where $\hat{\theta}$ is the MLE for a given likelihood function. Two-finger swipe 'breaks' heads-up notifications on Lollipop? I have a Nexus 7 (2013) and a Moto X (2014) running Lollipop. On both of these, if I get a heads-up notification (i.e., those that show up on top of the screen when the device is unlocked) and swipe down on it with 2 fingers, it 'breaks' further heads-up notifications:   I can't tap on them to open the responsible app For, e.g., an incoming phone call with 'answer' and 'dismiss' buttons, tapping the buttons does nothing. I can't answer phone calls anymore!   I can still swipe to the side to dismiss the notifications, and they still disappear on their own after a few seconds. I haven't been able to find a way to get the correct behavior back aside from a restart.  Yeah, the obvious workaround is to not two-finger swipe on them, but it's second nature as that same gesture expands notifications in other contexts.  I'm guessing the problem is generic, but I've triggered it on Hangouts and Phone notifications.  Do others experience the same thing? Any known 'fixes' aside from restarting? Grammatical number agreement in a complex phrase using singular "they" What are the advantages of 10-bit monitors? To support 10-bit color the following are needed:   A monitor supporting it. A GPU supporting it (only AMD FirePro and NVIDIA Quadro support this?). Compatible software. Unless I am mistaken there are very few programs out there supporting 10-bit color. Photoshop is a notable example.   The questions are about how 10-bit monitors perform in comparison with 8-bit monitors:   In which situations would a 10-bit monitor give a noticeable advantage over an 8-bit monitor (say, for professional photography)? Have 10-bit monitors been compared against 8-bit monitors based on subjective or objective tests? What were the results? Human eyes can see only 10m colors, so would using a monitor with 1b colors make a difference? How do I completly remove XP from my pc. I currently have a dual boot with XP and Windows 7. Since installing Windows 7, I have never used XP. Can I remove it without causing problems with Windows 7? Multiple citations: citation order different to bibliography order I wish to cite several sources at once and sort my in-text citations in a different manner to how they appear in my bibliography. I want my citations to be sorted by year and my bibliography to be sorted by author. I am using BibLaTeX with Biber. I used  to achieve this with TeX Live 2015 but since upgrading to 2016 (as well as upgrading all my packages) this does not work.  Below is a minimal working example (with a second bibliography for illustrative purposes). I wish for the citations to be sorted ascending by year (2001, 2002, 2003) and the bibliographies to be sorted alphabetically (a, b, c) and descending by year (2003, 2002, 2001) respectively, but below is an image of the result; the bibliographies stay true to the desired sorting but the citations in-text are sorted descending by year.  If I remove the last \newrefcontext then everything (citations and bibliographies) is sorted alphabetically, and if I remove both \newrefcontexts then everything is sorted ascending by year (which was the option specified when originally calling BibLaTeX). It seems that the citations follow the last sorting referenced; ynt as per BibLaTeX options when both \newrefcontexts are removed or else whatever sorting is specified in the last \newrefcontext.  I am compiling in order pdflatex, biber, pdflatex, pdflatex and am on MacTeX.  It seems this would have worked as desired in TeX Live 2015 so is this a bug or has something changed which requires the citation sorting to be set in some other way?  \documentclass{article}  \usepackage[            backend=biber,            style=authoryear,            sorting=ynt,            sortcites,            ]{biblatex}  \usepackage{filecontents} \begin{filecontents}{lib.bib} @article{test1,   author = {b},   title = {b},   year=2003, } @article{test2,   author = {c},   title = {c},   year=2001, } @article{test3,   author = {a},   title = {a},   year=2002, } \end{filecontents}  \addbibresource{lib.bib}  \begin{document}      Hello World! \parencite{test1,test2,test3}      \newrefcontext[sorting=nyt]     \printbibliography      \newrefcontext[sorting=ydnt]     \printbibliography  \end{document}     Edit  I have a workaround but it's super crap: Typeset the document with global sorting=ynt, copy the pdf to another file, then typeset the document with global sorting=nyt; using a PDF editing tool (Apple's Preview suffices) cut the pages containing the bibliography with the desired sorting from one PDF and paste into the other. As I said super crap. I'm not sure if I'd even do this as I'd feel dirty, but it's a workaround nonetheless.  If a solution does not exist or this is a bug without a patch, then what would be similar but much better would be some kind of package (which probably doesn't exist) which only changes certain pages at a time within the PDF (while still actually 'compiling' the whole document so that all the citations are done). It might look something like:  % document preamble % ...  \usepackage{onlychange} \onlychangerange{10,12}  % Bibliography found on pages 10--12 % On next compilation will typeset all pages except 10--12  % ...   It's a long shot but maybe someone knows of such a package or this rambling has inspired an actual solution. How can I block all ports except some? I am trying to use iptables but I am clueless in understanding the documentation even so that I've locked myself out of my server twice already whilst trying to implement it.  These are the simple rules that I want to implement:   Allow ports 80, 6667 and 6697 to everyone Allow port 22 to just my IP for example 10.10.10.10   Please can someone help me implement these simple rules, without locking myself out? Is there a word for colloquial forms of address? For example, "dude," "man," "buddy," "pal," etc, when used to stand in for someone's name.  "Hey, pal, how's it going?"  Is there a word for terms like these?  Or is "colloquialism" as close as we can get?