Move template sqr function to header.

Move template sqr funtion to header, has to be like this.