What is the reason of this error in this case?       'it' was not declared in this scope   I don't understand why I get that error, I defined it in statement of for loop..  #include &lt;vector&gt; #include &lt;iostream&gt; template&lt;class T&gt; void LoopFunction() {     std::vector&lt;T&gt; vec;     for (std::vector&lt;T&gt;::iterator it = vec.begin(); it != vec.end(); it++) { // **error in this line**         //....     } }
In templates, where and why do I have to put typename and template on dependent names? What exactly are dependent names anyway?    I have the following code:  template &lt;typename T, typename Tail&gt; // Tail will be a UnionNode too. struct UnionNode : public Tail {     // ...     template&lt;typename U&gt; struct inUnion {         // Q: where to add typename/template here?         typedef Tail::inUnion&lt;U&gt; dummy;      };     template&lt; &gt; struct inUnion&lt;T&gt; {     }; }; template &lt;typename T&gt; // For the last node Tn. struct UnionNode&lt;T, void&gt; {     // ...     template&lt;typename U&gt; struct inUnion {         char fail[ -2 + (sizeof(U)%2) ]; // Cannot be instantiated for any U     };     template&lt; &gt; struct inUnion&lt;T&gt; {     }; };   The problem I have is in the typedef Tail::inUnion&lt;U&gt; dummy line. I'm fairly certain that inUnion is a dependent name, and VC++ is quite right in choking on it. I also know that I should be able to add template somewhere to tell the compiler that inUnion is a template-id. But where exactly? And should it then assume that inUnion is a class template, i.e. inUnion&lt;U&gt; names a type and not a function?
Writing a character N times using the printf command I found the following command to repeat a character in Linux:  printf 'H%.0s' {1..5000} &gt; H.txt   I want, for example, H to repeat 5000 times. What does %.0s mean here? Split file into multiple small files, separate by the newline symbol Is there a utility that split file by newline symbol? e.g if a file contains the following lines,  aa bbb cccc   If I want to split it to 3 files, the desired output would be:  aa, bbb And cccc (in 3 different files)  I already checked the split command, it only cut file by file sizes, not what I want.  If I don't wrote a utility myself, is there any standard tool to use? Pearson VS Deviance Residuals in logistic regression I know that standardized Pearson Residuals are obtained in a traditional probabilistic way: $$ r_i = \frac{y_i-\hat{\pi}_i}{\sqrt{\hat{\pi}_i(1-\hat{\pi}_i)}}$$ and Deviance Residuals are obtained through a more statistical way (the contribution of each point to the likelihood): $$ d_i = s_i \sqrt{-2[y_i \log \hat{\pi_i} + (1 - y_i)\log(1-\hat{\pi}_i)]} $$ where $s_i$ = 1 if $y_i$ = 1 and $s_i$ = -1 if $y_i$ = 0. Can you explain to me, intuitively, how to interpret the formula for deviance residuals? Moreover, if I want to choose one, which one is more suitable and why? BTW, some references claim that we derive the deviance residuals based on the term $$-\frac{1}{2}{r_i}^2$$ where $r_i$ is mentioned above. Positive integer multiples of an irrational mod 1 are dense I'm not sure how to solve this one. Thank you!  $2.$ For any $\alpha\in \mathbb R$ we define $$\lfloor \alpha \rfloor = \max_{n\in\mathbb Z}\{\,n\mid n\leq \alpha\,\}$$ and $$\alpha\bmod 1 = \alpha - \lfloor \alpha \rfloor$$ Let $\alpha$ be irrational. (a) Given $n\in\mathbb N$ show that $\{\,k\alpha\bmod1\mid k\in\mathbb N\,\}\cap\left[0,\frac{1}{n}\right]\neq\emptyset$ (b) Prove that $\{\,n\alpha\bmod 1\mid n\in\mathbb N\,\}$ is dense in $[0,1]$. What is the best way to include R code in the Latex paragraph I am a newbie in Latex. I have two simple questions regarding including R code in Latex.  Q1: For a block of R code, I use 'listings' package, as follows.  \documentclass[12pt]{report} \usepackage{listings} \begin{document} \begin{lstlisting}[language=R] &gt; dpareto(4, 2, 3) [1] 0.09375 &gt; dpareto(4, -2, 3) [1] NaN &gt; dpareto(seq(-1, 4, 1), 2, 3) [1] 0.0000000 0.0000000 0.0000000 0.0000000 0.2962963 0.0937500 \end{lstlisting} \end{document}   I feel it's not professional. What is the best way to present the block of R code?  Q2: For code pieces in the paragraph, for example I wish to include a R function, or variable, or package name in my Latex context, what is the best way to do that? Possible Duplicate:             According to , Win 7 only supports 4 GB of RAM. I, however have been reading some forums and some say they are using 8 GB RAM with good performance. I am wondering if I can use 8 GB before I purchase. After reading an article about Ubuntu's netflix support I decided to try running netflix through chromium but I got this error code: M7063-1913 I assumed that it was a problem with html5 but in the playback preferences it doesn't give me the option to use it. Remove completed reminders in OS X and iOS Mathematical physics text with plenty of applications I'm looking for texts on mathematical physics. I've seen various other threads, but the texts recommended in those threads were mathematical methods of theoretical physics texts, that is to say those texts focused on the math methods useful for physicists and assumed the applications of those methods would be covered in some other text. What I'm looking for is a book which introduces some math and then looks at its applications (back and forth) rather than a text which just goes over some math. (Example of books which are NOT what I'm looking for: Mathematics for physicists by Dennery, Math methods for physicists by Weber and Arfken etc)  I've taken courses in multi-variable calc, linear algebra, real analysis, and I'm currently taking a course in abstract algebra. But so far I've only seen applications of multi-variable to physics. I'm looking for books which look at the applications of the other subjects mentioned above to physics, of course books which cover subjects beyond those mentioned are also welcome.   So far I'm liking the flavor of the text "A Course in Modern Mathematical Physics" by Szekeres, but I'd prefer a text which got to the physics side of things more quickly (in the Szekeres text the first eight chapters are strictly on pure math).   After some amazon searching it looks like Theoretical Physics by Joos, Mathematical Physics by Henzel, and Physical Mathematics by Cahill may be good bets? What is a single word in English which means to look down on others (due to their younger age, lower socio-economic position, lesser experience, etc)    Not look down upon everyone else in general, but look down upon some particular person due to a feeling of superiority of oneself over them ( this superiority may come from the fact that one feels has more money, talent, etc)?    By "look down upon" I don't mean just the feeling of having superiority over another, but acting to them in a manner that reflects this pride as well (for example, perhaps he acts very rudely to them, since he feels superior to them and feels he can get away with it, or he feels it doesn't matter at all due to his superiority) Why does the question's closed status disappear when clicking to load a new edit? Why use gradient descent for linear regression, when a closed-form math solution is available? I am taking the Machine Learning courses online and learnt about Gradient Descent for calculating the optimal values in the hypothesis.  h(x) = B0 + B1X   why we need to use Gradient Descent if we can easily find the values with the below formula? This looks straight forward and easy too. but GD needs multiple iterations to get the value.  B1 = Correlation * (Std. Dev. of y/ Std. Dev. of x)  B0 = Mean(Y) – B1 * Mean(X)   NOTE: Taken as in   I did checked on the below questions and for me it was not clear to understand.      The above answers compares GD vs. using derivatives. Evil thoughts without actions? Two trains travel on the same track towards each other, each going at a speed of 50 kph. They start out 100km apart. A fly starts at the front of one train and flies at 75 kph to the front of the other; when it gets there, it turns around and flies back towards the first. It continues flying back and forth till the two trains meet and it gets squashed. How far did the fly travel before it got squashed?  The question is relatively simple - the trains take an hour to collide, and in an hour the fly would travel 75 km. However, the question got me wondering: Lets say you are given a time $t$ in hours(where $t&lt; 1$) How many &quot;rounds&quot; would the fly make in $t$ time? A round  is defined as moving from one train to another and back. How would I model the equation? How to support different screen size in android In Python, how do I determine if an object is iterable? Sending Text Cross Domain By Bookmarklet Exponential of the differential operator I am not sure whether this question is even well-posed. But today I learnt that $e^Df(x) = f(x+1)$ where $D$ is differential operator and  $$e^D \triangleq \sum_{i=0}^{\infty} \frac{D^i}{i!}.$$  (ref. )  So I was curious as to whether the differential equation  $$\frac{df(t)}{dt} = e^Df(t) = f(t+1)$$  has any solutions apart from $f = 0$? Predicting the number of decimal digits needed to express a rational number You require a reputation of 50 to leave comments on others' questions/answers; the FAQ simply states this as a fact but does not explain it. I'm a new user and I have identified this as an issue very quickly through my own experiences so far. Looking at other questions seems to also provide justification against this 50 reputation requirement for comments on others' questions/answers.      In my own experience, I've seen a few questions like "how do I do x?" then the same poster has answered with "in the end I did it like this: ..." where their solution was perfectly sensible, but there may be some gotchas to watch for - in this case I want to vote up their answer and/or comment on it to point out the potential gotchas, but I can do neither!  To me all of the above seems justification against this rep requirement to comment, so what is the counter-argument and justification for it?