Example usage for org.apache.commons.math3.complex Complex getImaginary

List of usage examples for org.apache.commons.math3.complex Complex getImaginary

Introduction

In this page you can find the example usage for org.apache.commons.math3.complex Complex getImaginary.

Prototype

public double getImaginary() 

Source Link

Document

Access the imaginary part.

Usage

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

/**
 * arcsinh - evaluate the inverse hyperbolic sine function on each element of the dataset
 * @param a// w  w  w .j av a  2  s  .com
 * @param o output can be null - in which case, a new dataset is created
 * @return dataset
 */
public static Dataset arcsinh(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.log(ix + Math.sqrt(ix * ix + 1)));
                oi8data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                byte ox;
                ox = (byte) toLong(Math.log(ix + Math.sqrt(ix * ix + 1)));
                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.log(ix + Math.sqrt(ix * ix + 1)));
                oi16data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                short ox;
                ox = (short) toLong(Math.log(ix + Math.sqrt(ix * ix + 1)));
                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.log(ix + Math.sqrt(ix * ix + 1)));
                oi64data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                long ox;
                ox = toLong(Math.log(ix + Math.sqrt(ix * ix + 1)));
                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.log(ix + Math.sqrt(ix * ix + 1)));
                oi32data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                int ox;
                ox = (int) toLong(Math.log(ix + Math.sqrt(ix * ix + 1)));
                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.log(ix + Math.sqrt(ix * ix + 1)));
                    oai8data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    byte ox;
                    ox = (byte) toLong(Math.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                        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.log(ix + Math.sqrt(ix * ix + 1)));
                        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.log(ix + Math.sqrt(ix * ix + 1)));
                    oai16data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    short ox;
                    ox = (short) toLong(Math.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                        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.log(ix + Math.sqrt(ix * ix + 1)));
                        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.log(ix + Math.sqrt(ix * ix + 1)));
                    oai64data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    long ox;
                    ox = toLong(Math.log(ix + Math.sqrt(ix * ix + 1)));
                    oai64data[it.oIndex] = ox;
                }
            }
        } else if (as == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    long ox;
                    ox = toLong(Math.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                        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.log(ix + Math.sqrt(ix * ix + 1)));
                        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.log(ix + Math.sqrt(ix * ix + 1)));
                    oai32data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    int ox;
                    ox = (int) toLong(Math.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                        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.log(ix + Math.sqrt(ix * ix + 1)));
                        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.log(ix + Math.sqrt(ix * ix + 1)));
                of32data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                float ox;
                ox = (float) (Math.log(ix + Math.sqrt(ix * ix + 1)));
                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.log(ix + Math.sqrt(ix * ix + 1)));
                of64data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                double ox;
                ox = (Math.log(ix + Math.sqrt(ix * ix + 1)));
                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.log(ix + Math.sqrt(ix * ix + 1)));
                    oaf32data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    float ox;
                    ox = (float) (Math.log(ix + Math.sqrt(ix * ix + 1)));
                    oaf32data[it.oIndex] = ox;
                }
            }
        } else if (as == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    float ox;
                    ox = (float) (Math.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                        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.log(ix + Math.sqrt(ix * ix + 1)));
                        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.log(ix + Math.sqrt(ix * ix + 1)));
                    oaf64data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    double ox;
                    ox = (Math.log(ix + Math.sqrt(ix * ix + 1)));
                    oaf64data[it.oIndex] = ox;
                }
            }
        } else if (as == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    double ox;
                    ox = (Math.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                        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.log(ix + Math.sqrt(ix * ix + 1)));
                        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(-iy, ix).asin();
                ox = (float) (tz.getImaginary());
                oy = (float) (-tz.getReal());
                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(-iy, ix).asin();
                ox = (float) (tz.getImaginary());
                oy = (float) (-tz.getReal());
                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(-iy, ix).asin();
                ox = (tz.getImaginary());
                oy = (-tz.getReal());
                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(-iy, ix).asin();
                ox = (tz.getImaginary());
                oy = (-tz.getReal());
                oc128data[it.oIndex] = ox;
                oc128data[it.oIndex + 1] = oy;
            }
        }
        break;
    default:
        throw new IllegalArgumentException(
                "arcsinh supports integer, compound integer, real, compound real, complex datasets only");
    }

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

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

/**
 * arccosh - evaluate the inverse hyperbolic cosine function on each element of the dataset
 * @param a/*w  w  w  .  jav a 2  s .  co m*/
 * @param o output can be null - in which case, a new dataset is created
 * @return dataset
 */
