List of usage examples for java.lang Math sinh
public static double sinh(double x)
From source file:syncleus.dann.math.ComplexNumber.java
@Override public final ComplexNumber tanh() { final double denominator = Math.cosh(2.0 * getReal()) + Math.cos(2.0 * getImaginary()); return new ComplexNumber(Math.sinh(2.0 * getReal()) / denominator, Math.sin(2.0 * getImaginary()) / denominator); }
From source file:org.moeaframework.util.tree.NodeTest.java
@Test public void testSinh() { Node node = new Sinh().setArgument(0, new Constant(Math.PI / 4.0)); Assert.assertTrue(// w w w . j a v a2s.co m NumberArithmetic.equals(Math.sinh(Math.PI / 4.0), (Number) node.evaluate(new UnusedEnvironment()))); }
From source file:com.rapidminer.tools.expression.internal.function.AntlrParserTrigonometricTest.java
@Test public void sinhInt() { try {//from w w w . ja v a2 s . c om Expression expression = getExpressionWithFunctionContext("sinh(16)"); assertEquals(ExpressionType.DOUBLE, expression.getExpressionType()); assertEquals(Math.sinh(16), expression.evaluateNumerical(), 1e-15); } catch (ExpressionException e) { assertNotNull(e.getMessage()); } }
From source file:com.rapidminer.tools.expression.internal.function.AntlrParserTrigonometricTest.java
@Test public void sinhDouble() { try {// w w w . ja va2s.c o m Expression expression = getExpressionWithFunctionContext("sinh(33.3)"); assertEquals(ExpressionType.DOUBLE, expression.getExpressionType()); assertEquals(Math.sinh(33.3), expression.evaluateNumerical(), 1e-15); } catch (ExpressionException e) { assertNotNull(e.getMessage()); } }
From source file:com.rapidminer.tools.expression.internal.function.AntlrParserTrigonometricTest.java
@Test public void sinhNegative() { try {// w w w.j av a 2 s . c o m Expression expression = getExpressionWithFunctionContext("sinh(-10)"); assertEquals(ExpressionType.DOUBLE, expression.getExpressionType()); assertEquals(Math.sinh(-10), expression.evaluateNumerical(), 1e-15); } catch (ExpressionException e) { assertNotNull(e.getMessage()); } }
From source file:com.rapidminer.tools.expression.internal.function.AntlrParserTrigonometricTest.java
@Test public void sinhNull() { try {// ww w .jav a 2 s . c o m Expression expression = getExpressionWithFunctionContext("sinh(0)"); assertEquals(ExpressionType.DOUBLE, expression.getExpressionType()); assertEquals(Math.sinh(0), expression.evaluateNumerical(), 1e-15); } catch (ExpressionException e) { assertNotNull(e.getMessage()); } }
From source file:com.rapidminer.tools.expression.internal.function.AntlrParserTrigonometricTest.java
@Test public void sinhNinety() { try {/* www . ja va 2 s . co m*/ Expression expression = getExpressionWithFunctionContext("sinh(90)"); assertEquals(ExpressionType.DOUBLE, expression.getExpressionType()); assertEquals(Math.sinh(90), expression.evaluateNumerical(), 1e-15); } catch (ExpressionException e) { assertNotNull(e.getMessage()); } }
From source file:com.rapidminer.tools.expression.internal.function.AntlrParserTrigonometricTest.java
@Test public void sinhPi() { try {/*from ww w. j a v a 2s .c o m*/ Expression expression = getExpressionWithFunctionContext("sinh(pi)"); assertEquals(ExpressionType.DOUBLE, expression.getExpressionType()); assertEquals(Math.sinh(Math.PI), expression.evaluateNumerical(), 1e-15); } catch (ExpressionException e) { assertNotNull(e.getMessage()); } }
From source file:com.rapidminer.tools.expression.internal.function.AntlrParserTrigonometricTest.java
@Test public void sinhPiHalf() { try {/*from w w w. jav a2 s .c o m*/ Expression expression = getExpressionWithFunctionContext("sinh(pi/2)"); assertEquals(ExpressionType.DOUBLE, expression.getExpressionType()); assertEquals(Math.sinh(Math.PI / 2), expression.evaluateNumerical(), 1e-15); } catch (ExpressionException e) { assertNotNull(e.getMessage()); } }
From source file:uk.ac.diamond.scisoft.analysis.dataset.Maths.java
/** * sin - evaluate the sine function on each element of the dataset * @param a/*from w w w .ja va 2s . co m*/ * @return dataset */ @SuppressWarnings("cast") public static AbstractDataset sin(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.sin(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.sin(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.sin(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.sin(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.sin(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.sin(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.sin(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.sin(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.sin(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.sin(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.sin(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.sin(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.sin(ix) * Math.cosh(iy)); oy = (float) (Math.cos(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.sin(ix) * Math.cosh(iy)); oy = (double) (Math.cos(ix) * Math.sinh(iy)); oc128data[i++] = ox; oc128data[i++] = oy; } break; default: throw new IllegalArgumentException( "sin supports integer, compound integer, real, compound real, complex datasets only"); } ds.setName(a.getName()); addFunctionName(ds, "sin"); return ds; }