title: Turning Java code into fast Clojure code
body: <p>Can this Java code be translated to Clojure code that's as fast or nearly as fast? </p>
  
  <p>I've been able to get simpler functions like adding two arrays to run at reasonable speeds with type hinting, but I couldn't get Clojure to do what the functions below do at all in a reasonable amount of time using either Java interop or Incanter matrices and using either functional or imperative styles.  </p>
  
  <p>Am I missing something about type hinting or is it just best to do this kind of thing in Java?</p>
  
  <pre><code>static double[][] grad2_stencil= { {0,0,-1,0,0}, 
                               {0,0,16,0,0}, 
                               {-1,16,-60,16,-1}, 
                               {0,0,16,0,0}, 
                               {0,0,-1,0,0} };
  
  public static double grad2(double[][] array, int x, int y){
      double temp=0;
      int L=array.length;
      for(int i=0; i&lt;5; i++){
          for(int j=0; j&lt;5; j++){
              temp+=array[((x+i-2)%L+L)%L][((y+j-2)%L+L)%L]*grad2_stencil[i][j];
          }
      }
      return temp/12.0;
  }
  
  public static double[][] grad2_field(double[][] arr){
      int L=arr.length;
      double[][] result=new double[L][L];
  
      for(int i=0; i&lt;L; i++){
          for(int j=0; j&lt;L; j++){
              result[i][j]=grad2(arr, i, j);
          }
      }
  
      return result;
  }
  </code></pre>