public static Dataset arccosh(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.log(ix + Math.sqrt(ix * ix - 1)));
                oi8data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                byte ox;
                ox = (byte) toLong(Math.log(ix + Math.sqrt(ix * ix - 1)));
                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.log(ix + Math.sqrt(ix * ix - 1)));
                oi16data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                short ox;
                ox = (short) toLong(Math.log(ix + Math.sqrt(ix * ix - 1)));
                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.log(ix + Math.sqrt(ix * ix - 1)));
                oi64data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                long ox;
                ox = toLong(Math.log(ix + Math.sqrt(ix * ix - 1)));
                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.log(ix + Math.sqrt(ix * ix - 1)));
                oi32data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                int ox;
                ox = (int) toLong(Math.log(ix + Math.sqrt(ix * ix - 1)));
                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.log(ix + Math.sqrt(ix * ix - 1)));
                    oai8data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    byte ox;
                    ox = (byte) toLong(Math.log(ix + Math.sqrt(ix * ix - 1)));
                    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.log(ix + Math.sqrt(ix * ix - 1)));
                    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.log(ix + Math.sqrt(ix * ix - 1)));
                    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.log(ix + Math.sqrt(ix * ix - 1)));
                        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.log(ix + Math.sqrt(ix * ix - 1)));
                        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.log(ix + Math.sqrt(ix * ix - 1)));
                    oai16data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    short ox;
                    ox = (short) toLong(Math.log(ix + Math.sqrt(ix * ix - 1)));
                    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.log(ix + Math.sqrt(ix * ix - 1)));
                    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.log(ix + Math.sqrt(ix * ix - 1)));
                    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.log(ix + Math.sqrt(ix * ix - 1)));
                        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.log(ix + Math.sqrt(ix * ix - 1)));
                        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.log(ix + Math.sqrt(ix * ix - 1)));
                    oai64data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    long ox;
                    ox = toLong(Math.log(ix + Math.sqrt(ix * ix - 1)));
                    oai64data[it.oIndex] = ox;
                }
            }
        } else if (as == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    long ox;
                    ox = toLong(Math.log(ix + Math.sqrt(ix * ix - 1)));
                    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.log(ix + Math.sqrt(ix * ix - 1)));
                    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.log(ix + Math.sqrt(ix * ix - 1)));
                        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.log(ix + Math.sqrt(ix * ix - 1)));
                        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.log(ix + Math.sqrt(ix * ix - 1)));
                    oai32data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    int ox;
                    ox = (int) toLong(Math.log(ix + Math.sqrt(ix * ix - 1)));
                    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.log(ix + Math.sqrt(ix * ix - 1)));
                    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.log(ix + Math.sqrt(ix * ix - 1)));
                    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.log(ix + Math.sqrt(ix * ix - 1)));
                        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.log(ix + Math.sqrt(ix * ix - 1)));
                        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.log(ix + Math.sqrt(ix * ix - 1)));
                of32data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                float ox;
                ox = (float) (Math.log(ix + Math.sqrt(ix * ix - 1)));
                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.log(ix + Math.sqrt(ix * ix - 1)));
                of64data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                double ox;
                ox = (Math.log(ix + Math.sqrt(ix * ix - 1)));
                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.log(ix + Math.sqrt(ix * ix - 1)));
                    oaf32data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    float ox;
                    ox = (float) (Math.log(ix + Math.sqrt(ix * ix - 1)));
                    oaf32data[it.oIndex] = ox;
                }
            }
        } else if (as == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    float ox;
                    ox = (float) (Math.log(ix + Math.sqrt(ix * ix - 1)));
                    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.log(ix + Math.sqrt(ix * ix - 1)));
                    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.log(ix + Math.sqrt(ix * ix - 1)));
                        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.log(ix + Math.sqrt(ix * ix - 1)));
                        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.log(ix + Math.sqrt(ix * ix - 1)));
                    oaf64data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    double ox;
                    ox = (Math.log(ix + Math.sqrt(ix * ix - 1)));
                    oaf64data[it.oIndex] = ox;
                }
            }
        } else if (as == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    double ox;
                    ox = (Math.log(ix + Math.sqrt(ix * ix - 1)));
                    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.log(ix + Math.sqrt(ix * ix - 1)));
                    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.log(ix + Math.sqrt(ix * ix - 1)));
                        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.log(ix + Math.sqrt(ix * ix - 1)));
                        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(-iy, ix).acos();
                ox = (float) (tz.getImaginary());
                oy = (float) (-tz.getReal());
                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(-iy, ix).acos();
                ox = (float) (tz.getImaginary());
                oy = (float) (-tz.getReal());
                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(-iy, ix).acos();
                ox = (tz.getImaginary());
                oy = (-tz.getReal());
                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(-iy, ix).acos();
                ox = (tz.getImaginary());
                oy = (-tz.getReal());
                oc128data[it.oIndex] = ox;
                oc128data[it.oIndex + 1] = oy;
            }
        }
        break;
    default:
        throw new IllegalArgumentException(
                "arccosh supports integer, compound integer, real, compound real, complex datasets only");
    }

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

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

/**
 * arctanh - evaluate the inverse hyperbolic tangent function on each element of the dataset
 * @param a//from   w  ww.ja  va2  s.  c om
 * @param o output can be null - in which case, a new dataset is created
 * @return dataset
 */
