Example usage for java.lang Math cbrt

List of usage examples for java.lang Math cbrt

Introduction

In this page you can find the example usage for java.lang Math cbrt.

Prototype

public static double cbrt(double a) 

Source Link

Document

Returns the cube root of a double value.

Usage

From source file:org.esa.beam.util.math.FastMathPerformance.java

public void testCbrt() {
    System.gc();// w ww . ja  v a2 s . c o m
    double x = 0;
    long time = System.nanoTime();
    for (int i = 0; i < RUNS; i++)
        x += StrictMath.cbrt(i * F1);
    long strictTime = System.nanoTime() - time;

    System.gc();
    double y = 0;
    time = System.nanoTime();
    for (int i = 0; i < RUNS; i++)
        y += FastMath.cbrt(i * F1);
    long fastTime = System.nanoTime() - time;

    System.gc();
    double z = 0;
    time = System.nanoTime();
    for (int i = 0; i < RUNS; i++)
        z += Math.cbrt(i * F1);
    long mathTime = System.nanoTime() - time;

    report("cbrt", x + y + z, strictTime, fastTime, mathTime);
}

From source file:org.florescu.android.rangeseekbar.RangeSeekBar.java

public void setRangeValues(T minValue, T maxValue, boolean generateNewValues) {
    this.absoluteMinValue = minValue;
    this.absoluteMaxValue = maxValue;
    if (minValue.intValue() >= maxValue.intValue()) {
        throw new IllegalArgumentException("Min value must be less than max value");
    }/*from   ww  w.jav  a  2  s . co m*/
    if (rangeType == RangeType.CUBIC) {
        cubicMultiplier = Math.cbrt(absoluteMaxValue.intValue() - absoluteMinValue.intValue());
    } else if (rangeType == RangeType.GENERATED && generateNewValues) {
        generateCustomSteps();
    }
    updateMinDistance();
    setValuePrimAndNumberType();
    invalidate();
}

From source file:qupath.lib.gui.panels.classify.RandomTrainingRegionSelector.java

public static double[] makeCIELAB(final int rgb, double[] lab) {
    if (lab == null || lab.length < 3)
        lab = new double[3];

    double r = ColorTools.red(rgb) / 255.0;
    double g = ColorTools.green(rgb) / 255.0;
    double b = ColorTools.blue(rgb) / 255.0;

    double X = 0.412453 * r + 0.357580 * g + 0.180423 * b;
    double Y = 0.212671 * r + 0.715160 * g + 0.072169 * b;
    double Z = 0.019334 * r + 0.119193 * g + 0.950227 * b;
    X /= 0.950456;/*from w ww.ja  v a2s  .c om*/
    Z /= 1.088754;
    double L = Y > 0.008856 ? 116 * Math.cbrt(Y) - 16 : 903.3 * Y;

    double A = 500 * (f(X) - f(Y));
    double B = 200 * (f(Y) - f(Z));

    lab[0] = L;
    lab[1] = A;
    lab[2] = B;

    //      if (L > 100 || L < 0)
    //         logger.warn("L = " + L);
    //      if (A < -127 || A > 127)
    //         logger.warn("a = " + A);
    //      if (B < -127 || B > 127)
    //         logger.warn("b = " + B);
    //      
    ////      System.out.println(B);
    return lab;
}

From source file:qupath.lib.gui.panels.classify.RandomTrainingRegionSelector.java

private static double f(final double t) {
    if (t > 0.008856)
        return Math.cbrt(t);
    return 7.787 * t + 16.0 / 116.0;
}

From source file:uk.ac.diamond.scisoft.analysis.dataset.Maths.java

/**
 * cbrt - evaluate the cube root function on each element of the dataset
 * @param a/*  www  .  j  ava2  s.  c o m*/
 * @return dataset
 */
