List of usage examples for org.apache.commons.math3.complex Complex getImaginary
public double getImaginary()
From source file:org.eclipse.dataset.Maths.java
/** * cbrt - evaluate the cube root function on each element of the dataset * @param a//from w ww. j a va 2 s . co m * @param o output can be null - in which case, a new dataset is created * @return dataset */ public static Dataset cbrt(final Object a, final Dataset o) { final Dataset da = a instanceof Dataset ? (Dataset) a : DatasetFactory.createFromObject(a); final SingleInputBroadcastIterator it = new SingleInputBroadcastIterator(da, o, true); final Dataset result = it.getOutput(); final int is = result.getElementsPerItem(); final int dt = result.getDtype(); switch (dt) { case Dataset.INT8: final byte[] oi8data = ((ByteDataset) result).data; if (it.isOutputDouble()) { while (it.hasNext()) { final double ix = it.aDouble; byte ox; ox = (byte) toLong(Math.cbrt(ix)); oi8data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; byte ox; ox = (byte) toLong(Math.cbrt(ix)); oi8data[it.oIndex] = ox; } } break; case Dataset.INT16: final short[] oi16data = ((ShortDataset) result).data; if (it.isOutputDouble()) { while (it.hasNext()) { final double ix = it.aDouble; short ox; ox = (short) toLong(Math.cbrt(ix)); oi16data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; short ox; ox = (short) toLong(Math.cbrt(ix)); oi16data[it.oIndex] = ox; } } break; case Dataset.INT64: final long[] oi64data = ((LongDataset) result).data; if (it.isOutputDouble()) { while (it.hasNext()) { final double ix = it.aDouble; long ox; ox = toLong(Math.cbrt(ix)); oi64data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; long ox; ox = toLong(Math.cbrt(ix)); oi64data[it.oIndex] = ox; } } break; case Dataset.INT32: final int[] oi32data = ((IntegerDataset) result).data; if (it.isOutputDouble()) { while (it.hasNext()) { final double ix = it.aDouble; int ox; ox = (int) toLong(Math.cbrt(ix)); oi32data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; int ox; ox = (int) toLong(Math.cbrt(ix)); oi32data[it.oIndex] = ox; } } break; case Dataset.ARRAYINT8: final byte[] oai8data = ((CompoundByteDataset) result).data; if (is == 1) { if (it.isOutputDouble()) { while (it.hasNext()) { final double ix = it.aDouble; byte ox; ox = (byte) toLong(Math.cbrt(ix)); oai8data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; byte ox; ox = (byte) toLong(Math.cbrt(ix)); oai8data[it.oIndex] = ox; } } } else if (da.getElementsPerItem() == 1) { if (it.isOutputDouble()) { while (it.hasNext()) { final double ix = it.aDouble; byte ox; ox = (byte) toLong(Math.cbrt(ix)); for (int j = 0; j < is; j++) { oai8data[it.oIndex + j] = ox; } } } else { while (it.hasNext()) { final long ix = it.aLong; byte ox; ox = (byte) toLong(Math.cbrt(ix)); for (int j = 0; j < is; j++) { oai8data[it.oIndex + j] = ox; } } } } else { if (it.isOutputDouble()) { while (it.hasNext()) { for (int j = 0; j < is; j++) { final double ix = da.getElementDoubleAbs(it.aIndex + j); byte ox; ox = (byte) toLong(Math.cbrt(ix)); oai8data[it.oIndex + j] = ox; } } } else { while (it.hasNext()) { for (int j = 0; j < is; j++) { final long ix = da.getElementLongAbs(it.aIndex + j); byte ox; ox = (byte) toLong(Math.cbrt(ix)); oai8data[it.oIndex + j] = ox; } } } } break; case Dataset.ARRAYINT16: final short[] oai16data = ((CompoundShortDataset) result).data; if (is == 1) { if (it.isOutputDouble()) { while (it.hasNext()) { final double ix = it.aDouble; short ox; ox = (short) toLong(Math.cbrt(ix)); oai16data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; short ox; ox = (short) toLong(Math.cbrt(ix)); oai16data[it.oIndex] = ox; } } } else if (da.getElementsPerItem() == 1) { if (it.isOutputDouble()) { while (it.hasNext()) { final double ix = it.aDouble; short ox; ox = (short) toLong(Math.cbrt(ix)); for (int j = 0; j < is; j++) { oai16data[it.oIndex + j] = ox; } } } else { while (it.hasNext()) { final long ix = it.aLong; short ox; ox = (short) toLong(Math.cbrt(ix)); for (int j = 0; j < is; j++) { oai16data[it.oIndex + j] = ox; } } } } else { if (it.isOutputDouble()) { while (it.hasNext()) { for (int j = 0; j < is; j++) { final double ix = da.getElementDoubleAbs(it.aIndex + j); short ox; ox = (short) toLong(Math.cbrt(ix)); oai16data[it.oIndex + j] = ox; } } } else { while (it.hasNext()) { for (int j = 0; j < is; j++) { final long ix = da.getElementLongAbs(it.aIndex + j); short ox; ox = (short) toLong(Math.cbrt(ix)); oai16data[it.oIndex + j] = ox; } } } } break; case Dataset.ARRAYINT64: final long[] oai64data = ((CompoundLongDataset) result).data; if (is == 1) { if (it.isOutputDouble()) { while (it.hasNext()) { final double ix = it.aDouble; long ox; ox = toLong(Math.cbrt(ix)); oai64data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; long ox; ox = toLong(Math.cbrt(ix)); oai64data[it.oIndex] = ox; } } } else if (da.getElementsPerItem() == 1) { if (it.isOutputDouble()) { while (it.hasNext()) { final double ix = it.aDouble; long ox; ox = toLong(Math.cbrt(ix)); for (int j = 0; j < is; j++) { oai64data[it.oIndex + j] = ox; } } } else { while (it.hasNext()) { final long ix = it.aLong; long ox; ox = toLong(Math.cbrt(ix)); for (int j = 0; j < is; j++) { oai64data[it.oIndex + j] = ox; } } } } else { if (it.isOutputDouble()) { while (it.hasNext()) { for (int j = 0; j < is; j++) { final double ix = da.getElementDoubleAbs(it.aIndex + j); long ox; ox = toLong(Math.cbrt(ix)); oai64data[it.oIndex + j] = ox; } } } else { while (it.hasNext()) { for (int j = 0; j < is; j++) { final long ix = da.getElementLongAbs(it.aIndex + j); long ox; ox = toLong(Math.cbrt(ix)); oai64data[it.oIndex + j] = ox; } } } } break; case Dataset.ARRAYINT32: final int[] oai32data = ((CompoundIntegerDataset) result).data; if (is == 1) { if (it.isOutputDouble()) { while (it.hasNext()) { final double ix = it.aDouble; int ox; ox = (int) toLong(Math.cbrt(ix)); oai32data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; int ox; ox = (int) toLong(Math.cbrt(ix)); oai32data[it.oIndex] = ox; } } } else if (da.getElementsPerItem() == 1) { if (it.isOutputDouble()) { while (it.hasNext()) { final double ix = it.aDouble; int ox; ox = (int) toLong(Math.cbrt(ix)); for (int j = 0; j < is; j++) { oai32data[it.oIndex + j] = ox; } } } else { while (it.hasNext()) { final long ix = it.aLong; int ox; ox = (int) toLong(Math.cbrt(ix)); for (int j = 0; j < is; j++) { oai32data[it.oIndex + j] = ox; } } } } else { if (it.isOutputDouble()) { while (it.hasNext()) { for (int j = 0; j < is; j++) { final double ix = da.getElementDoubleAbs(it.aIndex + j); int ox; ox = (int) toLong(Math.cbrt(ix)); oai32data[it.oIndex + j] = ox; } } } else { while (it.hasNext()) { for (int j = 0; j < is; j++) { final long ix = da.getElementLongAbs(it.aIndex + j); int ox; ox = (int) toLong(Math.cbrt(ix)); oai32data[it.oIndex + j] = ox; } } } } break; case Dataset.FLOAT32: final float[] of32data = ((FloatDataset) result).data; if (it.isOutputDouble()) { while (it.hasNext()) { final double ix = it.aDouble; float ox; ox = (float) (Math.cbrt(ix)); of32data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; float ox; ox = (float) (Math.cbrt(ix)); of32data[it.oIndex] = ox; } } break; case Dataset.FLOAT64: final double[] of64data = ((DoubleDataset) result).data; if (it.isOutputDouble()) { while (it.hasNext()) { final double ix = it.aDouble; double ox; ox = (Math.cbrt(ix)); of64data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; double ox; ox = (Math.cbrt(ix)); of64data[it.oIndex] = ox; } } break; case Dataset.ARRAYFLOAT32: final float[] oaf32data = ((CompoundFloatDataset) result).data; if (is == 1) { if (it.isOutputDouble()) { while (it.hasNext()) { final double ix = it.aDouble; float ox; ox = (float) (Math.cbrt(ix)); oaf32data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; float ox; ox = (float) (Math.cbrt(ix)); oaf32data[it.oIndex] = ox; } } } else if (da.getElementsPerItem() == 1) { if (it.isOutputDouble()) { while (it.hasNext()) { final double ix = it.aDouble; float ox; ox = (float) (Math.cbrt(ix)); for (int j = 0; j < is; j++) { oaf32data[it.oIndex + j] = ox; } } } else { while (it.hasNext()) { final long ix = it.aLong; float ox; ox = (float) (Math.cbrt(ix)); for (int j = 0; j < is; j++) { oaf32data[it.oIndex + j] = ox; } } } } else { if (it.isOutputDouble()) { while (it.hasNext()) { for (int j = 0; j < is; j++) { final double ix = da.getElementDoubleAbs(it.aIndex + j); float ox; ox = (float) (Math.cbrt(ix)); oaf32data[it.oIndex + j] = ox; } } } else { while (it.hasNext()) { for (int j = 0; j < is; j++) { final long ix = da.getElementLongAbs(it.aIndex + j); float ox; ox = (float) (Math.cbrt(ix)); oaf32data[it.oIndex + j] = ox; } } } } break; case Dataset.ARRAYFLOAT64: final double[] oaf64data = ((CompoundDoubleDataset) result).data; if (is == 1) { if (it.isOutputDouble()) { while (it.hasNext()) { final double ix = it.aDouble; double ox; ox = (Math.cbrt(ix)); oaf64data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; double ox; ox = (Math.cbrt(ix)); oaf64data[it.oIndex] = ox; } } } else if (da.getElementsPerItem() == 1) { if (it.isOutputDouble()) { while (it.hasNext()) { final double ix = it.aDouble; double ox; ox = (Math.cbrt(ix)); for (int j = 0; j < is; j++) { oaf64data[it.oIndex + j] = ox; } } } else { while (it.hasNext()) { final long ix = it.aLong; double ox; ox = (Math.cbrt(ix)); for (int j = 0; j < is; j++) { oaf64data[it.oIndex + j] = ox; } } } } else { if (it.isOutputDouble()) { while (it.hasNext()) { for (int j = 0; j < is; j++) { final double ix = da.getElementDoubleAbs(it.aIndex + j); double ox; ox = (Math.cbrt(ix)); oaf64data[it.oIndex + j] = ox; } } } else { while (it.hasNext()) { for (int j = 0; j < is; j++) { final long ix = da.getElementLongAbs(it.aIndex + j); double ox; ox = (Math.cbrt(ix)); oaf64data[it.oIndex + j] = ox; } } } } break; case Dataset.COMPLEX64: final float[] oc64data = ((ComplexFloatDataset) result).data; if (da.getElementsPerItem() == 1) { final double iy = 0; while (it.hasNext()) { final double ix = it.aDouble; Complex tz; float ox; float oy; tz = new Complex(ix, iy).pow(new Complex(1. / 3., 0)); ox = (float) (tz.getReal()); oy = (float) (tz.getImaginary()); oc64data[it.oIndex] = ox; oc64data[it.oIndex + 1] = oy; } } else { while (it.hasNext()) { final double ix = it.aDouble; final double iy = da.getElementDoubleAbs(it.aIndex + 1); Complex tz; float ox; float oy; tz = new Complex(ix, iy).pow(new Complex(1. / 3., 0)); ox = (float) (tz.getReal()); oy = (float) (tz.getImaginary()); oc64data[it.oIndex] = ox; oc64data[it.oIndex + 1] = oy; } } break; case Dataset.COMPLEX128: final double[] oc128data = ((ComplexDoubleDataset) result).data; if (da.getElementsPerItem() == 1) { final double iy = 0; while (it.hasNext()) { final double ix = it.aDouble; Complex tz; double ox; double oy; tz = new Complex(ix, iy).pow(new Complex(1. / 3., 0)); ox = (tz.getReal()); oy = (tz.getImaginary()); oc128data[it.oIndex] = ox; oc128data[it.oIndex + 1] = oy; } } else { while (it.hasNext()) { final double ix = it.aDouble; final double iy = da.getElementDoubleAbs(it.aIndex + 1); Complex tz; double ox; double oy; tz = new Complex(ix, iy).pow(new Complex(1. / 3., 0)); ox = (tz.getReal()); oy = (tz.getImaginary()); oc128data[it.oIndex] = ox; oc128data[it.oIndex + 1] = oy; } } break; default: throw new IllegalArgumentException( "cbrt supports integer, compound integer, real, compound real, complex datasets only"); } addFunctionName(result, "cbrt"); return result; }
From source file:org.eclipse.dawnsci.analysis.examples.dataset.impl.ComplexDoubleDatasetTest.java
@Test public void testGetter() { double[] da = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; ComplexDoubleDataset a = new ComplexDoubleDataset(da); int l = da.length / 2; for (int i = 0; i < l; i++) { assertEquals(2 * i, a.getComplex(i).getReal(), 1e-5 * i); assertEquals(2 * i + 1, a.getComplex(i).getImaginary(), 1e-5 * i); }/*from www . j av a 2 s . com*/ for (int i = 0; i < l; i++) { int r = l - 1 - i; assertEquals(2 * r, a.getComplex(-(i + 1)).getReal(), 1e-5 * i); assertEquals(2 * r + 1, a.getComplex(-(i + 1)).getImaginary(), 1e-5 * i); } ComplexDoubleDataset sv = (ComplexDoubleDataset) a.getSliceView(new Slice(1, 4)); ComplexDoubleDataset sc = (ComplexDoubleDataset) a.getSlice(new Slice(1, 4)); l = sc.getSize(); for (int i = 0; i < l; i++) { Complex r = sc.getComplex(-(i + 1)); Complex q = sv.getComplex(-(i + 1)); assertEquals(r.getReal(), q.getReal(), 1e-5 * r.getReal()); assertEquals(r.getImaginary(), q.getImaginary(), 1e-5 * r.getImaginary()); } }
From source file:org.eclipse.january.dataset.BinaryOperationTest.java
@Test public void testOp() { for (int i = 0, imax = operands.length; i < imax; i++) { Object[] vs = operands[i]; Object ex = expected[i];/*from w ww . jav a2s . co m*/ String s = toString() + Arrays.toString(vs); if (ex instanceof Boolean) { assertEquals(s, ex, operation.booleanOperate((Long) vs[0], (Long) vs[1])); } else if (ex instanceof Long) { assertEquals(s, ex, operation.longOperate((Long) vs[0], (Long) vs[1])); } else if (ex instanceof Double) { TestUtils.assertEquals(s, (Double) ex, operation.doubleOperate((Double) vs[0], (Double) vs[1])); } else if (ex instanceof Complex) { Complex cz = (Complex) ex; double[] cpx = new double[2]; operation.complexOperate(cpx, (Double) vs[0], (Double) vs[1], (Double) vs[2], (Double) vs[3]); TestUtils.assertEquals(s + ": real", cz.getReal(), cpx[0], 1e-14, 7e-17); TestUtils.assertEquals(s + ": imag", cz.getImaginary(), cpx[1]); } } }
From source file:org.eclipse.january.dataset.ComplexDoubleDataset.java
@Override public ComplexDoubleDataset ipower(final Object b) { setDirty();/*from www. j a va2 s . com*/ Dataset bds = b instanceof Dataset ? (Dataset) b : DatasetFactory.createFromObject(b); if (bds.getSize() == 1) { final IndexIterator it = getIterator(); final double r2 = bds.getElementDoubleAbs(0); if (!bds.isComplex() || bds.getElementDoubleAbs(1) == 0) { while (it.hasNext()) { final Complex zd = new Complex(data[it.index], data[it.index + 1]).pow(r2); data[it.index] = zd.getReal(); // ADD_CAST data[it.index + 1] = zd.getImaginary(); // ADD_CAST } } else { final Complex zv = new Complex(r2, bds.getElementDoubleAbs(1)); while (it.hasNext()) { final Complex zd = new Complex(data[it.index], data[it.index + 1]).pow(zv); data[it.index] = zd.getReal(); // ADD_CAST data[it.index + 1] = zd.getImaginary(); // ADD_CAST } } } else { final BroadcastIterator it = BroadcastIterator.createIterator(this, bds); it.setOutputDouble(true); if (bds.isComplex()) { while (it.hasNext()) { final Complex zv = new Complex(it.bDouble, bds.getElementDoubleAbs(it.bIndex + 1)); final Complex zd = new Complex(it.aDouble, data[it.aIndex + 1]).pow(zv); data[it.aIndex] = zd.getReal(); // ADD_CAST data[it.aIndex + 1] = zd.getImaginary(); // ADD_CAST } } else { while (it.hasNext()) { final Complex zd = new Complex(it.aDouble, data[it.aIndex + 1]).pow(it.bDouble); data[it.aIndex] = zd.getReal(); // ADD_CAST data[it.aIndex + 1] = zd.getImaginary(); // ADD_CAST } } } return this; }
From source file:org.eclipse.january.dataset.ComplexFloatDataset.java
@Override public ComplexFloatDataset ipower(final Object b) { setDirty();//w w w .j a v a2 s . com Dataset bds = b instanceof Dataset ? (Dataset) b : DatasetFactory.createFromObject(b); if (bds.getSize() == 1) { final IndexIterator it = getIterator(); final double r2 = bds.getElementDoubleAbs(0); if (!bds.isComplex() || bds.getElementDoubleAbs(1) == 0) { while (it.hasNext()) { final Complex zd = new Complex(data[it.index], data[it.index + 1]).pow(r2); data[it.index] = (float) zd.getReal(); // ADD_CAST data[it.index + 1] = (float) zd.getImaginary(); // ADD_CAST } } else { final Complex zv = new Complex(r2, bds.getElementDoubleAbs(1)); while (it.hasNext()) { final Complex zd = new Complex(data[it.index], data[it.index + 1]).pow(zv); data[it.index] = (float) zd.getReal(); // ADD_CAST data[it.index + 1] = (float) zd.getImaginary(); // ADD_CAST } } } else { final BroadcastIterator it = BroadcastIterator.createIterator(this, bds); it.setOutputDouble(true); if (bds.isComplex()) { while (it.hasNext()) { final Complex zv = new Complex(it.bDouble, bds.getElementDoubleAbs(it.bIndex + 1)); final Complex zd = new Complex(it.aDouble, data[it.aIndex + 1]).pow(zv); data[it.aIndex] = (float) zd.getReal(); // ADD_CAST data[it.aIndex + 1] = (float) zd.getImaginary(); // ADD_CAST } } else { while (it.hasNext()) { final Complex zd = new Complex(it.aDouble, data[it.aIndex + 1]).pow(it.bDouble); data[it.aIndex] = (float) zd.getReal(); // ADD_CAST data[it.aIndex + 1] = (float) zd.getImaginary(); // ADD_CAST } } } return this; }
From source file:org.eclipse.january.dataset.DTypeUtils.java
public static byte[] toByteArray(final Object b, final int itemSize) { byte[] result = null; if (b instanceof Number) { result = new byte[itemSize]; final byte val = ((Number) b).byteValue(); for (int i = 0; i < itemSize; i++) { result[i] = val; }//from w w w . j a va2 s.c o m } else if (b instanceof byte[]) { result = (byte[]) b; if (result.length < itemSize) { result = new byte[itemSize]; int ilen = result.length; for (int i = 0; i < ilen; i++) { result[i] = ((byte[]) b)[i]; } } } else if (b instanceof List<?>) { result = new byte[itemSize]; List<?> jl = (List<?>) b; int ilen = jl.size(); if (ilen > 0 && !(jl.get(0) instanceof Number)) { logger.error("Given array was not of a numerical primitive type"); throw new IllegalArgumentException("Given array was not of a numerical primitive type"); } ilen = Math.min(itemSize, ilen); for (int i = 0; i < ilen; i++) { result[i] = (byte) toLong(jl.get(i)); } } else if (b.getClass().isArray()) { result = new byte[itemSize]; int ilen = Array.getLength(b); if (ilen > 0 && !(Array.get(b, 0) instanceof Number)) { logger.error("Given array was not of a numerical primitive type"); throw new IllegalArgumentException("Given array was not of a numerical primitive type"); } ilen = Math.min(itemSize, ilen); for (int i = 0; i < ilen; i++) { result[i] = (byte) ((Number) Array.get(b, i)).longValue(); } } else if (b instanceof Complex) { if (itemSize > 2) { logger.error("Complex number will not fit in compound dataset"); throw new IllegalArgumentException("Complex number will not fit in compound dataset"); } Complex cb = (Complex) b; switch (itemSize) { default: case 0: break; case 1: result = new byte[] { (byte) cb.getReal() }; break; case 2: result = new byte[] { (byte) cb.getReal(), (byte) cb.getImaginary() }; break; } } else if (b instanceof Dataset) { Dataset db = (Dataset) b; if (db.getSize() != 1) { logger.error("Given dataset must have only one item"); throw new IllegalArgumentException("Given dataset must have only one item"); } return toByteArray(db.getObjectAbs(0), itemSize); } else if (b instanceof IDataset) { IDataset db = (Dataset) b; if (db.getSize() != 1) { logger.error("Given dataset must have only one item"); throw new IllegalArgumentException("Given dataset must have only one item"); } return toByteArray(db.getObject(new int[db.getRank()]), itemSize); } return result; }
From source file:org.eclipse.january.dataset.GeneratedMaths.java
/** * power operator//from ww w.j ava 2 s .c o m * @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 as = da.getElementsPerItem(); final int bs = db.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 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).getData(); 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).getData(); 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).getData(); 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).getData(); 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 (as == 1 || as < bs) { 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 (bs == 1 || as > bs) { 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).getData(); 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 (as == 1 || as < bs) { 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 (bs == 1 || as > bs) { 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).getData(); 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 (as == 1 || as < bs) { 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 (bs == 1 || as > bs) { 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).getData(); 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 (as == 1 || as < bs) { 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 (bs == 1 || as > bs) { 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).getData(); 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).getData(); 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).getData(); 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 (as == 1 || as < bs) { 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 (bs == 1 || as > bs) { 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).getData(); 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 (as == 1 || as < bs) { 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 (bs == 1 || as > bs) { 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).getData(); if (as == 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 (bs == 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).getData(); if (as == 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 (bs == 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.GeneratedMaths.java
/** * arcsin - evaluate the inverse sine function on each element of the dataset * @param a/*from www .j a va 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 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.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).getData(); 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).getData(); 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).getData(); 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).getData(); 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 (as == 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).getData(); 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 (as == 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).getData(); 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 (as == 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).getData(); 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 (as == 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).getData(); 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).getData(); 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).getData(); 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 (as == 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).getData(); 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 (as == 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).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).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).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).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.GeneratedMaths.java
/** * arccos - evaluate the inverse cosine function on each element of the dataset * @param a/* www.jav a 2s. 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 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.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).getData(); 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).getData(); 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).getData(); 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).getData(); 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 (as == 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).getData(); 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 (as == 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).getData(); 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 (as == 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).getData(); 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 (as == 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).getData(); 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).getData(); 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).getData(); 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 (as == 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).getData(); 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 (as == 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).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).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).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).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.GeneratedMaths.java
/** * arctan - evaluate the inverse tangent function on each element of the dataset * @param a//from w w w . j a v a 2 s .c o m * @param o output can be null - in which case, a new dataset is created * @return dataset */ public static Dataset 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 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.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).getData(); 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).getData(); 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).getData(); 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).getData(); 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 (as == 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).getData(); 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 (as == 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).getData(); 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 (as == 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).getData(); 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 (as == 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).getData(); 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).getData(); 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).getData(); 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 (as == 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).getData(); 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 (as == 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).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).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).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).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; }