public static Dataset arctanh(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(0.5 * Math.log((1 + ix) / (1 - ix)));
                oi8data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                byte ox;
                ox = (byte) toLong(0.5 * Math.log((1 + ix) / (1 - 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(0.5 * Math.log((1 + ix) / (1 - ix)));
                oi16data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                short ox;
                ox = (short) toLong(0.5 * Math.log((1 + ix) / (1 - 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(0.5 * Math.log((1 + ix) / (1 - ix)));
                oi64data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                long ox;
                ox = toLong(0.5 * Math.log((1 + ix) / (1 - 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(0.5 * Math.log((1 + ix) / (1 - ix)));
                oi32data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                int ox;
                ox = (int) toLong(0.5 * Math.log((1 + ix) / (1 - 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(0.5 * Math.log((1 + ix) / (1 - ix)));
                    oai8data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    byte ox;
                    ox = (byte) toLong(0.5 * Math.log((1 + ix) / (1 - 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(0.5 * Math.log((1 + ix) / (1 - 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(0.5 * Math.log((1 + ix) / (1 - 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(0.5 * Math.log((1 + ix) / (1 - 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(0.5 * Math.log((1 + ix) / (1 - 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(0.5 * Math.log((1 + ix) / (1 - ix)));
                    oai16data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    short ox;
                    ox = (short) toLong(0.5 * Math.log((1 + ix) / (1 - 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(0.5 * Math.log((1 + ix) / (1 - 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(0.5 * Math.log((1 + ix) / (1 - 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(0.5 * Math.log((1 + ix) / (1 - 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(0.5 * Math.log((1 + ix) / (1 - 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(0.5 * Math.log((1 + ix) / (1 - ix)));
                    oai64data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    long ox;
                    ox = toLong(0.5 * Math.log((1 + ix) / (1 - ix)));
                    oai64data[it.oIndex] = ox;
                }
            }
        } else if (as == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    long ox;
                    ox = toLong(0.5 * Math.log((1 + ix) / (1 - 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(0.5 * Math.log((1 + ix) / (1 - 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(0.5 * Math.log((1 + ix) / (1 - 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(0.5 * Math.log((1 + ix) / (1 - 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(0.5 * Math.log((1 + ix) / (1 - ix)));
                    oai32data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    int ox;
                    ox = (int) toLong(0.5 * Math.log((1 + ix) / (1 - 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(0.5 * Math.log((1 + ix) / (1 - 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(0.5 * Math.log((1 + ix) / (1 - 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(0.5 * Math.log((1 + ix) / (1 - 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(0.5 * Math.log((1 + ix) / (1 - 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) (0.5 * Math.log((1 + ix) / (1 - ix)));
                of32data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                float ox;
                ox = (float) (0.5 * Math.log((1 + ix) / (1 - 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 = (0.5 * Math.log((1 + ix) / (1 - ix)));
                of64data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                double ox;
                ox = (0.5 * Math.log((1 + ix) / (1 - 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) (0.5 * Math.log((1 + ix) / (1 - ix)));
                    oaf32data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    float ox;
                    ox = (float) (0.5 * Math.log((1 + ix) / (1 - ix)));
                    oaf32data[it.oIndex] = ox;
                }
            }
        } else if (as == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    float ox;
                    ox = (float) (0.5 * Math.log((1 + ix) / (1 - 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) (0.5 * Math.log((1 + ix) / (1 - 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) (0.5 * Math.log((1 + ix) / (1 - 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) (0.5 * Math.log((1 + ix) / (1 - 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 = (0.5 * Math.log((1 + ix) / (1 - ix)));
                    oaf64data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    double ox;
                    ox = (0.5 * Math.log((1 + ix) / (1 - ix)));
                    oaf64data[it.oIndex] = ox;
                }
            }
        } else if (as == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    double ox;
                    ox = (0.5 * Math.log((1 + ix) / (1 - 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 = (0.5 * Math.log((1 + ix) / (1 - 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 = (0.5 * Math.log((1 + ix) / (1 - 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 = (0.5 * Math.log((1 + ix) / (1 - 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(-iy, ix).atan();
                ox = (float) (tz.getImaginary());
                oy = (float) (-tz.getReal());
                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(-iy, ix).atan();
                ox = (float) (tz.getImaginary());
                oy = (float) (-tz.getReal());
                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(-iy, ix).atan();
                ox = (tz.getImaginary());
                oy = (-tz.getReal());
                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(-iy, ix).atan();
                ox = (tz.getImaginary());
                oy = (-tz.getReal());
                oc128data[it.oIndex] = ox;
                oc128data[it.oIndex + 1] = oy;
            }
        }
        break;
    default:
        throw new IllegalArgumentException(
                "arctanh supports integer, compound integer, real, compound real, complex datasets only");
    }

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

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

/**
 * sqrt - evaluate the square root function on each element of the dataset
 * @param a/*  ww  w  .  j a va  2s  .  c  om*/
 * @param o output can be null - in which case, a new dataset is created
 * @return dataset
 */
public static Dataset sqrt(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.sqrt(ix));
                oi8data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                byte ox;
                ox = (byte) toLong(Math.sqrt(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.sqrt(ix));
                oi16data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                short ox;
                ox = (short) toLong(Math.sqrt(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.sqrt(ix));
                oi64data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                long ox;
                ox = toLong(Math.sqrt(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.sqrt(ix));
                oi32data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                int ox;
                ox = (int) toLong(Math.sqrt(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.sqrt(ix));
                    oai8data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    byte ox;
                    ox = (byte) toLong(Math.sqrt(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.sqrt(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.sqrt(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.sqrt(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.sqrt(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.sqrt(ix));
                    oai16data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    short ox;
                    ox = (short) toLong(Math.sqrt(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.sqrt(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.sqrt(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.sqrt(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.sqrt(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.sqrt(ix));
                    oai64data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    long ox;
                    ox = toLong(Math.sqrt(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.sqrt(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.sqrt(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.sqrt(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.sqrt(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.sqrt(ix));
                    oai32data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    int ox;
                    ox = (int) toLong(Math.sqrt(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.sqrt(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.sqrt(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.sqrt(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.sqrt(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.sqrt(ix));
                of32data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                float ox;
                ox = (float) (Math.sqrt(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.sqrt(ix));
                of64data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                double ox;
                ox = (Math.sqrt(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.sqrt(ix));
                    oaf32data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    float ox;
                    ox = (float) (Math.sqrt(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.sqrt(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.sqrt(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.sqrt(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.sqrt(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.sqrt(ix));
                    oaf64data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    double ox;
                    ox = (Math.sqrt(ix));
                    oaf64data[it.oIndex] = ox;
                }
            }
        } else if (as == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    double ox;
                    ox = (Math.sqrt(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.sqrt(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.sqrt(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.sqrt(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).sqrt();
                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).sqrt();
                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).sqrt();
                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).sqrt();
                ox = (tz.getReal());
                oy = (tz.getImaginary());
                oc128data[it.oIndex] = ox;
                oc128data[it.oIndex + 1] = oy;
            }
        }
        break;
    default:
        throw new IllegalArgumentException(
                "sqrt supports integer, compound integer, real, compound real, complex datasets only");
    }

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

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 .  ja v a2 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 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

/**
 * power operator/*from   w w w  . j  av a 2s .com*/
 * @param a
 * @param b
 * @param o output can be null - in which case, a new dataset is created
 * @return a ** b, raise a to power of b
 */
public static Dataset power(final Object a, final Object b, final Dataset o) {
    final Dataset da = a instanceof Dataset ? (Dataset) a : DatasetFactory.createFromObject(a);
    final Dataset db = b instanceof Dataset ? (Dataset) b : DatasetFactory.createFromObject(b);
    final BroadcastIterator it = BroadcastIterator.createIterator(da, db, 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 iax = it.aDouble;
                final double ibx = it.bDouble;
                byte ox;
                ox = (byte) toLong(Math.pow(iax, ibx));
                oi8data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long iax = it.aLong;
                final long ibx = it.bLong;
                byte ox;
                ox = (byte) toLong(Math.pow(iax, ibx));
                oi8data[it.oIndex] = ox;
            }
        }
        break;
    case Dataset.INT16:
        final short[] oi16data = ((ShortDataset) result).data;
        if (it.isOutputDouble()) {
            while (it.hasNext()) {
                final double iax = it.aDouble;
                final double ibx = it.bDouble;
                short ox;
                ox = (short) toLong(Math.pow(iax, ibx));
                oi16data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long iax = it.aLong;
                final long ibx = it.bLong;
                short ox;
                ox = (short) toLong(Math.pow(iax, ibx));
                oi16data[it.oIndex] = ox;
            }
        }
        break;
    case Dataset.INT64:
        final long[] oi64data = ((LongDataset) result).data;
        if (it.isOutputDouble()) {
            while (it.hasNext()) {
                final double iax = it.aDouble;
                final double ibx = it.bDouble;
                long ox;
                ox = toLong(Math.pow(iax, ibx));
                oi64data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long iax = it.aLong;
                final long ibx = it.bLong;
                long ox;
                ox = toLong(Math.pow(iax, ibx));
                oi64data[it.oIndex] = ox;
            }
        }
        break;
    case Dataset.INT32:
        final int[] oi32data = ((IntegerDataset) result).data;
        if (it.isOutputDouble()) {
            while (it.hasNext()) {
                final double iax = it.aDouble;
                final double ibx = it.bDouble;
                int ox;
                ox = (int) toLong(Math.pow(iax, ibx));
                oi32data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long iax = it.aLong;
                final long ibx = it.bLong;
                int ox;
                ox = (int) toLong(Math.pow(iax, ibx));
                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 iax = it.aDouble;
                    final double ibx = it.bDouble;
                    byte ox;
                    ox = (byte) toLong(Math.pow(iax, ibx));
                    oai8data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long iax = it.aLong;
                    final long ibx = it.bLong;
                    byte ox;
                    ox = (byte) toLong(Math.pow(iax, ibx));
                    oai8data[it.oIndex] = ox;
                }
            }
        } else if (da.getElementsPerItem() == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double iax = it.aDouble;
                    double ibx = it.bDouble;
                    byte ox;
                    ox = (byte) toLong(Math.pow(iax, ibx));
                    oai8data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        ibx = db.getElementDoubleAbs(it.bIndex + j);
                        ox = (byte) toLong(Math.pow(iax, ibx));
                        oai8data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    final long iax = it.aLong;
                    long ibx = it.bLong;
                    byte ox;
                    ox = (byte) toLong(Math.pow(iax, ibx));
                    oai8data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        ibx = db.getElementLongAbs(it.bIndex + j);
                        ox = (byte) toLong(Math.pow(iax, ibx));
                        oai8data[it.oIndex + j] = ox;
                    }
                }
            }
        } else if (db.getElementsPerItem() == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    double iax = it.aDouble;
                    final double ibx = it.bDouble;
                    byte ox;
                    ox = (byte) toLong(Math.pow(iax, ibx));
                    oai8data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        iax = da.getElementDoubleAbs(it.aIndex + j);
                        ox = (byte) toLong(Math.pow(iax, ibx));
                        oai8data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    long iax = it.aLong;
                    final long ibx = it.bLong;
                    byte ox;
                    ox = (byte) toLong(Math.pow(iax, ibx));
                    oai8data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        iax = da.getElementLongAbs(it.aIndex + j);
                        ox = (byte) toLong(Math.pow(iax, ibx));
                        oai8data[it.oIndex + j] = ox;
                    }
                }
            }
        } else {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    double iax = it.aDouble;
                    double ibx = it.bDouble;
                    byte ox;
                    ox = (byte) toLong(Math.pow(iax, ibx));
                    oai8data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        iax = da.getElementDoubleAbs(it.aIndex + j);
                        ibx = db.getElementDoubleAbs(it.bIndex + j);
                        ox = (byte) toLong(Math.pow(iax, ibx));
                        oai8data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    long iax = it.aLong;
                    long ibx = it.bLong;
                    byte ox;
                    ox = (byte) toLong(Math.pow(iax, ibx));
                    oai8data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        iax = da.getElementLongAbs(it.aIndex + j);
                        ibx = db.getElementLongAbs(it.bIndex + j);
                        ox = (byte) toLong(Math.pow(iax, ibx));
                        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 iax = it.aDouble;
                    final double ibx = it.bDouble;
                    short ox;
                    ox = (short) toLong(Math.pow(iax, ibx));
                    oai16data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long iax = it.aLong;
                    final long ibx = it.bLong;
                    short ox;
                    ox = (short) toLong(Math.pow(iax, ibx));
                    oai16data[it.oIndex] = ox;
                }
            }
        } else if (da.getElementsPerItem() == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double iax = it.aDouble;
                    double ibx = it.bDouble;
                    short ox;
                    ox = (short) toLong(Math.pow(iax, ibx));
                    oai16data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        ibx = db.getElementDoubleAbs(it.bIndex + j);
                        ox = (short) toLong(Math.pow(iax, ibx));
                        oai16data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    final long iax = it.aLong;
                    long ibx = it.bLong;
                    short ox;
                    ox = (short) toLong(Math.pow(iax, ibx));
                    oai16data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        ibx = db.getElementLongAbs(it.bIndex + j);
                        ox = (short) toLong(Math.pow(iax, ibx));
                        oai16data[it.oIndex + j] = ox;
                    }
                }
            }
        } else if (db.getElementsPerItem() == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    double iax = it.aDouble;
                    final double ibx = it.bDouble;
                    short ox;
                    ox = (short) toLong(Math.pow(iax, ibx));
                    oai16data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        iax = da.getElementDoubleAbs(it.aIndex + j);
                        ox = (short) toLong(Math.pow(iax, ibx));
                        oai16data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    long iax = it.aLong;
                    final long ibx = it.bLong;
                    short ox;
                    ox = (short) toLong(Math.pow(iax, ibx));
                    oai16data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        iax = da.getElementLongAbs(it.aIndex + j);
                        ox = (short) toLong(Math.pow(iax, ibx));
                        oai16data[it.oIndex + j] = ox;
                    }
                }
            }
        } else {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    double iax = it.aDouble;
                    double ibx = it.bDouble;
                    short ox;
                    ox = (short) toLong(Math.pow(iax, ibx));
                    oai16data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        iax = da.getElementDoubleAbs(it.aIndex + j);
                        ibx = db.getElementDoubleAbs(it.bIndex + j);
                        ox = (short) toLong(Math.pow(iax, ibx));
                        oai16data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    long iax = it.aLong;
                    long ibx = it.bLong;
                    short ox;
                    ox = (short) toLong(Math.pow(iax, ibx));
                    oai16data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        iax = da.getElementLongAbs(it.aIndex + j);
                        ibx = db.getElementLongAbs(it.bIndex + j);
                        ox = (short) toLong(Math.pow(iax, ibx));
                        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 iax = it.aDouble;
                    final double ibx = it.bDouble;
                    long ox;
                    ox = toLong(Math.pow(iax, ibx));
                    oai64data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long iax = it.aLong;
                    final long ibx = it.bLong;
                    long ox;
                    ox = toLong(Math.pow(iax, ibx));
                    oai64data[it.oIndex] = ox;
                }
            }
        } else if (da.getElementsPerItem() == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double iax = it.aDouble;
                    double ibx = it.bDouble;
                    long ox;
                    ox = toLong(Math.pow(iax, ibx));
                    oai64data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        ibx = db.getElementDoubleAbs(it.bIndex + j);
                        ox = toLong(Math.pow(iax, ibx));
                        oai64data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    final long iax = it.aLong;
                    long ibx = it.bLong;
                    long ox;
                    ox = toLong(Math.pow(iax, ibx));
                    oai64data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        ibx = db.getElementLongAbs(it.bIndex + j);
                        ox = toLong(Math.pow(iax, ibx));
                        oai64data[it.oIndex + j] = ox;
                    }
                }
            }
        } else if (db.getElementsPerItem() == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    double iax = it.aDouble;
                    final double ibx = it.bDouble;
                    long ox;
                    ox = toLong(Math.pow(iax, ibx));
                    oai64data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        iax = da.getElementDoubleAbs(it.aIndex + j);
                        ox = toLong(Math.pow(iax, ibx));
                        oai64data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    long iax = it.aLong;
                    final long ibx = it.bLong;
                    long ox;
                    ox = toLong(Math.pow(iax, ibx));
                    oai64data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        iax = da.getElementLongAbs(it.aIndex + j);
                        ox = toLong(Math.pow(iax, ibx));
                        oai64data[it.oIndex + j] = ox;
                    }
                }
            }
        } else {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    double iax = it.aDouble;
                    double ibx = it.bDouble;
                    long ox;
                    ox = toLong(Math.pow(iax, ibx));
                    oai64data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        iax = da.getElementDoubleAbs(it.aIndex + j);
                        ibx = db.getElementDoubleAbs(it.bIndex + j);
                        ox = toLong(Math.pow(iax, ibx));
                        oai64data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    long iax = it.aLong;
                    long ibx = it.bLong;
                    long ox;
                    ox = toLong(Math.pow(iax, ibx));
                    oai64data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        iax = da.getElementLongAbs(it.aIndex + j);
                        ibx = db.getElementLongAbs(it.bIndex + j);
                        ox = toLong(Math.pow(iax, ibx));
                        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 iax = it.aDouble;
                    final double ibx = it.bDouble;
                    int ox;
                    ox = (int) toLong(Math.pow(iax, ibx));
                    oai32data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long iax = it.aLong;
                    final long ibx = it.bLong;
                    int ox;
                    ox = (int) toLong(Math.pow(iax, ibx));
                    oai32data[it.oIndex] = ox;
                }
            }
        } else if (da.getElementsPerItem() == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double iax = it.aDouble;
                    double ibx = it.bDouble;
                    int ox;
                    ox = (int) toLong(Math.pow(iax, ibx));
                    oai32data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        ibx = db.getElementDoubleAbs(it.bIndex + j);
                        ox = (int) toLong(Math.pow(iax, ibx));
                        oai32data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    final long iax = it.aLong;
                    long ibx = it.bLong;
                    int ox;
                    ox = (int) toLong(Math.pow(iax, ibx));
                    oai32data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        ibx = db.getElementLongAbs(it.bIndex + j);
                        ox = (int) toLong(Math.pow(iax, ibx));
                        oai32data[it.oIndex + j] = ox;
                    }
                }
            }
        } else if (db.getElementsPerItem() == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    double iax = it.aDouble;
                    final double ibx = it.bDouble;
                    int ox;
                    ox = (int) toLong(Math.pow(iax, ibx));
                    oai32data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        iax = da.getElementDoubleAbs(it.aIndex + j);
                        ox = (int) toLong(Math.pow(iax, ibx));
                        oai32data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    long iax = it.aLong;
                    final long ibx = it.bLong;
                    int ox;
                    ox = (int) toLong(Math.pow(iax, ibx));
                    oai32data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        iax = da.getElementLongAbs(it.aIndex + j);
                        ox = (int) toLong(Math.pow(iax, ibx));
                        oai32data[it.oIndex + j] = ox;
                    }
                }
            }
        } else {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    double iax = it.aDouble;
                    double ibx = it.bDouble;
                    int ox;
                    ox = (int) toLong(Math.pow(iax, ibx));
                    oai32data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        iax = da.getElementDoubleAbs(it.aIndex + j);
                        ibx = db.getElementDoubleAbs(it.bIndex + j);
                        ox = (int) toLong(Math.pow(iax, ibx));
                        oai32data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    long iax = it.aLong;
                    long ibx = it.bLong;
                    int ox;
                    ox = (int) toLong(Math.pow(iax, ibx));
                    oai32data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        iax = da.getElementLongAbs(it.aIndex + j);
                        ibx = db.getElementLongAbs(it.bIndex + j);
                        ox = (int) toLong(Math.pow(iax, ibx));
                        oai32data[it.oIndex + j] = ox;
                    }
                }
            }
        }
        break;
    case Dataset.FLOAT32:
        final float[] of32data = ((FloatDataset) result).data;
        if (it.isOutputDouble()) {
            while (it.hasNext()) {
                final double iax = it.aDouble;
                final double ibx = it.bDouble;
                float ox;
                ox = (float) (Math.pow(iax, ibx));
                of32data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long iax = it.aLong;
                final long ibx = it.bLong;
                float ox;
                ox = (float) (Math.pow(iax, ibx));
                of32data[it.oIndex] = ox;
            }
        }
        break;
    case Dataset.FLOAT64:
        final double[] of64data = ((DoubleDataset) result).data;
        if (it.isOutputDouble()) {
            while (it.hasNext()) {
                final double iax = it.aDouble;
                final double ibx = it.bDouble;
                double ox;
                ox = (Math.pow(iax, ibx));
                of64data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long iax = it.aLong;
                final long ibx = it.bLong;
                double ox;
                ox = (Math.pow(iax, ibx));
                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 iax = it.aDouble;
                    final double ibx = it.bDouble;
                    float ox;
                    ox = (float) (Math.pow(iax, ibx));
                    oaf32data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long iax = it.aLong;
                    final long ibx = it.bLong;
                    float ox;
                    ox = (float) (Math.pow(iax, ibx));
                    oaf32data[it.oIndex] = ox;
                }
            }
        } else if (da.getElementsPerItem() == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double iax = it.aDouble;
                    double ibx = it.bDouble;
                    float ox;
                    ox = (float) (Math.pow(iax, ibx));
                    oaf32data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        ibx = db.getElementDoubleAbs(it.bIndex + j);
                        ox = (float) (Math.pow(iax, ibx));
                        oaf32data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    final long iax = it.aLong;
                    long ibx = it.bLong;
                    float ox;
                    ox = (float) (Math.pow(iax, ibx));
                    oaf32data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        ibx = db.getElementLongAbs(it.bIndex + j);
                        ox = (float) (Math.pow(iax, ibx));
                        oaf32data[it.oIndex + j] = ox;
                    }
                }
            }
        } else if (db.getElementsPerItem() == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    double iax = it.aDouble;
                    final double ibx = it.bDouble;
                    float ox;
                    ox = (float) (Math.pow(iax, ibx));
                    oaf32data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        iax = da.getElementDoubleAbs(it.aIndex + j);
                        ox = (float) (Math.pow(iax, ibx));
                        oaf32data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    long iax = it.aLong;
                    final long ibx = it.bLong;
                    float ox;
                    ox = (float) (Math.pow(iax, ibx));
                    oaf32data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        iax = da.getElementLongAbs(it.aIndex + j);
                        ox = (float) (Math.pow(iax, ibx));
                        oaf32data[it.oIndex + j] = ox;
                    }
                }
            }
        } else {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    double iax = it.aDouble;
                    double ibx = it.bDouble;
                    float ox;
                    ox = (float) (Math.pow(iax, ibx));
                    oaf32data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        iax = da.getElementDoubleAbs(it.aIndex + j);
                        ibx = db.getElementDoubleAbs(it.bIndex + j);
                        ox = (float) (Math.pow(iax, ibx));
                        oaf32data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    long iax = it.aLong;
                    long ibx = it.bLong;
                    float ox;
                    ox = (float) (Math.pow(iax, ibx));
                    oaf32data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        iax = da.getElementLongAbs(it.aIndex + j);
                        ibx = db.getElementLongAbs(it.bIndex + j);
                        ox = (float) (Math.pow(iax, ibx));
                        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 iax = it.aDouble;
                    final double ibx = it.bDouble;
                    double ox;
                    ox = (Math.pow(iax, ibx));
                    oaf64data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long iax = it.aLong;
                    final long ibx = it.bLong;
                    double ox;
                    ox = (Math.pow(iax, ibx));
                    oaf64data[it.oIndex] = ox;
                }
            }
        } else if (da.getElementsPerItem() == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double iax = it.aDouble;
                    double ibx = it.bDouble;
                    double ox;
                    ox = (Math.pow(iax, ibx));
                    oaf64data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        ibx = db.getElementDoubleAbs(it.bIndex + j);
                        ox = (Math.pow(iax, ibx));
                        oaf64data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    final long iax = it.aLong;
                    long ibx = it.bLong;
                    double ox;
                    ox = (Math.pow(iax, ibx));
                    oaf64data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        ibx = db.getElementLongAbs(it.bIndex + j);
                        ox = (Math.pow(iax, ibx));
                        oaf64data[it.oIndex + j] = ox;
                    }
                }
            }
        } else if (db.getElementsPerItem() == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    double iax = it.aDouble;
                    final double ibx = it.bDouble;
                    double ox;
                    ox = (Math.pow(iax, ibx));
                    oaf64data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        iax = da.getElementDoubleAbs(it.aIndex + j);
                        ox = (Math.pow(iax, ibx));
                        oaf64data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    long iax = it.aLong;
                    final long ibx = it.bLong;
                    double ox;
                    ox = (Math.pow(iax, ibx));
                    oaf64data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        iax = da.getElementLongAbs(it.aIndex + j);
                        ox = (Math.pow(iax, ibx));
                        oaf64data[it.oIndex + j] = ox;
                    }
                }
            }
        } else {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    double iax = it.aDouble;
                    double ibx = it.bDouble;
                    double ox;
                    ox = (Math.pow(iax, ibx));
                    oaf64data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        iax = da.getElementDoubleAbs(it.aIndex + j);
                        ibx = db.getElementDoubleAbs(it.bIndex + j);
                        ox = (Math.pow(iax, ibx));
                        oaf64data[it.oIndex + j] = ox;
                    }
                }
            } else {
                while (it.hasNext()) {
                    long iax = it.aLong;
                    long ibx = it.bLong;
                    double ox;
                    ox = (Math.pow(iax, ibx));
                    oaf64data[it.oIndex] = ox;
                    for (int j = 1; j < is; j++) {
                        iax = da.getElementLongAbs(it.aIndex + j);
                        ibx = db.getElementLongAbs(it.bIndex + j);
                        ox = (Math.pow(iax, ibx));
                        oaf64data[it.oIndex + j] = ox;
                    }
                }
            }
        }
        break;
    case Dataset.COMPLEX64:
        final float[] oc64data = ((ComplexFloatDataset) result).data;
        if (da.getElementsPerItem() == 1) {
            final double iay = 0;
            while (it.hasNext()) {
                final double iax = it.aDouble;
                final double ibx = it.bDouble;
                final double iby = db.getElementDoubleAbs(it.bIndex + 1);
                Complex tz;
                float ox;
                float oy;
                tz = new Complex(iax, iay).pow(new Complex(ibx, iby));
                ox = (float) (tz.getReal());
                oy = (float) (tz.getImaginary());
                oc64data[it.oIndex] = ox;
                oc64data[it.oIndex + 1] = oy;
            }
        } else if (db.getElementsPerItem() == 1) {
            final double iby = 0;
            while (it.hasNext()) {
                final double iax = it.aDouble;
                final double ibx = it.bDouble;
                final double iay = da.getElementDoubleAbs(it.aIndex + 1);
                Complex tz;
                float ox;
                float oy;
                tz = new Complex(iax, iay).pow(new Complex(ibx, iby));
                ox = (float) (tz.getReal());
                oy = (float) (tz.getImaginary());
                oc64data[it.oIndex] = ox;
                oc64data[it.oIndex + 1] = oy;
            }
        } else {
            while (it.hasNext()) {
                final double iax = it.aDouble;
                final double ibx = it.bDouble;
                final double iay = da.getElementDoubleAbs(it.aIndex + 1);
                final double iby = db.getElementDoubleAbs(it.bIndex + 1);
                Complex tz;
                float ox;
                float oy;
                tz = new Complex(iax, iay).pow(new Complex(ibx, iby));
                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 iay = 0;
            while (it.hasNext()) {
                final double iax = it.aDouble;
                final double ibx = it.bDouble;
                final double iby = db.getElementDoubleAbs(it.bIndex + 1);
                Complex tz;
                double ox;
                double oy;
                tz = new Complex(iax, iay).pow(new Complex(ibx, iby));
                ox = (tz.getReal());
                oy = (tz.getImaginary());
                oc128data[it.oIndex] = ox;
                oc128data[it.oIndex + 1] = oy;
            }
        } else if (db.getElementsPerItem() == 1) {
            final double iby = 0;
            while (it.hasNext()) {
                final double iax = it.aDouble;
                final double ibx = it.bDouble;
                final double iay = da.getElementDoubleAbs(it.aIndex + 1);
                Complex tz;
                double ox;
                double oy;
                tz = new Complex(iax, iay).pow(new Complex(ibx, iby));
                ox = (tz.getReal());
                oy = (tz.getImaginary());
                oc128data[it.oIndex] = ox;
                oc128data[it.oIndex + 1] = oy;
            }
        } else {
            while (it.hasNext()) {
                final double iax = it.aDouble;
                final double ibx = it.bDouble;
                final double iay = da.getElementDoubleAbs(it.aIndex + 1);
                final double iby = db.getElementDoubleAbs(it.bIndex + 1);
                Complex tz;
                double ox;
                double oy;
                tz = new Complex(iax, iay).pow(new Complex(ibx, iby));
                ox = (tz.getReal());
                oy = (tz.getImaginary());
                oc128data[it.oIndex] = ox;
                oc128data[it.oIndex + 1] = oy;
            }
        }
        break;
    default:
        throw new IllegalArgumentException(
                "power supports integer, compound integer, real, compound real, complex datasets only");
    }

    addBinaryOperatorName(da, db, result, "**");
    return result;
}

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

/**
 * arcsin - evaluate the inverse sine function on each element of the dataset
 * @param a/*from  www.java  2  s  .c  o  m*/
 * @param o output can be null - in which case, a new dataset is created
 * @return dataset
 */
public static Dataset arcsin(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.asin(ix));
                oi8data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                byte ox;
                ox = (byte) toLong(Math.asin(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.asin(ix));
                oi16data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                short ox;
                ox = (short) toLong(Math.asin(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.asin(ix));
                oi64data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                long ox;
                ox = toLong(Math.asin(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.asin(ix));
                oi32data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                int ox;
                ox = (int) toLong(Math.asin(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.asin(ix));
                    oai8data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    byte ox;
                    ox = (byte) toLong(Math.asin(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.asin(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.asin(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.asin(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.asin(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.asin(ix));
                    oai16data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    short ox;
                    ox = (short) toLong(Math.asin(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.asin(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.asin(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.asin(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.asin(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.asin(ix));
                    oai64data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    long ox;
                    ox = toLong(Math.asin(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.asin(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.asin(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.asin(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.asin(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.asin(ix));
                    oai32data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    int ox;
                    ox = (int) toLong(Math.asin(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.asin(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.asin(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.asin(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.asin(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.asin(ix));
                of32data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                float ox;
                ox = (float) (Math.asin(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.asin(ix));
                of64data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                double ox;
                ox = (Math.asin(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.asin(ix));
                    oaf32data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    float ox;
                    ox = (float) (Math.asin(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.asin(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.asin(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.asin(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.asin(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.asin(ix));
                    oaf64data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    double ox;
                    ox = (Math.asin(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.asin(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.asin(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.asin(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.asin(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).asin();
                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).asin();
                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).asin();
                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).asin();
                ox = (tz.getReal());
                oy = (tz.getImaginary());
                oc128data[it.oIndex] = ox;
                oc128data[it.oIndex + 1] = oy;
            }
        }
        break;
    default:
        throw new IllegalArgumentException(
                "arcsin supports integer, compound integer, real, compound real, complex datasets only");
    }

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

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

/**
 * arccos - evaluate the inverse cosine function on each element of the dataset
 * @param a/*from   www  .j  av  a2  s  . c  o m*/
 * @param o output can be null - in which case, a new dataset is created
 * @return dataset
 */
public static Dataset arccos(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.acos(ix));
                oi8data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                byte ox;
                ox = (byte) toLong(Math.acos(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.acos(ix));
                oi16data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                short ox;
                ox = (short) toLong(Math.acos(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.acos(ix));
                oi64data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                long ox;
                ox = toLong(Math.acos(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.acos(ix));
                oi32data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                int ox;
                ox = (int) toLong(Math.acos(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.acos(ix));
                    oai8data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    byte ox;
                    ox = (byte) toLong(Math.acos(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.acos(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.acos(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.acos(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.acos(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.acos(ix));
                    oai16data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    short ox;
                    ox = (short) toLong(Math.acos(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.acos(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.acos(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.acos(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.acos(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.acos(ix));
                    oai64data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    long ox;
                    ox = toLong(Math.acos(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.acos(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.acos(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.acos(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.acos(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.acos(ix));
                    oai32data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    int ox;
                    ox = (int) toLong(Math.acos(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.acos(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.acos(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.acos(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.acos(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.acos(ix));
                of32data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                float ox;
                ox = (float) (Math.acos(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.acos(ix));
                of64data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                double ox;
                ox = (Math.acos(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.acos(ix));
                    oaf32data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    float ox;
                    ox = (float) (Math.acos(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.acos(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.acos(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.acos(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.acos(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.acos(ix));
                    oaf64data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    double ox;
                    ox = (Math.acos(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.acos(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.acos(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.acos(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.acos(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).acos();
                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).acos();
                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).acos();
                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).acos();
                ox = (tz.getReal());
                oy = (tz.getImaginary());
                oc128data[it.oIndex] = ox;
                oc128data[it.oIndex + 1] = oy;
            }
        }
        break;
    default:
        throw new IllegalArgumentException(
                "arccos supports integer, compound integer, real, compound real, complex datasets only");
    }

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

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

/**
 * arctan - evaluate the inverse tangent function on each element of the dataset
 * @param a/*from   w  w  w.ja  v  a2  s. c  o m*/
 * @param o output can be null - in which case, a new dataset is created
 * @return dataset
 */
public static Dataset arctan(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.atan(ix));
                oi8data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                byte ox;
                ox = (byte) toLong(Math.atan(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.atan(ix));
                oi16data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                short ox;
                ox = (short) toLong(Math.atan(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.atan(ix));
                oi64data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                long ox;
                ox = toLong(Math.atan(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.atan(ix));
                oi32data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                int ox;
                ox = (int) toLong(Math.atan(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.atan(ix));
                    oai8data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    byte ox;
                    ox = (byte) toLong(Math.atan(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.atan(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.atan(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.atan(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.atan(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.atan(ix));
                    oai16data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    short ox;
                    ox = (short) toLong(Math.atan(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.atan(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.atan(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.atan(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.atan(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.atan(ix));
                    oai64data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    long ox;
                    ox = toLong(Math.atan(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.atan(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.atan(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.atan(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.atan(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.atan(ix));
                    oai32data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    int ox;
                    ox = (int) toLong(Math.atan(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.atan(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.atan(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.atan(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.atan(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.atan(ix));
                of32data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                float ox;
                ox = (float) (Math.atan(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.atan(ix));
                of64data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                double ox;
                ox = (Math.atan(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.atan(ix));
                    oaf32data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    float ox;
                    ox = (float) (Math.atan(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.atan(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.atan(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.atan(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.atan(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.atan(ix));
                    oaf64data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    double ox;
                    ox = (Math.atan(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.atan(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.atan(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.atan(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.atan(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).atan();
                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).atan();
                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).atan();
                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).atan();
                ox = (tz.getReal());
                oy = (tz.getImaginary());
                oc128data[it.oIndex] = ox;
                oc128data[it.oIndex + 1] = oy;
            }
        }
        break;
    default:
        throw new IllegalArgumentException(
                "arctan supports integer, compound integer, real, compound real, complex datasets only");
    }

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

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

/**
 * arcsinh - evaluate the inverse hyperbolic sine function on each element of the dataset
 * @param a/*w w w .j  av  a2s  .co  m*/
 * @param o output can be null - in which case, a new dataset is created
 * @return dataset
 */
public static Dataset arcsinh(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.log(ix + Math.sqrt(ix * ix + 1)));
                oi8data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                byte ox;
                ox = (byte) toLong(Math.log(ix + Math.sqrt(ix * ix + 1)));
                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.log(ix + Math.sqrt(ix * ix + 1)));
                oi16data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                short ox;
                ox = (short) toLong(Math.log(ix + Math.sqrt(ix * ix + 1)));
                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.log(ix + Math.sqrt(ix * ix + 1)));
                oi64data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                long ox;
                ox = toLong(Math.log(ix + Math.sqrt(ix * ix + 1)));
                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.log(ix + Math.sqrt(ix * ix + 1)));
                oi32data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                int ox;
                ox = (int) toLong(Math.log(ix + Math.sqrt(ix * ix + 1)));
                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.log(ix + Math.sqrt(ix * ix + 1)));
                    oai8data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    byte ox;
                    ox = (byte) toLong(Math.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                        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.log(ix + Math.sqrt(ix * ix + 1)));
                        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.log(ix + Math.sqrt(ix * ix + 1)));
                    oai16data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    short ox;
                    ox = (short) toLong(Math.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                        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.log(ix + Math.sqrt(ix * ix + 1)));
                        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.log(ix + Math.sqrt(ix * ix + 1)));
                    oai64data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    long ox;
                    ox = toLong(Math.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                        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.log(ix + Math.sqrt(ix * ix + 1)));
                        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.log(ix + Math.sqrt(ix * ix + 1)));
                    oai32data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    int ox;
                    ox = (int) toLong(Math.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                        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.log(ix + Math.sqrt(ix * ix + 1)));
                        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.log(ix + Math.sqrt(ix * ix + 1)));
                of32data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                float ox;
                ox = (float) (Math.log(ix + Math.sqrt(ix * ix + 1)));
                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.log(ix + Math.sqrt(ix * ix + 1)));
                of64data[it.oIndex] = ox;
            }
        } else {
            while (it.hasNext()) {
                final long ix = it.aLong;
                double ox;
                ox = (Math.log(ix + Math.sqrt(ix * ix + 1)));
                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.log(ix + Math.sqrt(ix * ix + 1)));
                    oaf32data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    float ox;
                    ox = (float) (Math.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                        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.log(ix + Math.sqrt(ix * ix + 1)));
                        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.log(ix + Math.sqrt(ix * ix + 1)));
                    oaf64data[it.oIndex] = ox;
                }
            } else {
                while (it.hasNext()) {
                    final long ix = it.aLong;
                    double ox;
                    ox = (Math.log(ix + Math.sqrt(ix * ix + 1)));
                    oaf64data[it.oIndex] = ox;
                }
            }
        } else if (da.getElementsPerItem() == 1) {
            if (it.isOutputDouble()) {
                while (it.hasNext()) {
                    final double ix = it.aDouble;
                    double ox;
                    ox = (Math.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                    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.log(ix + Math.sqrt(ix * ix + 1)));
                        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.log(ix + Math.sqrt(ix * ix + 1)));
                        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(-iy, ix).asin();
                ox = (float) (tz.getImaginary());
                oy = (float) (-tz.getReal());
                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(-iy, ix).asin();
                ox = (float) (tz.getImaginary());
                oy = (float) (-tz.getReal());
                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(-iy, ix).asin();
                ox = (tz.getImaginary());
                oy = (-tz.getReal());
                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(-iy, ix).asin();
                ox = (tz.getImaginary());
                oy = (-tz.getReal());
                oc128data[it.oIndex] = ox;
                oc128data[it.oIndex + 1] = oy;
            }
        }
        break;
    default:
        throw new IllegalArgumentException(
                "arcsinh supports integer, compound integer, real, compound real, complex datasets only");
    }

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