@SuppressWarnings("cast")
public static AbstractDataset cbrt(final AbstractDataset a) {
    final int isize;
    final IndexIterator it = a.getIterator();
    AbstractDataset ds;
    final int dt = a.getDtype();

    switch (dt) {
    case AbstractDataset.INT8:
        ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT32);
        final byte[] i8data = ((ByteDataset) a).data;
        final float[] oi8data = ((FloatDataset) ds).getData();
        for (int i = 0; it.hasNext();) {
            final byte ix = i8data[it.index];
            float ox;
            ox = (float) (Math.cbrt(ix));
            oi8data[i++] = ox;
        }
        break;
    case AbstractDataset.INT16:
        ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT32);
        final short[] i16data = ((ShortDataset) a).data;
        final float[] oi16data = ((FloatDataset) ds).getData();
        for (int i = 0; it.hasNext();) {
            final short ix = i16data[it.index];
            float ox;
            ox = (float) (Math.cbrt(ix));
            oi16data[i++] = ox;
        }
        break;
    case AbstractDataset.INT32:
        ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT64);
        final int[] i32data = ((IntegerDataset) a).data;
        final double[] oi32data = ((DoubleDataset) ds).getData();
        for (int i = 0; it.hasNext();) {
            final int ix = i32data[it.index];
            double ox;
            ox = (double) (Math.cbrt(ix));
            oi32data[i++] = ox;
        }
        break;
    case AbstractDataset.INT64:
        ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT64);
        final long[] i64data = ((LongDataset) a).data;
        final double[] oi64data = ((DoubleDataset) ds).getData();
        for (int i = 0; it.hasNext();) {
            final long ix = i64data[it.index];
            double ox;
            ox = (double) (Math.cbrt(ix));
            oi64data[i++] = ox;
        }
        break;
    case AbstractDataset.ARRAYINT8:
        ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT32);
        isize = a.getElementsPerItem();
        final byte[] ai8data = ((CompoundByteDataset) a).data;
        final float[] oai8data = ((CompoundFloatDataset) ds).getData();
        for (int i = 0; it.hasNext();) {
            for (int j = 0; j < isize; j++) {
                final byte ix = ai8data[it.index + j];
                float ox;
                ox = (float) (Math.cbrt(ix));
                oai8data[i++] = ox;
            }
        }
        break;
    case AbstractDataset.ARRAYINT16:
        ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT32);
        isize = a.getElementsPerItem();
        final short[] ai16data = ((CompoundShortDataset) a).data;
        final float[] oai16data = ((CompoundFloatDataset) ds).getData();
        for (int i = 0; it.hasNext();) {
            for (int j = 0; j < isize; j++) {
                final short ix = ai16data[it.index + j];
                float ox;
                ox = (float) (Math.cbrt(ix));
                oai16data[i++] = ox;
            }
        }
        break;
    case AbstractDataset.ARRAYINT32:
        ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT64);
        isize = a.getElementsPerItem();
        final int[] ai32data = ((CompoundIntegerDataset) a).data;
        final double[] oai32data = ((CompoundDoubleDataset) ds).getData();
        for (int i = 0; it.hasNext();) {
            for (int j = 0; j < isize; j++) {
                final int ix = ai32data[it.index + j];
                double ox;
                ox = (double) (Math.cbrt(ix));
                oai32data[i++] = ox;
            }
        }
        break;
    case AbstractDataset.ARRAYINT64:
        ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT64);
        isize = a.getElementsPerItem();
        final long[] ai64data = ((CompoundLongDataset) a).data;
        final double[] oai64data = ((CompoundDoubleDataset) ds).getData();
        for (int i = 0; it.hasNext();) {
            for (int j = 0; j < isize; j++) {
                final long ix = ai64data[it.index + j];
                double ox;
                ox = (double) (Math.cbrt(ix));
                oai64data[i++] = ox;
            }
        }
        break;
    case AbstractDataset.FLOAT32:
        ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT32);
        final float[] f32data = ((FloatDataset) a).data;
        final float[] of32data = ((FloatDataset) ds).getData();
        for (int i = 0; it.hasNext();) {
            final float ix = f32data[it.index];
            float ox;
            ox = (float) (Math.cbrt(ix));
            of32data[i++] = ox;
        }
        break;
    case AbstractDataset.FLOAT64:
        ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT64);
        final double[] f64data = ((DoubleDataset) a).data;
        final double[] of64data = ((DoubleDataset) ds).getData();
        for (int i = 0; it.hasNext();) {
            final double ix = f64data[it.index];
            double ox;
            ox = (double) (Math.cbrt(ix));
            of64data[i++] = ox;
        }
        break;
    case AbstractDataset.ARRAYFLOAT32:
        ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT32);
        isize = a.getElementsPerItem();
        final float[] af32data = ((CompoundFloatDataset) a).data;
        final float[] oaf32data = ((CompoundFloatDataset) ds).getData();
        for (int i = 0; it.hasNext();) {
            for (int j = 0; j < isize; j++) {
                final float ix = af32data[it.index + j];
                float ox;
                ox = (float) (Math.cbrt(ix));
                oaf32data[i++] = ox;
            }
        }
        break;
    case AbstractDataset.ARRAYFLOAT64:
        ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT64);
        isize = a.getElementsPerItem();
        final double[] af64data = ((CompoundDoubleDataset) a).data;
        final double[] oaf64data = ((CompoundDoubleDataset) ds).getData();
        for (int i = 0; it.hasNext();) {
            for (int j = 0; j < isize; j++) {
                final double ix = af64data[it.index + j];
                double ox;
                ox = (double) (Math.cbrt(ix));
                oaf64data[i++] = ox;
            }
        }
        break;
    case AbstractDataset.COMPLEX64:
        ds = AbstractDataset.zeros(a, AbstractDataset.COMPLEX64);
        final float[] c64data = ((ComplexFloatDataset) a).data;
        final float[] oc64data = ((ComplexFloatDataset) ds).getData();
        for (int i = 0; it.hasNext();) {
            final float ix = c64data[it.index];
            final float iy = c64data[it.index + 1];
            Complex tz;
            float ox;
            float oy;
            tz = new Complex(ix, iy).pow(new Complex(1. / 3., 0));
            ox = (float) (tz.getReal());
            oy = (float) (tz.getImaginary());
            oc64data[i++] = ox;
            oc64data[i++] = oy;
        }
        break;
    case AbstractDataset.COMPLEX128:
        ds = AbstractDataset.zeros(a, AbstractDataset.COMPLEX128);
        final double[] c128data = ((ComplexDoubleDataset) a).data;
        final double[] oc128data = ((ComplexDoubleDataset) ds).getData();
        for (int i = 0; it.hasNext();) {
            final double ix = c128data[it.index];
            final double iy = c128data[it.index + 1];
            Complex tz;
            double ox;
            double oy;
            tz = new Complex(ix, iy).pow(new Complex(1. / 3., 0));
            ox = (double) (tz.getReal());
            oy = (double) (tz.getImaginary());
            oc128data[i++] = ox;
            oc128data[i++] = oy;
        }
        break;
    default:
        throw new IllegalArgumentException(
                "cbrt supports integer, compound integer, real, compound real, complex datasets only");
    }

    ds.setName(a.getName());
    addFunctionName(ds, "cbrt");
    return ds;
}

From source file:org.eclipse.january.dataset.GeneratedMaths.java

/**
 * cbrt - evaluate the cube root function on each element of the dataset
 * @param a//from w  w  w.java2  s.c  om
 * @param o output can be null - in which case, a new dataset is created
 * @return dataset
 */
