Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting a gradient of a bi-variant function
    text
    copied!<p>I'm doing some video processing, for each frame I need to get a gradient of a bi-variate function. The function is represented as a two dimensional array of doubles. Where the domain is the rows and columns indices and the range is the double value of the corresponding indices values. Or more simply put, the function <code>f</code> is defined for <code>double[][] matrix</code> as such:</p> <p><code>f(x,y)=matrix[x][y]</code></p> <p>I'm trying to use the Apache Commons Math library for it:</p> <pre><code>SmoothingPolynomialBicubicSplineInterpolator iterpolator = new SmoothingPolynomialBicubicSplineInterpolator(); BicubicSplineInterpolatingFunction f = iterpolator.interpolate(xs, ys, matrix.getData()); for (int i = 0; i &lt; ans.length; i++) { for (int j = 0; j &lt; ans[0].length; j++) { ans[i][j] = f.partialDerivativeY(i, j); } } </code></pre> <ul> <li>with xs, as a sorted array of the x indices <code>(0,1,...,matrix.getRowDimension() - 1)</code></li> <li>ys the same on the columns dimension <code>(0,1,...,matrix.getColumnDimension() - 1)</code></li> </ul> <p>The problem is that for a typical matrix in the size of <code>150X80</code> it takes as much as <code>1.4</code> seconds to run, which renders it completely irrelevant for my needs. So, as a novice user of this library, and programmatic numeric analysis in general, I want to know:</p> <ol> <li>Am I doing something wrong?</li> <li>Is there another, faster, way I can accomplish this task with?</li> <li>Is there another open source library (preferably maven-friendly) that offers a solution?</li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload