/** * - * @param axes specify real and imaginary coordinates as two 1d datasets * * @return a list containing a dataset of recursion limits */ @Override public List<Dataset> value(IDataset... axes) { Dataset xaxis, yaxis; if (axes.length < 2) { throw new IllegalArgumentException("Need two axes"); } xaxis = DatasetUtils.convertToDataset(axes[0]); yaxis = DatasetUtils.convertToDataset(axes[1]); if (xaxis.getRank() != 1 || yaxis.getRank() != 1) { throw new IllegalArgumentException("Need both axes to be 1d datasets"); } IntegerDataset count = DatasetFactory.zeros(IntegerDataset.class, yaxis.getShapeRef()[0], xaxis.getShapeRef()[0]); List<Dataset> result = new ArrayList<Dataset>(); final IndexIterator iy = yaxis.getIterator(); int n = 0; while (iy.hasNext()) { final double iv = yaxis.getElementDoubleAbs(iy.index); final IndexIterator ix = xaxis.getIterator(); while (ix.hasNext()) { final double rv = xaxis.getElementDoubleAbs(ix.index); double x = 0, y = 0; int c = -1; do { double t = x * x - y * y + rv; y = 2. * x * y + iv; x = t; } while (++c < maxRecursion && x * x + y * y <= 4.); count.setAbs(n++, c); } } result.add(count); return result; }