public static Dataset cbrt(final Object a, final Dataset o) {
    final Dataset da = a instanceof Dataset ? (Dataset) a : DatasetFactory.createFromObject(a);
    final SingleInputBroadcastIterator it = new SingleInputBroadcastIterator(da, o, true);
    final Dataset result = it.getOutput();
    final int is = result.getElementsPerItem();
    final int as = da.getElementsPerItem();
    final int dt = result.getDType();

    switch (dt) {
    case Dataset.INT8:
        final byte[] oi8data = ((ByteDataset) result).getData();
        if (it.isOutputDouble()) {
            while (it.hasNext()) {
                final double ix = it.aDouble;
                byte ox;
                ox = (byte) toLong(Math.cbrt(ix));
                oi8data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                byte ox;
                ox = (byte) toLong(Math.cbrt(ix));
                oi8data[it.oIndex] = ox;
            }
        }
        break;
    case Dataset.INT16:
        final short[] oi16data = ((ShortDataset) result).getData();
        if (it.isOutputDouble()) {
            while (it.hasNext()) {
                final double ix = it.aDouble;
                short ox;
                ox = (short) toLong(Math.cbrt(ix));
                oi16data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                short ox;
                ox = (short) toLong(Math.cbrt(ix));
                oi16data[it.oIndex] = ox;
            }
        }
        break;
    case Dataset.INT64:
        final long[] oi64data = ((LongDataset) result).getData();
        if (it.isOutputDouble()) {
            while (it.hasNext()) {
                final double ix = it.aDouble;
                long ox;
                ox = toLong(Math.cbrt(ix));
                oi64data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                long ox;
                ox = toLong(Math.cbrt(ix));
                oi64data[it.oIndex] = ox;
            }
        }
        break;
    case Dataset.INT32:
        final int[] oi32data = ((IntegerDataset) result).getData();
        if (it.isOutputDouble()) {
            while (it.hasNext()) {
                final double ix = it.aDouble;
                int ox;
                ox = (int) toLong(Math.cbrt(ix));
                oi32data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                int ox;
                ox = (int) toLong(Math.cbrt(ix));
                oi32data[it.oIndex] = ox;
            }
        }
        break;
    case Dataset.ARRAYINT8:
        final byte[] oai8data = ((CompoundByteDataset) result).getData();
        if (is == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    byte ox;
                    ox = (byte) toLong(Math.cbrt(ix));
                    oai8data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    byte ox;
                    ox = (byte) toLong(Math.cbrt(ix));
                    oai8data[it.oIndex] = ox;
                }
            }
        } else if (as == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    byte ox;
                    ox = (byte) toLong(Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oai8data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    byte ox;
                    ox = (byte) toLong(Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oai8data[it.oIndex + j] = ox;
                    }
                }
            }
        } else {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final double ix = da.getElementDoubleAbs(it.aIndex + j);
                        byte ox;
                        ox = (byte) toLong(Math.cbrt(ix));
                        oai8data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final long ix = da.getElementLongAbs(it.aIndex + j);
                        byte ox;
                        ox = (byte) toLong(Math.cbrt(ix));
                        oai8data[it.oIndex + j] = ox;
                    }
                }
            }
        }
        break;
    case Dataset.ARRAYINT16:
        final short[] oai16data = ((CompoundShortDataset) result).getData();
        if (is == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    short ox;
                    ox = (short) toLong(Math.cbrt(ix));
                    oai16data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    short ox;
                    ox = (short) toLong(Math.cbrt(ix));
                    oai16data[it.oIndex] = ox;
                }
            }
        } else if (as == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    short ox;
                    ox = (short) toLong(Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oai16data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    short ox;
                    ox = (short) toLong(Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oai16data[it.oIndex + j] = ox;
                    }
                }
            }
        } else {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final double ix = da.getElementDoubleAbs(it.aIndex + j);
                        short ox;
                        ox = (short) toLong(Math.cbrt(ix));
                        oai16data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final long ix = da.getElementLongAbs(it.aIndex + j);
                        short ox;
                        ox = (short) toLong(Math.cbrt(ix));
                        oai16data[it.oIndex + j] = ox;
                    }
                }
            }
        }
        break;
    case Dataset.ARRAYINT64:
        final long[] oai64data = ((CompoundLongDataset) result).getData();
        if (is == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    long ox;
                    ox = toLong(Math.cbrt(ix));
                    oai64data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    long ox;
                    ox = toLong(Math.cbrt(ix));
                    oai64data[it.oIndex] = ox;
                }
            }
        } else if (as == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    long ox;
                    ox = toLong(Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oai64data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    long ox;
                    ox = toLong(Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oai64data[it.oIndex + j] = ox;
                    }
                }
            }
        } else {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final double ix = da.getElementDoubleAbs(it.aIndex + j);
                        long ox;
                        ox = toLong(Math.cbrt(ix));
                        oai64data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final long ix = da.getElementLongAbs(it.aIndex + j);
                        long ox;
                        ox = toLong(Math.cbrt(ix));
                        oai64data[it.oIndex + j] = ox;
                    }
                }
            }
        }
        break;
    case Dataset.ARRAYINT32:
        final int[] oai32data = ((CompoundIntegerDataset) result).getData();
        if (is == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    int ox;
                    ox = (int) toLong(Math.cbrt(ix));
                    oai32data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    int ox;
                    ox = (int) toLong(Math.cbrt(ix));
                    oai32data[it.oIndex] = ox;
                }
            }
        } else if (as == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    int ox;
                    ox = (int) toLong(Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oai32data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    int ox;
                    ox = (int) toLong(Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oai32data[it.oIndex + j] = ox;
                    }
                }
            }
        } else {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final double ix = da.getElementDoubleAbs(it.aIndex + j);
                        int ox;
                        ox = (int) toLong(Math.cbrt(ix));
                        oai32data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final long ix = da.getElementLongAbs(it.aIndex + j);
                        int ox;
                        ox = (int) toLong(Math.cbrt(ix));
                        oai32data[it.oIndex + j] = ox;
                    }
                }
            }
        }
        break;
    case Dataset.FLOAT32:
        final float[] of32data = ((FloatDataset) result).getData();
        if (it.isOutputDouble()) {
            while (it.hasNext()) {
                final double ix = it.aDouble;
                float ox;
                ox = (float) (Math.cbrt(ix));
                of32data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                float ox;
                ox = (float) (Math.cbrt(ix));
                of32data[it.oIndex] = ox;
            }
        }
        break;
    case Dataset.FLOAT64:
        final double[] of64data = ((DoubleDataset) result).getData();
        if (it.isOutputDouble()) {
            while (it.hasNext()) {
                final double ix = it.aDouble;
                double ox;
                ox = (Math.cbrt(ix));
                of64data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                double ox;
                ox = (Math.cbrt(ix));
                of64data[it.oIndex] = ox;
            }
        }
        break;
    case Dataset.ARRAYFLOAT32:
        final float[] oaf32data = ((CompoundFloatDataset) result).getData();
        if (is == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    float ox;
                    ox = (float) (Math.cbrt(ix));
                    oaf32data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    float ox;
                    ox = (float) (Math.cbrt(ix));
                    oaf32data[it.oIndex] = ox;
                }
            }
        } else if (as == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    float ox;
                    ox = (float) (Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oaf32data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    float ox;
                    ox = (float) (Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oaf32data[it.oIndex + j] = ox;
                    }
                }
            }
        } else {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final double ix = da.getElementDoubleAbs(it.aIndex + j);
                        float ox;
                        ox = (float) (Math.cbrt(ix));
                        oaf32data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final long ix = da.getElementLongAbs(it.aIndex + j);
                        float ox;
                        ox = (float) (Math.cbrt(ix));
                        oaf32data[it.oIndex + j] = ox;
                    }
                }
            }
        }
        break;
    case Dataset.ARRAYFLOAT64:
        final double[] oaf64data = ((CompoundDoubleDataset) result).getData();
        if (is == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    double ox;
                    ox = (Math.cbrt(ix));
                    oaf64data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    double ox;
                    ox = (Math.cbrt(ix));
                    oaf64data[it.oIndex] = ox;
                }
            }
        } else if (as == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    double ox;
                    ox = (Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oaf64data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    double ox;
                    ox = (Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oaf64data[it.oIndex + j] = ox;
                    }
                }
            }
        } else {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final double ix = da.getElementDoubleAbs(it.aIndex + j);
                        double ox;
                        ox = (Math.cbrt(ix));
                        oaf64data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final long ix = da.getElementLongAbs(it.aIndex + j);
                        double ox;
                        ox = (Math.cbrt(ix));
                        oaf64data[it.oIndex + j] = ox;
                    }
                }
            }
        }
        break;
    case Dataset.COMPLEX64:
        final float[] oc64data = ((ComplexFloatDataset) result).getData();
        if (as == 1) {
            final double iy = 0;
            while (it.hasNext()) {
                final double ix = it.aDouble;
                Complex tz;
                float ox;
                float oy;
                tz = new Complex(ix, iy).pow(new Complex(1. / 3., 0));
                ox = (float) (tz.getReal());
                oy = (float) (tz.getImaginary());
                oc64data[it.oIndex] = ox;
                oc64data[it.oIndex + 1] = oy;
            }
        } else {
            while (it.hasNext()) {
                final double ix = it.aDouble;
                final double iy = da.getElementDoubleAbs(it.aIndex + 1);
                Complex tz;
                float ox;
                float oy;
                tz = new Complex(ix, iy).pow(new Complex(1. / 3., 0));
                ox = (float) (tz.getReal());
                oy = (float) (tz.getImaginary());
                oc64data[it.oIndex] = ox;
                oc64data[it.oIndex + 1] = oy;
            }
        }
        break;
    case Dataset.COMPLEX128:
        final double[] oc128data = ((ComplexDoubleDataset) result).getData();
        if (as == 1) {
            final double iy = 0;
            while (it.hasNext()) {
                final double ix = it.aDouble;
                Complex tz;
                double ox;
                double oy;
                tz = new Complex(ix, iy).pow(new Complex(1. / 3., 0));
                ox = (tz.getReal());
                oy = (tz.getImaginary());
                oc128data[it.oIndex] = ox;
                oc128data[it.oIndex + 1] = oy;
            }
        } else {
            while (it.hasNext()) {
                final double ix = it.aDouble;
                final double iy = da.getElementDoubleAbs(it.aIndex + 1);
                Complex tz;
                double ox;
                double oy;
                tz = new Complex(ix, iy).pow(new Complex(1. / 3., 0));
                ox = (tz.getReal());
                oy = (tz.getImaginary());
                oc128data[it.oIndex] = ox;
                oc128data[it.oIndex + 1] = oy;
            }
        }
        break;
    default:
        throw new IllegalArgumentException(
                "cbrt supports integer, compound integer, real, compound real, complex datasets only");
    }

    addFunctionName(result, "cbrt");
    return result;
}

