Code-Golf: Lattice Points inside a Circle The following picture shows the problem:  



Write a function that, given an integer as the circle radius, calculates the number of lattice points inside the centered circle (including the boundary).

The image shows:  

f[1] = 5  (blue points)
f[2] = 13 (blue + red points)  


other values for your checking/debugging:  

f[3]    = 29
f[10]   = 317
f[1000] = 3,141,549
f[2000] = 12,566,345  


Should have a reasonable performance. Let's say less than a minute for f[1000].  

Shortest code wins. Usual Code-Golf rules apply.  

Please post the calculation and timing of f[1001] as an example.
J, 21 19 18

+/@,@(&gt;:|@j./~@i:)


Builds complexes from -x-xj to x+xj and takes magnitude. 

Edit: With &gt;:

Edit 2: With hook and monadic ~. Runs a few times slower for some reason, but still 10-ish seconds for f(1000).