Merge "Test the new native_* functions." into lmp-dev
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/CoreMathVerifier.java b/tests/tests/renderscript/src/android/renderscript/cts/CoreMathVerifier.java
index 27fa363..74c34e3 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/CoreMathVerifier.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/CoreMathVerifier.java
@@ -1050,6 +1050,84 @@
args.out = new Floaty(Float.NaN, 0, 0);
}
+ static public void computeNativeAcos(TestNativeAcos.ArgumentsFloatFloat args) {
+ args.out = new Floaty(acos(args.inV), NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
+ static public void computeNativeAcosh(TestNativeAcosh.ArgumentsFloatFloat args) {
+ args.out = new Floaty(acosh(args.in), NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
+ static public void computeNativeAcospi(TestNativeAcospi.ArgumentsFloatFloat args) {
+ args.out = new Floaty(acos(args.inV) / (float) Math.PI, NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
+ static public void computeNativeAsin(TestNativeAsin.ArgumentsFloatFloat args) {
+ args.out = new Floaty(asin(args.inV), NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
+ static public void computeNativeAsinh(TestNativeAsinh.ArgumentsFloatFloat args) {
+ args.out = new Floaty(asinh(args.in), NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
+ static public void computeNativeAsinpi(TestNativeAsinpi.ArgumentsFloatFloat args) {
+ args.out = new Floaty(asin(args.inV) / (float) Math.PI, NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
+ static public void computeNativeAtan(TestNativeAtan.ArgumentsFloatFloat args) {
+ args.out = new Floaty(atan(args.inV), NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
+ static public void computeNativeAtanh(TestNativeAtanh.ArgumentsFloatFloat args) {
+ args.out = new Floaty(atanh(args.in), NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
+ static public void computeNativeAtanpi(TestNativeAtanpi.ArgumentsFloatFloat args) {
+ args.out = new Floaty(atan(args.inV) / (float) Math.PI, NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
+ static public void computeNativeAtan2(TestNativeAtan2.ArgumentsFloatFloatFloat args) {
+ args.out = new Floaty(atan2(args.inY, args.inX), NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
+ static public void computeNativeAtan2pi(TestNativeAtan2pi.ArgumentsFloatFloatFloat args) {
+ args.out = new Floaty(atan2(args.inY, args.inX) / (float)Math.PI, NATIVE_PRECISION,
+ NATIVE_PRECISION);
+ }
+
+ static public void computeNativeCbrt(TestNativeCbrt.ArgumentsFloatFloat args) {
+ args.out = new Floaty(cbrt(args.in), NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
+ static public void computeNativeCos(TestNativeCos.ArgumentsFloatFloat args) {
+ args.out = new Floaty(cos(args.in), NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
+ static public void computeNativeCosh(TestNativeCosh.ArgumentsFloatFloat args) {
+ args.out = new Floaty(cosh(args.in), NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
+ static public void computeNativeCospi(TestNativeCospi.ArgumentsFloatFloat args) {
+ Floaty ip = new Floaty((float) ((double)args.in * Math.PI), 1, 1);
+ args.out = Floaty.FloatyFromRange(
+ (float) Math.cos(ip.getDoubleMin()),
+ (float) Math.cos(ip.getDoubleMax()), NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
+ static public void computeNativeDistance(TestNativeDistance.ArgumentsFloatFloatFloat args) {
+ args.out = distance(new float[]{args.inLhs}, new float[]{args.inRhs}, NATIVE_PRECISION,
+ NATIVE_PRECISION);
+ }
+
+ static public void computeNativeDistance(TestNativeDistance.ArgumentsFloatNFloatNFloat args) {
+ args.out = distance(args.inLhs, args.inRhs, NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
+ static public void computeNativeDivide(TestNativeDivide.ArgumentsFloatFloatFloat args) {
+ args.out = Floaty.divide(new Floaty(args.inLhs), new Floaty(args.inRhs));
+ args.out.setMinimumError(NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
static public void computeNativeExp(TestNativeExp.ArgumentsFloatFloat args) {
// TODO we would like to use NATIVE_PRECISION, NATIVE_PRECISION
args.out = new Floaty(exp(args.inV), 9500, 9500);
@@ -1065,6 +1143,14 @@
args.out = new Floaty(exp2(args.inV), 13000, 13000);
}
+ static public void computeNativeExpm1(TestNativeExpm1.ArgumentsFloatFloat args) {
+ args.out = new Floaty(expm1(args.in), NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
+ static public void computeNativeHypot(TestNativeHypot.ArgumentsFloatFloatFloat args) {
+ args.out = new Floaty(hypot(args.inX, args.inY), NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
static public void computeNativeLog(TestNativeLog.ArgumentsFloatFloat args) {
args.out = new Floaty(log(args.inV), NATIVE_PRECISION, NATIVE_PRECISION);
}
@@ -1073,6 +1159,10 @@
args.out = new Floaty(log10(args.inV), NATIVE_PRECISION, NATIVE_PRECISION);
}
+ static public void computeNativeLog1p(TestNativeLog1p.ArgumentsFloatFloat args) {
+ args.out = new Floaty(log1p(args.in), NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
static public void computeNativeLog2(TestNativeLog2.ArgumentsFloatFloat args) {
args.out = new Floaty(log2(args.inV), NATIVE_PRECISION, NATIVE_PRECISION);
}
@@ -1095,11 +1185,6 @@
normalize(args.inV, args.out, NATIVE_PRECISION, NATIVE_PRECISION);
}
- static public void computeNativeRecip(TestNativeRecip.ArgumentsFloatFloat args) {
- args.out = new Floaty(1.0f / args.inV, NATIVE_PRECISION, NATIVE_PRECISION);
- }
-
-
/* TODO enable once fixed handling of v = 0
static public void computeNativePowr(TestNativePowr.ArgumentsFloatFloatFloat args) {
// TODO we would like to use NATIVE_PRECISION, NATIVE_PRECISION
@@ -1107,6 +1192,53 @@
}
*/
+ static public void computeNativeRecip(TestNativeRecip.ArgumentsFloatFloat args) {
+ args.out = new Floaty(1.0f / args.inV, NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
+ static public void computeNativeRsqrt(TestNativeRsqrt.ArgumentsFloatFloat args) {
+ args.out = new Floaty(1f / sqrt(args.in), NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
+ static public void computeNativeSin(TestNativeSin.ArgumentsFloatFloat args) {
+ args.out = new Floaty(sin(args.in), NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
+ static public void computeNativeSincos(TestNativeSincos.ArgumentsFloatFloatFloat args) {
+ args.outCosptr = new Floaty(cos(args.inV), NATIVE_PRECISION, NATIVE_PRECISION);
+ args.out = new Floaty(sin(args.inV), NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
+ static public void computeNativeSinh(TestNativeSinh.ArgumentsFloatFloat args) {
+ args.out = new Floaty(sinh(args.in), NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
+ static public void computeNativeSinpi(TestNativeSinpi.ArgumentsFloatFloat args) {
+ Floaty ip = new Floaty((float) ((double)args.in * Math.PI), 1, 1);
+ args.out = Floaty.FloatyFromRange(
+ (float) Math.sin(ip.getDoubleMin()),
+ (float) Math.sin(ip.getDoubleMax()), NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
+ static public void computeNativeSqrt(TestNativeSqrt.ArgumentsFloatFloat args) {
+ args.out = new Floaty(sqrt(args.in), NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
+ static public void computeNativeTan(TestNativeTan.ArgumentsFloatFloat args) {
+ args.out = new Floaty(tan(args.in), NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
+ static public void computeNativeTanh(TestNativeTanh.ArgumentsFloatFloat args) {
+ args.out = new Floaty(tanh(args.in), NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
+ static public void computeNativeTanpi(TestNativeTanpi.ArgumentsFloatFloat args) {
+ Floaty ip = new Floaty((float) ((double)args.in * Math.PI), 1, 1);
+ args.out = Floaty.FloatyFromRange(
+ (float) Math.tan(ip.getDoubleMin()),
+ (float) Math.tan(ip.getDoubleMax()), NATIVE_PRECISION, NATIVE_PRECISION);
+ }
+
static public void computeNextafter(TestNextafter.ArgumentsFloatFloatFloat args) {
args.out = new Floaty(Math.nextAfter(args.inX, args.inY), 0, 0);
}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAcos.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAcos.java
index 7e03ee0..793f609 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAcos.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAcos.java
@@ -34,70 +34,247 @@
scriptRelaxed = new ScriptC_TestNativeAcosRelaxed(mRS);
}
+ public class ArgumentsFloatFloat {
+ public float inV;
+ public Floaty out;
+ }
+
private void checkNativeAcosFloatFloat() {
Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x7749aa14657f3d94l, -1, 1);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.forEach_testNativeAcosFloatFloat(inV, out);
+ verifyResultsNativeAcosFloatFloat(inV, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcosFloatFloat: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.forEach_testNativeAcosFloatFloat(inV, out);
+ verifyResultsNativeAcosFloatFloat(inV, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcosFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeAcosFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 1];
+ inV.copyTo(arrayInV);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.inV = arrayInV[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAcos(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAcosFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAcosFloat2Float2() {
Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x92e82297d87e02d8l, -1, 1);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.forEach_testNativeAcosFloat2Float2(inV, out);
+ verifyResultsNativeAcosFloat2Float2(inV, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcosFloat2Float2: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.forEach_testNativeAcosFloat2Float2(inV, out);
+ verifyResultsNativeAcosFloat2Float2(inV, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcosFloat2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeAcosFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 2];
+ inV.copyTo(arrayInV);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.inV = arrayInV[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAcos(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAcosFloat2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAcosFloat3Float3() {
Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x92e9ebb2ce9923b6l, -1, 1);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.forEach_testNativeAcosFloat3Float3(inV, out);
+ verifyResultsNativeAcosFloat3Float3(inV, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcosFloat3Float3: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.forEach_testNativeAcosFloat3Float3(inV, out);
+ verifyResultsNativeAcosFloat3Float3(inV, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcosFloat3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeAcosFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 4];
+ inV.copyTo(arrayInV);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.inV = arrayInV[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAcos(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAcosFloat3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAcosFloat4Float4() {
Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x92ebb4cdc4b44494l, -1, 1);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.forEach_testNativeAcosFloat4Float4(inV, out);
+ verifyResultsNativeAcosFloat4Float4(inV, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcosFloat4Float4: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.forEach_testNativeAcosFloat4Float4(inV, out);
+ verifyResultsNativeAcosFloat4Float4(inV, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcosFloat4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeAcosFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 4];
+ inV.copyTo(arrayInV);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.inV = arrayInV[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAcos(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAcosFloat4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeAcos() {
checkNativeAcosFloatFloat();
checkNativeAcosFloat2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAcosh.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAcosh.java
index 8a595ae..ae56fcf 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAcosh.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAcosh.java
@@ -34,70 +34,247 @@
scriptRelaxed = new ScriptC_TestNativeAcoshRelaxed(mRS);
}
+ public class ArgumentsFloatFloat {
+ public float in;
+ public Floaty out;
+ }
+
private void checkNativeAcoshFloatFloat() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x332857238c9c505cl, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.forEach_testNativeAcoshFloatFloat(in, out);
+ verifyResultsNativeAcoshFloatFloat(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcoshFloatFloat: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.forEach_testNativeAcoshFloatFloat(in, out);
+ verifyResultsNativeAcoshFloatFloat(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcoshFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeAcoshFloatFloat(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 1];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAcosh(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAcoshFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAcoshFloat2Float2() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x7e5c81be4638e398l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.forEach_testNativeAcoshFloat2Float2(in, out);
+ verifyResultsNativeAcoshFloat2Float2(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcoshFloat2Float2: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.forEach_testNativeAcoshFloat2Float2(in, out);
+ verifyResultsNativeAcoshFloat2Float2(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcoshFloat2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeAcoshFloat2Float2(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 2];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAcosh(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAcoshFloat2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAcoshFloat3Float3() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x7e5c8c5fa53f7932l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.forEach_testNativeAcoshFloat3Float3(in, out);
+ verifyResultsNativeAcoshFloat3Float3(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcoshFloat3Float3: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.forEach_testNativeAcoshFloat3Float3(in, out);
+ verifyResultsNativeAcoshFloat3Float3(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcoshFloat3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeAcoshFloat3Float3(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAcosh(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAcoshFloat3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAcoshFloat4Float4() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x7e5c970104460eccl, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.forEach_testNativeAcoshFloat4Float4(in, out);
+ verifyResultsNativeAcoshFloat4Float4(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcoshFloat4Float4: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.forEach_testNativeAcoshFloat4Float4(in, out);
+ verifyResultsNativeAcoshFloat4Float4(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcoshFloat4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeAcoshFloat4Float4(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAcosh(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAcoshFloat4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeAcosh() {
checkNativeAcoshFloatFloat();
checkNativeAcoshFloat2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAcospi.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAcospi.java
index b01286b..b8adf58 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAcospi.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAcospi.java
@@ -34,70 +34,247 @@
scriptRelaxed = new ScriptC_TestNativeAcospiRelaxed(mRS);
}
+ public class ArgumentsFloatFloat {
+ public float inV;
+ public Floaty out;
+ }
+
private void checkNativeAcospiFloatFloat() {
Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xdcf67f5599c7d8ffl, -1, 1);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.forEach_testNativeAcospiFloatFloat(inV, out);
+ verifyResultsNativeAcospiFloatFloat(inV, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcospiFloatFloat: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.forEach_testNativeAcospiFloatFloat(inV, out);
+ verifyResultsNativeAcospiFloatFloat(inV, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcospiFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeAcospiFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 1];
+ inV.copyTo(arrayInV);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.inV = arrayInV[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAcospi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAcospiFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAcospiFloat2Float2() {
Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xf038668a78e88aabl, -1, 1);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.forEach_testNativeAcospiFloat2Float2(inV, out);
+ verifyResultsNativeAcospiFloat2Float2(inV, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcospiFloat2Float2: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.forEach_testNativeAcospiFloat2Float2(inV, out);
+ verifyResultsNativeAcospiFloat2Float2(inV, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcospiFloat2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeAcospiFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 2];
+ inV.copyTo(arrayInV);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.inV = arrayInV[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAcospi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAcospiFloat2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAcospiFloat3Float3() {
Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xf03a2fa56f03ab89l, -1, 1);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.forEach_testNativeAcospiFloat3Float3(inV, out);
+ verifyResultsNativeAcospiFloat3Float3(inV, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcospiFloat3Float3: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.forEach_testNativeAcospiFloat3Float3(inV, out);
+ verifyResultsNativeAcospiFloat3Float3(inV, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcospiFloat3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeAcospiFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 4];
+ inV.copyTo(arrayInV);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.inV = arrayInV[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAcospi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAcospiFloat3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAcospiFloat4Float4() {
Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xf03bf8c0651ecc67l, -1, 1);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.forEach_testNativeAcospiFloat4Float4(inV, out);
+ verifyResultsNativeAcospiFloat4Float4(inV, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcospiFloat4Float4: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.forEach_testNativeAcospiFloat4Float4(inV, out);
+ verifyResultsNativeAcospiFloat4Float4(inV, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAcospiFloat4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeAcospiFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 4];
+ inV.copyTo(arrayInV);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.inV = arrayInV[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAcospi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAcospiFloat4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeAcospi() {
checkNativeAcospiFloatFloat();
checkNativeAcospiFloat2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAsin.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAsin.java
index 9cf00bd..95a4980 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAsin.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAsin.java
@@ -34,70 +34,247 @@
scriptRelaxed = new ScriptC_TestNativeAsinRelaxed(mRS);
}
+ public class ArgumentsFloatFloat {
+ public float inV;
+ public Floaty out;
+ }
+
private void checkNativeAsinFloatFloat() {
Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x1167d6d8d3e5bc7l, -1, 1);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.forEach_testNativeAsinFloatFloat(inV, out);
+ verifyResultsNativeAsinFloatFloat(inV, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinFloatFloat: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.forEach_testNativeAsinFloatFloat(inV, out);
+ verifyResultsNativeAsinFloatFloat(inV, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeAsinFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 1];
+ inV.copyTo(arrayInV);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.inV = arrayInV[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAsin(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAsinFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAsinFloat2Float2() {
Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xdb4aa187ebdf2133l, -1, 1);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.forEach_testNativeAsinFloat2Float2(inV, out);
+ verifyResultsNativeAsinFloat2Float2(inV, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinFloat2Float2: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.forEach_testNativeAsinFloat2Float2(inV, out);
+ verifyResultsNativeAsinFloat2Float2(inV, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinFloat2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeAsinFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 2];
+ inV.copyTo(arrayInV);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.inV = arrayInV[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAsin(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAsinFloat2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAsinFloat3Float3() {
Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xdb4c6aa2e1fa4211l, -1, 1);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.forEach_testNativeAsinFloat3Float3(inV, out);
+ verifyResultsNativeAsinFloat3Float3(inV, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinFloat3Float3: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.forEach_testNativeAsinFloat3Float3(inV, out);
+ verifyResultsNativeAsinFloat3Float3(inV, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinFloat3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeAsinFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 4];
+ inV.copyTo(arrayInV);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.inV = arrayInV[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAsin(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAsinFloat3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAsinFloat4Float4() {
Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xdb4e33bdd81562efl, -1, 1);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.forEach_testNativeAsinFloat4Float4(inV, out);
+ verifyResultsNativeAsinFloat4Float4(inV, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinFloat4Float4: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.forEach_testNativeAsinFloat4Float4(inV, out);
+ verifyResultsNativeAsinFloat4Float4(inV, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinFloat4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeAsinFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 4];
+ inV.copyTo(arrayInV);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.inV = arrayInV[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAsin(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAsinFloat4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeAsin() {
checkNativeAsinFloatFloat();
checkNativeAsinFloat2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAsinh.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAsinh.java
index 958764a..830140e 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAsinh.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAsinh.java
@@ -34,70 +34,247 @@
scriptRelaxed = new ScriptC_TestNativeAsinhRelaxed(mRS);
}
+ public class ArgumentsFloatFloat {
+ public float in;
+ public Floaty out;
+ }
+
private void checkNativeAsinhFloatFloat() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xbcf52a7cb45b6e8fl, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.forEach_testNativeAsinhFloatFloat(in, out);
+ verifyResultsNativeAsinhFloatFloat(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinhFloatFloat: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.forEach_testNativeAsinhFloatFloat(in, out);
+ verifyResultsNativeAsinhFloatFloat(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinhFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeAsinhFloatFloat(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 1];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAsinh(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAsinhFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAsinhFloat2Float2() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xc6bf00ae599a01f3l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.forEach_testNativeAsinhFloat2Float2(in, out);
+ verifyResultsNativeAsinhFloat2Float2(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinhFloat2Float2: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.forEach_testNativeAsinhFloat2Float2(in, out);
+ verifyResultsNativeAsinhFloat2Float2(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinhFloat2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeAsinhFloat2Float2(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 2];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAsinh(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAsinhFloat2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAsinhFloat3Float3() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xc6bf0b4fb8a0978dl, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.forEach_testNativeAsinhFloat3Float3(in, out);
+ verifyResultsNativeAsinhFloat3Float3(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinhFloat3Float3: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.forEach_testNativeAsinhFloat3Float3(in, out);
+ verifyResultsNativeAsinhFloat3Float3(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinhFloat3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeAsinhFloat3Float3(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAsinh(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAsinhFloat3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAsinhFloat4Float4() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xc6bf15f117a72d27l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.forEach_testNativeAsinhFloat4Float4(in, out);
+ verifyResultsNativeAsinhFloat4Float4(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinhFloat4Float4: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.forEach_testNativeAsinhFloat4Float4(in, out);
+ verifyResultsNativeAsinhFloat4Float4(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinhFloat4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeAsinhFloat4Float4(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAsinh(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAsinhFloat4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeAsinh() {
checkNativeAsinhFloatFloat();
checkNativeAsinhFloat2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAsinpi.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAsinpi.java
index bd2ece4..04824d8 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAsinpi.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAsinpi.java
@@ -34,70 +34,247 @@
scriptRelaxed = new ScriptC_TestNativeAsinpiRelaxed(mRS);
}
+ public class ArgumentsFloatFloat {
+ public float inV;
+ public Floaty out;
+ }
+
private void checkNativeAsinpiFloatFloat() {
Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x2558fe45ad28f75al, -1, 1);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.forEach_testNativeAsinpiFloatFloat(inV, out);
+ verifyResultsNativeAsinpiFloatFloat(inV, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinpiFloatFloat: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.forEach_testNativeAsinpiFloatFloat(inV, out);
+ verifyResultsNativeAsinpiFloatFloat(inV, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinpiFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeAsinpiFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 1];
+ inV.copyTo(arrayInV);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.inV = arrayInV[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAsinpi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAsinpiFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAsinpiFloat2Float2() {
Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xbf9f3a86715cc9eel, -1, 1);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.forEach_testNativeAsinpiFloat2Float2(inV, out);
+ verifyResultsNativeAsinpiFloat2Float2(inV, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinpiFloat2Float2: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.forEach_testNativeAsinpiFloat2Float2(inV, out);
+ verifyResultsNativeAsinpiFloat2Float2(inV, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinpiFloat2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeAsinpiFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 2];
+ inV.copyTo(arrayInV);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.inV = arrayInV[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAsinpi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAsinpiFloat2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAsinpiFloat3Float3() {
Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xbfa103a16777eaccl, -1, 1);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.forEach_testNativeAsinpiFloat3Float3(inV, out);
+ verifyResultsNativeAsinpiFloat3Float3(inV, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinpiFloat3Float3: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.forEach_testNativeAsinpiFloat3Float3(inV, out);
+ verifyResultsNativeAsinpiFloat3Float3(inV, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinpiFloat3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeAsinpiFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 4];
+ inV.copyTo(arrayInV);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.inV = arrayInV[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAsinpi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAsinpiFloat3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAsinpiFloat4Float4() {
Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xbfa2ccbc5d930baal, -1, 1);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.forEach_testNativeAsinpiFloat4Float4(inV, out);
+ verifyResultsNativeAsinpiFloat4Float4(inV, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinpiFloat4Float4: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.forEach_testNativeAsinpiFloat4Float4(inV, out);
+ verifyResultsNativeAsinpiFloat4Float4(inV, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAsinpiFloat4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeAsinpiFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 4];
+ inV.copyTo(arrayInV);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.inV = arrayInV[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAsinpi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAsinpiFloat4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeAsinpi() {
checkNativeAsinpiFloatFloat();
checkNativeAsinpiFloat2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtan.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtan.java
index 2bd7aa7..c60520c 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtan.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtan.java
@@ -34,70 +34,247 @@
scriptRelaxed = new ScriptC_TestNativeAtanRelaxed(mRS);
}
+ public class ArgumentsFloatFloat {
+ public float inV;
+ public Floaty out;
+ }
+
private void checkNativeAtanFloatFloat() {
Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xaafbf9b325b34e42l, -1, 1);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.forEach_testNativeAtanFloatFloat(inV, out);
+ verifyResultsNativeAtanFloatFloat(inV, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanFloatFloat: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.forEach_testNativeAtanFloatFloat(inV, out);
+ verifyResultsNativeAtanFloatFloat(inV, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeAtanFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 1];
+ inV.copyTo(arrayInV);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.inV = arrayInV[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAtan(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAtanFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAtanFloat2Float2() {
Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xf5c93432108a7b96l, -1, 1);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.forEach_testNativeAtanFloat2Float2(inV, out);
+ verifyResultsNativeAtanFloat2Float2(inV, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanFloat2Float2: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.forEach_testNativeAtanFloat2Float2(inV, out);
+ verifyResultsNativeAtanFloat2Float2(inV, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanFloat2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeAtanFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 2];
+ inV.copyTo(arrayInV);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.inV = arrayInV[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAtan(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAtanFloat2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAtanFloat3Float3() {
Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xf5cafd4d06a59c74l, -1, 1);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.forEach_testNativeAtanFloat3Float3(inV, out);
+ verifyResultsNativeAtanFloat3Float3(inV, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanFloat3Float3: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.forEach_testNativeAtanFloat3Float3(inV, out);
+ verifyResultsNativeAtanFloat3Float3(inV, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanFloat3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeAtanFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 4];
+ inV.copyTo(arrayInV);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.inV = arrayInV[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAtan(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAtanFloat3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAtanFloat4Float4() {
Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xf5ccc667fcc0bd52l, -1, 1);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.forEach_testNativeAtanFloat4Float4(inV, out);
+ verifyResultsNativeAtanFloat4Float4(inV, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanFloat4Float4: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.forEach_testNativeAtanFloat4Float4(inV, out);
+ verifyResultsNativeAtanFloat4Float4(inV, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanFloat4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeAtanFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 4];
+ inV.copyTo(arrayInV);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.inV = arrayInV[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAtan(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAtanFloat4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeAtan() {
checkNativeAtanFloatFloat();
checkNativeAtanFloat2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtan2.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtan2.java
index bf30b43..6d3fca7 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtan2.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtan2.java
@@ -34,6 +34,12 @@
scriptRelaxed = new ScriptC_TestNativeAtan2Relaxed(mRS);
}
+ public class ArgumentsFloatFloatFloat {
+ public float inY;
+ public float inX;
+ public Floaty out;
+ }
+
private void checkNativeAtan2FloatFloatFloat() {
Allocation inY = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x4ecf7d3b9e2a276fl, false);
Allocation inX = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x4ecf7d3b9e2a276el, false);
@@ -41,6 +47,7 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.set_gAllocInX(inX);
script.forEach_testNativeAtan2FloatFloatFloat(inY, out);
+ verifyResultsNativeAtan2FloatFloatFloat(inY, inX, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2FloatFloatFloat: " + e.toString());
}
@@ -48,11 +55,60 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.set_gAllocInX(inX);
scriptRelaxed.forEach_testNativeAtan2FloatFloatFloat(inY, out);
+ verifyResultsNativeAtan2FloatFloatFloat(inY, inX, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2FloatFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeAtan2FloatFloatFloat(Allocation inY, Allocation inX, Allocation out, boolean relaxed) {
+ float[] arrayInY = new float[INPUTSIZE * 1];
+ inY.copyTo(arrayInY);
+ float[] arrayInX = new float[INPUTSIZE * 1];
+ inX.copyTo(arrayInX);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat();
+ args.inY = arrayInY[i];
+ args.inX = arrayInX[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAtan2(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inY: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inY, Float.floatToRawIntBits(args.inY), args.inY));
+ message.append("\n");
+ message.append("Input inX: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inX, Float.floatToRawIntBits(args.inX), args.inX));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAtan2FloatFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAtan2Float2Float2Float2() {
Allocation inY = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x3c2d1a09d1c2a8c7l, false);
Allocation inX = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x3c2d1a09d1c2a8c6l, false);
@@ -60,6 +116,7 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.set_gAllocInX(inX);
script.forEach_testNativeAtan2Float2Float2Float2(inY, out);
+ verifyResultsNativeAtan2Float2Float2Float2(inY, inX, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2Float2Float2Float2: " + e.toString());
}
@@ -67,11 +124,60 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.set_gAllocInX(inX);
scriptRelaxed.forEach_testNativeAtan2Float2Float2Float2(inY, out);
+ verifyResultsNativeAtan2Float2Float2Float2(inY, inX, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2Float2Float2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeAtan2Float2Float2Float2(Allocation inY, Allocation inX, Allocation out, boolean relaxed) {
+ float[] arrayInY = new float[INPUTSIZE * 2];
+ inY.copyTo(arrayInY);
+ float[] arrayInX = new float[INPUTSIZE * 2];
+ inX.copyTo(arrayInX);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat();
+ args.inY = arrayInY[i * 2 + j];
+ args.inX = arrayInX[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAtan2(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inY: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inY, Float.floatToRawIntBits(args.inY), args.inY));
+ message.append("\n");
+ message.append("Input inX: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inX, Float.floatToRawIntBits(args.inX), args.inX));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAtan2Float2Float2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAtan2Float3Float3Float3() {
Allocation inY = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x9091f829d3a0aa68l, false);
Allocation inX = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x9091f829d3a0aa67l, false);
@@ -79,6 +185,7 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.set_gAllocInX(inX);
script.forEach_testNativeAtan2Float3Float3Float3(inY, out);
+ verifyResultsNativeAtan2Float3Float3Float3(inY, inX, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2Float3Float3Float3: " + e.toString());
}
@@ -86,11 +193,60 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.set_gAllocInX(inX);
scriptRelaxed.forEach_testNativeAtan2Float3Float3Float3(inY, out);
+ verifyResultsNativeAtan2Float3Float3Float3(inY, inX, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2Float3Float3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeAtan2Float3Float3Float3(Allocation inY, Allocation inX, Allocation out, boolean relaxed) {
+ float[] arrayInY = new float[INPUTSIZE * 4];
+ inY.copyTo(arrayInY);
+ float[] arrayInX = new float[INPUTSIZE * 4];
+ inX.copyTo(arrayInX);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat();
+ args.inY = arrayInY[i * 4 + j];
+ args.inX = arrayInX[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAtan2(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inY: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inY, Float.floatToRawIntBits(args.inY), args.inY));
+ message.append("\n");
+ message.append("Input inX: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inX, Float.floatToRawIntBits(args.inX), args.inX));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAtan2Float3Float3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAtan2Float4Float4Float4() {
Allocation inY = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xe4f6d649d57eac09l, false);
Allocation inX = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xe4f6d649d57eac08l, false);
@@ -98,6 +254,7 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.set_gAllocInX(inX);
script.forEach_testNativeAtan2Float4Float4Float4(inY, out);
+ verifyResultsNativeAtan2Float4Float4Float4(inY, inX, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2Float4Float4Float4: " + e.toString());
}
@@ -105,11 +262,60 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.set_gAllocInX(inX);
scriptRelaxed.forEach_testNativeAtan2Float4Float4Float4(inY, out);
+ verifyResultsNativeAtan2Float4Float4Float4(inY, inX, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2Float4Float4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeAtan2Float4Float4Float4(Allocation inY, Allocation inX, Allocation out, boolean relaxed) {
+ float[] arrayInY = new float[INPUTSIZE * 4];
+ inY.copyTo(arrayInY);
+ float[] arrayInX = new float[INPUTSIZE * 4];
+ inX.copyTo(arrayInX);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat();
+ args.inY = arrayInY[i * 4 + j];
+ args.inX = arrayInX[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAtan2(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inY: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inY, Float.floatToRawIntBits(args.inY), args.inY));
+ message.append("\n");
+ message.append("Input inX: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inX, Float.floatToRawIntBits(args.inX), args.inX));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAtan2Float4Float4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeAtan2() {
checkNativeAtan2FloatFloatFloat();
checkNativeAtan2Float2Float2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtan2pi.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtan2pi.java
index 0dcae63..1cb13e7 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtan2pi.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtan2pi.java
@@ -34,6 +34,12 @@
scriptRelaxed = new ScriptC_TestNativeAtan2piRelaxed(mRS);
}
+ public class ArgumentsFloatFloatFloat {
+ public float inY;
+ public float inX;
+ public Floaty out;
+ }
+
private void checkNativeAtan2piFloatFloatFloat() {
Allocation inY = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x39c4f8fd35fc5dc8l, false);
Allocation inX = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x39c4f8fd35fc5dc7l, false);
@@ -41,6 +47,7 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.set_gAllocInX(inX);
script.forEach_testNativeAtan2piFloatFloatFloat(inY, out);
+ verifyResultsNativeAtan2piFloatFloatFloat(inY, inX, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2piFloatFloatFloat: " + e.toString());
}
@@ -48,11 +55,60 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.set_gAllocInX(inX);
scriptRelaxed.forEach_testNativeAtan2piFloatFloatFloat(inY, out);
+ verifyResultsNativeAtan2piFloatFloatFloat(inY, inX, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2piFloatFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeAtan2piFloatFloatFloat(Allocation inY, Allocation inX, Allocation out, boolean relaxed) {
+ float[] arrayInY = new float[INPUTSIZE * 1];
+ inY.copyTo(arrayInY);
+ float[] arrayInX = new float[INPUTSIZE * 1];
+ inX.copyTo(arrayInX);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat();
+ args.inY = arrayInY[i];
+ args.inX = arrayInX[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAtan2pi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inY: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inY, Float.floatToRawIntBits(args.inY), args.inY));
+ message.append("\n");
+ message.append("Input inX: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inX, Float.floatToRawIntBits(args.inX), args.inX));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAtan2piFloatFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAtan2piFloat2Float2Float2() {
Allocation inY = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x6aff980c8d47a3e2l, false);
Allocation inX = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x6aff980c8d47a3e1l, false);
@@ -60,6 +116,7 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.set_gAllocInX(inX);
script.forEach_testNativeAtan2piFloat2Float2Float2(inY, out);
+ verifyResultsNativeAtan2piFloat2Float2Float2(inY, inX, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2piFloat2Float2Float2: " + e.toString());
}
@@ -67,11 +124,60 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.set_gAllocInX(inX);
scriptRelaxed.forEach_testNativeAtan2piFloat2Float2Float2(inY, out);
+ verifyResultsNativeAtan2piFloat2Float2Float2(inY, inX, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2piFloat2Float2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeAtan2piFloat2Float2Float2(Allocation inY, Allocation inX, Allocation out, boolean relaxed) {
+ float[] arrayInY = new float[INPUTSIZE * 2];
+ inY.copyTo(arrayInY);
+ float[] arrayInX = new float[INPUTSIZE * 2];
+ inX.copyTo(arrayInX);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat();
+ args.inY = arrayInY[i * 2 + j];
+ args.inX = arrayInX[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAtan2pi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inY: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inY, Float.floatToRawIntBits(args.inY), args.inY));
+ message.append("\n");
+ message.append("Input inX: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inX, Float.floatToRawIntBits(args.inX), args.inX));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAtan2piFloat2Float2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAtan2piFloat3Float3Float3() {
Allocation inY = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xbf64762c8f25a583l, false);
Allocation inX = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xbf64762c8f25a582l, false);
@@ -79,6 +185,7 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.set_gAllocInX(inX);
script.forEach_testNativeAtan2piFloat3Float3Float3(inY, out);
+ verifyResultsNativeAtan2piFloat3Float3Float3(inY, inX, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2piFloat3Float3Float3: " + e.toString());
}
@@ -86,11 +193,60 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.set_gAllocInX(inX);
scriptRelaxed.forEach_testNativeAtan2piFloat3Float3Float3(inY, out);
+ verifyResultsNativeAtan2piFloat3Float3Float3(inY, inX, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2piFloat3Float3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeAtan2piFloat3Float3Float3(Allocation inY, Allocation inX, Allocation out, boolean relaxed) {
+ float[] arrayInY = new float[INPUTSIZE * 4];
+ inY.copyTo(arrayInY);
+ float[] arrayInX = new float[INPUTSIZE * 4];
+ inX.copyTo(arrayInX);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat();
+ args.inY = arrayInY[i * 4 + j];
+ args.inX = arrayInX[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAtan2pi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inY: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inY, Float.floatToRawIntBits(args.inY), args.inY));
+ message.append("\n");
+ message.append("Input inX: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inX, Float.floatToRawIntBits(args.inX), args.inX));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAtan2piFloat3Float3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAtan2piFloat4Float4Float4() {
Allocation inY = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x13c9544c9103a724l, false);
Allocation inX = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x13c9544c9103a723l, false);
@@ -98,6 +254,7 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.set_gAllocInX(inX);
script.forEach_testNativeAtan2piFloat4Float4Float4(inY, out);
+ verifyResultsNativeAtan2piFloat4Float4Float4(inY, inX, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2piFloat4Float4Float4: " + e.toString());
}
@@ -105,11 +262,60 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.set_gAllocInX(inX);
scriptRelaxed.forEach_testNativeAtan2piFloat4Float4Float4(inY, out);
+ verifyResultsNativeAtan2piFloat4Float4Float4(inY, inX, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtan2piFloat4Float4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeAtan2piFloat4Float4Float4(Allocation inY, Allocation inX, Allocation out, boolean relaxed) {
+ float[] arrayInY = new float[INPUTSIZE * 4];
+ inY.copyTo(arrayInY);
+ float[] arrayInX = new float[INPUTSIZE * 4];
+ inX.copyTo(arrayInX);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat();
+ args.inY = arrayInY[i * 4 + j];
+ args.inX = arrayInX[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAtan2pi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inY: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inY, Float.floatToRawIntBits(args.inY), args.inY));
+ message.append("\n");
+ message.append("Input inX: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inX, Float.floatToRawIntBits(args.inX), args.inX));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAtan2piFloat4Float4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeAtan2pi() {
checkNativeAtan2piFloatFloatFloat();
checkNativeAtan2piFloat2Float2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtanh.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtanh.java
index fffc9ae..b6a6f4e 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtanh.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtanh.java
@@ -34,70 +34,247 @@
scriptRelaxed = new ScriptC_TestNativeAtanhRelaxed(mRS);
}
+ public class ArgumentsFloatFloat {
+ public float in;
+ public Floaty out;
+ }
+
private void checkNativeAtanhFloatFloat() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x66daa6c24cd0610al, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.forEach_testNativeAtanhFloatFloat(in, out);
+ verifyResultsNativeAtanhFloatFloat(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanhFloatFloat: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.forEach_testNativeAtanhFloatFloat(in, out);
+ verifyResultsNativeAtanhFloatFloat(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanhFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeAtanhFloatFloat(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 1];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAtanh(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAtanhFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAtanhFloat2Float2() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xe13d93587e455c56l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.forEach_testNativeAtanhFloat2Float2(in, out);
+ verifyResultsNativeAtanhFloat2Float2(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanhFloat2Float2: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.forEach_testNativeAtanhFloat2Float2(in, out);
+ verifyResultsNativeAtanhFloat2Float2(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanhFloat2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeAtanhFloat2Float2(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 2];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAtanh(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAtanhFloat2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAtanhFloat3Float3() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xe13d9df9dd4bf1f0l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.forEach_testNativeAtanhFloat3Float3(in, out);
+ verifyResultsNativeAtanhFloat3Float3(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanhFloat3Float3: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.forEach_testNativeAtanhFloat3Float3(in, out);
+ verifyResultsNativeAtanhFloat3Float3(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanhFloat3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeAtanhFloat3Float3(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAtanh(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAtanhFloat3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAtanhFloat4Float4() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xe13da89b3c52878al, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.forEach_testNativeAtanhFloat4Float4(in, out);
+ verifyResultsNativeAtanhFloat4Float4(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanhFloat4Float4: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.forEach_testNativeAtanhFloat4Float4(in, out);
+ verifyResultsNativeAtanhFloat4Float4(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanhFloat4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeAtanhFloat4Float4(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAtanh(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAtanhFloat4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeAtanh() {
checkNativeAtanhFloatFloat();
checkNativeAtanhFloat2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtanpi.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtanpi.java
index aa26b10..0a17823 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtanpi.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeAtanpi.java
@@ -34,70 +34,247 @@
scriptRelaxed = new ScriptC_TestNativeAtanpiRelaxed(mRS);
}
+ public class ArgumentsFloatFloat {
+ public float inV;
+ public Floaty out;
+ }
+
private void checkNativeAtanpiFloatFloat() {
Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x3fd790efd1d451bdl, -1, 1);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.forEach_testNativeAtanpiFloatFloat(inV, out);
+ verifyResultsNativeAtanpiFloatFloat(inV, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanpiFloatFloat: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.forEach_testNativeAtanpiFloatFloat(inV, out);
+ verifyResultsNativeAtanpiFloatFloat(inV, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanpiFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeAtanpiFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 1];
+ inV.copyTo(arrayInV);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.inV = arrayInV[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAtanpi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAtanpiFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAtanpiFloat2Float2() {
Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x1bd089694afc9ef9l, -1, 1);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.forEach_testNativeAtanpiFloat2Float2(inV, out);
+ verifyResultsNativeAtanpiFloat2Float2(inV, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanpiFloat2Float2: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.forEach_testNativeAtanpiFloat2Float2(inV, out);
+ verifyResultsNativeAtanpiFloat2Float2(inV, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanpiFloat2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeAtanpiFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 2];
+ inV.copyTo(arrayInV);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.inV = arrayInV[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAtanpi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAtanpiFloat2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAtanpiFloat3Float3() {
Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x1bd252844117bfd7l, -1, 1);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.forEach_testNativeAtanpiFloat3Float3(inV, out);
+ verifyResultsNativeAtanpiFloat3Float3(inV, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanpiFloat3Float3: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.forEach_testNativeAtanpiFloat3Float3(inV, out);
+ verifyResultsNativeAtanpiFloat3Float3(inV, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanpiFloat3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeAtanpiFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 4];
+ inV.copyTo(arrayInV);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.inV = arrayInV[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAtanpi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAtanpiFloat3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeAtanpiFloat4Float4() {
Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x1bd41b9f3732e0b5l, -1, 1);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.forEach_testNativeAtanpiFloat4Float4(inV, out);
+ verifyResultsNativeAtanpiFloat4Float4(inV, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanpiFloat4Float4: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.forEach_testNativeAtanpiFloat4Float4(inV, out);
+ verifyResultsNativeAtanpiFloat4Float4(inV, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeAtanpiFloat4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeAtanpiFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 4];
+ inV.copyTo(arrayInV);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.inV = arrayInV[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeAtanpi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeAtanpiFloat4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeAtanpi() {
checkNativeAtanpiFloatFloat();
checkNativeAtanpiFloat2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeCbrt.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeCbrt.java
index a947902..2f11069 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeCbrt.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeCbrt.java
@@ -34,70 +34,247 @@
scriptRelaxed = new ScriptC_TestNativeCbrtRelaxed(mRS);
}
+ public class ArgumentsFloatFloat {
+ public float in;
+ public Floaty out;
+ }
+
private void checkNativeCbrtFloatFloat() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x6eed1901e2ca9d19l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.forEach_testNativeCbrtFloatFloat(in, out);
+ verifyResultsNativeCbrtFloatFloat(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCbrtFloatFloat: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.forEach_testNativeCbrtFloatFloat(in, out);
+ verifyResultsNativeCbrtFloatFloat(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCbrtFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeCbrtFloatFloat(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 1];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeCbrt(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeCbrtFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeCbrtFloat2Float2() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x2e78c09abaa124adl, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.forEach_testNativeCbrtFloat2Float2(in, out);
+ verifyResultsNativeCbrtFloat2Float2(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCbrtFloat2Float2: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.forEach_testNativeCbrtFloat2Float2(in, out);
+ verifyResultsNativeCbrtFloat2Float2(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCbrtFloat2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeCbrtFloat2Float2(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 2];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeCbrt(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeCbrtFloat2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeCbrtFloat3Float3() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x2e78cb3c19a7ba47l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.forEach_testNativeCbrtFloat3Float3(in, out);
+ verifyResultsNativeCbrtFloat3Float3(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCbrtFloat3Float3: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.forEach_testNativeCbrtFloat3Float3(in, out);
+ verifyResultsNativeCbrtFloat3Float3(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCbrtFloat3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeCbrtFloat3Float3(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeCbrt(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeCbrtFloat3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeCbrtFloat4Float4() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x2e78d5dd78ae4fe1l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.forEach_testNativeCbrtFloat4Float4(in, out);
+ verifyResultsNativeCbrtFloat4Float4(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCbrtFloat4Float4: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.forEach_testNativeCbrtFloat4Float4(in, out);
+ verifyResultsNativeCbrtFloat4Float4(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCbrtFloat4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeCbrtFloat4Float4(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeCbrt(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeCbrtFloat4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeCbrt() {
checkNativeCbrtFloatFloat();
checkNativeCbrtFloat2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeCos.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeCos.java
index e778390..347f96a 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeCos.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeCos.java
@@ -34,70 +34,247 @@
scriptRelaxed = new ScriptC_TestNativeCosRelaxed(mRS);
}
+ public class ArgumentsFloatFloat {
+ public float in;
+ public Floaty out;
+ }
+
private void checkNativeCosFloatFloat() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x95ef4a20c73e7e3dl, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.forEach_testNativeCosFloatFloat(in, out);
+ verifyResultsNativeCosFloatFloat(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCosFloatFloat: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.forEach_testNativeCosFloatFloat(in, out);
+ verifyResultsNativeCosFloatFloat(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCosFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeCosFloatFloat(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 1];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeCos(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeCosFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeCosFloat2Float2() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xed4d88bac39641b1l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.forEach_testNativeCosFloat2Float2(in, out);
+ verifyResultsNativeCosFloat2Float2(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCosFloat2Float2: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.forEach_testNativeCosFloat2Float2(in, out);
+ verifyResultsNativeCosFloat2Float2(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCosFloat2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeCosFloat2Float2(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 2];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeCos(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeCosFloat2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeCosFloat3Float3() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xed4d935c229cd74bl, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.forEach_testNativeCosFloat3Float3(in, out);
+ verifyResultsNativeCosFloat3Float3(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCosFloat3Float3: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.forEach_testNativeCosFloat3Float3(in, out);
+ verifyResultsNativeCosFloat3Float3(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCosFloat3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeCosFloat3Float3(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeCos(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeCosFloat3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeCosFloat4Float4() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xed4d9dfd81a36ce5l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.forEach_testNativeCosFloat4Float4(in, out);
+ verifyResultsNativeCosFloat4Float4(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCosFloat4Float4: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.forEach_testNativeCosFloat4Float4(in, out);
+ verifyResultsNativeCosFloat4Float4(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCosFloat4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeCosFloat4Float4(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeCos(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeCosFloat4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeCos() {
checkNativeCosFloatFloat();
checkNativeCosFloat2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeCosh.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeCosh.java
index c8a177b..a3ba2df 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeCosh.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeCosh.java
@@ -34,70 +34,247 @@
scriptRelaxed = new ScriptC_TestNativeCoshRelaxed(mRS);
}
+ public class ArgumentsFloatFloat {
+ public float in;
+ public Floaty out;
+ }
+
private void checkNativeCoshFloatFloat() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xeb1020909e9c475dl, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.forEach_testNativeCoshFloatFloat(in, out);
+ verifyResultsNativeCoshFloatFloat(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCoshFloatFloat: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.forEach_testNativeCoshFloatFloat(in, out);
+ verifyResultsNativeCoshFloatFloat(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCoshFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeCoshFloatFloat(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 1];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeCosh(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeCoshFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeCoshFloat2Float2() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xc77a568547f7e9d1l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.forEach_testNativeCoshFloat2Float2(in, out);
+ verifyResultsNativeCoshFloat2Float2(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCoshFloat2Float2: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.forEach_testNativeCoshFloat2Float2(in, out);
+ verifyResultsNativeCoshFloat2Float2(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCoshFloat2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeCoshFloat2Float2(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 2];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeCosh(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeCoshFloat2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeCoshFloat3Float3() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xc77a6126a6fe7f6bl, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.forEach_testNativeCoshFloat3Float3(in, out);
+ verifyResultsNativeCoshFloat3Float3(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCoshFloat3Float3: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.forEach_testNativeCoshFloat3Float3(in, out);
+ verifyResultsNativeCoshFloat3Float3(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCoshFloat3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeCoshFloat3Float3(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeCosh(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeCoshFloat3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeCoshFloat4Float4() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xc77a6bc806051505l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.forEach_testNativeCoshFloat4Float4(in, out);
+ verifyResultsNativeCoshFloat4Float4(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCoshFloat4Float4: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.forEach_testNativeCoshFloat4Float4(in, out);
+ verifyResultsNativeCoshFloat4Float4(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCoshFloat4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeCoshFloat4Float4(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeCosh(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeCoshFloat4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeCosh() {
checkNativeCoshFloatFloat();
checkNativeCoshFloat2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeCospi.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeCospi.java
index b4c62ce..0136d45 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeCospi.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeCospi.java
@@ -34,70 +34,247 @@
scriptRelaxed = new ScriptC_TestNativeCospiRelaxed(mRS);
}
+ public class ArgumentsFloatFloat {
+ public float in;
+ public Floaty out;
+ }
+
private void checkNativeCospiFloatFloat() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x8fc4f0187aafc9a6l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.forEach_testNativeCospiFloatFloat(in, out);
+ verifyResultsNativeCospiFloatFloat(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCospiFloatFloat: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.forEach_testNativeCospiFloatFloat(in, out);
+ verifyResultsNativeCospiFloatFloat(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCospiFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeCospiFloatFloat(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 1];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeCospi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeCospiFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeCospiFloat2Float2() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x656942c9d0dfeb12l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.forEach_testNativeCospiFloat2Float2(in, out);
+ verifyResultsNativeCospiFloat2Float2(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCospiFloat2Float2: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.forEach_testNativeCospiFloat2Float2(in, out);
+ verifyResultsNativeCospiFloat2Float2(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCospiFloat2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeCospiFloat2Float2(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 2];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeCospi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeCospiFloat2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeCospiFloat3Float3() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x65694d6b2fe680acl, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.forEach_testNativeCospiFloat3Float3(in, out);
+ verifyResultsNativeCospiFloat3Float3(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCospiFloat3Float3: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.forEach_testNativeCospiFloat3Float3(in, out);
+ verifyResultsNativeCospiFloat3Float3(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCospiFloat3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeCospiFloat3Float3(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeCospi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeCospiFloat3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeCospiFloat4Float4() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x6569580c8eed1646l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.forEach_testNativeCospiFloat4Float4(in, out);
+ verifyResultsNativeCospiFloat4Float4(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCospiFloat4Float4: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.forEach_testNativeCospiFloat4Float4(in, out);
+ verifyResultsNativeCospiFloat4Float4(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeCospiFloat4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeCospiFloat4Float4(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeCospi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeCospiFloat4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeCospi() {
checkNativeCospiFloatFloat();
checkNativeCospiFloat2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeDistance.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeDistance.java
index 00833a3..975910e 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeDistance.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeDistance.java
@@ -34,6 +34,12 @@
scriptRelaxed = new ScriptC_TestNativeDistanceRelaxed(mRS);
}
+ public class ArgumentsFloatFloatFloat {
+ public float inLhs;
+ public float inRhs;
+ public Floaty out;
+ }
+
private void checkNativeDistanceFloatFloatFloat() {
Allocation inLhs = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe0fd4252f8556ff6l, false);
Allocation inRhs = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe0fd4252f8559b4cl, false);
@@ -41,6 +47,7 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.set_gAllocInRhs(inRhs);
script.forEach_testNativeDistanceFloatFloatFloat(inLhs, out);
+ verifyResultsNativeDistanceFloatFloatFloat(inLhs, inRhs, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceFloatFloatFloat: " + e.toString());
}
@@ -48,11 +55,65 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.set_gAllocInRhs(inRhs);
scriptRelaxed.forEach_testNativeDistanceFloatFloatFloat(inLhs, out);
+ verifyResultsNativeDistanceFloatFloatFloat(inLhs, inRhs, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceFloatFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeDistanceFloatFloatFloat(Allocation inLhs, Allocation inRhs, Allocation out, boolean relaxed) {
+ float[] arrayInLhs = new float[INPUTSIZE * 1];
+ inLhs.copyTo(arrayInLhs);
+ float[] arrayInRhs = new float[INPUTSIZE * 1];
+ inRhs.copyTo(arrayInRhs);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat();
+ // Create the appropriate sized arrays in args
+ // Fill args with the input values
+ args.inLhs = arrayInLhs[i];
+ args.inRhs = arrayInRhs[i];
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeDistance(args);
+
+ // Compare the expected outputs to the actual values returned by RS.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inLhs: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayInLhs[i], Float.floatToRawIntBits(arrayInLhs[i]), arrayInLhs[i]));
+ message.append("\n");
+ message.append("Input inRhs: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayInRhs[i], Float.floatToRawIntBits(arrayInRhs[i]), arrayInRhs[i]));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i], Float.floatToRawIntBits(arrayOut[i]), arrayOut[i]));
+ if (!args.out.couldBe(arrayOut[i])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeDistanceFloatFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+
+ public class ArgumentsFloatNFloatNFloat {
+ public float[] inLhs;
+ public float[] inRhs;
+ public Floaty out;
+ }
+
private void checkNativeDistanceFloat2Float2Float() {
Allocation inLhs = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x28a9ea2ea1fd926al, false);
Allocation inRhs = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x28a9ea2ea1fdbdc0l, false);
@@ -60,6 +121,7 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.set_gAllocInRhs(inRhs);
script.forEach_testNativeDistanceFloat2Float2Float(inLhs, out);
+ verifyResultsNativeDistanceFloat2Float2Float(inLhs, inRhs, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceFloat2Float2Float: " + e.toString());
}
@@ -67,11 +129,69 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.set_gAllocInRhs(inRhs);
scriptRelaxed.forEach_testNativeDistanceFloat2Float2Float(inLhs, out);
+ verifyResultsNativeDistanceFloat2Float2Float(inLhs, inRhs, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceFloat2Float2Float: " + e.toString());
}
}
+ private void verifyResultsNativeDistanceFloat2Float2Float(Allocation inLhs, Allocation inRhs, Allocation out, boolean relaxed) {
+ float[] arrayInLhs = new float[INPUTSIZE * 2];
+ inLhs.copyTo(arrayInLhs);
+ float[] arrayInRhs = new float[INPUTSIZE * 2];
+ inRhs.copyTo(arrayInRhs);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ ArgumentsFloatNFloatNFloat args = new ArgumentsFloatNFloatNFloat();
+ // Create the appropriate sized arrays in args
+ args.inLhs = new float[2];
+ args.inRhs = new float[2];
+ // Fill args with the input values
+ for (int j = 0; j < 2 ; j++) {
+ args.inLhs[j] = arrayInLhs[i * 2 + j];
+ }
+ for (int j = 0; j < 2 ; j++) {
+ args.inRhs[j] = arrayInRhs[i * 2 + j];
+ }
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeDistance(args);
+
+ // Compare the expected outputs to the actual values returned by RS.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ for (int j = 0; j < 2 ; j++) {
+ message.append("Input inLhs: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayInLhs[i * 2 + j], Float.floatToRawIntBits(arrayInLhs[i * 2 + j]), arrayInLhs[i * 2 + j]));
+ message.append("\n");
+ }
+ for (int j = 0; j < 2 ; j++) {
+ message.append("Input inRhs: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayInRhs[i * 2 + j], Float.floatToRawIntBits(arrayInRhs[i * 2 + j]), arrayInRhs[i * 2 + j]));
+ message.append("\n");
+ }
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i], Float.floatToRawIntBits(arrayOut[i]), arrayOut[i]));
+ if (!args.out.couldBe(arrayOut[i])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeDistanceFloat2Float2Float" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+
private void checkNativeDistanceFloat3Float3Float() {
Allocation inLhs = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x559b398ef213adc4l, false);
Allocation inRhs = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x559b398ef213d91al, false);
@@ -79,6 +199,7 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.set_gAllocInRhs(inRhs);
script.forEach_testNativeDistanceFloat3Float3Float(inLhs, out);
+ verifyResultsNativeDistanceFloat3Float3Float(inLhs, inRhs, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceFloat3Float3Float: " + e.toString());
}
@@ -86,11 +207,69 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.set_gAllocInRhs(inRhs);
scriptRelaxed.forEach_testNativeDistanceFloat3Float3Float(inLhs, out);
+ verifyResultsNativeDistanceFloat3Float3Float(inLhs, inRhs, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceFloat3Float3Float: " + e.toString());
}
}
+ private void verifyResultsNativeDistanceFloat3Float3Float(Allocation inLhs, Allocation inRhs, Allocation out, boolean relaxed) {
+ float[] arrayInLhs = new float[INPUTSIZE * 4];
+ inLhs.copyTo(arrayInLhs);
+ float[] arrayInRhs = new float[INPUTSIZE * 4];
+ inRhs.copyTo(arrayInRhs);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ ArgumentsFloatNFloatNFloat args = new ArgumentsFloatNFloatNFloat();
+ // Create the appropriate sized arrays in args
+ args.inLhs = new float[3];
+ args.inRhs = new float[3];
+ // Fill args with the input values
+ for (int j = 0; j < 3 ; j++) {
+ args.inLhs[j] = arrayInLhs[i * 4 + j];
+ }
+ for (int j = 0; j < 3 ; j++) {
+ args.inRhs[j] = arrayInRhs[i * 4 + j];
+ }
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeDistance(args);
+
+ // Compare the expected outputs to the actual values returned by RS.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ for (int j = 0; j < 3 ; j++) {
+ message.append("Input inLhs: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayInLhs[i * 4 + j], Float.floatToRawIntBits(arrayInLhs[i * 4 + j]), arrayInLhs[i * 4 + j]));
+ message.append("\n");
+ }
+ for (int j = 0; j < 3 ; j++) {
+ message.append("Input inRhs: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayInRhs[i * 4 + j], Float.floatToRawIntBits(arrayInRhs[i * 4 + j]), arrayInRhs[i * 4 + j]));
+ message.append("\n");
+ }
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i], Float.floatToRawIntBits(arrayOut[i]), arrayOut[i]));
+ if (!args.out.couldBe(arrayOut[i])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeDistanceFloat3Float3Float" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+
private void checkNativeDistanceFloat4Float4Float() {
Allocation inLhs = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x828c88ef4229c91el, false);
Allocation inRhs = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x828c88ef4229f474l, false);
@@ -98,6 +277,7 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.set_gAllocInRhs(inRhs);
script.forEach_testNativeDistanceFloat4Float4Float(inLhs, out);
+ verifyResultsNativeDistanceFloat4Float4Float(inLhs, inRhs, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceFloat4Float4Float: " + e.toString());
}
@@ -105,11 +285,69 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.set_gAllocInRhs(inRhs);
scriptRelaxed.forEach_testNativeDistanceFloat4Float4Float(inLhs, out);
+ verifyResultsNativeDistanceFloat4Float4Float(inLhs, inRhs, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDistanceFloat4Float4Float: " + e.toString());
}
}
+ private void verifyResultsNativeDistanceFloat4Float4Float(Allocation inLhs, Allocation inRhs, Allocation out, boolean relaxed) {
+ float[] arrayInLhs = new float[INPUTSIZE * 4];
+ inLhs.copyTo(arrayInLhs);
+ float[] arrayInRhs = new float[INPUTSIZE * 4];
+ inRhs.copyTo(arrayInRhs);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ ArgumentsFloatNFloatNFloat args = new ArgumentsFloatNFloatNFloat();
+ // Create the appropriate sized arrays in args
+ args.inLhs = new float[4];
+ args.inRhs = new float[4];
+ // Fill args with the input values
+ for (int j = 0; j < 4 ; j++) {
+ args.inLhs[j] = arrayInLhs[i * 4 + j];
+ }
+ for (int j = 0; j < 4 ; j++) {
+ args.inRhs[j] = arrayInRhs[i * 4 + j];
+ }
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeDistance(args);
+
+ // Compare the expected outputs to the actual values returned by RS.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ for (int j = 0; j < 4 ; j++) {
+ message.append("Input inLhs: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayInLhs[i * 4 + j], Float.floatToRawIntBits(arrayInLhs[i * 4 + j]), arrayInLhs[i * 4 + j]));
+ message.append("\n");
+ }
+ for (int j = 0; j < 4 ; j++) {
+ message.append("Input inRhs: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayInRhs[i * 4 + j], Float.floatToRawIntBits(arrayInRhs[i * 4 + j]), arrayInRhs[i * 4 + j]));
+ message.append("\n");
+ }
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i], Float.floatToRawIntBits(arrayOut[i]), arrayOut[i]));
+ if (!args.out.couldBe(arrayOut[i])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeDistanceFloat4Float4Float" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+
public void testNativeDistance() {
checkNativeDistanceFloatFloatFloat();
checkNativeDistanceFloat2Float2Float();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeDivide.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeDivide.java
index 3a2323f..e77a9cf 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeDivide.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeDivide.java
@@ -34,6 +34,12 @@
scriptRelaxed = new ScriptC_TestNativeDivideRelaxed(mRS);
}
+ public class ArgumentsFloatFloatFloat {
+ public float inLhs;
+ public float inRhs;
+ public Floaty out;
+ }
+
private void checkNativeDivideFloatFloatFloat() {
Allocation inLhs = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe2845ef0c23d02del, false);
Allocation inRhs = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe2845ef0c23d2e34l, false);
@@ -41,6 +47,7 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.set_gAllocInRhs(inRhs);
script.forEach_testNativeDivideFloatFloatFloat(inLhs, out);
+ verifyResultsNativeDivideFloatFloatFloat(inLhs, inRhs, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDivideFloatFloatFloat: " + e.toString());
}
@@ -48,11 +55,60 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.set_gAllocInRhs(inRhs);
scriptRelaxed.forEach_testNativeDivideFloatFloatFloat(inLhs, out);
+ verifyResultsNativeDivideFloatFloatFloat(inLhs, inRhs, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDivideFloatFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeDivideFloatFloatFloat(Allocation inLhs, Allocation inRhs, Allocation out, boolean relaxed) {
+ float[] arrayInLhs = new float[INPUTSIZE * 1];
+ inLhs.copyTo(arrayInLhs);
+ float[] arrayInRhs = new float[INPUTSIZE * 1];
+ inRhs.copyTo(arrayInRhs);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat();
+ args.inLhs = arrayInLhs[i];
+ args.inRhs = arrayInRhs[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeDivide(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inLhs: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inLhs, Float.floatToRawIntBits(args.inLhs), args.inLhs));
+ message.append("\n");
+ message.append("Input inRhs: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inRhs, Float.floatToRawIntBits(args.inRhs), args.inRhs));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeDivideFloatFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeDivideFloat2Float2Float2() {
Allocation inLhs = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x51c6d6ecaeab1c48l, false);
Allocation inRhs = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x51c6d6ecaeab479el, false);
@@ -60,6 +116,7 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.set_gAllocInRhs(inRhs);
script.forEach_testNativeDivideFloat2Float2Float2(inLhs, out);
+ verifyResultsNativeDivideFloat2Float2Float2(inLhs, inRhs, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDivideFloat2Float2Float2: " + e.toString());
}
@@ -67,11 +124,60 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.set_gAllocInRhs(inRhs);
scriptRelaxed.forEach_testNativeDivideFloat2Float2Float2(inLhs, out);
+ verifyResultsNativeDivideFloat2Float2Float2(inLhs, inRhs, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDivideFloat2Float2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeDivideFloat2Float2Float2(Allocation inLhs, Allocation inRhs, Allocation out, boolean relaxed) {
+ float[] arrayInLhs = new float[INPUTSIZE * 2];
+ inLhs.copyTo(arrayInLhs);
+ float[] arrayInRhs = new float[INPUTSIZE * 2];
+ inRhs.copyTo(arrayInRhs);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat();
+ args.inLhs = arrayInLhs[i * 2 + j];
+ args.inRhs = arrayInRhs[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeDivide(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inLhs: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inLhs, Float.floatToRawIntBits(args.inLhs), args.inLhs));
+ message.append("\n");
+ message.append("Input inRhs: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inRhs, Float.floatToRawIntBits(args.inRhs), args.inRhs));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeDivideFloat2Float2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeDivideFloat3Float3Float3() {
Allocation inLhs = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xde4f2c1a2b24e021l, false);
Allocation inRhs = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xde4f2c1a2b250b77l, false);
@@ -79,6 +185,7 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.set_gAllocInRhs(inRhs);
script.forEach_testNativeDivideFloat3Float3Float3(inLhs, out);
+ verifyResultsNativeDivideFloat3Float3Float3(inLhs, inRhs, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDivideFloat3Float3Float3: " + e.toString());
}
@@ -86,11 +193,60 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.set_gAllocInRhs(inRhs);
scriptRelaxed.forEach_testNativeDivideFloat3Float3Float3(inLhs, out);
+ verifyResultsNativeDivideFloat3Float3Float3(inLhs, inRhs, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDivideFloat3Float3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeDivideFloat3Float3Float3(Allocation inLhs, Allocation inRhs, Allocation out, boolean relaxed) {
+ float[] arrayInLhs = new float[INPUTSIZE * 4];
+ inLhs.copyTo(arrayInLhs);
+ float[] arrayInRhs = new float[INPUTSIZE * 4];
+ inRhs.copyTo(arrayInRhs);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat();
+ args.inLhs = arrayInLhs[i * 4 + j];
+ args.inRhs = arrayInRhs[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeDivide(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inLhs: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inLhs, Float.floatToRawIntBits(args.inLhs), args.inLhs));
+ message.append("\n");
+ message.append("Input inRhs: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inRhs, Float.floatToRawIntBits(args.inRhs), args.inRhs));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeDivideFloat3Float3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeDivideFloat4Float4Float4() {
Allocation inLhs = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x6ad78147a79ea3fal, false);
Allocation inRhs = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x6ad78147a79ecf50l, false);
@@ -98,6 +254,7 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.set_gAllocInRhs(inRhs);
script.forEach_testNativeDivideFloat4Float4Float4(inLhs, out);
+ verifyResultsNativeDivideFloat4Float4Float4(inLhs, inRhs, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDivideFloat4Float4Float4: " + e.toString());
}
@@ -105,11 +262,60 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.set_gAllocInRhs(inRhs);
scriptRelaxed.forEach_testNativeDivideFloat4Float4Float4(inLhs, out);
+ verifyResultsNativeDivideFloat4Float4Float4(inLhs, inRhs, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeDivideFloat4Float4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeDivideFloat4Float4Float4(Allocation inLhs, Allocation inRhs, Allocation out, boolean relaxed) {
+ float[] arrayInLhs = new float[INPUTSIZE * 4];
+ inLhs.copyTo(arrayInLhs);
+ float[] arrayInRhs = new float[INPUTSIZE * 4];
+ inRhs.copyTo(arrayInRhs);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat();
+ args.inLhs = arrayInLhs[i * 4 + j];
+ args.inRhs = arrayInRhs[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeDivide(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inLhs: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inLhs, Float.floatToRawIntBits(args.inLhs), args.inLhs));
+ message.append("\n");
+ message.append("Input inRhs: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inRhs, Float.floatToRawIntBits(args.inRhs), args.inRhs));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeDivideFloat4Float4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeDivide() {
checkNativeDivideFloatFloatFloat();
checkNativeDivideFloat2Float2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeExpm1.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeExpm1.java
index 5e2cde6..4b8b102 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeExpm1.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeExpm1.java
@@ -34,70 +34,247 @@
scriptRelaxed = new ScriptC_TestNativeExpm1Relaxed(mRS);
}
+ public class ArgumentsFloatFloat {
+ public float in;
+ public Floaty out;
+ }
+
private void checkNativeExpm1FloatFloat() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x209e2820fcaa295fl, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.forEach_testNativeExpm1FloatFloat(in, out);
+ verifyResultsNativeExpm1FloatFloat(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpm1FloatFloat: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.forEach_testNativeExpm1FloatFloat(in, out);
+ verifyResultsNativeExpm1FloatFloat(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpm1FloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeExpm1FloatFloat(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 1];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeExpm1(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeExpm1FloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeExpm1Float2Float2() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x964ef83c9a3d4a43l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.forEach_testNativeExpm1Float2Float2(in, out);
+ verifyResultsNativeExpm1Float2Float2(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpm1Float2Float2: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.forEach_testNativeExpm1Float2Float2(in, out);
+ verifyResultsNativeExpm1Float2Float2(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpm1Float2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeExpm1Float2Float2(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 2];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeExpm1(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeExpm1Float2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeExpm1Float3Float3() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x964f02ddf943dfddl, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.forEach_testNativeExpm1Float3Float3(in, out);
+ verifyResultsNativeExpm1Float3Float3(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpm1Float3Float3: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.forEach_testNativeExpm1Float3Float3(in, out);
+ verifyResultsNativeExpm1Float3Float3(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpm1Float3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeExpm1Float3Float3(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeExpm1(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeExpm1Float3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeExpm1Float4Float4() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x964f0d7f584a7577l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.forEach_testNativeExpm1Float4Float4(in, out);
+ verifyResultsNativeExpm1Float4Float4(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpm1Float4Float4: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.forEach_testNativeExpm1Float4Float4(in, out);
+ verifyResultsNativeExpm1Float4Float4(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeExpm1Float4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeExpm1Float4Float4(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeExpm1(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeExpm1Float4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeExpm1() {
checkNativeExpm1FloatFloat();
checkNativeExpm1Float2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeHypot.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeHypot.java
index d1b5f76..b3538d5 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeHypot.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeHypot.java
@@ -34,6 +34,12 @@
scriptRelaxed = new ScriptC_TestNativeHypotRelaxed(mRS);
}
+ public class ArgumentsFloatFloatFloat {
+ public float inX;
+ public float inY;
+ public Floaty out;
+ }
+
private void checkNativeHypotFloatFloatFloat() {
Allocation inX = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x3d61f129bdf66018l, false);
Allocation inY = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x3d61f129bdf66019l, false);
@@ -41,6 +47,7 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.set_gAllocInY(inY);
script.forEach_testNativeHypotFloatFloatFloat(inX, out);
+ verifyResultsNativeHypotFloatFloatFloat(inX, inY, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeHypotFloatFloatFloat: " + e.toString());
}
@@ -48,11 +55,60 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.set_gAllocInY(inY);
scriptRelaxed.forEach_testNativeHypotFloatFloatFloat(inX, out);
+ verifyResultsNativeHypotFloatFloatFloat(inX, inY, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeHypotFloatFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeHypotFloatFloatFloat(Allocation inX, Allocation inY, Allocation out, boolean relaxed) {
+ float[] arrayInX = new float[INPUTSIZE * 1];
+ inX.copyTo(arrayInX);
+ float[] arrayInY = new float[INPUTSIZE * 1];
+ inY.copyTo(arrayInY);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat();
+ args.inX = arrayInX[i];
+ args.inY = arrayInY[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeHypot(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inX: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inX, Float.floatToRawIntBits(args.inX), args.inX));
+ message.append("\n");
+ message.append("Input inY: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inY, Float.floatToRawIntBits(args.inY), args.inY));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeHypotFloatFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeHypotFloat2Float2Float2() {
Allocation inX = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x92a8064760a50e64l, false);
Allocation inY = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x92a8064760a50e65l, false);
@@ -60,6 +116,7 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.set_gAllocInY(inY);
script.forEach_testNativeHypotFloat2Float2Float2(inX, out);
+ verifyResultsNativeHypotFloat2Float2Float2(inX, inY, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeHypotFloat2Float2Float2: " + e.toString());
}
@@ -67,11 +124,60 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.set_gAllocInY(inY);
scriptRelaxed.forEach_testNativeHypotFloat2Float2Float2(inX, out);
+ verifyResultsNativeHypotFloat2Float2Float2(inX, inY, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeHypotFloat2Float2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeHypotFloat2Float2Float2(Allocation inX, Allocation inY, Allocation out, boolean relaxed) {
+ float[] arrayInX = new float[INPUTSIZE * 2];
+ inX.copyTo(arrayInX);
+ float[] arrayInY = new float[INPUTSIZE * 2];
+ inY.copyTo(arrayInY);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat();
+ args.inX = arrayInX[i * 2 + j];
+ args.inY = arrayInY[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeHypot(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inX: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inX, Float.floatToRawIntBits(args.inX), args.inX));
+ message.append("\n");
+ message.append("Input inY: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inY, Float.floatToRawIntBits(args.inY), args.inY));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeHypotFloat2Float2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeHypotFloat3Float3Float3() {
Allocation inX = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xe70ce46762831005l, false);
Allocation inY = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xe70ce46762831006l, false);
@@ -79,6 +185,7 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.set_gAllocInY(inY);
script.forEach_testNativeHypotFloat3Float3Float3(inX, out);
+ verifyResultsNativeHypotFloat3Float3Float3(inX, inY, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeHypotFloat3Float3Float3: " + e.toString());
}
@@ -86,11 +193,60 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.set_gAllocInY(inY);
scriptRelaxed.forEach_testNativeHypotFloat3Float3Float3(inX, out);
+ verifyResultsNativeHypotFloat3Float3Float3(inX, inY, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeHypotFloat3Float3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeHypotFloat3Float3Float3(Allocation inX, Allocation inY, Allocation out, boolean relaxed) {
+ float[] arrayInX = new float[INPUTSIZE * 4];
+ inX.copyTo(arrayInX);
+ float[] arrayInY = new float[INPUTSIZE * 4];
+ inY.copyTo(arrayInY);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat();
+ args.inX = arrayInX[i * 4 + j];
+ args.inY = arrayInY[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeHypot(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inX: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inX, Float.floatToRawIntBits(args.inX), args.inX));
+ message.append("\n");
+ message.append("Input inY: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inY, Float.floatToRawIntBits(args.inY), args.inY));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeHypotFloat3Float3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeHypotFloat4Float4Float4() {
Allocation inX = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3b71c287646111a6l, false);
Allocation inY = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3b71c287646111a7l, false);
@@ -98,6 +254,7 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.set_gAllocInY(inY);
script.forEach_testNativeHypotFloat4Float4Float4(inX, out);
+ verifyResultsNativeHypotFloat4Float4Float4(inX, inY, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeHypotFloat4Float4Float4: " + e.toString());
}
@@ -105,11 +262,60 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.set_gAllocInY(inY);
scriptRelaxed.forEach_testNativeHypotFloat4Float4Float4(inX, out);
+ verifyResultsNativeHypotFloat4Float4Float4(inX, inY, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeHypotFloat4Float4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeHypotFloat4Float4Float4(Allocation inX, Allocation inY, Allocation out, boolean relaxed) {
+ float[] arrayInX = new float[INPUTSIZE * 4];
+ inX.copyTo(arrayInX);
+ float[] arrayInY = new float[INPUTSIZE * 4];
+ inY.copyTo(arrayInY);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat();
+ args.inX = arrayInX[i * 4 + j];
+ args.inY = arrayInY[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeHypot(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inX: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inX, Float.floatToRawIntBits(args.inX), args.inX));
+ message.append("\n");
+ message.append("Input inY: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inY, Float.floatToRawIntBits(args.inY), args.inY));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeHypotFloat4Float4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeHypot() {
checkNativeHypotFloatFloatFloat();
checkNativeHypotFloat2Float2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeLog1p.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeLog1p.java
index d138fe8..60cb122 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeLog1p.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeLog1p.java
@@ -34,70 +34,247 @@
scriptRelaxed = new ScriptC_TestNativeLog1pRelaxed(mRS);
}
+ public class ArgumentsFloatFloat {
+ public float in;
+ public Floaty out;
+ }
+
private void checkNativeLog1pFloatFloat() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x444585911437d95l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.forEach_testNativeLog1pFloatFloat(in, out);
+ verifyResultsNativeLog1pFloatFloat(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog1pFloatFloat: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.forEach_testNativeLog1pFloatFloat(in, out);
+ verifyResultsNativeLog1pFloatFloat(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog1pFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeLog1pFloatFloat(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 1];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeLog1p(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeLog1pFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeLog1pFloat2Float2() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xd1a13d4961ae8449l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.forEach_testNativeLog1pFloat2Float2(in, out);
+ verifyResultsNativeLog1pFloat2Float2(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog1pFloat2Float2: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.forEach_testNativeLog1pFloat2Float2(in, out);
+ verifyResultsNativeLog1pFloat2Float2(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog1pFloat2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeLog1pFloat2Float2(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 2];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeLog1p(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeLog1pFloat2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeLog1pFloat3Float3() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xd1a147eac0b519e3l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.forEach_testNativeLog1pFloat3Float3(in, out);
+ verifyResultsNativeLog1pFloat3Float3(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog1pFloat3Float3: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.forEach_testNativeLog1pFloat3Float3(in, out);
+ verifyResultsNativeLog1pFloat3Float3(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog1pFloat3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeLog1pFloat3Float3(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeLog1p(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeLog1pFloat3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeLog1pFloat4Float4() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xd1a1528c1fbbaf7dl, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.forEach_testNativeLog1pFloat4Float4(in, out);
+ verifyResultsNativeLog1pFloat4Float4(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog1pFloat4Float4: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.forEach_testNativeLog1pFloat4Float4(in, out);
+ verifyResultsNativeLog1pFloat4Float4(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeLog1pFloat4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeLog1pFloat4Float4(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeLog1p(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeLog1pFloat4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeLog1p() {
checkNativeLog1pFloatFloat();
checkNativeLog1pFloat2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeRsqrt.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeRsqrt.java
index 2e364eb..99c30ff 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeRsqrt.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeRsqrt.java
@@ -34,70 +34,247 @@
scriptRelaxed = new ScriptC_TestNativeRsqrtRelaxed(mRS);
}
+ public class ArgumentsFloatFloat {
+ public float in;
+ public Floaty out;
+ }
+
private void checkNativeRsqrtFloatFloat() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xf3cf23b51aa29de0l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.forEach_testNativeRsqrtFloatFloat(in, out);
+ verifyResultsNativeRsqrtFloatFloat(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRsqrtFloatFloat: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.forEach_testNativeRsqrtFloatFloat(in, out);
+ verifyResultsNativeRsqrtFloatFloat(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRsqrtFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeRsqrtFloatFloat(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 1];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeRsqrt(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeRsqrtFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeRsqrtFloat2Float2() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xf318090911bec1fcl, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.forEach_testNativeRsqrtFloat2Float2(in, out);
+ verifyResultsNativeRsqrtFloat2Float2(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRsqrtFloat2Float2: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.forEach_testNativeRsqrtFloat2Float2(in, out);
+ verifyResultsNativeRsqrtFloat2Float2(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRsqrtFloat2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeRsqrtFloat2Float2(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 2];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeRsqrt(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeRsqrtFloat2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeRsqrtFloat3Float3() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xf31813aa70c55796l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.forEach_testNativeRsqrtFloat3Float3(in, out);
+ verifyResultsNativeRsqrtFloat3Float3(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRsqrtFloat3Float3: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.forEach_testNativeRsqrtFloat3Float3(in, out);
+ verifyResultsNativeRsqrtFloat3Float3(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRsqrtFloat3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeRsqrtFloat3Float3(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeRsqrt(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeRsqrtFloat3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeRsqrtFloat4Float4() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xf3181e4bcfcbed30l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.forEach_testNativeRsqrtFloat4Float4(in, out);
+ verifyResultsNativeRsqrtFloat4Float4(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRsqrtFloat4Float4: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.forEach_testNativeRsqrtFloat4Float4(in, out);
+ verifyResultsNativeRsqrtFloat4Float4(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeRsqrtFloat4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeRsqrtFloat4Float4(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeRsqrt(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeRsqrtFloat4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeRsqrt() {
checkNativeRsqrtFloatFloat();
checkNativeRsqrtFloat2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeSin.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeSin.java
index 80df250..1399f7e 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeSin.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeSin.java
@@ -34,70 +34,247 @@
scriptRelaxed = new ScriptC_TestNativeSinRelaxed(mRS);
}
+ public class ArgumentsFloatFloat {
+ public float in;
+ public Floaty out;
+ }
+
private void checkNativeSinFloatFloat() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x33ee19763354cc56l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.forEach_testNativeSinFloatFloat(in, out);
+ verifyResultsNativeSinFloatFloat(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinFloatFloat: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.forEach_testNativeSinFloatFloat(in, out);
+ verifyResultsNativeSinFloatFloat(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeSinFloatFloat(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 1];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeSin(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeSinFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeSinFloat2Float2() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x12b508b470b05442l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.forEach_testNativeSinFloat2Float2(in, out);
+ verifyResultsNativeSinFloat2Float2(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinFloat2Float2: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.forEach_testNativeSinFloat2Float2(in, out);
+ verifyResultsNativeSinFloat2Float2(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinFloat2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeSinFloat2Float2(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 2];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeSin(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeSinFloat2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeSinFloat3Float3() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x12b51355cfb6e9dcl, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.forEach_testNativeSinFloat3Float3(in, out);
+ verifyResultsNativeSinFloat3Float3(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinFloat3Float3: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.forEach_testNativeSinFloat3Float3(in, out);
+ verifyResultsNativeSinFloat3Float3(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinFloat3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeSinFloat3Float3(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeSin(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeSinFloat3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeSinFloat4Float4() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x12b51df72ebd7f76l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.forEach_testNativeSinFloat4Float4(in, out);
+ verifyResultsNativeSinFloat4Float4(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinFloat4Float4: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.forEach_testNativeSinFloat4Float4(in, out);
+ verifyResultsNativeSinFloat4Float4(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinFloat4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeSinFloat4Float4(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeSin(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeSinFloat4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeSin() {
checkNativeSinFloatFloat();
checkNativeSinFloat2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeSincos.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeSincos.java
index 70df1a1..7cb57cb 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeSincos.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeSincos.java
@@ -34,6 +34,12 @@
scriptRelaxed = new ScriptC_TestNativeSincosRelaxed(mRS);
}
+ public class ArgumentsFloatFloatFloat {
+ public float inV;
+ public Floaty outCosptr;
+ public Floaty out;
+ }
+
private void checkNativeSincosFloatFloatFloat() {
Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe15df2366436cc13l, false);
try {
@@ -41,6 +47,7 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.set_gAllocOutCosptr(outCosptr);
script.forEach_testNativeSincosFloatFloatFloat(inV, out);
+ verifyResultsNativeSincosFloatFloatFloat(inV, outCosptr, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSincosFloatFloatFloat: " + e.toString());
}
@@ -49,11 +56,68 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.set_gAllocOutCosptr(outCosptr);
scriptRelaxed.forEach_testNativeSincosFloatFloatFloat(inV, out);
+ verifyResultsNativeSincosFloatFloatFloat(inV, outCosptr, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSincosFloatFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeSincosFloatFloatFloat(Allocation inV, Allocation outCosptr, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 1];
+ inV.copyTo(arrayInV);
+ float[] arrayOutCosptr = new float[INPUTSIZE * 1];
+ outCosptr.copyTo(arrayOutCosptr);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat();
+ args.inV = arrayInV[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeSincos(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.outCosptr.couldBe(arrayOutCosptr[i * 1 + j])) {
+ valid = false;
+ }
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output outCosptr: ");
+ message.append(args.outCosptr.toString());
+ message.append("\n");
+ message.append("Actual output outCosptr: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOutCosptr[i * 1 + j], Float.floatToRawIntBits(arrayOutCosptr[i * 1 + j]), arrayOutCosptr[i * 1 + j]));
+ if (!args.outCosptr.couldBe(arrayOutCosptr[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeSincosFloatFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeSincosFloat2Float2Float2() {
Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xe5a1f1dcda676ea9l, false);
try {
@@ -61,6 +125,7 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.set_gAllocOutCosptr(outCosptr);
script.forEach_testNativeSincosFloat2Float2Float2(inV, out);
+ verifyResultsNativeSincosFloat2Float2Float2(inV, outCosptr, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSincosFloat2Float2Float2: " + e.toString());
}
@@ -69,11 +134,68 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.set_gAllocOutCosptr(outCosptr);
scriptRelaxed.forEach_testNativeSincosFloat2Float2Float2(inV, out);
+ verifyResultsNativeSincosFloat2Float2Float2(inV, outCosptr, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSincosFloat2Float2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeSincosFloat2Float2Float2(Allocation inV, Allocation outCosptr, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 2];
+ inV.copyTo(arrayInV);
+ float[] arrayOutCosptr = new float[INPUTSIZE * 2];
+ outCosptr.copyTo(arrayOutCosptr);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat();
+ args.inV = arrayInV[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeSincos(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.outCosptr.couldBe(arrayOutCosptr[i * 2 + j])) {
+ valid = false;
+ }
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output outCosptr: ");
+ message.append(args.outCosptr.toString());
+ message.append("\n");
+ message.append("Actual output outCosptr: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOutCosptr[i * 2 + j], Float.floatToRawIntBits(arrayOutCosptr[i * 2 + j]), arrayOutCosptr[i * 2 + j]));
+ if (!args.outCosptr.couldBe(arrayOutCosptr[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeSincosFloat2Float2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeSincosFloat3Float3Float3() {
Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x3a06cffcdc45704al, false);
try {
@@ -81,6 +203,7 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.set_gAllocOutCosptr(outCosptr);
script.forEach_testNativeSincosFloat3Float3Float3(inV, out);
+ verifyResultsNativeSincosFloat3Float3Float3(inV, outCosptr, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSincosFloat3Float3Float3: " + e.toString());
}
@@ -89,11 +212,68 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.set_gAllocOutCosptr(outCosptr);
scriptRelaxed.forEach_testNativeSincosFloat3Float3Float3(inV, out);
+ verifyResultsNativeSincosFloat3Float3Float3(inV, outCosptr, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSincosFloat3Float3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeSincosFloat3Float3Float3(Allocation inV, Allocation outCosptr, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 4];
+ inV.copyTo(arrayInV);
+ float[] arrayOutCosptr = new float[INPUTSIZE * 4];
+ outCosptr.copyTo(arrayOutCosptr);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat();
+ args.inV = arrayInV[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeSincos(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.outCosptr.couldBe(arrayOutCosptr[i * 4 + j])) {
+ valid = false;
+ }
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output outCosptr: ");
+ message.append(args.outCosptr.toString());
+ message.append("\n");
+ message.append("Actual output outCosptr: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOutCosptr[i * 4 + j], Float.floatToRawIntBits(arrayOutCosptr[i * 4 + j]), arrayOutCosptr[i * 4 + j]));
+ if (!args.outCosptr.couldBe(arrayOutCosptr[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeSincosFloat3Float3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeSincosFloat4Float4Float4() {
Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8e6bae1cde2371ebl, false);
try {
@@ -101,6 +281,7 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.set_gAllocOutCosptr(outCosptr);
script.forEach_testNativeSincosFloat4Float4Float4(inV, out);
+ verifyResultsNativeSincosFloat4Float4Float4(inV, outCosptr, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSincosFloat4Float4Float4: " + e.toString());
}
@@ -109,11 +290,68 @@
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.set_gAllocOutCosptr(outCosptr);
scriptRelaxed.forEach_testNativeSincosFloat4Float4Float4(inV, out);
+ verifyResultsNativeSincosFloat4Float4Float4(inV, outCosptr, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSincosFloat4Float4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeSincosFloat4Float4Float4(Allocation inV, Allocation outCosptr, Allocation out, boolean relaxed) {
+ float[] arrayInV = new float[INPUTSIZE * 4];
+ inV.copyTo(arrayInV);
+ float[] arrayOutCosptr = new float[INPUTSIZE * 4];
+ outCosptr.copyTo(arrayOutCosptr);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloatFloat args = new ArgumentsFloatFloatFloat();
+ args.inV = arrayInV[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeSincos(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.outCosptr.couldBe(arrayOutCosptr[i * 4 + j])) {
+ valid = false;
+ }
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input inV: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.inV, Float.floatToRawIntBits(args.inV), args.inV));
+ message.append("\n");
+ message.append("Expected output outCosptr: ");
+ message.append(args.outCosptr.toString());
+ message.append("\n");
+ message.append("Actual output outCosptr: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOutCosptr[i * 4 + j], Float.floatToRawIntBits(arrayOutCosptr[i * 4 + j]), arrayOutCosptr[i * 4 + j]));
+ if (!args.outCosptr.couldBe(arrayOutCosptr[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeSincosFloat4Float4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeSincos() {
checkNativeSincosFloatFloatFloat();
checkNativeSincosFloat2Float2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeSinh.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeSinh.java
index c4321c45..e94b6a0 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeSinh.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeSinh.java
@@ -34,70 +34,247 @@
scriptRelaxed = new ScriptC_TestNativeSinhRelaxed(mRS);
}
+ public class ArgumentsFloatFloat {
+ public float in;
+ public Floaty out;
+ }
+
private void checkNativeSinhFloatFloat() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x74dcf3e9c65b6590l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.forEach_testNativeSinhFloatFloat(in, out);
+ verifyResultsNativeSinhFloatFloat(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinhFloatFloat: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.forEach_testNativeSinhFloatFloat(in, out);
+ verifyResultsNativeSinhFloatFloat(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinhFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeSinhFloatFloat(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 1];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeSinh(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeSinhFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeSinhFloat2Float2() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xfdcd5755b59082cl, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.forEach_testNativeSinhFloat2Float2(in, out);
+ verifyResultsNativeSinhFloat2Float2(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinhFloat2Float2: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.forEach_testNativeSinhFloat2Float2(in, out);
+ verifyResultsNativeSinhFloat2Float2(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinhFloat2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeSinhFloat2Float2(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 2];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeSinh(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeSinhFloat2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeSinhFloat3Float3() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xfdce016ba5f9dc6l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.forEach_testNativeSinhFloat3Float3(in, out);
+ verifyResultsNativeSinhFloat3Float3(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinhFloat3Float3: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.forEach_testNativeSinhFloat3Float3(in, out);
+ verifyResultsNativeSinhFloat3Float3(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinhFloat3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeSinhFloat3Float3(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeSinh(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeSinhFloat3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeSinhFloat4Float4() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xfdceab819663360l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.forEach_testNativeSinhFloat4Float4(in, out);
+ verifyResultsNativeSinhFloat4Float4(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinhFloat4Float4: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.forEach_testNativeSinhFloat4Float4(in, out);
+ verifyResultsNativeSinhFloat4Float4(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinhFloat4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeSinhFloat4Float4(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeSinh(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeSinhFloat4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeSinh() {
checkNativeSinhFloatFloat();
checkNativeSinhFloat2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeSinpi.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeSinpi.java
index 6e2bf9b..61e550f 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeSinpi.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeSinpi.java
@@ -34,70 +34,247 @@
scriptRelaxed = new ScriptC_TestNativeSinpiRelaxed(mRS);
}
+ public class ArgumentsFloatFloat {
+ public float in;
+ public Floaty out;
+ }
+
private void checkNativeSinpiFloatFloat() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xb52c701227c9dc37l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.forEach_testNativeSinpiFloatFloat(in, out);
+ verifyResultsNativeSinpiFloatFloat(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinpiFloatFloat: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.forEach_testNativeSinpiFloatFloat(in, out);
+ verifyResultsNativeSinpiFloatFloat(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinpiFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeSinpiFloatFloat(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 1];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeSinpi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeSinpiFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeSinpiFloat2Float2() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x8df4951d1230045bl, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.forEach_testNativeSinpiFloat2Float2(in, out);
+ verifyResultsNativeSinpiFloat2Float2(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinpiFloat2Float2: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.forEach_testNativeSinpiFloat2Float2(in, out);
+ verifyResultsNativeSinpiFloat2Float2(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinpiFloat2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeSinpiFloat2Float2(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 2];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeSinpi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeSinpiFloat2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeSinpiFloat3Float3() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x8df49fbe713699f5l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.forEach_testNativeSinpiFloat3Float3(in, out);
+ verifyResultsNativeSinpiFloat3Float3(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinpiFloat3Float3: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.forEach_testNativeSinpiFloat3Float3(in, out);
+ verifyResultsNativeSinpiFloat3Float3(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinpiFloat3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeSinpiFloat3Float3(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeSinpi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeSinpiFloat3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeSinpiFloat4Float4() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8df4aa5fd03d2f8fl, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.forEach_testNativeSinpiFloat4Float4(in, out);
+ verifyResultsNativeSinpiFloat4Float4(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinpiFloat4Float4: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.forEach_testNativeSinpiFloat4Float4(in, out);
+ verifyResultsNativeSinpiFloat4Float4(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSinpiFloat4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeSinpiFloat4Float4(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeSinpi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeSinpiFloat4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeSinpi() {
checkNativeSinpiFloatFloat();
checkNativeSinpiFloat2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeSqrt.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeSqrt.java
index b59a992..a16ea4e 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeSqrt.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeSqrt.java
@@ -34,70 +34,247 @@
scriptRelaxed = new ScriptC_TestNativeSqrtRelaxed(mRS);
}
+ public class ArgumentsFloatFloat {
+ public float in;
+ public Floaty out;
+ }
+
private void checkNativeSqrtFloatFloat() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xb4c9e7b9972ac810l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.forEach_testNativeSqrtFloatFloat(in, out);
+ verifyResultsNativeSqrtFloatFloat(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSqrtFloatFloat: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.forEach_testNativeSqrtFloatFloat(in, out);
+ verifyResultsNativeSqrtFloatFloat(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSqrtFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeSqrtFloatFloat(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 1];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeSqrt(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeSqrtFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeSqrtFloat2Float2() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xc649cd70853776acl, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.forEach_testNativeSqrtFloat2Float2(in, out);
+ verifyResultsNativeSqrtFloat2Float2(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSqrtFloat2Float2: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.forEach_testNativeSqrtFloat2Float2(in, out);
+ verifyResultsNativeSqrtFloat2Float2(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSqrtFloat2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeSqrtFloat2Float2(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 2];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeSqrt(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeSqrtFloat2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeSqrtFloat3Float3() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xc649d811e43e0c46l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.forEach_testNativeSqrtFloat3Float3(in, out);
+ verifyResultsNativeSqrtFloat3Float3(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSqrtFloat3Float3: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.forEach_testNativeSqrtFloat3Float3(in, out);
+ verifyResultsNativeSqrtFloat3Float3(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSqrtFloat3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeSqrtFloat3Float3(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeSqrt(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeSqrtFloat3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeSqrtFloat4Float4() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xc649e2b34344a1e0l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.forEach_testNativeSqrtFloat4Float4(in, out);
+ verifyResultsNativeSqrtFloat4Float4(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSqrtFloat4Float4: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.forEach_testNativeSqrtFloat4Float4(in, out);
+ verifyResultsNativeSqrtFloat4Float4(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeSqrtFloat4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeSqrtFloat4Float4(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeSqrt(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeSqrtFloat4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeSqrt() {
checkNativeSqrtFloatFloat();
checkNativeSqrtFloat2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeTan.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeTan.java
index 7a4b927..084bfeb 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeTan.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeTan.java
@@ -34,70 +34,247 @@
scriptRelaxed = new ScriptC_TestNativeTanRelaxed(mRS);
}
+ public class ArgumentsFloatFloat {
+ public float in;
+ public Floaty out;
+ }
+
private void checkNativeTanFloatFloat() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x5b9a224e25042b47l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.forEach_testNativeTanFloatFloat(in, out);
+ verifyResultsNativeTanFloatFloat(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanFloatFloat: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.forEach_testNativeTanFloatFloat(in, out);
+ verifyResultsNativeTanFloatFloat(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeTanFloatFloat(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 1];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeTan(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeTanFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeTanFloat2Float2() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x9c40e8650c550eebl, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.forEach_testNativeTanFloat2Float2(in, out);
+ verifyResultsNativeTanFloat2Float2(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanFloat2Float2: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.forEach_testNativeTanFloat2Float2(in, out);
+ verifyResultsNativeTanFloat2Float2(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanFloat2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeTanFloat2Float2(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 2];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeTan(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeTanFloat2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeTanFloat3Float3() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x9c40f3066b5ba485l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.forEach_testNativeTanFloat3Float3(in, out);
+ verifyResultsNativeTanFloat3Float3(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanFloat3Float3: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.forEach_testNativeTanFloat3Float3(in, out);
+ verifyResultsNativeTanFloat3Float3(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanFloat3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeTanFloat3Float3(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeTan(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeTanFloat3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeTanFloat4Float4() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x9c40fda7ca623a1fl, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.forEach_testNativeTanFloat4Float4(in, out);
+ verifyResultsNativeTanFloat4Float4(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanFloat4Float4: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.forEach_testNativeTanFloat4Float4(in, out);
+ verifyResultsNativeTanFloat4Float4(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanFloat4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeTanFloat4Float4(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeTan(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeTanFloat4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeTan() {
checkNativeTanFloatFloat();
checkNativeTanFloat2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeTanh.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeTanh.java
index ddcaca0..4b335d3 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeTanh.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeTanh.java
@@ -34,70 +34,247 @@
scriptRelaxed = new ScriptC_TestNativeTanhRelaxed(mRS);
}
+ public class ArgumentsFloatFloat {
+ public float in;
+ public Floaty out;
+ }
+
private void checkNativeTanhFloatFloat() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x1ec2702f5ed0580bl, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.forEach_testNativeTanhFloatFloat(in, out);
+ verifyResultsNativeTanhFloatFloat(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanhFloatFloat: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.forEach_testNativeTanhFloatFloat(in, out);
+ verifyResultsNativeTanhFloatFloat(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanhFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeTanhFloatFloat(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 1];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeTanh(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeTanhFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeTanhFloat2Float2() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x2a5b681f8004628fl, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.forEach_testNativeTanhFloat2Float2(in, out);
+ verifyResultsNativeTanhFloat2Float2(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanhFloat2Float2: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.forEach_testNativeTanhFloat2Float2(in, out);
+ verifyResultsNativeTanhFloat2Float2(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanhFloat2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeTanhFloat2Float2(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 2];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeTanh(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeTanhFloat2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeTanhFloat3Float3() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x2a5b72c0df0af829l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.forEach_testNativeTanhFloat3Float3(in, out);
+ verifyResultsNativeTanhFloat3Float3(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanhFloat3Float3: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.forEach_testNativeTanhFloat3Float3(in, out);
+ verifyResultsNativeTanhFloat3Float3(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanhFloat3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeTanhFloat3Float3(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeTanh(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeTanhFloat3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeTanhFloat4Float4() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x2a5b7d623e118dc3l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.forEach_testNativeTanhFloat4Float4(in, out);
+ verifyResultsNativeTanhFloat4Float4(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanhFloat4Float4: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.forEach_testNativeTanhFloat4Float4(in, out);
+ verifyResultsNativeTanhFloat4Float4(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanhFloat4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeTanhFloat4Float4(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeTanh(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeTanhFloat4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeTanh() {
checkNativeTanhFloatFloat();
checkNativeTanhFloat2Float2();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeTanpi.java b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeTanpi.java
index 65dd51b..00b9ca1 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/TestNativeTanpi.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TestNativeTanpi.java
@@ -34,70 +34,247 @@
scriptRelaxed = new ScriptC_TestNativeTanpiRelaxed(mRS);
}
+ public class ArgumentsFloatFloat {
+ public float in;
+ public Floaty out;
+ }
+
private void checkNativeTanpiFloatFloat() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x3eb84fc2c36e96e0l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
script.forEach_testNativeTanpiFloatFloat(in, out);
+ verifyResultsNativeTanpiFloatFloat(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanpiFloatFloat: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
scriptRelaxed.forEach_testNativeTanpiFloatFloat(in, out);
+ verifyResultsNativeTanpiFloatFloat(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanpiFloatFloat: " + e.toString());
}
}
+ private void verifyResultsNativeTanpiFloatFloat(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 1];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 1];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 1 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeTanpi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
+ if (!args.out.couldBe(arrayOut[i * 1 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeTanpiFloatFloat" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeTanpiFloat2Float2() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x13737b13af832fcl, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
script.forEach_testNativeTanpiFloat2Float2(in, out);
+ verifyResultsNativeTanpiFloat2Float2(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanpiFloat2Float2: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
scriptRelaxed.forEach_testNativeTanpiFloat2Float2(in, out);
+ verifyResultsNativeTanpiFloat2Float2(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanpiFloat2Float2: " + e.toString());
}
}
+ private void verifyResultsNativeTanpiFloat2Float2(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 2];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 2];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 2 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 2 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeTanpi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
+ if (!args.out.couldBe(arrayOut[i * 2 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeTanpiFloat2Float2" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeTanpiFloat3Float3() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x137425299fec896l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
script.forEach_testNativeTanpiFloat3Float3(in, out);
+ verifyResultsNativeTanpiFloat3Float3(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanpiFloat3Float3: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
scriptRelaxed.forEach_testNativeTanpiFloat3Float3(in, out);
+ verifyResultsNativeTanpiFloat3Float3(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanpiFloat3Float3: " + e.toString());
}
}
+ private void verifyResultsNativeTanpiFloat3Float3(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 3 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeTanpi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeTanpiFloat3Float3" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
private void checkNativeTanpiFloat4Float4() {
Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x1374cf3f9055e30l, false);
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
script.forEach_testNativeTanpiFloat4Float4(in, out);
+ verifyResultsNativeTanpiFloat4Float4(in, out, false);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanpiFloat4Float4: " + e.toString());
}
try {
Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
scriptRelaxed.forEach_testNativeTanpiFloat4Float4(in, out);
+ verifyResultsNativeTanpiFloat4Float4(in, out, true);
} catch (Exception e) {
throw new RSRuntimeException("RenderScript. Can't invoke forEach_testNativeTanpiFloat4Float4: " + e.toString());
}
}
+ private void verifyResultsNativeTanpiFloat4Float4(Allocation in, Allocation out, boolean relaxed) {
+ float[] arrayIn = new float[INPUTSIZE * 4];
+ in.copyTo(arrayIn);
+ float[] arrayOut = new float[INPUTSIZE * 4];
+ out.copyTo(arrayOut);
+ for (int i = 0; i < INPUTSIZE; i++) {
+ for (int j = 0; j < 4 ; j++) {
+ // Extract the inputs.
+ ArgumentsFloatFloat args = new ArgumentsFloatFloat();
+ args.in = arrayIn[i * 4 + j];
+ // Figure out what the outputs should have been.
+ Floaty.setRelaxed(relaxed);
+ CoreMathVerifier.computeNativeTanpi(args);
+ // Validate the outputs.
+ boolean valid = true;
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ valid = false;
+ }
+ if (!valid) {
+ StringBuilder message = new StringBuilder();
+ message.append("Input in: ");
+ message.append(String.format("%14.8g %8x %15a",
+ args.in, Float.floatToRawIntBits(args.in), args.in));
+ message.append("\n");
+ message.append("Expected output out: ");
+ message.append(args.out.toString());
+ message.append("\n");
+ message.append("Actual output out: ");
+ message.append(String.format("%14.8g %8x %15a",
+ arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
+ if (!args.out.couldBe(arrayOut[i * 4 + j])) {
+ message.append(" FAIL");
+ }
+ message.append("\n");
+ assertTrue("Incorrect output for checkNativeTanpiFloat4Float4" +
+ (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
+ }
+ }
+ }
+ }
+
public void testNativeTanpi() {
checkNativeTanpiFloatFloat();
checkNativeTanpiFloat2Float2();