From source file:org.eclipse.january.dataset.Maths.java

/**
 * cbrt - evaluate the cube root function on each element of the dataset
 * @param a/*  www . j a  v  a  2 s. c o m*/
 * @param o output can be null - in which case, a new dataset is created
 * @return dataset
 */
public static Dataset cbrt(final Object a, final Dataset o) {
    final Dataset da = a instanceof Dataset ? (Dataset) a : DatasetFactory.createFromObject(a);
    final SingleInputBroadcastIterator it = new SingleInputBroadcastIterator(da, o, true);
    final Dataset result = it.getOutput();
    final int is = result.getElementsPerItem();
    final int dt = result.getDType();

    switch (dt) {
    case Dataset.INT8:
        final byte[] oi8data = ((ByteDataset) result).data;
        if (it.isOutputDouble()) {
            while (it.hasNext()) {
                final double ix = it.aDouble;
                byte ox;
                ox = (byte) toLong(Math.cbrt(ix));
                oi8data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                byte ox;
                ox = (byte) toLong(Math.cbrt(ix));
                oi8data[it.oIndex] = ox;
            }
        }
        break;
    case Dataset.INT16:
        final short[] oi16data = ((ShortDataset) result).data;
        if (it.isOutputDouble()) {
            while (it.hasNext()) {
                final double ix = it.aDouble;
                short ox;
                ox = (short) toLong(Math.cbrt(ix));
                oi16data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                short ox;
                ox = (short) toLong(Math.cbrt(ix));
                oi16data[it.oIndex] = ox;
            }
        }
        break;
    case Dataset.INT64:
        final long[] oi64data = ((LongDataset) result).data;
        if (it.isOutputDouble()) {
            while (it.hasNext()) {
                final double ix = it.aDouble;
                long ox;
                ox = toLong(Math.cbrt(ix));
                oi64data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                long ox;
                ox = toLong(Math.cbrt(ix));
                oi64data[it.oIndex] = ox;
            }
        }
        break;
    case Dataset.INT32:
        final int[] oi32data = ((IntegerDataset) result).data;
        if (it.isOutputDouble()) {
            while (it.hasNext()) {
                final double ix = it.aDouble;
                int ox;
                ox = (int) toLong(Math.cbrt(ix));
                oi32data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                int ox;
                ox = (int) toLong(Math.cbrt(ix));
                oi32data[it.oIndex] = ox;
            }
        }
        break;
    case Dataset.ARRAYINT8:
        final byte[] oai8data = ((CompoundByteDataset) result).data;
        if (is == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    byte ox;
                    ox = (byte) toLong(Math.cbrt(ix));
                    oai8data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    byte ox;
                    ox = (byte) toLong(Math.cbrt(ix));
                    oai8data[it.oIndex] = ox;
                }
            }
        } else if (da.getElementsPerItem() == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    byte ox;
                    ox = (byte) toLong(Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oai8data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    byte ox;
                    ox = (byte) toLong(Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oai8data[it.oIndex + j] = ox;
                    }
                }
            }
        } else {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final double ix = da.getElementDoubleAbs(it.aIndex + j);
                        byte ox;
                        ox = (byte) toLong(Math.cbrt(ix));
                        oai8data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final long ix = da.getElementLongAbs(it.aIndex + j);
                        byte ox;
                        ox = (byte) toLong(Math.cbrt(ix));
                        oai8data[it.oIndex + j] = ox;
                    }
                }
            }
        }
        break;
    case Dataset.ARRAYINT16:
        final short[] oai16data = ((CompoundShortDataset) result).data;
        if (is == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    short ox;
                    ox = (short) toLong(Math.cbrt(ix));
                    oai16data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    short ox;
                    ox = (short) toLong(Math.cbrt(ix));
                    oai16data[it.oIndex] = ox;
                }
            }
        } else if (da.getElementsPerItem() == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    short ox;
                    ox = (short) toLong(Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oai16data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    short ox;
                    ox = (short) toLong(Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oai16data[it.oIndex + j] = ox;
                    }
                }
            }
        } else {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final double ix = da.getElementDoubleAbs(it.aIndex + j);
                        short ox;
                        ox = (short) toLong(Math.cbrt(ix));
                        oai16data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final long ix = da.getElementLongAbs(it.aIndex + j);
                        short ox;
                        ox = (short) toLong(Math.cbrt(ix));
                        oai16data[it.oIndex + j] = ox;
                    }
                }
            }
        }
        break;
    case Dataset.ARRAYINT64:
        final long[] oai64data = ((CompoundLongDataset) result).data;
        if (is == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    long ox;
                    ox = toLong(Math.cbrt(ix));
                    oai64data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    long ox;
                    ox = toLong(Math.cbrt(ix));
                    oai64data[it.oIndex] = ox;
                }
            }
        } else if (da.getElementsPerItem() == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    long ox;
                    ox = toLong(Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oai64data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    long ox;
                    ox = toLong(Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oai64data[it.oIndex + j] = ox;
                    }
                }
            }
        } else {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final double ix = da.getElementDoubleAbs(it.aIndex + j);
                        long ox;
                        ox = toLong(Math.cbrt(ix));
                        oai64data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final long ix = da.getElementLongAbs(it.aIndex + j);
                        long ox;
                        ox = toLong(Math.cbrt(ix));
                        oai64data[it.oIndex + j] = ox;
                    }
                }
            }
        }
        break;
    case Dataset.ARRAYINT32:
        final int[] oai32data = ((CompoundIntegerDataset) result).data;
        if (is == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    int ox;
                    ox = (int) toLong(Math.cbrt(ix));
                    oai32data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    int ox;
                    ox = (int) toLong(Math.cbrt(ix));
                    oai32data[it.oIndex] = ox;
                }
            }
        } else if (da.getElementsPerItem() == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    int ox;
                    ox = (int) toLong(Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oai32data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    int ox;
                    ox = (int) toLong(Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oai32data[it.oIndex + j] = ox;
                    }
                }
            }
        } else {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final double ix = da.getElementDoubleAbs(it.aIndex + j);
                        int ox;
                        ox = (int) toLong(Math.cbrt(ix));
                        oai32data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final long ix = da.getElementLongAbs(it.aIndex + j);
                        int ox;
                        ox = (int) toLong(Math.cbrt(ix));
                        oai32data[it.oIndex + j] = ox;
                    }
                }
            }
        }
        break;
    case Dataset.FLOAT32:
        final float[] of32data = ((FloatDataset) result).data;
        if (it.isOutputDouble()) {
            while (it.hasNext()) {
                final double ix = it.aDouble;
                float ox;
                ox = (float) (Math.cbrt(ix));
                of32data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                float ox;
                ox = (float) (Math.cbrt(ix));
                of32data[it.oIndex] = ox;
            }
        }
        break;
    case Dataset.FLOAT64:
        final double[] of64data = ((DoubleDataset) result).data;
        if (it.isOutputDouble()) {
            while (it.hasNext()) {
                final double ix = it.aDouble;
                double ox;
                ox = (Math.cbrt(ix));
                of64data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                double ox;
                ox = (Math.cbrt(ix));
                of64data[it.oIndex] = ox;
            }
        }
        break;
    case Dataset.ARRAYFLOAT32:
        final float[] oaf32data = ((CompoundFloatDataset) result).data;
        if (is == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    float ox;
                    ox = (float) (Math.cbrt(ix));
                    oaf32data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    float ox;
                    ox = (float) (Math.cbrt(ix));
                    oaf32data[it.oIndex] = ox;
                }
            }
        } else if (da.getElementsPerItem() == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    float ox;
                    ox = (float) (Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oaf32data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    float ox;
                    ox = (float) (Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oaf32data[it.oIndex + j] = ox;
                    }
                }
            }
        } else {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final double ix = da.getElementDoubleAbs(it.aIndex + j);
                        float ox;
                        ox = (float) (Math.cbrt(ix));
                        oaf32data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final long ix = da.getElementLongAbs(it.aIndex + j);
                        float ox;
                        ox = (float) (Math.cbrt(ix));
                        oaf32data[it.oIndex + j] = ox;
                    }
                }
            }
        }
        break;
    case Dataset.ARRAYFLOAT64:
        final double[] oaf64data = ((CompoundDoubleDataset) result).data;
        if (is == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    double ox;
                    ox = (Math.cbrt(ix));
                    oaf64data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    double ox;
                    ox = (Math.cbrt(ix));
                    oaf64data[it.oIndex] = ox;
                }
            }
        } else if (da.getElementsPerItem() == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    double ox;
                    ox = (Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oaf64data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    double ox;
                    ox = (Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oaf64data[it.oIndex + j] = ox;
                    }
                }
            }
        } else {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final double ix = da.getElementDoubleAbs(it.aIndex + j);
                        double ox;
                        ox = (Math.cbrt(ix));
                        oaf64data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final long ix = da.getElementLongAbs(it.aIndex + j);
                        double ox;
                        ox = (Math.cbrt(ix));
                        oaf64data[it.oIndex + j] = ox;
                    }
                }
            }
        }
        break;
    case Dataset.COMPLEX64:
        final float[] oc64data = ((ComplexFloatDataset) result).data;
        if (da.getElementsPerItem() == 1) {
            final double iy = 0;
            while (it.hasNext()) {
                final double ix = it.aDouble;
                Complex tz;
                float ox;
                float oy;
                tz = new Complex(ix, iy).pow(new Complex(1. / 3., 0));
                ox = (float) (tz.getReal());
                oy = (float) (tz.getImaginary());
                oc64data[it.oIndex] = ox;
                oc64data[it.oIndex + 1] = oy;
            }
        } else {
            while (it.hasNext()) {
                final double ix = it.aDouble;
                final double iy = da.getElementDoubleAbs(it.aIndex + 1);
                Complex tz;
                float ox;
                float oy;
                tz = new Complex(ix, iy).pow(new Complex(1. / 3., 0));
                ox = (float) (tz.getReal());
                oy = (float) (tz.getImaginary());
                oc64data[it.oIndex] = ox;
                oc64data[it.oIndex + 1] = oy;
            }
        }
        break;
    case Dataset.COMPLEX128:
        final double[] oc128data = ((ComplexDoubleDataset) result).data;
        if (da.getElementsPerItem() == 1) {
            final double iy = 0;
            while (it.hasNext()) {
                final double ix = it.aDouble;
                Complex tz;
                double ox;
                double oy;
                tz = new Complex(ix, iy).pow(new Complex(1. / 3., 0));
                ox = (tz.getReal());
                oy = (tz.getImaginary());
                oc128data[it.oIndex] = ox;
                oc128data[it.oIndex + 1] = oy;
            }
        } else {
            while (it.hasNext()) {
                final double ix = it.aDouble;
                final double iy = da.getElementDoubleAbs(it.aIndex + 1);
                Complex tz;
                double ox;
                double oy;
                tz = new Complex(ix, iy).pow(new Complex(1. / 3., 0));
                ox = (tz.getReal());
                oy = (tz.getImaginary());
                oc128data[it.oIndex] = ox;
                oc128data[it.oIndex + 1] = oy;
            }
        }
        break;
    default:
        throw new IllegalArgumentException(
                "cbrt supports integer, compound integer, real, compound real, complex datasets only");
    }

    addFunctionName(result, "cbrt");
    return result;
}

