I want to implement a generic method that will take a vector of Points (Point can be of type integer, float or double) and return rectangle. (I am using OpenCV).  By reading the online tutorial of generics in c++ from  I have implemented the above method but I am getting a compile-time error.      Error: Error LNK2001    unresolved external symbol "public: static class cv::Rect_&lt;int&gt; __cdecl getRect&lt;int&gt;(class std::vector&lt;class cv::Point_&lt;int&gt;,class std::allocator&lt;class cv::Point_&lt;int&gt; &gt; &gt;)" (??$getRect@H@CvUtil@i2v@@SA?AV?$Rect_@H@cv@@V?$vector@V?$Point_@H@cv@@V?$allocator@V?$Point_@H@cv@@@std@@@std@@@Z)   I am unable to understand this error. Can someone explain to me what could be wrong here?  Below is the code snippet of my implementation.  template&lt;typename T&gt; struct XCoordSortX {     bool operator() (cv::Point_&lt;T&gt; pt1, cv::Point_&lt;T&gt; pt2) { return (pt1.x &lt; pt2.x); } }; template&lt;typename T2&gt; struct XCoordSortY {     bool operator() (cv::Point_&lt;T2&gt; pt1, cv::Point_&lt;T2&gt; pt2) { return (pt1.y &lt; pt2.y); } };  template&lt;class T3&gt; cv::Rect getRect(const std::vector&lt;cv::Point_&lt;T3&gt;&gt; points) {     cv::Rect rect;     std::vector&lt;cv::Point_&lt;T3&gt;&gt; tempPoints(points);     XCoordSortX&lt;T3&gt; sortX;     std::sort(tempPoints.begin(), tempPoints.end(), sortX); // sorting by x coordinate      rect.x = tempPoints[0].x; // setting top left point as lowest x     rect.width = tempPoints[tempPoints.size() - 1].x - tempPoints[0].x; // width will be diff between largest and smallest      XCoordSortY&lt;T3&gt; sortY;     std::sort(tempPoints.begin(), tempPoints.end(), sortY);     rect.y = tempPoints[0].y; // setting top left point as lowest y     rect.height = tempPoints[tempPoints.size() - 1].y - tempPoints[0].y;// height will be diff between largest and smallest     return rect; }  int main() {     std::vector&lt;cv::Point&gt; pointVec;     pointVec.push_back(cv::Point(2, 3));   // cv::Point is cv::Point_&lt;int&gt; type     pointVec.push_back(cv::Point(2, 10));     pointVec.push_back(cv::Point(10, 3));     pointVec.push_back(cv::Point(12, 5));      pointVec.push_back(cv::Point(40, 50));     pointVec.push_back(cv::Point(40 ,100));     pointVec.push_back(cv::Point(100, 40));     pointVec.push_back(cv::Point(50,50));      cv::Rect newRoi = getRect&lt;int&gt;(pointVec); // Error here }
Quote from :     The only portable way of using templates at the moment is to implement them in header files by using inline functions.   Why is this?  (Clarification: header files are not the only portable solution. But they are the most convenient portable solution.)
Why don't the White Walkers take the sea route to Westeros After watching 6 seasons of Game of Thrones, we know that the only roadblock for White Walkers is "The Wall" to stop them from attacking Westeros. However, we see that King Stannis attacked wildlings through a ship route without crossing the Wall.  What is stopping the White Walkers from doing the same? They can ask wights to make Ships or rowboats. They have a lot of forests to get wood for making ships. They can simply land at the coast of the North and attack Winterfell or whatever they want. Internal or external oscillator I always use the internal oscillator that pics have as I have never found the need to run anything at higher frequency than 8 MHz (which is the fastest the pics I use tend to be able to go). Are there any reasons, beyond going above 8 MHz, that mean I should use an external oscillator? It just seems like one more thing to go wrong to me but I'd be interested to hear what others do. Smoothing/generalizing polygon in QGIS? Is it possible to smooth or generalize a polygon in QGIS, perhaps by using a plugin like the generalizer-plugin for lines?  I could convert my polygons to lines, smooth them and convert them back to polygons but this is not working for my polygons because of several reasons. No indent in the first paragraph in a section? Ubuntu 19.10 change desktop environment Electric circuits in TeX, LaTeX, and Friends What are some ways to draw electric circuits in TeX systems?  I'm making this community wiki since I haven't found a question related to this.  I was thinking along the lines of . What do you think of that? Other examples are more than welcome, of course. What are irreducibles in the ring $R$ of entire functions? What is dependency injection? There have been several questions already posted with specific questions about , such as when to use it and what frameworks are there for it. However,  What is dependency injection and when/why should or shouldn't it be used? I'm experimenting with VPNs, so I wanted to install pptpd.  john@desktop:~$ sudo apt-get install pptpd [sudo] password for john:  &lt;snip&gt; The following extra packages will be installed:   bcrelay The following NEW packages will be installed:   bcrelay pptpd 0 upgraded, 2 newly installed, 0 to remove and 11 not upgraded. Need to get 90.5 kB of archives. After this operation, 442 kB of additional disk space will be used. Do you want to continue [Y/n]? y   And everything runs fine until I get down to here:  WARNING: The following packages cannot be authenticated!   bcrelay pptpd Install these packages without verification [y/N]? n E: Some packages could not be authenticated   No authentication?  I'm no security expert, but I'm fairly sure that's a bad thing.  So I .  john@desktop:~$ apt-cache policy pptpd pptpd:   Installed: (none)   Candidate: 1.3.4-3ubuntu1   Version table:      1.3.4-3ubuntu1 0         500 http://us.archive.ubuntu.com/ubuntu/ natty/main i386 Packages john@desktop:~$ apt-cache policy bcrelay bcrelay:   Installed: (none)   Candidate: 1.3.4-3ubuntu1   Version table:      1.3.4-3ubuntu1 0         500 http://us.archive.ubuntu.com/ubuntu/ natty/main i386 Packages   They're coming from Ubuntu.com and not being properly authenticated?  What's going on here? Identity involving Euler's totient function: $\sum \limits_{k=1}^n \left\lfloor \frac{n}{k} \right\rfloor \varphi(k) = \frac{n(n+1)}{2}$ Let $\varphi(n)$ be Euler's totient function, the number of positive integers less than or equal to $n$ and relatively prime to $n$.    Challenge: Prove  $$\sum_{k=1}^n \left\lfloor \frac{n}{k} \right\rfloor \varphi(k) = \frac{n(n+1)}{2}.$$   I have two proofs, one of which is partially combinatorial.    I'm posing this problem partly because I think some folks on this site would be interested in working on it and partly because I would like to see a purely combinatorial proof.  (But please post any proofs; I would be interested in noncombinatorial ones, too.  I've learned a lot on this site by reading alternative proofs of results I already know.)  I'll wait a few days to give others a chance to respond before posting my proofs.  EDIT: The two proofs in full are now given among the answers. How to debug "Cross-thread operation not valid" error in C#? Loading D3.js data from a simple JSON string Show that every irrational number in $\mathbb{R}$ is the limit of a   sequence of rational numbers. Every rational number in $\mathbb{R}$ is   the limit of a sequence of irrational numbers.   How can I prove this? Textbook clarification: $\log = \ln$ Textbook reads:     All logarithms are natural logarithms: $\log = \ln$.   Does this mean $n\log(n) = n\ln(n)$? Computing sums of divisors in $O(\sqrt n)$ time? I have a sequence: $1,3,5,8,10,14,16,20,23,27,\dots$  I know that the recursive relation is:  $$p[i] := p[i-1] + \text{number of factors of $i$}, \quad \text{with $p[1]=1$.}$$  How do I solve this recursive relation in $O(n^{0.5})$ time? I have to write a program for it, and $n$ can be as large as $10^9$. So, some appropriate precomputation and prestorage is allowed, provided that they comply (memory and time wise) with the range of $n$. How to redirect entire phone traffic (including all apps) to a proxy (with out rooting the phone)  We are developing a parental control app for Android, in that we have requirement to capture all out going traffic from Android phone for categorization. Is there a way to achieve this in Android with out rooting the phone.  Thanks, Gopi. I have been trying around different ranges of summations:  $$ \sum_{(m,n) \in \mathbb{Z}^2} \frac{m^2 - n^2}{(m^2 + n^2)^2} = 0$$  That's not any good.  What about if we restrict to $m, n \in \mathbb{Z}$ as positive integers.    $$ \sum_{m &gt; 0, n &gt; 0} \frac{m^2 - n^2}{(m^2 + n^2)^2} = 0$$  Now here's an anti-symmetry.  I do not like taking out the symmetry, but perhaps I can ask about:   $$ \sum_{m &gt;  n &gt; 0} \frac{m^2 - n^2}{(m^2 + n^2)^2}  = \; ? \tag{$*$} $$  There doesn't seem to be a change of variables that can work.  And we've used symmetry about as much as we can.  This looks related to:  $$  \sum \frac{1}{n^2} = \frac{\pi^2}{6}$$  Perhaps this other series ($*$) also has a special value. Let $S = \{ax + by: x,y \in \mathbb{Z}\}$  and let $e &gt; 0$ be the smallest element in $S$. Prove that $e \mid a$, and hence prove that $e = \gcd(a,b)$  I'm afraid I can't provide much of my initial working here because I'm at a loss of how to start.  I suppose that to show $e\mid a$ I would have to show that $eg = a$ for some $g \in \mathbb{Z}$. But I have no idea how I would do this. Unable to shrink transaction log file in SQL Server I moved to a new company recently wherein they have 2 databases in a SQL server of size 20-25 GB. I'm unable to shrink the log file of the databases. Transaction log backup of the databases are set to run every 30 mins from 6 AM-7PM. They are of size 10 and 2 Gb respectively. I tried to shrink it around 8-9 PM last night but I was not able to do.  The log_reuse_wait column stated it's waiting on a log_backup. I tried taking couple of log backups which didn't help. I ran DBCC OPENTRAN but there are no open transactions.  Also, this morning even after the Tlog backups started at 6:00 AM till now(10:30) it still shows LOG_BACKUP in log_reuse_wait column. And no OPEN TRAN as well.  When I researched on this I found this article from Paul Randal:   It states that if the DB is small and all the content of tlog file is in same VLF it couldn't truncate. I have some 300-400 VLFs in the Databases. So that doesn't make sense here as well.   One thing I noticed that every morning at 6 AM the tlog is a little bigger than the other ones. So I'm thinking to check with the lead DBA to run tlog round the clock. Other than that, I would like to see why is this happening and Am i missing anything.  I tried to shrink with the below command:  Use DB1 go DBCC SHRINKFILE(2,10)  GO   Note: It's SQL 2012 instance running 0n 2012 compatibility How can I check if /bin/x86_64/bin/ls is a directory in a bash shell script  Here is what I tried:  #!/bin/bash  if [ $# -eq 2 ]; then     if [[ "$1" = /* ]]     then     cd ./bin/x86_64/bin/ls         if [ -d "$1" ]; then             echo "ok"             i="$1"             echo $i         else             echo "error2"             exit         fi     else         echo "error"         exit     fi fi