splat.js
function splatND(out, points, weights, radius) {
  var n = points.shape[0]
  var d = points.shape[1]
  var lo = new Array(d)
  var hi = new Array(d)
  var bounds = out.shape
  var coord = new Array(d+1)
  var w = 1.0
  function splatRec(k) {
    if(k < 0) {
      coord[d] = out.get.apply(out, coord) + w
      out.set.apply(out, coord)
      return
    }
    var wprev = w
    var x = points.get(i, k)
    for(coord[k]=lo[k]; coord[k]<hi[k]; ++coord[k]) {
      w = wprev * dirichlet(bounds[k], coord[k] - x)
      splatRec(k-1)
    }
    w = wprev
  }

  for(var i=0; i<=d; ++i) {
    coord[i] = 0
  }

  for(var i=0; i<n; ++i) {
    for(var j=0; j<d; ++j) {
      var x = points.get(i,j)
      lo[j] = Math.max(x-radius, 0)
      hi[j] = Math.min(x+radius, bounds[j]-1)
    }
    w = weights.get(i)
    splatRec(d-1)
  }
}
function splatND(out, points, weights, radius) {
  var n = points.shape[0]
  var d = points.shape[1]
  var lo = new Array(d)
  var hi = new Array(d)
  var bounds = out.shape
  var coord = new Array(d+1)
  var w = 1.0
  function splatRec(k) {
    if(k < 0) {
      coord[d] = out.get.apply(out, coord) + w
      out.set.apply(out, coord)
      return
    }
    var wprev = w
    var x = points.get(i, k)
    for(coord[k]=lo[k]; coord[k]<hi[k]; ++coord[k]) {
      w = wprev * dirichlet(bounds[k], coord[k] - x)
      splatRec(k-1)
    }
    w = wprev
  }

  for(var i=0; i<=d; ++i) {
    coord[i] = 0
  }

  for(var i=0; i<n; ++i) {
    for(var j=0; j<d; ++j) {
      var x = points.get(i,j)
      lo[j] = Math.max(x-radius, 0)
      hi[j] = Math.min(x+radius, bounds[j]-1)
    }
    w = weights.get(i)
    splatRec(d-1)
  }
}
function splatND ( out , points , weights , radius ) { var n = points . shape [ 0 ] var d = points . shape [ 1 ] var lo = new Array ( d ) var hi = new Array ( d ) var bounds = out . shape var coord = new Array ( d + 1 ) var w = 1.0 function splatRec ( k ) { if ( k < 0 ) { coord [ d ] = out . get . apply ( out , coord ) + w out . set . apply ( out , coord ) return } var wprev = w var x = points . get ( i , k ) for ( coord [ k ] = lo [ k ] ; coord [ k ] < hi [ k ] ; ++ coord [ k ] ) { w = wprev * dirichlet ( bounds [ k ] , coord [ k ] - x ) splatRec ( k - 1 ) } w = wprev } for ( var i = 0 ; i <= d ; ++ i ) { coord [ i ] = 0 } for ( var i = 0 ; i < n ; ++ i ) { for ( var j = 0 ; j < d ; ++ j ) { var x = points . get ( i , j ) lo [ j ] = Math . max ( x - radius , 0 ) hi [ j ] = Math . min ( x + radius , bounds [ j ] - 1 ) } w = weights . get ( i ) splatRec ( d - 1 ) } }
Slow generic routine
Slow generic routine