From source file:org.eclipse.dataset.Maths.java

/**
 * cbrt - evaluate the cube root function on each element of the dataset
 * @param a//from ww w .ja  v a  2  s  . c o m
 * @param o output can be null - in which case, a new dataset is created
 * @return dataset
 */
public static Dataset cbrt(final Object a, final Dataset o) {
    final Dataset da = a instanceof Dataset ? (Dataset) a : DatasetFactory.createFromObject(a);
    final SingleInputBroadcastIterator it = new SingleInputBroadcastIterator(da, o, true);
    final Dataset result = it.getOutput();
    final int is = result.getElementsPerItem();
    final int dt = result.getDtype();

    switch (dt) {
    case Dataset.INT8:
        final byte[] oi8data = ((ByteDataset) result).data;
        if (it.isOutputDouble()) {
            while (it.hasNext()) {
                final double ix = it.aDouble;
                byte ox;
                ox = (byte) toLong(Math.cbrt(ix));
                oi8data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                byte ox;
                ox = (byte) toLong(Math.cbrt(ix));
                oi8data[it.oIndex] = ox;
            }
        }
        break;
    case Dataset.INT16:
        final short[] oi16data = ((ShortDataset) result).data;
        if (it.isOutputDouble()) {
            while (it.hasNext()) {
                final double ix = it.aDouble;
                short ox;
                ox = (short) toLong(Math.cbrt(ix));
                oi16data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                short ox;
                ox = (short) toLong(Math.cbrt(ix));
                oi16data[it.oIndex] = ox;
            }
        }
        break;
    case Dataset.INT64:
        final long[] oi64data = ((LongDataset) result).data;
        if (it.isOutputDouble()) {
            while (it.hasNext()) {
                final double ix = it.aDouble;
                long ox;
                ox = toLong(Math.cbrt(ix));
                oi64data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                long ox;
                ox = toLong(Math.cbrt(ix));
                oi64data[it.oIndex] = ox;
            }
        }
        break;
    case Dataset.INT32:
        final int[] oi32data = ((IntegerDataset) result).data;
        if (it.isOutputDouble()) {
            while (it.hasNext()) {
                final double ix = it.aDouble;
                int ox;
                ox = (int) toLong(Math.cbrt(ix));
                oi32data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                int ox;
                ox = (int) toLong(Math.cbrt(ix));
                oi32data[it.oIndex] = ox;
            }
        }
        break;
    case Dataset.ARRAYINT8:
        final byte[] oai8data = ((CompoundByteDataset) result).data;
        if (is == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    byte ox;
                    ox = (byte) toLong(Math.cbrt(ix));
                    oai8data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    byte ox;
                    ox = (byte) toLong(Math.cbrt(ix));
                    oai8data[it.oIndex] = ox;
                }
            }
        } else if (da.getElementsPerItem() == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    byte ox;
                    ox = (byte) toLong(Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oai8data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    byte ox;
                    ox = (byte) toLong(Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oai8data[it.oIndex + j] = ox;
                    }
                }
            }
        } else {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final double ix = da.getElementDoubleAbs(it.aIndex + j);
                        byte ox;
                        ox = (byte) toLong(Math.cbrt(ix));
                        oai8data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final long ix = da.getElementLongAbs(it.aIndex + j);
                        byte ox;
                        ox = (byte) toLong(Math.cbrt(ix));
                        oai8data[it.oIndex + j] = ox;
                    }
                }
            }
        }
        break;
    case Dataset.ARRAYINT16:
        final short[] oai16data = ((CompoundShortDataset) result).data;
        if (is == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    short ox;
                    ox = (short) toLong(Math.cbrt(ix));
                    oai16data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    short ox;
                    ox = (short) toLong(Math.cbrt(ix));
                    oai16data[it.oIndex] = ox;
                }
            }
        } else if (da.getElementsPerItem() == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    short ox;
                    ox = (short) toLong(Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oai16data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    short ox;
                    ox = (short) toLong(Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oai16data[it.oIndex + j] = ox;
                    }
                }
            }
        } else {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final double ix = da.getElementDoubleAbs(it.aIndex + j);
                        short ox;
                        ox = (short) toLong(Math.cbrt(ix));
                        oai16data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final long ix = da.getElementLongAbs(it.aIndex + j);
                        short ox;
                        ox = (short) toLong(Math.cbrt(ix));
                        oai16data[it.oIndex + j] = ox;
                    }
                }
            }
        }
        break;
    case Dataset.ARRAYINT64:
        final long[] oai64data = ((CompoundLongDataset) result).data;
        if (is == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    long ox;
                    ox = toLong(Math.cbrt(ix));
                    oai64data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    long ox;
                    ox = toLong(Math.cbrt(ix));
                    oai64data[it.oIndex] = ox;
                }
            }
        } else if (da.getElementsPerItem() == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    long ox;
                    ox = toLong(Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oai64data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    long ox;
                    ox = toLong(Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oai64data[it.oIndex + j] = ox;
                    }
                }
            }
        } else {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final double ix = da.getElementDoubleAbs(it.aIndex + j);
                        long ox;
                        ox = toLong(Math.cbrt(ix));
                        oai64data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final long ix = da.getElementLongAbs(it.aIndex + j);
                        long ox;
                        ox = toLong(Math.cbrt(ix));
                        oai64data[it.oIndex + j] = ox;
                    }
                }
            }
        }
        break;
    case Dataset.ARRAYINT32:
        final int[] oai32data = ((CompoundIntegerDataset) result).data;
        if (is == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    int ox;
                    ox = (int) toLong(Math.cbrt(ix));
                    oai32data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    int ox;
                    ox = (int) toLong(Math.cbrt(ix));
                    oai32data[it.oIndex] = ox;
                }
            }
        } else if (da.getElementsPerItem() == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    int ox;
                    ox = (int) toLong(Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oai32data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    int ox;
                    ox = (int) toLong(Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oai32data[it.oIndex + j] = ox;
                    }
                }
            }
        } else {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final double ix = da.getElementDoubleAbs(it.aIndex + j);
                        int ox;
                        ox = (int) toLong(Math.cbrt(ix));
                        oai32data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final long ix = da.getElementLongAbs(it.aIndex + j);
                        int ox;
                        ox = (int) toLong(Math.cbrt(ix));
                        oai32data[it.oIndex + j] = ox;
                    }
                }
            }
        }
        break;
    case Dataset.FLOAT32:
        final float[] of32data = ((FloatDataset) result).data;
        if (it.isOutputDouble()) {
            while (it.hasNext()) {
                final double ix = it.aDouble;
                float ox;
                ox = (float) (Math.cbrt(ix));
                of32data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                float ox;
                ox = (float) (Math.cbrt(ix));
                of32data[it.oIndex] = ox;
            }
        }
        break;
    case Dataset.FLOAT64:
        final double[] of64data = ((DoubleDataset) result).data;
        if (it.isOutputDouble()) {
            while (it.hasNext()) {
                final double ix = it.aDouble;
                double ox;
                ox = (Math.cbrt(ix));
                of64data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                double ox;
                ox = (Math.cbrt(ix));
                of64data[it.oIndex] = ox;
            }
        }
        break;
    case Dataset.ARRAYFLOAT32:
        final float[] oaf32data = ((CompoundFloatDataset) result).data;
        if (is == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    float ox;
                    ox = (float) (Math.cbrt(ix));
                    oaf32data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    float ox;
                    ox = (float) (Math.cbrt(ix));
                    oaf32data[it.oIndex] = ox;
                }
            }
        } else if (da.getElementsPerItem() == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    float ox;
                    ox = (float) (Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oaf32data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    float ox;
                    ox = (float) (Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oaf32data[it.oIndex + j] = ox;
                    }
                }
            }
        } else {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final double ix = da.getElementDoubleAbs(it.aIndex + j);
                        float ox;
                        ox = (float) (Math.cbrt(ix));
                        oaf32data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final long ix = da.getElementLongAbs(it.aIndex + j);
                        float ox;
                        ox = (float) (Math.cbrt(ix));
                        oaf32data[it.oIndex + j] = ox;
                    }
                }
            }
        }
        break;
    case Dataset.ARRAYFLOAT64:
        final double[] oaf64data = ((CompoundDoubleDataset) result).data;
        if (is == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    double ox;
                    ox = (Math.cbrt(ix));
                    oaf64data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    double ox;
                    ox = (Math.cbrt(ix));
                    oaf64data[it.oIndex] = ox;
                }
            }
        } else if (da.getElementsPerItem() == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    double ox;
                    ox = (Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oaf64data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    double ox;
                    ox = (Math.cbrt(ix));
                    for (int j = 0; j < is; j++) {
                        oaf64data[it.oIndex + j] = ox;
                    }
                }
            }
        } else {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final double ix = da.getElementDoubleAbs(it.aIndex + j);
                        double ox;
                        ox = (Math.cbrt(ix));
                        oaf64data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    for (int j = 0; j < is; j++) {
                        final long ix = da.getElementLongAbs(it.aIndex + j);
                        double ox;
                        ox = (Math.cbrt(ix));
                        oaf64data[it.oIndex + j] = ox;
                    }
                }
            }
        }
        break;
    case Dataset.COMPLEX64:
        final float[] oc64data = ((ComplexFloatDataset) result).data;
        if (da.getElementsPerItem() == 1) {
            final double iy = 0;
            while (it.hasNext()) {
                final double ix = it.aDouble;
                Complex tz;
                float ox;
                float oy;
                tz = new Complex(ix, iy).pow(new Complex(1. / 3., 0));
                ox = (float) (tz.getReal());
                oy = (float) (tz.getImaginary());
                oc64data[it.oIndex] = ox;
                oc64data[it.oIndex + 1] = oy;
            }
        } else {
            while (it.hasNext()) {
                final double ix = it.aDouble;
                final double iy = da.getElementDoubleAbs(it.aIndex + 1);
                Complex tz;
                float ox;
                float oy;
                tz = new Complex(ix, iy).pow(new Complex(1. / 3., 0));
                ox = (float) (tz.getReal());
                oy = (float) (tz.getImaginary());
                oc64data[it.oIndex] = ox;
                oc64data[it.oIndex + 1] = oy;
            }
        }
        break;
    case Dataset.COMPLEX128:
        final double[] oc128data = ((ComplexDoubleDataset) result).data;
        if (da.getElementsPerItem() == 1) {
            final double iy = 0;
            while (it.hasNext()) {
                final double ix = it.aDouble;
                Complex tz;
                double ox;
                double oy;
                tz = new Complex(ix, iy).pow(new Complex(1. / 3., 0));
                ox = (tz.getReal());
                oy = (tz.getImaginary());
                oc128data[it.oIndex] = ox;
                oc128data[it.oIndex + 1] = oy;
            }
        } else {
            while (it.hasNext()) {
                final double ix = it.aDouble;
                final double iy = da.getElementDoubleAbs(it.aIndex + 1);
                Complex tz;
                double ox;
                double oy;
                tz = new Complex(ix, iy).pow(new Complex(1. / 3., 0));
                ox = (tz.getReal());
                oy = (tz.getImaginary());
                oc128data[it.oIndex] = ox;
                oc128data[it.oIndex + 1] = oy;
            }
        }
        break;
    default:
        throw new IllegalArgumentException(
                "cbrt supports integer, compound integer, real, compound real, complex datasets only");
    }

    addFunctionName(result, "cbrt");
    return result;
}