List of usage examples for java.lang Math sinh
public static double sinh(double x)
From source file:uk.ac.diamond.scisoft.analysis.dataset.Maths.java
/** * cos - evaluate the cosine function on each element of the dataset * @param a/*from w ww . j a v a 2s . com*/ * @return dataset */ @SuppressWarnings("cast") public static AbstractDataset cos(final AbstractDataset a) { final int isize; final IndexIterator it = a.getIterator(); AbstractDataset ds; final int dt = a.getDtype(); switch (dt) { case AbstractDataset.INT8: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT32); final byte[] i8data = ((ByteDataset) a).data; final float[] oi8data = ((FloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { final byte ix = i8data[it.index]; float ox; ox = (float) (Math.cos(ix)); oi8data[i++] = ox; } break; case AbstractDataset.INT16: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT32); final short[] i16data = ((ShortDataset) a).data; final float[] oi16data = ((FloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { final short ix = i16data[it.index]; float ox; ox = (float) (Math.cos(ix)); oi16data[i++] = ox; } break; case AbstractDataset.INT32: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT64); final int[] i32data = ((IntegerDataset) a).data; final double[] oi32data = ((DoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { final int ix = i32data[it.index]; double ox; ox = (double) (Math.cos(ix)); oi32data[i++] = ox; } break; case AbstractDataset.INT64: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT64); final long[] i64data = ((LongDataset) a).data; final double[] oi64data = ((DoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { final long ix = i64data[it.index]; double ox; ox = (double) (Math.cos(ix)); oi64data[i++] = ox; } break; case AbstractDataset.ARRAYINT8: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT32); isize = a.getElementsPerItem(); final byte[] ai8data = ((CompoundByteDataset) a).data; final float[] oai8data = ((CompoundFloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final byte ix = ai8data[it.index + j]; float ox; ox = (float) (Math.cos(ix)); oai8data[i++] = ox; } } break; case AbstractDataset.ARRAYINT16: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT32); isize = a.getElementsPerItem(); final short[] ai16data = ((CompoundShortDataset) a).data; final float[] oai16data = ((CompoundFloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final short ix = ai16data[it.index + j]; float ox; ox = (float) (Math.cos(ix)); oai16data[i++] = ox; } } break; case AbstractDataset.ARRAYINT32: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT64); isize = a.getElementsPerItem(); final int[] ai32data = ((CompoundIntegerDataset) a).data; final double[] oai32data = ((CompoundDoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final int ix = ai32data[it.index + j]; double ox; ox = (double) (Math.cos(ix)); oai32data[i++] = ox; } } break; case AbstractDataset.ARRAYINT64: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT64); isize = a.getElementsPerItem(); final long[] ai64data = ((CompoundLongDataset) a).data; final double[] oai64data = ((CompoundDoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final long ix = ai64data[it.index + j]; double ox; ox = (double) (Math.cos(ix)); oai64data[i++] = ox; } } break; case AbstractDataset.FLOAT32: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT32); final float[] f32data = ((FloatDataset) a).data; final float[] of32data = ((FloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { final float ix = f32data[it.index]; float ox; ox = (float) (Math.cos(ix)); of32data[i++] = ox; } break; case AbstractDataset.FLOAT64: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT64); final double[] f64data = ((DoubleDataset) a).data; final double[] of64data = ((DoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { final double ix = f64data[it.index]; double ox; ox = (double) (Math.cos(ix)); of64data[i++] = ox; } break; case AbstractDataset.ARRAYFLOAT32: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT32); isize = a.getElementsPerItem(); final float[] af32data = ((CompoundFloatDataset) a).data; final float[] oaf32data = ((CompoundFloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final float ix = af32data[it.index + j]; float ox; ox = (float) (Math.cos(ix)); oaf32data[i++] = ox; } } break; case AbstractDataset.ARRAYFLOAT64: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT64); isize = a.getElementsPerItem(); final double[] af64data = ((CompoundDoubleDataset) a).data; final double[] oaf64data = ((CompoundDoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final double ix = af64data[it.index + j]; double ox; ox = (double) (Math.cos(ix)); oaf64data[i++] = ox; } } break; case AbstractDataset.COMPLEX64: ds = AbstractDataset.zeros(a, AbstractDataset.COMPLEX64); final float[] c64data = ((ComplexFloatDataset) a).data; final float[] oc64data = ((ComplexFloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { final float ix = c64data[it.index]; final float iy = c64data[it.index + 1]; float ox; float oy; ox = (float) (Math.cos(ix) * Math.cosh(iy)); oy = (float) (-Math.sin(ix) * Math.sinh(iy)); oc64data[i++] = ox; oc64data[i++] = oy; } break; case AbstractDataset.COMPLEX128: ds = AbstractDataset.zeros(a, AbstractDataset.COMPLEX128); final double[] c128data = ((ComplexDoubleDataset) a).data; final double[] oc128data = ((ComplexDoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { final double ix = c128data[it.index]; final double iy = c128data[it.index + 1]; double ox; double oy; ox = (double) (Math.cos(ix) * Math.cosh(iy)); oy = (double) (-Math.sin(ix) * Math.sinh(iy)); oc128data[i++] = ox; oc128data[i++] = oy; } break; default: throw new IllegalArgumentException( "cos supports integer, compound integer, real, compound real, complex datasets only"); } ds.setName(a.getName()); addFunctionName(ds, "cos"); return ds; }
From source file:uk.ac.diamond.scisoft.analysis.dataset.Maths.java
/** * tan - evaluate the tangent function on each element of the dataset * @param a//w ww.j a v a 2s . c o m * @return dataset */ @SuppressWarnings("cast") public static AbstractDataset tan(final AbstractDataset a) { final int isize; final IndexIterator it = a.getIterator(); AbstractDataset ds; final int dt = a.getDtype(); switch (dt) { case AbstractDataset.INT8: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT32); final byte[] i8data = ((ByteDataset) a).data; final float[] oi8data = ((FloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { final byte ix = i8data[it.index]; float ox; ox = (float) (Math.tan(ix)); oi8data[i++] = ox; } break; case AbstractDataset.INT16: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT32); final short[] i16data = ((ShortDataset) a).data; final float[] oi16data = ((FloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { final short ix = i16data[it.index]; float ox; ox = (float) (Math.tan(ix)); oi16data[i++] = ox; } break; case AbstractDataset.INT32: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT64); final int[] i32data = ((IntegerDataset) a).data; final double[] oi32data = ((DoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { final int ix = i32data[it.index]; double ox; ox = (double) (Math.tan(ix)); oi32data[i++] = ox; } break; case AbstractDataset.INT64: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT64); final long[] i64data = ((LongDataset) a).data; final double[] oi64data = ((DoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { final long ix = i64data[it.index]; double ox; ox = (double) (Math.tan(ix)); oi64data[i++] = ox; } break; case AbstractDataset.ARRAYINT8: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT32); isize = a.getElementsPerItem(); final byte[] ai8data = ((CompoundByteDataset) a).data; final float[] oai8data = ((CompoundFloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final byte ix = ai8data[it.index + j]; float ox; ox = (float) (Math.tan(ix)); oai8data[i++] = ox; } } break; case AbstractDataset.ARRAYINT16: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT32); isize = a.getElementsPerItem(); final short[] ai16data = ((CompoundShortDataset) a).data; final float[] oai16data = ((CompoundFloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final short ix = ai16data[it.index + j]; float ox; ox = (float) (Math.tan(ix)); oai16data[i++] = ox; } } break; case AbstractDataset.ARRAYINT32: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT64); isize = a.getElementsPerItem(); final int[] ai32data = ((CompoundIntegerDataset) a).data; final double[] oai32data = ((CompoundDoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final int ix = ai32data[it.index + j]; double ox; ox = (double) (Math.tan(ix)); oai32data[i++] = ox; } } break; case AbstractDataset.ARRAYINT64: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT64); isize = a.getElementsPerItem(); final long[] ai64data = ((CompoundLongDataset) a).data; final double[] oai64data = ((CompoundDoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final long ix = ai64data[it.index + j]; double ox; ox = (double) (Math.tan(ix)); oai64data[i++] = ox; } } break; case AbstractDataset.FLOAT32: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT32); final float[] f32data = ((FloatDataset) a).data; final float[] of32data = ((FloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { final float ix = f32data[it.index]; float ox; ox = (float) (Math.tan(ix)); of32data[i++] = ox; } break; case AbstractDataset.FLOAT64: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT64); final double[] f64data = ((DoubleDataset) a).data; final double[] of64data = ((DoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { final double ix = f64data[it.index]; double ox; ox = (double) (Math.tan(ix)); of64data[i++] = ox; } break; case AbstractDataset.ARRAYFLOAT32: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT32); isize = a.getElementsPerItem(); final float[] af32data = ((CompoundFloatDataset) a).data; final float[] oaf32data = ((CompoundFloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final float ix = af32data[it.index + j]; float ox; ox = (float) (Math.tan(ix)); oaf32data[i++] = ox; } } break; case AbstractDataset.ARRAYFLOAT64: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT64); isize = a.getElementsPerItem(); final double[] af64data = ((CompoundDoubleDataset) a).data; final double[] oaf64data = ((CompoundDoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final double ix = af64data[it.index + j]; double ox; ox = (double) (Math.tan(ix)); oaf64data[i++] = ox; } } break; case AbstractDataset.COMPLEX64: ds = AbstractDataset.zeros(a, AbstractDataset.COMPLEX64); final float[] c64data = ((ComplexFloatDataset) a).data; final float[] oc64data = ((ComplexFloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { final float ix = c64data[it.index]; final float iy = c64data[it.index + 1]; float x; float y; float tf; float ox; float oy; x = (float) (2. * ix); y = (float) (2. * iy); tf = (float) (1. / (Math.cos(x) + Math.cosh(y))); ox = (float) (tf * Math.sin(x)); oy = (float) (tf * Math.sinh(y)); oc64data[i++] = ox; oc64data[i++] = oy; } break; case AbstractDataset.COMPLEX128: ds = AbstractDataset.zeros(a, AbstractDataset.COMPLEX128); final double[] c128data = ((ComplexDoubleDataset) a).data; final double[] oc128data = ((ComplexDoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { final double ix = c128data[it.index]; final double iy = c128data[it.index + 1]; double x; double y; double tf; double ox; double oy; x = (double) (2. * ix); y = (double) (2. * iy); tf = (double) (1. / (Math.cos(x) + Math.cosh(y))); ox = (double) (tf * Math.sin(x)); oy = (double) (tf * Math.sinh(y)); oc128data[i++] = ox; oc128data[i++] = oy; } break; default: throw new IllegalArgumentException( "tan supports integer, compound integer, real, compound real, complex datasets only"); } ds.setName(a.getName()); addFunctionName(ds, "tan"); return ds; }
From source file:uk.ac.diamond.scisoft.analysis.dataset.Maths.java
/** * sinh - evaluate the hyperbolic sine function on each element of the dataset * @param a/*from ww w. j a va 2s. c o m*/ * @return dataset */ @SuppressWarnings("cast") public static AbstractDataset sinh(final AbstractDataset a) { final int isize; final IndexIterator it = a.getIterator(); AbstractDataset ds; final int dt = a.getDtype(); switch (dt) { case AbstractDataset.INT8: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT32); final byte[] i8data = ((ByteDataset) a).data; final float[] oi8data = ((FloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { final byte ix = i8data[it.index]; float ox; ox = (float) (Math.sinh(ix)); oi8data[i++] = ox; } break; case AbstractDataset.INT16: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT32); final short[] i16data = ((ShortDataset) a).data; final float[] oi16data = ((FloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { final short ix = i16data[it.index]; float ox; ox = (float) (Math.sinh(ix)); oi16data[i++] = ox; } break; case AbstractDataset.INT32: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT64); final int[] i32data = ((IntegerDataset) a).data; final double[] oi32data = ((DoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { final int ix = i32data[it.index]; double ox; ox = (double) (Math.sinh(ix)); oi32data[i++] = ox; } break; case AbstractDataset.INT64: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT64); final long[] i64data = ((LongDataset) a).data; final double[] oi64data = ((DoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { final long ix = i64data[it.index]; double ox; ox = (double) (Math.sinh(ix)); oi64data[i++] = ox; } break; case AbstractDataset.ARRAYINT8: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT32); isize = a.getElementsPerItem(); final byte[] ai8data = ((CompoundByteDataset) a).data; final float[] oai8data = ((CompoundFloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final byte ix = ai8data[it.index + j]; float ox; ox = (float) (Math.sinh(ix)); oai8data[i++] = ox; } } break; case AbstractDataset.ARRAYINT16: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT32); isize = a.getElementsPerItem(); final short[] ai16data = ((CompoundShortDataset) a).data; final float[] oai16data = ((CompoundFloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final short ix = ai16data[it.index + j]; float ox; ox = (float) (Math.sinh(ix)); oai16data[i++] = ox; } } break; case AbstractDataset.ARRAYINT32: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT64); isize = a.getElementsPerItem(); final int[] ai32data = ((CompoundIntegerDataset) a).data; final double[] oai32data = ((CompoundDoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final int ix = ai32data[it.index + j]; double ox; ox = (double) (Math.sinh(ix)); oai32data[i++] = ox; } } break; case AbstractDataset.ARRAYINT64: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT64); isize = a.getElementsPerItem(); final long[] ai64data = ((CompoundLongDataset) a).data; final double[] oai64data = ((CompoundDoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final long ix = ai64data[it.index + j]; double ox; ox = (double) (Math.sinh(ix)); oai64data[i++] = ox; } } break; case AbstractDataset.FLOAT32: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT32); final float[] f32data = ((FloatDataset) a).data; final float[] of32data = ((FloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { final float ix = f32data[it.index]; float ox; ox = (float) (Math.sinh(ix)); of32data[i++] = ox; } break; case AbstractDataset.FLOAT64: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT64); final double[] f64data = ((DoubleDataset) a).data; final double[] of64data = ((DoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { final double ix = f64data[it.index]; double ox; ox = (double) (Math.sinh(ix)); of64data[i++] = ox; } break; case AbstractDataset.ARRAYFLOAT32: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT32); isize = a.getElementsPerItem(); final float[] af32data = ((CompoundFloatDataset) a).data; final float[] oaf32data = ((CompoundFloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final float ix = af32data[it.index + j]; float ox; ox = (float) (Math.sinh(ix)); oaf32data[i++] = ox; } } break; case AbstractDataset.ARRAYFLOAT64: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT64); isize = a.getElementsPerItem(); final double[] af64data = ((CompoundDoubleDataset) a).data; final double[] oaf64data = ((CompoundDoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final double ix = af64data[it.index + j]; double ox; ox = (double) (Math.sinh(ix)); oaf64data[i++] = ox; } } break; case AbstractDataset.COMPLEX64: ds = AbstractDataset.zeros(a, AbstractDataset.COMPLEX64); final float[] c64data = ((ComplexFloatDataset) a).data; final float[] oc64data = ((ComplexFloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { final float ix = c64data[it.index]; final float iy = c64data[it.index + 1]; float ox; float oy; ox = (float) (Math.sinh(ix) * Math.cos(iy)); oy = (float) (Math.cosh(ix) * Math.sin(iy)); oc64data[i++] = ox; oc64data[i++] = oy; } break; case AbstractDataset.COMPLEX128: ds = AbstractDataset.zeros(a, AbstractDataset.COMPLEX128); final double[] c128data = ((ComplexDoubleDataset) a).data; final double[] oc128data = ((ComplexDoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { final double ix = c128data[it.index]; final double iy = c128data[it.index + 1]; double ox; double oy; ox = (double) (Math.sinh(ix) * Math.cos(iy)); oy = (double) (Math.cosh(ix) * Math.sin(iy)); oc128data[i++] = ox; oc128data[i++] = oy; } break; default: throw new IllegalArgumentException( "sinh supports integer, compound integer, real, compound real, complex datasets only"); } ds.setName(a.getName()); addFunctionName(ds, "sinh"); return ds; }
From source file:uk.ac.diamond.scisoft.analysis.dataset.Maths.java
/** * cosh - evaluate the hyperbolic cosine function on each element of the dataset * @param a/*from w w w . java2 s .co m*/ * @return dataset */ @SuppressWarnings("cast") public static AbstractDataset cosh(final AbstractDataset a) { final int isize; final IndexIterator it = a.getIterator(); AbstractDataset ds; final int dt = a.getDtype(); switch (dt) { case AbstractDataset.INT8: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT32); final byte[] i8data = ((ByteDataset) a).data; final float[] oi8data = ((FloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { final byte ix = i8data[it.index]; float ox; ox = (float) (Math.cosh(ix)); oi8data[i++] = ox; } break; case AbstractDataset.INT16: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT32); final short[] i16data = ((ShortDataset) a).data; final float[] oi16data = ((FloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { final short ix = i16data[it.index]; float ox; ox = (float) (Math.cosh(ix)); oi16data[i++] = ox; } break; case AbstractDataset.INT32: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT64); final int[] i32data = ((IntegerDataset) a).data; final double[] oi32data = ((DoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { final int ix = i32data[it.index]; double ox; ox = (double) (Math.cosh(ix)); oi32data[i++] = ox; } break; case AbstractDataset.INT64: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT64); final long[] i64data = ((LongDataset) a).data; final double[] oi64data = ((DoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { final long ix = i64data[it.index]; double ox; ox = (double) (Math.cosh(ix)); oi64data[i++] = ox; } break; case AbstractDataset.ARRAYINT8: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT32); isize = a.getElementsPerItem(); final byte[] ai8data = ((CompoundByteDataset) a).data; final float[] oai8data = ((CompoundFloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final byte ix = ai8data[it.index + j]; float ox; ox = (float) (Math.cosh(ix)); oai8data[i++] = ox; } } break; case AbstractDataset.ARRAYINT16: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT32); isize = a.getElementsPerItem(); final short[] ai16data = ((CompoundShortDataset) a).data; final float[] oai16data = ((CompoundFloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final short ix = ai16data[it.index + j]; float ox; ox = (float) (Math.cosh(ix)); oai16data[i++] = ox; } } break; case AbstractDataset.ARRAYINT32: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT64); isize = a.getElementsPerItem(); final int[] ai32data = ((CompoundIntegerDataset) a).data; final double[] oai32data = ((CompoundDoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final int ix = ai32data[it.index + j]; double ox; ox = (double) (Math.cosh(ix)); oai32data[i++] = ox; } } break; case AbstractDataset.ARRAYINT64: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT64); isize = a.getElementsPerItem(); final long[] ai64data = ((CompoundLongDataset) a).data; final double[] oai64data = ((CompoundDoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final long ix = ai64data[it.index + j]; double ox; ox = (double) (Math.cosh(ix)); oai64data[i++] = ox; } } break; case AbstractDataset.FLOAT32: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT32); final float[] f32data = ((FloatDataset) a).data; final float[] of32data = ((FloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { final float ix = f32data[it.index]; float ox; ox = (float) (Math.cosh(ix)); of32data[i++] = ox; } break; case AbstractDataset.FLOAT64: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT64); final double[] f64data = ((DoubleDataset) a).data; final double[] of64data = ((DoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { final double ix = f64data[it.index]; double ox; ox = (double) (Math.cosh(ix)); of64data[i++] = ox; } break; case AbstractDataset.ARRAYFLOAT32: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT32); isize = a.getElementsPerItem(); final float[] af32data = ((CompoundFloatDataset) a).data; final float[] oaf32data = ((CompoundFloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final float ix = af32data[it.index + j]; float ox; ox = (float) (Math.cosh(ix)); oaf32data[i++] = ox; } } break; case AbstractDataset.ARRAYFLOAT64: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT64); isize = a.getElementsPerItem(); final double[] af64data = ((CompoundDoubleDataset) a).data; final double[] oaf64data = ((CompoundDoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final double ix = af64data[it.index + j]; double ox; ox = (double) (Math.cosh(ix)); oaf64data[i++] = ox; } } break; case AbstractDataset.COMPLEX64: ds = AbstractDataset.zeros(a, AbstractDataset.COMPLEX64); final float[] c64data = ((ComplexFloatDataset) a).data; final float[] oc64data = ((ComplexFloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { final float ix = c64data[it.index]; final float iy = c64data[it.index + 1]; float ox; float oy; ox = (float) (Math.cosh(ix) * Math.cos(iy)); oy = (float) (Math.sinh(ix) * Math.sin(iy)); oc64data[i++] = ox; oc64data[i++] = oy; } break; case AbstractDataset.COMPLEX128: ds = AbstractDataset.zeros(a, AbstractDataset.COMPLEX128); final double[] c128data = ((ComplexDoubleDataset) a).data; final double[] oc128data = ((ComplexDoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { final double ix = c128data[it.index]; final double iy = c128data[it.index + 1]; double ox; double oy; ox = (double) (Math.cosh(ix) * Math.cos(iy)); oy = (double) (Math.sinh(ix) * Math.sin(iy)); oc128data[i++] = ox; oc128data[i++] = oy; } break; default: throw new IllegalArgumentException( "cosh supports integer, compound integer, real, compound real, complex datasets only"); } ds.setName(a.getName()); addFunctionName(ds, "cosh"); return ds; }
From source file:uk.ac.diamond.scisoft.analysis.dataset.Maths.java
/** * tanh - evaluate the tangent hyperbolic function on each element of the dataset * @param a/*from w w w .j a v a 2s . c om*/ * @return dataset */ @SuppressWarnings("cast") public static AbstractDataset tanh(final AbstractDataset a) { final int isize; final IndexIterator it = a.getIterator(); AbstractDataset ds; final int dt = a.getDtype(); switch (dt) { case AbstractDataset.INT8: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT32); final byte[] i8data = ((ByteDataset) a).data; final float[] oi8data = ((FloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { final byte ix = i8data[it.index]; float ox; ox = (float) (Math.tanh(ix)); oi8data[i++] = ox; } break; case AbstractDataset.INT16: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT32); final short[] i16data = ((ShortDataset) a).data; final float[] oi16data = ((FloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { final short ix = i16data[it.index]; float ox; ox = (float) (Math.tanh(ix)); oi16data[i++] = ox; } break; case AbstractDataset.INT32: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT64); final int[] i32data = ((IntegerDataset) a).data; final double[] oi32data = ((DoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { final int ix = i32data[it.index]; double ox; ox = (double) (Math.tanh(ix)); oi32data[i++] = ox; } break; case AbstractDataset.INT64: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT64); final long[] i64data = ((LongDataset) a).data; final double[] oi64data = ((DoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { final long ix = i64data[it.index]; double ox; ox = (double) (Math.tanh(ix)); oi64data[i++] = ox; } break; case AbstractDataset.ARRAYINT8: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT32); isize = a.getElementsPerItem(); final byte[] ai8data = ((CompoundByteDataset) a).data; final float[] oai8data = ((CompoundFloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final byte ix = ai8data[it.index + j]; float ox; ox = (float) (Math.tanh(ix)); oai8data[i++] = ox; } } break; case AbstractDataset.ARRAYINT16: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT32); isize = a.getElementsPerItem(); final short[] ai16data = ((CompoundShortDataset) a).data; final float[] oai16data = ((CompoundFloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final short ix = ai16data[it.index + j]; float ox; ox = (float) (Math.tanh(ix)); oai16data[i++] = ox; } } break; case AbstractDataset.ARRAYINT32: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT64); isize = a.getElementsPerItem(); final int[] ai32data = ((CompoundIntegerDataset) a).data; final double[] oai32data = ((CompoundDoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final int ix = ai32data[it.index + j]; double ox; ox = (double) (Math.tanh(ix)); oai32data[i++] = ox; } } break; case AbstractDataset.ARRAYINT64: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT64); isize = a.getElementsPerItem(); final long[] ai64data = ((CompoundLongDataset) a).data; final double[] oai64data = ((CompoundDoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final long ix = ai64data[it.index + j]; double ox; ox = (double) (Math.tanh(ix)); oai64data[i++] = ox; } } break; case AbstractDataset.FLOAT32: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT32); final float[] f32data = ((FloatDataset) a).data; final float[] of32data = ((FloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { final float ix = f32data[it.index]; float ox; ox = (float) (Math.tanh(ix)); of32data[i++] = ox; } break; case AbstractDataset.FLOAT64: ds = AbstractDataset.zeros(a, AbstractDataset.FLOAT64); final double[] f64data = ((DoubleDataset) a).data; final double[] of64data = ((DoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { final double ix = f64data[it.index]; double ox; ox = (double) (Math.tanh(ix)); of64data[i++] = ox; } break; case AbstractDataset.ARRAYFLOAT32: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT32); isize = a.getElementsPerItem(); final float[] af32data = ((CompoundFloatDataset) a).data; final float[] oaf32data = ((CompoundFloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final float ix = af32data[it.index + j]; float ox; ox = (float) (Math.tanh(ix)); oaf32data[i++] = ox; } } break; case AbstractDataset.ARRAYFLOAT64: ds = AbstractDataset.zeros(a, AbstractDataset.ARRAYFLOAT64); isize = a.getElementsPerItem(); final double[] af64data = ((CompoundDoubleDataset) a).data; final double[] oaf64data = ((CompoundDoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { for (int j = 0; j < isize; j++) { final double ix = af64data[it.index + j]; double ox; ox = (double) (Math.tanh(ix)); oaf64data[i++] = ox; } } break; case AbstractDataset.COMPLEX64: ds = AbstractDataset.zeros(a, AbstractDataset.COMPLEX64); final float[] c64data = ((ComplexFloatDataset) a).data; final float[] oc64data = ((ComplexFloatDataset) ds).getData(); for (int i = 0; it.hasNext();) { final float ix = c64data[it.index]; final float iy = c64data[it.index + 1]; float tx; float ty; float tf; float ox; float oy; tx = (float) (2. * ix); ty = (float) (2. * iy); tf = (float) (1. / (Math.cos(tx) + Math.cosh(ty))); ox = (float) (tf * Math.sinh(tx)); oy = (float) (tf * Math.sin(ty)); oc64data[i++] = ox; oc64data[i++] = oy; } break; case AbstractDataset.COMPLEX128: ds = AbstractDataset.zeros(a, AbstractDataset.COMPLEX128); final double[] c128data = ((ComplexDoubleDataset) a).data; final double[] oc128data = ((ComplexDoubleDataset) ds).getData(); for (int i = 0; it.hasNext();) { final double ix = c128data[it.index]; final double iy = c128data[it.index + 1]; double tx; double ty; double tf; double ox; double oy; tx = (double) (2. * ix); ty = (double) (2. * iy); tf = (double) (1. / (Math.cos(tx) + Math.cosh(ty))); ox = (double) (tf * Math.sinh(tx)); oy = (double) (tf * Math.sin(ty)); oc128data[i++] = ox; oc128data[i++] = oy; } break; default: throw new IllegalArgumentException( "tanh supports integer, compound integer, real, compound real, complex datasets only"); } ds.setName(a.getName()); addFunctionName(ds, "tanh"); return ds; }
From source file:org.eclipse.january.dataset.GeneratedMaths.java
/** * sin - evaluate the sine function on each element of the dataset * @param a/*from www . j a va 2 s . c om*/ * @param o output can be null - in which case, a new dataset is created * @return dataset */ public static Dataset sin(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.sin(ix)); oi8data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; byte ox; ox = (byte) toLong(Math.sin(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.sin(ix)); oi16data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; short ox; ox = (short) toLong(Math.sin(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.sin(ix)); oi64data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; long ox; ox = toLong(Math.sin(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.sin(ix)); oi32data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; int ox; ox = (int) toLong(Math.sin(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.sin(ix)); oai8data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; byte ox; ox = (byte) toLong(Math.sin(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.sin(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.sin(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.sin(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.sin(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.sin(ix)); oai16data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; short ox; ox = (short) toLong(Math.sin(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.sin(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.sin(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.sin(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.sin(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.sin(ix)); oai64data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; long ox; ox = toLong(Math.sin(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.sin(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.sin(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.sin(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.sin(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.sin(ix)); oai32data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; int ox; ox = (int) toLong(Math.sin(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.sin(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.sin(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.sin(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.sin(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.sin(ix)); of32data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; float ox; ox = (float) (Math.sin(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.sin(ix)); of64data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; double ox; ox = (Math.sin(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.sin(ix)); oaf32data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; float ox; ox = (float) (Math.sin(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.sin(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.sin(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.sin(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.sin(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.sin(ix)); oaf64data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; double ox; ox = (Math.sin(ix)); oaf64data[it.oIndex] = ox; } } } else if (as == 1) { if (it.isOutputDouble()) { while (it.hasNext()) { final double ix = it.aDouble; double ox; ox = (Math.sin(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.sin(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.sin(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.sin(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; float ox; float oy; ox = (float) (Math.sin(ix) * Math.cosh(iy)); oy = (float) (Math.cos(ix) * Math.sinh(iy)); 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); float ox; float oy; ox = (float) (Math.sin(ix) * Math.cosh(iy)); oy = (float) (Math.cos(ix) * Math.sinh(iy)); 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; double ox; double oy; ox = (Math.sin(ix) * Math.cosh(iy)); oy = (Math.cos(ix) * Math.sinh(iy)); 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); double ox; double oy; ox = (Math.sin(ix) * Math.cosh(iy)); oy = (Math.cos(ix) * Math.sinh(iy)); oc128data[it.oIndex] = ox; oc128data[it.oIndex + 1] = oy; } } break; default: throw new IllegalArgumentException( "sin supports integer, compound integer, real, compound real, complex datasets only"); } addFunctionName(result, "sin"); return result; }
From source file:org.eclipse.january.dataset.GeneratedMaths.java
/** * cos - evaluate the cosine function on each element of the dataset * @param a//from ww w . jav a 2 s . c om * @param o output can be null - in which case, a new dataset is created * @return dataset */ public static Dataset cos(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.cos(ix)); oi8data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; byte ox; ox = (byte) toLong(Math.cos(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.cos(ix)); oi16data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; short ox; ox = (short) toLong(Math.cos(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.cos(ix)); oi64data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; long ox; ox = toLong(Math.cos(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.cos(ix)); oi32data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; int ox; ox = (int) toLong(Math.cos(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.cos(ix)); oai8data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; byte ox; ox = (byte) toLong(Math.cos(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.cos(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.cos(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.cos(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.cos(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.cos(ix)); oai16data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; short ox; ox = (short) toLong(Math.cos(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.cos(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.cos(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.cos(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.cos(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.cos(ix)); oai64data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; long ox; ox = toLong(Math.cos(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.cos(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.cos(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.cos(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.cos(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.cos(ix)); oai32data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; int ox; ox = (int) toLong(Math.cos(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.cos(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.cos(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.cos(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.cos(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.cos(ix)); of32data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; float ox; ox = (float) (Math.cos(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.cos(ix)); of64data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; double ox; ox = (Math.cos(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.cos(ix)); oaf32data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; float ox; ox = (float) (Math.cos(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.cos(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.cos(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.cos(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.cos(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.cos(ix)); oaf64data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; double ox; ox = (Math.cos(ix)); oaf64data[it.oIndex] = ox; } } } else if (as == 1) { if (it.isOutputDouble()) { while (it.hasNext()) { final double ix = it.aDouble; double ox; ox = (Math.cos(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.cos(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.cos(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.cos(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; float ox; float oy; ox = (float) (Math.cos(ix) * Math.cosh(iy)); oy = (float) (-Math.sin(ix) * Math.sinh(iy)); 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); float ox; float oy; ox = (float) (Math.cos(ix) * Math.cosh(iy)); oy = (float) (-Math.sin(ix) * Math.sinh(iy)); 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; double ox; double oy; ox = (Math.cos(ix) * Math.cosh(iy)); oy = (-Math.sin(ix) * Math.sinh(iy)); 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); double ox; double oy; ox = (Math.cos(ix) * Math.cosh(iy)); oy = (-Math.sin(ix) * Math.sinh(iy)); oc128data[it.oIndex] = ox; oc128data[it.oIndex + 1] = oy; } } break; default: throw new IllegalArgumentException( "cos supports integer, compound integer, real, compound real, complex datasets only"); } addFunctionName(result, "cos"); return result; }
From source file:org.eclipse.january.dataset.GeneratedMaths.java
/** * tan - evaluate the tangent function on each element of the dataset * @param a/*from w w w . j av a 2 s. c om*/ * @param o output can be null - in which case, a new dataset is created * @return dataset */ public static Dataset tan(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.tan(ix)); oi8data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; byte ox; ox = (byte) toLong(Math.tan(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.tan(ix)); oi16data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; short ox; ox = (short) toLong(Math.tan(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.tan(ix)); oi64data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; long ox; ox = toLong(Math.tan(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.tan(ix)); oi32data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; int ox; ox = (int) toLong(Math.tan(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.tan(ix)); oai8data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; byte ox; ox = (byte) toLong(Math.tan(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.tan(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.tan(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.tan(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.tan(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.tan(ix)); oai16data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; short ox; ox = (short) toLong(Math.tan(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.tan(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.tan(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.tan(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.tan(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.tan(ix)); oai64data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; long ox; ox = toLong(Math.tan(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.tan(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.tan(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.tan(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.tan(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.tan(ix)); oai32data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; int ox; ox = (int) toLong(Math.tan(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.tan(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.tan(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.tan(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.tan(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.tan(ix)); of32data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; float ox; ox = (float) (Math.tan(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.tan(ix)); of64data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; double ox; ox = (Math.tan(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.tan(ix)); oaf32data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; float ox; ox = (float) (Math.tan(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.tan(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.tan(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.tan(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.tan(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.tan(ix)); oaf64data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; double ox; ox = (Math.tan(ix)); oaf64data[it.oIndex] = ox; } } } else if (as == 1) { if (it.isOutputDouble()) { while (it.hasNext()) { final double ix = it.aDouble; double ox; ox = (Math.tan(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.tan(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.tan(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.tan(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; float x; float y; float tf; float ox; float oy; x = (float) (2. * ix); y = (float) (2. * iy); tf = (float) (1. / (Math.cos(x) + Math.cosh(y))); ox = (float) (tf * Math.sin(x)); oy = (float) (tf * Math.sinh(y)); 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); float x; float y; float tf; float ox; float oy; x = (float) (2. * ix); y = (float) (2. * iy); tf = (float) (1. / (Math.cos(x) + Math.cosh(y))); ox = (float) (tf * Math.sin(x)); oy = (float) (tf * Math.sinh(y)); 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; double x; double y; double tf; double ox; double oy; x = (2. * ix); y = (2. * iy); tf = (1. / (Math.cos(x) + Math.cosh(y))); ox = (tf * Math.sin(x)); oy = (tf * Math.sinh(y)); 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); double x; double y; double tf; double ox; double oy; x = (2. * ix); y = (2. * iy); tf = (1. / (Math.cos(x) + Math.cosh(y))); ox = (tf * Math.sin(x)); oy = (tf * Math.sinh(y)); oc128data[it.oIndex] = ox; oc128data[it.oIndex + 1] = oy; } } break; default: throw new IllegalArgumentException( "tan supports integer, compound integer, real, compound real, complex datasets only"); } addFunctionName(result, "tan"); return result; }
From source file:org.eclipse.january.dataset.GeneratedMaths.java
/** * sinh - evaluate the hyperbolic sine function on each element of the dataset * @param a// ww w.j a v a2 s .co m * @param o output can be null - in which case, a new dataset is created * @return dataset */ public static Dataset sinh(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.sinh(ix)); oi8data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; byte ox; ox = (byte) toLong(Math.sinh(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.sinh(ix)); oi16data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; short ox; ox = (short) toLong(Math.sinh(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.sinh(ix)); oi64data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; long ox; ox = toLong(Math.sinh(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.sinh(ix)); oi32data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; int ox; ox = (int) toLong(Math.sinh(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.sinh(ix)); oai8data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; byte ox; ox = (byte) toLong(Math.sinh(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.sinh(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.sinh(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.sinh(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.sinh(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.sinh(ix)); oai16data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; short ox; ox = (short) toLong(Math.sinh(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.sinh(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.sinh(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.sinh(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.sinh(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.sinh(ix)); oai64data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; long ox; ox = toLong(Math.sinh(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.sinh(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.sinh(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.sinh(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.sinh(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.sinh(ix)); oai32data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; int ox; ox = (int) toLong(Math.sinh(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.sinh(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.sinh(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.sinh(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.sinh(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.sinh(ix)); of32data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; float ox; ox = (float) (Math.sinh(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.sinh(ix)); of64data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; double ox; ox = (Math.sinh(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.sinh(ix)); oaf32data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; float ox; ox = (float) (Math.sinh(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.sinh(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.sinh(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.sinh(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.sinh(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.sinh(ix)); oaf64data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; double ox; ox = (Math.sinh(ix)); oaf64data[it.oIndex] = ox; } } } else if (as == 1) { if (it.isOutputDouble()) { while (it.hasNext()) { final double ix = it.aDouble; double ox; ox = (Math.sinh(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.sinh(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.sinh(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.sinh(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; float ox; float oy; ox = (float) (Math.sinh(ix) * Math.cos(iy)); oy = (float) (Math.cosh(ix) * Math.sin(iy)); 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); float ox; float oy; ox = (float) (Math.sinh(ix) * Math.cos(iy)); oy = (float) (Math.cosh(ix) * Math.sin(iy)); 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; double ox; double oy; ox = (Math.sinh(ix) * Math.cos(iy)); oy = (Math.cosh(ix) * Math.sin(iy)); 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); double ox; double oy; ox = (Math.sinh(ix) * Math.cos(iy)); oy = (Math.cosh(ix) * Math.sin(iy)); oc128data[it.oIndex] = ox; oc128data[it.oIndex + 1] = oy; } } break; default: throw new IllegalArgumentException( "sinh supports integer, compound integer, real, compound real, complex datasets only"); } addFunctionName(result, "sinh"); return result; }
From source file:org.eclipse.january.dataset.Maths.java
/** * sin - evaluate the sine function on each element of the dataset * @param a/*from w ww. j a va2 s . c o m*/ * @param o output can be null - in which case, a new dataset is created * @return dataset */ public static Dataset sin(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.sin(ix)); oi8data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; byte ox; ox = (byte) toLong(Math.sin(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.sin(ix)); oi16data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; short ox; ox = (short) toLong(Math.sin(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.sin(ix)); oi64data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; long ox; ox = toLong(Math.sin(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.sin(ix)); oi32data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; int ox; ox = (int) toLong(Math.sin(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.sin(ix)); oai8data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; byte ox; ox = (byte) toLong(Math.sin(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.sin(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.sin(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.sin(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.sin(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.sin(ix)); oai16data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; short ox; ox = (short) toLong(Math.sin(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.sin(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.sin(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.sin(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.sin(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.sin(ix)); oai64data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; long ox; ox = toLong(Math.sin(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.sin(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.sin(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.sin(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.sin(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.sin(ix)); oai32data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; int ox; ox = (int) toLong(Math.sin(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.sin(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.sin(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.sin(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.sin(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.sin(ix)); of32data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; float ox; ox = (float) (Math.sin(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.sin(ix)); of64data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; double ox; ox = (Math.sin(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.sin(ix)); oaf32data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; float ox; ox = (float) (Math.sin(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.sin(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.sin(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.sin(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.sin(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.sin(ix)); oaf64data[it.oIndex] = ox; } } else { while (it.hasNext()) { final long ix = it.aLong; double ox; ox = (Math.sin(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.sin(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.sin(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.sin(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.sin(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; float ox; float oy; ox = (float) (Math.sin(ix) * Math.cosh(iy)); oy = (float) (Math.cos(ix) * Math.sinh(iy)); 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); float ox; float oy; ox = (float) (Math.sin(ix) * Math.cosh(iy)); oy = (float) (Math.cos(ix) * Math.sinh(iy)); 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; double ox; double oy; ox = (Math.sin(ix) * Math.cosh(iy)); oy = (Math.cos(ix) * Math.sinh(iy)); 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); double ox; double oy; ox = (Math.sin(ix) * Math.cosh(iy)); oy = (Math.cos(ix) * Math.sinh(iy)); oc128data[it.oIndex] = ox; oc128data[it.oIndex + 1] = oy; } } break; default: throw new IllegalArgumentException( "sin supports integer, compound integer, real, compound real, complex datasets only"); } addFunctionName(result, "sin"); return result; }