So I have to write my own method.  I did  the following:   vector&lt;float&gt; remove(vector&lt;float&gt;&amp; sortedVector, float input) {      for (vector&lt;float&gt;::iterator it = sortedVector.begin() ; it != sortedVector.end(); ++it)     {         if(input == *it)         {             sortedVector.erase(it);         }     }      return sortedVector; }   However compiler breaks at for loop. Where did I go wrong? I need to return the modified vector after the given value of the user is removed from the vector.
I want to clear a element from a vector using the erase method. But the problem here is that the element is not guaranteed to occur only once in the vector. It may be present multiple times and I need to clear all of them. My code is something like this:  void erase(std::vector&lt;int&gt;&amp; myNumbers_in, int number_in) {     std::vector&lt;int&gt;::iterator iter = myNumbers_in.begin();     std::vector&lt;int&gt;::iterator endIter = myNumbers_in.end();     for(; iter != endIter; ++iter)     {         if(*iter == number_in)         {             myNumbers_in.erase(iter);         }     } }  int main(int argc, char* argv[]) {     std::vector&lt;int&gt; myNmbers;     for(int i = 0; i &lt; 2; ++i)     {         myNmbers.push_back(i);         myNmbers.push_back(i);     }      erase(myNmbers, 1);      return 0; }   This code obviously crashes because I am changing the end of the vector while iterating through it. What is the best way to achieve this? I.e. is there any way to do this without iterating through the vector multiple times or creating one more copy of the vector?
Trouble downloading packages list due to a "Hash sum mismatch" error When I check for updates, I get a "Failed To Download Repository Information" error.   This is what comes up under details:   W: Failed to fetch gzip:/var/lib/apt/lists/partial/us.archive.ubuntu.com_ubuntu_dists_natty_main_source_Sources  Hash Sum mismatch,  E: Some index files failed to download. They have been ignored, or old ones used instead. Can I list the resources in a given package? How do I make my document use the Times font, both for the text and the math? I know that I can put \usepackage{times} in the preamble in order to use the Times font instead of Computer Modern for my document.  But this only affects the text; the math is still typeset using Computer Modern.  How can I make Latex use Times also for the math? series of young adult science fiction books from early 1980s about last of a race of martial experts that sees the destruction of his home planet Just curious whether the process takes a while, and whether it scrapes through history to determine if it was once valid or not. Currently, I have 6 0-vote accepted answers and 20 1+-vote answers (), and that makes it > 5 and > 20% but not for long if voting goes up or down from here. ;-P  Update:  Special thanks to Grace Note for pointing out the  to follow. I upgraded this to a bug because it's been 48 hours during which the criteria supposedly were met. 6 0-votes, 20-23 1+ votes during the whole period. The criteria only last so long, so it may go out of scope soon. If it only checks every 3 days, I'm not sure if that's intentional or a bug. How to get the current URL within a Django template? How can I vertically align elements in a div? How can I check dependency list for a deb package How can I check dependency list for a deb package. I am running Ubuntu 11.10 and I have backed up all deb packages from var/cache/apt/archives. I want to format my pc and re-install selected applications only. Also how can I get the list of installed packages and dependencies. How to trim whitespace from a Bash variable? I have a shell script with this code:  var=`hg st -R "$path"` if [ -n "$var" ]; then     echo $var fi   But the conditional code always executes, because hg st always prints at least one newline character.   Is there a simple way to strip whitespace from $var (like trim() in )?   or   Is there a standard way of dealing with this issue?   I could use  or , but I'd like to think there is a more elegant solution to this problem. How do I install Geforce GTX 660 in 13.10 Just bought a Geforce GTX 660 and replaced my Radeon HD 5870 (it finally died after 3 years). I'm having terrible problems getting the video card to work. As I only had command line options so far I've ran:  (purged fglrx*)  then  sudo add-apt-repository ppa:xorg-edgers/ppa sudo apt-get update sudo apt-get install nvidia-331  and then I started getting low graphics mode errors. did some searching on my tablet, and I tried several things but what finally worked better was:   sudo apt-get install bumblebee bumblebee-nvidia  However now that I'm logged into my computer finally, I have no access to terminal, no access to the top bar, and hitting Super Key does nothing, alt-f2 does nothing, and I only can post because I tried running WoW and it had an error and the error report opened a link.   All I can see on my desktop is my wallpaper and desktop icons. I can CTRL+ALT+F1, and navigate to the downloaded official nvidia driver, however that won't run because of x-server, and I can't run it from my desktop.   Can anyone help me? Geometric interpretation of Electromagnetism Why doesn't "its" have an apostrophe? I know that its is the possessive and it's is the contraction, and know when to use them.  But why doesn't the possessive have an apostrophe?   "The bear's eating a fish." [contraction] "The bear's coat is brown." [possessive] "It's eating a fish." [contraction] "Its coat is brown." [possessive] "One's eating a fish." [contraction] "One's coat is brown." [possessive]    lists the etymology as "From  +‎ ", and  says that this is actually the original form:     Originally written it's, and still deliberately spelled thus by some writers until early 1800s.   So what happened to the apostrophe?  When did people stop using it, and why did they?  It seems that it's as the possessive is more natural, as most people do this until they're taught that it is wrong (or even after).  Update: Online Etymology Dictionary has been updated to include two potential explanations:     The apostrophe came to be omitted, perhaps because it's already was established as a contraction of it is, or by general habit of omitting apostrophes in personal pronouns (hers, yours, theirs, etc.).   Can anyone back up either of these arguments?  The possessive one's still has the apostrophe, despite these. Adding user to a group - Why had to reboot? I was not able to access the VirtualBox shared folder, so I made the user part of the vboxsf group. But, still not able to access it. Rebooting the guest resolved the problem. Is it a bug? A reboot is not required to add a user to a group.   sudo usermod -a -G vboxsf praveensripati   There was similar query .  I am using 11.10 and don't remember seeing similar behavior in 11.04. Grandi's Series; tends to $1/2$, but why is this considered a valid sum? Grandi's series,  $$1+1-1+1-1+1-1+...$$  can be expressed as the below:  $$\sum_{n=0}^\infty(-1)^n$$  Two valid sums that make sense to me are $1$, and $0$, depending on how you approach the series. $(1+1)-(1+1)-(1+1)-...=0$, and $1+(1-1)+(1-1)+(1-1)+...=1$.  There is consensus, however, that the actual sum is $\frac{1}{2}$. Why? I understand the approach of finding partial means of the series, and they do indeed tend to $\frac{1}{2}$, but it seems unintuitive to assert that the sum is neither $1$ or $0$.  A more convincing method I found was assuming the series is $S$, then shifting it such that $S-1 = S$, then through algebra finding $S = \frac{1}{2}$, but again, it seems more intuitive answer is either $0$ or $1$. I say this strictly because adding and subtracting integers should equal an integer, never a fraction.  Is this a characteristic of infinite series, which is not specific to Grandi's series? Practically speaking, how do people handle ANOVA when the data doesn't quite meet assumptions? This isn't a strictly stats question--I can read all the textbooks about ANOVA assumptions--I'm trying to figure out how actual working analysts handle data that doesn't quite meet the assumptions. I've gone through a lot of questions on this site looking for answers and I keep finding posts about when not to use ANOVA (in an abstract, idealized mathematical context) or how to do some of the things I describe below in R. I'm really trying to figure out what decisions people actually make and why.   I'm running analysis on grouped data from trees (actual trees, not statistical trees) in four groups. I've got data for about 35 attributes for each tree and I'm going through each attribute to determine if the groups differ significantly on that attribute. However, in a couple of cases, the ANOVA assumptions are slightly violated because the variances aren't equal (according to a Levene's test, using alpha=.05).   As I see it, my options are to: 1. Power transform the data and see if it changes the Levene p-val. 2. Use a non-parametric test like a Wilcoxon (if so, which one?). 3. Do some kind of correction to the ANOVA result, like a Bonferroni (I'm not actually sure if something like this exists?). I've tried the first two options and gotten slightly different results--in some cases one approach is significant and the other is not. I'm afraid of falling into the p-value fishing trap, and I'm looking for advice that will help me justify which approach to use.  I've also read some things that suggest that heteroscedasticity isn't really that big of a problem for ANOVA unless the means and variances are correlated (i.e. they both increase together), so perhaps I can just ignore the Levene's result unless I see a pattern like that? If so, is there a test for this?  Finally, I should add that I'm doing this analysis for publication in a peer-reviewed journal, so whatever approach I settle on has to pass muster with reviewers. So, if anyone can provide links to similar, published examples that would be fantastic. How do I restrict my kids' computing time? Access to our computer (not only to the internet) needs to be restricted for the accounts of my kids (7, 8) until they are old enough to manage this by themselves. Until then we need to be able to define the following:   the hours of the day when computing is o.k. (e.g. 5 - 9 pm) the days of the week when computing is not o.k. (e.g. mondays to fridays) the amount of time allowed per day (e.g. 2 hours)   In 11.10 all of the following that used to do the job don't work any more:   : for > 11.10 no more available through the ppa. : command line alternative, but from 11.10 removed from the repositories. : Looks great but repeatedly crashes to force restarting X-server. So we can't use or recommed this program at the moment.   Are there any other alternatives? For random variables $X \in \mathbb{R}^h$, and a positive semi-definite matrix $A$: Is there a simplified expression for the expected value, $\mathop {\mathbb E}[Tr(X^TAX)]$ and variance, $Var[Tr(X^TAX)]$? Please note that $A$ is not a random variable. Is there any way to solve this problem using the diagonalization method? I know there's the proof that uses $\mathcal{P}(\mathbb{N})$ = set of all finite subsets $\cup$ set of all infinite subsets, but I'm trying to solve it using the diagonalization method specifically. I was thinking that we can assume the two have the same cardinality and arrive at a contradiction, but I don't know how to get there. How can we show there has to be some infinite set in the set of all infinite subsets that cannot match 1-1 with a natural number? iPhone 4 passcode lock disabled and no access to iTunes dollar-terminated strings In my assembly language class, our first assignment was to write a program to print out a simple dollar-terminated string in DOS.  It looked something like this:  BITS 32     global _main  section .data     msg db "Hello, world!", 13, 10, ’$’  section .text _main: mov ah, 9 mov edx, msg int 21h ret   As I understand it, the $ sign serves to terminate the sting like null does in C.  But what do I do if I want to put a dollar sign in the string (like I want to print out "it costs $30")?  This seems like a simple question, but my professor didn't know the answer and I don't seem to find it using a google search.