| /* |
| * Copyright (C) 2014 The Android Open Source Project |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| // Don't edit this file! It is auto-generated by frameworks/rs/api/gen_runtime. |
| |
| package android.renderscript.cts; |
| |
| import android.renderscript.Allocation; |
| import android.renderscript.RSRuntimeException; |
| import android.renderscript.Element; |
| |
| public class TestConvert extends RSBaseCompute { |
| |
| private ScriptC_TestConvert script; |
| private ScriptC_TestConvertRelaxed scriptRelaxed; |
| |
| @Override |
| protected void setUp() throws Exception { |
| super.setUp(); |
| script = new ScriptC_TestConvert(mRS); |
| scriptRelaxed = new ScriptC_TestConvertRelaxed(mRS); |
| } |
| |
| public class ArgumentsFloatFloat { |
| public float inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertFloat2Float2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xfb5215c44e1f6ac6l, -1.6163412428744576259e+38, 1.6163412428744576259e+38); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| script.forEach_testConvertFloat2Float2Float2(inV, out); |
| verifyResultsConvertFloat2Float2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Float2Float2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat2Float2Float2(inV, out); |
| verifyResultsConvertFloat2Float2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Float2Float2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat2Float2(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. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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 checkConvertFloat2Float2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertFloat3Float3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xfb53dedf443a8ba4l, -1.6163412428744576259e+38, 1.6163412428744576259e+38); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| script.forEach_testConvertFloat3Float3Float3(inV, out); |
| verifyResultsConvertFloat3Float3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Float3Float3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat3Float3Float3(inV, out); |
| verifyResultsConvertFloat3Float3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Float3Float3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat3Float3(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. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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 checkConvertFloat3Float3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertFloat4Float4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xfb55a7fa3a55ac82l, -1.6163412428744576259e+38, 1.6163412428744576259e+38); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| script.forEach_testConvertFloat4Float4Float4(inV, out); |
| verifyResultsConvertFloat4Float4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Float4Float4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat4Float4Float4(inV, out); |
| verifyResultsConvertFloat4Float4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Float4Float4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat4Float4(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. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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 checkConvertFloat4Float4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsCharFloat { |
| public byte inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertChar2Float2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x5861e2161f489286l, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| script.forEach_testConvertFloat2Char2Float2(inV, out); |
| verifyResultsConvertChar2Float2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Char2Float2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat2Char2Float2(inV, out); |
| verifyResultsConvertChar2Float2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Char2Float2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar2Float2(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[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. |
| ArgumentsCharFloat args = new ArgumentsCharFloat(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%d", 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 checkConvertChar2Float2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertChar3Float3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x5863ab311563b364l, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| script.forEach_testConvertFloat3Char3Float3(inV, out); |
| verifyResultsConvertChar3Float3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Char3Float3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat3Char3Float3(inV, out); |
| verifyResultsConvertChar3Float3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Char3Float3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar3Float3(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[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. |
| ArgumentsCharFloat args = new ArgumentsCharFloat(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%d", 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 checkConvertChar3Float3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertChar4Float4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x5865744c0b7ed442l, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| script.forEach_testConvertFloat4Char4Float4(inV, out); |
| verifyResultsConvertChar4Float4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Char4Float4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat4Char4Float4(inV, out); |
| verifyResultsConvertChar4Float4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Char4Float4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar4Float4(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[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. |
| ArgumentsCharFloat args = new ArgumentsCharFloat(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%d", 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 checkConvertChar4Float4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUcharFloat { |
| public byte inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertUchar2Float2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x7d30021dbb20ac31l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| script.forEach_testConvertFloat2Uchar2Float2(inV, out); |
| verifyResultsConvertUchar2Float2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Uchar2Float2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat2Uchar2Float2(inV, out); |
| verifyResultsConvertUchar2Float2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Uchar2Float2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar2Float2(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[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. |
| ArgumentsUcharFloat args = new ArgumentsUcharFloat(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("0x%x", 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 checkConvertUchar2Float2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUchar3Float3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x7d31cb38b13bcd0fl, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| script.forEach_testConvertFloat3Uchar3Float3(inV, out); |
| verifyResultsConvertUchar3Float3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Uchar3Float3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat3Uchar3Float3(inV, out); |
| verifyResultsConvertUchar3Float3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Uchar3Float3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar3Float3(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[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. |
| ArgumentsUcharFloat args = new ArgumentsUcharFloat(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("0x%x", 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 checkConvertUchar3Float3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUchar4Float4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7d339453a756ededl, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| script.forEach_testConvertFloat4Uchar4Float4(inV, out); |
| verifyResultsConvertUchar4Float4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Uchar4Float4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat4Uchar4Float4(inV, out); |
| verifyResultsConvertUchar4Float4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Uchar4Float4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar4Float4(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[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. |
| ArgumentsUcharFloat args = new ArgumentsUcharFloat(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("0x%x", 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 checkConvertUchar4Float4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsShortFloat { |
| public short inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertShort2Float2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x94ca184eff219172l, true, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| script.forEach_testConvertFloat2Short2Float2(inV, out); |
| verifyResultsConvertShort2Float2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Short2Float2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat2Short2Float2(inV, out); |
| verifyResultsConvertShort2Float2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Short2Float2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort2Float2(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[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. |
| ArgumentsShortFloat args = new ArgumentsShortFloat(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%d", 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 checkConvertShort2Float2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertShort3Float3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x94cbe169f53cb250l, true, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| script.forEach_testConvertFloat3Short3Float3(inV, out); |
| verifyResultsConvertShort3Float3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Short3Float3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat3Short3Float3(inV, out); |
| verifyResultsConvertShort3Float3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Short3Float3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort3Float3(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[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. |
| ArgumentsShortFloat args = new ArgumentsShortFloat(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%d", 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 checkConvertShort3Float3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertShort4Float4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x94cdaa84eb57d32el, true, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| script.forEach_testConvertFloat4Short4Float4(inV, out); |
| verifyResultsConvertShort4Float4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Short4Float4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat4Short4Float4(inV, out); |
| verifyResultsConvertShort4Float4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Short4Float4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort4Float4(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[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. |
| ArgumentsShortFloat args = new ArgumentsShortFloat(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%d", 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 checkConvertShort4Float4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUshortFloat { |
| public short inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertUshort2Float2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xc36979962c6de12bl, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| script.forEach_testConvertFloat2Ushort2Float2(inV, out); |
| verifyResultsConvertUshort2Float2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Ushort2Float2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat2Ushort2Float2(inV, out); |
| verifyResultsConvertUshort2Float2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Ushort2Float2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort2Float2(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[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. |
| ArgumentsUshortFloat args = new ArgumentsUshortFloat(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("0x%x", 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 checkConvertUshort2Float2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUshort3Float3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xc36b42b122890209l, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| script.forEach_testConvertFloat3Ushort3Float3(inV, out); |
| verifyResultsConvertUshort3Float3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Ushort3Float3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat3Ushort3Float3(inV, out); |
| verifyResultsConvertUshort3Float3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Ushort3Float3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort3Float3(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[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. |
| ArgumentsUshortFloat args = new ArgumentsUshortFloat(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("0x%x", 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 checkConvertUshort3Float3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUshort4Float4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xc36d0bcc18a422e7l, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| script.forEach_testConvertFloat4Ushort4Float4(inV, out); |
| verifyResultsConvertUshort4Float4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Ushort4Float4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat4Ushort4Float4(inV, out); |
| verifyResultsConvertUshort4Float4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Ushort4Float4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort4Float4(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[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. |
| ArgumentsUshortFloat args = new ArgumentsUshortFloat(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("0x%x", 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 checkConvertUshort4Float4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsIntFloat { |
| public int inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertInt2Float2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x2a52c7eb7402bfc5l, true, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| script.forEach_testConvertFloat2Int2Float2(inV, out); |
| verifyResultsConvertInt2Float2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Int2Float2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat2Int2Float2(inV, out); |
| verifyResultsConvertInt2Float2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Int2Float2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt2Float2(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[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. |
| ArgumentsIntFloat args = new ArgumentsIntFloat(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%d", 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 checkConvertInt2Float2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertInt3Float3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x2a5491066a1de0a3l, true, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| script.forEach_testConvertFloat3Int3Float3(inV, out); |
| verifyResultsConvertInt3Float3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Int3Float3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat3Int3Float3(inV, out); |
| verifyResultsConvertInt3Float3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Int3Float3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt3Float3(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[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. |
| ArgumentsIntFloat args = new ArgumentsIntFloat(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%d", 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 checkConvertInt3Float3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertInt4Float4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x2a565a2160390181l, true, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| script.forEach_testConvertFloat4Int4Float4(inV, out); |
| verifyResultsConvertInt4Float4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Int4Float4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat4Int4Float4(inV, out); |
| verifyResultsConvertInt4Float4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Int4Float4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt4Float4(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[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. |
| ArgumentsIntFloat args = new ArgumentsIntFloat(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%d", 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 checkConvertInt4Float4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUintFloat { |
| public int inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertUint2Float2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xd1e081390684cc46l, false, 32); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| script.forEach_testConvertFloat2Uint2Float2(inV, out); |
| verifyResultsConvertUint2Float2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Uint2Float2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat2Uint2Float2(inV, out); |
| verifyResultsConvertUint2Float2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Uint2Float2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint2Float2(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[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. |
| ArgumentsUintFloat args = new ArgumentsUintFloat(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("0x%x", 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 checkConvertUint2Float2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUint3Float3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xd1e24a53fc9fed24l, false, 32); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| script.forEach_testConvertFloat3Uint3Float3(inV, out); |
| verifyResultsConvertUint3Float3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Uint3Float3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat3Uint3Float3(inV, out); |
| verifyResultsConvertUint3Float3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Uint3Float3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint3Float3(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[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. |
| ArgumentsUintFloat args = new ArgumentsUintFloat(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("0x%x", 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 checkConvertUint3Float3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUint4Float4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xd1e4136ef2bb0e02l, false, 32); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| script.forEach_testConvertFloat4Uint4Float4(inV, out); |
| verifyResultsConvertUint4Float4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Uint4Float4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat4Uint4Float4(inV, out); |
| verifyResultsConvertUint4Float4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Uint4Float4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint4Float4(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[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. |
| ArgumentsUintFloat args = new ArgumentsUintFloat(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("0x%x", 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 checkConvertUint4Float4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsFloatChar { |
| public float inV; |
| public byte out; |
| } |
| |
| private void checkConvertFloat2Char2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x239cb25829789662l, -1.2800000000000000000e+02, 1.2700000000000000000e+02); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); |
| script.forEach_testConvertChar2Float2Char2(inV, out); |
| verifyResultsConvertFloat2Char2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Float2Char2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar2Float2Char2(inV, out); |
| verifyResultsConvertFloat2Char2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Float2Char2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat2Char2(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatChar args = new ArgumentsFloatChar(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != 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(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertFloat2Char2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertFloat3Char3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x239cbcf988805b56l, -1.2800000000000000000e+02, 1.2700000000000000000e+02); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); |
| script.forEach_testConvertChar3Float3Char3(inV, out); |
| verifyResultsConvertFloat3Char3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Float3Char3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar3Float3Char3(inV, out); |
| verifyResultsConvertFloat3Char3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Float3Char3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat3Char3(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatChar args = new ArgumentsFloatChar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != 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(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertFloat3Char3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertFloat4Char4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x239cc79ae788204al, -1.2800000000000000000e+02, 1.2700000000000000000e+02); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); |
| script.forEach_testConvertChar4Float4Char4(inV, out); |
| verifyResultsConvertFloat4Char4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Float4Char4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar4Float4Char4(inV, out); |
| verifyResultsConvertFloat4Char4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Float4Char4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat4Char4(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatChar args = new ArgumentsFloatChar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != 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(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertFloat4Char4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsCharChar { |
| public byte inV; |
| public byte out; |
| } |
| |
| private void checkConvertChar2Char2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xd8618777d5086da2l, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); |
| script.forEach_testConvertChar2Char2Char2(inV, out); |
| verifyResultsConvertChar2Char2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Char2Char2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar2Char2Char2(inV, out); |
| verifyResultsConvertChar2Char2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Char2Char2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar2Char2(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharChar args = new ArgumentsCharChar(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertChar2Char2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertChar3Char3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xd861921934103296l, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); |
| script.forEach_testConvertChar3Char3Char3(inV, out); |
| verifyResultsConvertChar3Char3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Char3Char3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar3Char3Char3(inV, out); |
| verifyResultsConvertChar3Char3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Char3Char3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar3Char3(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharChar args = new ArgumentsCharChar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertChar3Char3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertChar4Char4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xd8619cba9317f78al, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); |
| script.forEach_testConvertChar4Char4Char4(inV, out); |
| verifyResultsConvertChar4Char4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Char4Char4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar4Char4Char4(inV, out); |
| verifyResultsConvertChar4Char4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Char4Char4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar4Char4(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharChar args = new ArgumentsCharChar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertChar4Char4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUcharChar { |
| public byte inV; |
| public byte out; |
| } |
| |
| private void checkConvertUchar2Char2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x7fef40c5678a7a23l, false, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); |
| script.forEach_testConvertChar2Uchar2Char2(inV, out); |
| verifyResultsConvertUchar2Char2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Uchar2Char2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar2Uchar2Char2(inV, out); |
| verifyResultsConvertUchar2Char2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Uchar2Char2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar2Char2(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharChar args = new ArgumentsUcharChar(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUchar2Char2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUchar3Char3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x7fef4b66c6923f17l, false, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); |
| script.forEach_testConvertChar3Uchar3Char3(inV, out); |
| verifyResultsConvertUchar3Char3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Uchar3Char3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar3Uchar3Char3(inV, out); |
| verifyResultsConvertUchar3Char3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Uchar3Char3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar3Char3(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharChar args = new ArgumentsUcharChar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUchar3Char3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUchar4Char4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7fef5608259a040bl, false, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); |
| script.forEach_testConvertChar4Uchar4Char4(inV, out); |
| verifyResultsConvertUchar4Char4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Uchar4Char4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar4Uchar4Char4(inV, out); |
| verifyResultsConvertUchar4Char4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Uchar4Char4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar4Char4(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharChar args = new ArgumentsUcharChar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUchar4Char4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsShortChar { |
| public short inV; |
| public byte out; |
| } |
| |
| private void checkConvertShort2Char2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x68ab650215c60866l, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); |
| script.forEach_testConvertChar2Short2Char2(inV, out); |
| verifyResultsConvertShort2Char2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Short2Char2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar2Short2Char2(inV, out); |
| verifyResultsConvertShort2Char2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Short2Char2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort2Char2(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortChar args = new ArgumentsShortChar(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertShort2Char2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertShort3Char3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x68ab6fa374cdcd5al, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); |
| script.forEach_testConvertChar3Short3Char3(inV, out); |
| verifyResultsConvertShort3Char3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Short3Char3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar3Short3Char3(inV, out); |
| verifyResultsConvertShort3Char3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Short3Char3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort3Char3(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortChar args = new ArgumentsShortChar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertShort3Char3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertShort4Char4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x68ab7a44d3d5924el, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); |
| script.forEach_testConvertChar4Short4Char4(inV, out); |
| verifyResultsConvertShort4Char4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Short4Char4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar4Short4Char4(inV, out); |
| verifyResultsConvertShort4Char4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Short4Char4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort4Char4(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortChar args = new ArgumentsShortChar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertShort4Char4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUshortChar { |
| public short inV; |
| public byte out; |
| } |
| |
| private void checkConvertUshort2Char2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x8d798509b19e2211l, false, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); |
| script.forEach_testConvertChar2Ushort2Char2(inV, out); |
| verifyResultsConvertUshort2Char2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Ushort2Char2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar2Ushort2Char2(inV, out); |
| verifyResultsConvertUshort2Char2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Ushort2Char2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort2Char2(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortChar args = new ArgumentsUshortChar(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUshort2Char2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUshort3Char3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x8d798fab10a5e705l, false, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); |
| script.forEach_testConvertChar3Ushort3Char3(inV, out); |
| verifyResultsConvertUshort3Char3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Ushort3Char3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar3Ushort3Char3(inV, out); |
| verifyResultsConvertUshort3Char3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Ushort3Char3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort3Char3(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortChar args = new ArgumentsUshortChar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUshort3Char3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUshort4Char4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x8d799a4c6fadabf9l, false, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); |
| script.forEach_testConvertChar4Ushort4Char4(inV, out); |
| verifyResultsConvertUshort4Char4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Ushort4Char4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar4Ushort4Char4(inV, out); |
| verifyResultsConvertUshort4Char4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Ushort4Char4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort4Char4(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortChar args = new ArgumentsUshortChar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUshort4Char4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsIntChar { |
| public int inV; |
| public byte out; |
| } |
| |
| private void checkConvertInt2Char2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xd74f5147364256dfl, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); |
| script.forEach_testConvertChar2Int2Char2(inV, out); |
| verifyResultsConvertInt2Char2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Int2Char2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar2Int2Char2(inV, out); |
| verifyResultsConvertInt2Char2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Int2Char2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt2Char2(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntChar args = new ArgumentsIntChar(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertInt2Char2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertInt3Char3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xd74f5be8954a1bd3l, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); |
| script.forEach_testConvertChar3Int3Char3(inV, out); |
| verifyResultsConvertInt3Char3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Int3Char3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar3Int3Char3(inV, out); |
| verifyResultsConvertInt3Char3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Int3Char3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt3Char3(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntChar args = new ArgumentsIntChar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertInt3Char3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertInt4Char4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xd74f6689f451e0c7l, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); |
| script.forEach_testConvertChar4Int4Char4(inV, out); |
| verifyResultsConvertInt4Char4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Int4Char4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar4Int4Char4(inV, out); |
| verifyResultsConvertInt4Char4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Int4Char4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt4Char4(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntChar args = new ArgumentsIntChar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertInt4Char4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUintChar { |
| public int inV; |
| public byte out; |
| } |
| |
| private void checkConvertUint2Char2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xe71d083133b67ae2l, false, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); |
| script.forEach_testConvertChar2Uint2Char2(inV, out); |
| verifyResultsConvertUint2Char2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Uint2Char2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar2Uint2Char2(inV, out); |
| verifyResultsConvertUint2Char2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Uint2Char2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint2Char2(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintChar args = new ArgumentsUintChar(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUint2Char2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUint3Char3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xe71d12d292be3fd6l, false, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); |
| script.forEach_testConvertChar3Uint3Char3(inV, out); |
| verifyResultsConvertUint3Char3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Uint3Char3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar3Uint3Char3(inV, out); |
| verifyResultsConvertUint3Char3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Uint3Char3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint3Char3(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintChar args = new ArgumentsUintChar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUint3Char3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUint4Char4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xe71d1d73f1c604cal, false, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); |
| script.forEach_testConvertChar4Uint4Char4(inV, out); |
| verifyResultsConvertUint4Char4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Uint4Char4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar4Uint4Char4(inV, out); |
| verifyResultsConvertUint4Char4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Uint4Char4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint4Char4(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintChar args = new ArgumentsUintChar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUint4Char4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsFloatUchar { |
| public float inV; |
| public byte out; |
| } |
| |
| private void checkConvertFloat2Uchar2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xfb52b2f4fac15b79l, 0.0000000000000000000e+00, 2.5500000000000000000e+02); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); |
| script.forEach_testConvertUchar2Float2Uchar2(inV, out); |
| verifyResultsConvertFloat2Uchar2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Float2Uchar2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar2Float2Uchar2(inV, out); |
| verifyResultsConvertFloat2Uchar2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Float2Uchar2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat2Uchar2(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatUchar args = new ArgumentsFloatUchar(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != 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(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertFloat2Uchar2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertFloat3Uchar3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xfb547c0ff0dc7c57l, 0.0000000000000000000e+00, 2.5500000000000000000e+02); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); |
| script.forEach_testConvertUchar3Float3Uchar3(inV, out); |
| verifyResultsConvertFloat3Uchar3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Float3Uchar3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar3Float3Uchar3(inV, out); |
| verifyResultsConvertFloat3Uchar3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Float3Uchar3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat3Uchar3(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatUchar args = new ArgumentsFloatUchar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != 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(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertFloat3Uchar3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertFloat4Uchar4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xfb56452ae6f79d35l, 0.0000000000000000000e+00, 2.5500000000000000000e+02); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); |
| script.forEach_testConvertUchar4Float4Uchar4(inV, out); |
| verifyResultsConvertFloat4Uchar4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Float4Uchar4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar4Float4Uchar4(inV, out); |
| verifyResultsConvertFloat4Uchar4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Float4Uchar4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat4Uchar4(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatUchar args = new ArgumentsFloatUchar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != 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(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertFloat4Uchar4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsCharUchar { |
| public byte inV; |
| public byte out; |
| } |
| |
| private void checkConvertChar2Uchar2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x58627f46cbea8339l, false, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); |
| script.forEach_testConvertUchar2Char2Uchar2(inV, out); |
| verifyResultsConvertChar2Uchar2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Char2Uchar2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar2Char2Uchar2(inV, out); |
| verifyResultsConvertChar2Uchar2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Char2Uchar2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar2Uchar2(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharUchar args = new ArgumentsCharUchar(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertChar2Uchar2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertChar3Uchar3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x58644861c205a417l, false, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); |
| script.forEach_testConvertUchar3Char3Uchar3(inV, out); |
| verifyResultsConvertChar3Uchar3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Char3Uchar3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar3Char3Uchar3(inV, out); |
| verifyResultsConvertChar3Uchar3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Char3Uchar3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar3Uchar3(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharUchar args = new ArgumentsCharUchar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertChar3Uchar3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertChar4Uchar4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x5866117cb820c4f5l, false, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); |
| script.forEach_testConvertUchar4Char4Uchar4(inV, out); |
| verifyResultsConvertChar4Uchar4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Char4Uchar4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar4Char4Uchar4(inV, out); |
| verifyResultsConvertChar4Uchar4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Char4Uchar4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar4Uchar4(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharUchar args = new ArgumentsCharUchar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertChar4Uchar4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUcharUchar { |
| public byte inV; |
| public byte out; |
| } |
| |
| private void checkConvertUchar2Uchar2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x7d309f4e67c29ce4l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); |
| script.forEach_testConvertUchar2Uchar2Uchar2(inV, out); |
| verifyResultsConvertUchar2Uchar2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Uchar2Uchar2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar2Uchar2Uchar2(inV, out); |
| verifyResultsConvertUchar2Uchar2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Uchar2Uchar2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar2Uchar2(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharUchar args = new ArgumentsUcharUchar(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUchar2Uchar2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUchar3Uchar3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x7d3268695dddbdc2l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); |
| script.forEach_testConvertUchar3Uchar3Uchar3(inV, out); |
| verifyResultsConvertUchar3Uchar3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Uchar3Uchar3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar3Uchar3Uchar3(inV, out); |
| verifyResultsConvertUchar3Uchar3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Uchar3Uchar3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar3Uchar3(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharUchar args = new ArgumentsUcharUchar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUchar3Uchar3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUchar4Uchar4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7d34318453f8dea0l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); |
| script.forEach_testConvertUchar4Uchar4Uchar4(inV, out); |
| verifyResultsConvertUchar4Uchar4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Uchar4Uchar4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar4Uchar4Uchar4(inV, out); |
| verifyResultsConvertUchar4Uchar4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Uchar4Uchar4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar4Uchar4(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharUchar args = new ArgumentsUcharUchar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUchar4Uchar4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsShortUchar { |
| public short inV; |
| public byte out; |
| } |
| |
| private void checkConvertShort2Uchar2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x94cab57fabc38225l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); |
| script.forEach_testConvertUchar2Short2Uchar2(inV, out); |
| verifyResultsConvertShort2Uchar2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Short2Uchar2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar2Short2Uchar2(inV, out); |
| verifyResultsConvertShort2Uchar2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Short2Uchar2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort2Uchar2(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortUchar args = new ArgumentsShortUchar(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertShort2Uchar2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertShort3Uchar3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x94cc7e9aa1dea303l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); |
| script.forEach_testConvertUchar3Short3Uchar3(inV, out); |
| verifyResultsConvertShort3Uchar3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Short3Uchar3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar3Short3Uchar3(inV, out); |
| verifyResultsConvertShort3Uchar3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Short3Uchar3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort3Uchar3(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortUchar args = new ArgumentsShortUchar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertShort3Uchar3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertShort4Uchar4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x94ce47b597f9c3e1l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); |
| script.forEach_testConvertUchar4Short4Uchar4(inV, out); |
| verifyResultsConvertShort4Uchar4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Short4Uchar4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar4Short4Uchar4(inV, out); |
| verifyResultsConvertShort4Uchar4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Short4Uchar4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort4Uchar4(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortUchar args = new ArgumentsShortUchar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertShort4Uchar4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUshortUchar { |
| public short inV; |
| public byte out; |
| } |
| |
| private void checkConvertUshort2Uchar2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xc36a16c6d90fd1del, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); |
| script.forEach_testConvertUchar2Ushort2Uchar2(inV, out); |
| verifyResultsConvertUshort2Uchar2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Ushort2Uchar2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar2Ushort2Uchar2(inV, out); |
| verifyResultsConvertUshort2Uchar2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Ushort2Uchar2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort2Uchar2(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortUchar args = new ArgumentsUshortUchar(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUshort2Uchar2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUshort3Uchar3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xc36bdfe1cf2af2bcl, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); |
| script.forEach_testConvertUchar3Ushort3Uchar3(inV, out); |
| verifyResultsConvertUshort3Uchar3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Ushort3Uchar3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar3Ushort3Uchar3(inV, out); |
| verifyResultsConvertUshort3Uchar3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Ushort3Uchar3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort3Uchar3(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortUchar args = new ArgumentsUshortUchar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUshort3Uchar3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUshort4Uchar4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xc36da8fcc546139al, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); |
| script.forEach_testConvertUchar4Ushort4Uchar4(inV, out); |
| verifyResultsConvertUshort4Uchar4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Ushort4Uchar4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar4Ushort4Uchar4(inV, out); |
| verifyResultsConvertUshort4Uchar4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Ushort4Uchar4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort4Uchar4(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortUchar args = new ArgumentsUshortUchar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUshort4Uchar4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsIntUchar { |
| public int inV; |
| public byte out; |
| } |
| |
| private void checkConvertInt2Uchar2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x2a53651c20a4b078l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); |
| script.forEach_testConvertUchar2Int2Uchar2(inV, out); |
| verifyResultsConvertInt2Uchar2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Int2Uchar2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar2Int2Uchar2(inV, out); |
| verifyResultsConvertInt2Uchar2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Int2Uchar2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt2Uchar2(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntUchar args = new ArgumentsIntUchar(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertInt2Uchar2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertInt3Uchar3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x2a552e3716bfd156l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); |
| script.forEach_testConvertUchar3Int3Uchar3(inV, out); |
| verifyResultsConvertInt3Uchar3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Int3Uchar3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar3Int3Uchar3(inV, out); |
| verifyResultsConvertInt3Uchar3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Int3Uchar3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt3Uchar3(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntUchar args = new ArgumentsIntUchar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertInt3Uchar3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertInt4Uchar4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x2a56f7520cdaf234l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); |
| script.forEach_testConvertUchar4Int4Uchar4(inV, out); |
| verifyResultsConvertInt4Uchar4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Int4Uchar4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar4Int4Uchar4(inV, out); |
| verifyResultsConvertInt4Uchar4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Int4Uchar4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt4Uchar4(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntUchar args = new ArgumentsIntUchar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertInt4Uchar4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUintUchar { |
| public int inV; |
| public byte out; |
| } |
| |
| private void checkConvertUint2Uchar2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xd1e11e69b326bcf9l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); |
| script.forEach_testConvertUchar2Uint2Uchar2(inV, out); |
| verifyResultsConvertUint2Uchar2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Uint2Uchar2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar2Uint2Uchar2(inV, out); |
| verifyResultsConvertUint2Uchar2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Uint2Uchar2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint2Uchar2(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintUchar args = new ArgumentsUintUchar(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUint2Uchar2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUint3Uchar3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xd1e2e784a941ddd7l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); |
| script.forEach_testConvertUchar3Uint3Uchar3(inV, out); |
| verifyResultsConvertUint3Uchar3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Uint3Uchar3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar3Uint3Uchar3(inV, out); |
| verifyResultsConvertUint3Uchar3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Uint3Uchar3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint3Uchar3(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintUchar args = new ArgumentsUintUchar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUint3Uchar3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUint4Uchar4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xd1e4b09f9f5cfeb5l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); |
| script.forEach_testConvertUchar4Uint4Uchar4(inV, out); |
| verifyResultsConvertUint4Uchar4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Uint4Uchar4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar4Uint4Uchar4(inV, out); |
| verifyResultsConvertUint4Uchar4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Uint4Uchar4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint4Uchar4(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintUchar args = new ArgumentsUintUchar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUint4Uchar4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsFloatShort { |
| public float inV; |
| public short out; |
| } |
| |
| private void checkConvertFloat2Short2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xfb529ef98fcf2692l, -3.2768000000000000000e+04, 3.2767000000000000000e+04); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); |
| script.forEach_testConvertShort2Float2Short2(inV, out); |
| verifyResultsConvertFloat2Short2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Float2Short2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort2Float2Short2(inV, out); |
| verifyResultsConvertFloat2Short2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Float2Short2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat2Short2(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatShort args = new ArgumentsFloatShort(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != 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(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertFloat2Short2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertFloat3Short3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xfb54681485ea4770l, -3.2768000000000000000e+04, 3.2767000000000000000e+04); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); |
| script.forEach_testConvertShort3Float3Short3(inV, out); |
| verifyResultsConvertFloat3Short3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Float3Short3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort3Float3Short3(inV, out); |
| verifyResultsConvertFloat3Short3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Float3Short3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat3Short3(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatShort args = new ArgumentsFloatShort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != 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(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertFloat3Short3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertFloat4Short4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xfb56312f7c05684el, -3.2768000000000000000e+04, 3.2767000000000000000e+04); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); |
| script.forEach_testConvertShort4Float4Short4(inV, out); |
| verifyResultsConvertFloat4Short4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Float4Short4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort4Float4Short4(inV, out); |
| verifyResultsConvertFloat4Short4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Float4Short4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat4Short4(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatShort args = new ArgumentsFloatShort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != 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(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertFloat4Short4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsCharShort { |
| public byte inV; |
| public short out; |
| } |
| |
| private void checkConvertChar2Short2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x58626b4b60f84e52l, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); |
| script.forEach_testConvertShort2Char2Short2(inV, out); |
| verifyResultsConvertChar2Short2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Char2Short2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort2Char2Short2(inV, out); |
| verifyResultsConvertChar2Short2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Char2Short2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar2Short2(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharShort args = new ArgumentsCharShort(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertChar2Short2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertChar3Short3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x5864346657136f30l, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); |
| script.forEach_testConvertShort3Char3Short3(inV, out); |
| verifyResultsConvertChar3Short3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Char3Short3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort3Char3Short3(inV, out); |
| verifyResultsConvertChar3Short3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Char3Short3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar3Short3(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharShort args = new ArgumentsCharShort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertChar3Short3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertChar4Short4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x5865fd814d2e900el, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); |
| script.forEach_testConvertShort4Char4Short4(inV, out); |
| verifyResultsConvertChar4Short4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Char4Short4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort4Char4Short4(inV, out); |
| verifyResultsConvertChar4Short4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Char4Short4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar4Short4(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharShort args = new ArgumentsCharShort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertChar4Short4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUcharShort { |
| public byte inV; |
| public short out; |
| } |
| |
| private void checkConvertUchar2Short2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x7d308b52fcd067fdl, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); |
| script.forEach_testConvertShort2Uchar2Short2(inV, out); |
| verifyResultsConvertUchar2Short2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Uchar2Short2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort2Uchar2Short2(inV, out); |
| verifyResultsConvertUchar2Short2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Uchar2Short2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar2Short2(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharShort args = new ArgumentsUcharShort(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUchar2Short2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUchar3Short3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x7d32546df2eb88dbl, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); |
| script.forEach_testConvertShort3Uchar3Short3(inV, out); |
| verifyResultsConvertUchar3Short3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Uchar3Short3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort3Uchar3Short3(inV, out); |
| verifyResultsConvertUchar3Short3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Uchar3Short3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar3Short3(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharShort args = new ArgumentsUcharShort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUchar3Short3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUchar4Short4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7d341d88e906a9b9l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); |
| script.forEach_testConvertShort4Uchar4Short4(inV, out); |
| verifyResultsConvertUchar4Short4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Uchar4Short4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort4Uchar4Short4(inV, out); |
| verifyResultsConvertUchar4Short4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Uchar4Short4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar4Short4(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharShort args = new ArgumentsUcharShort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUchar4Short4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsShortShort { |
| public short inV; |
| public short out; |
| } |
| |
| private void checkConvertShort2Short2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x94caa18440d14d3el, true, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); |
| script.forEach_testConvertShort2Short2Short2(inV, out); |
| verifyResultsConvertShort2Short2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Short2Short2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort2Short2Short2(inV, out); |
| verifyResultsConvertShort2Short2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Short2Short2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort2Short2(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortShort args = new ArgumentsShortShort(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertShort2Short2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertShort3Short3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x94cc6a9f36ec6e1cl, true, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); |
| script.forEach_testConvertShort3Short3Short3(inV, out); |
| verifyResultsConvertShort3Short3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Short3Short3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort3Short3Short3(inV, out); |
| verifyResultsConvertShort3Short3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Short3Short3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort3Short3(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortShort args = new ArgumentsShortShort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertShort3Short3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertShort4Short4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x94ce33ba2d078efal, true, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); |
| script.forEach_testConvertShort4Short4Short4(inV, out); |
| verifyResultsConvertShort4Short4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Short4Short4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort4Short4Short4(inV, out); |
| verifyResultsConvertShort4Short4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Short4Short4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort4Short4(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortShort args = new ArgumentsShortShort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertShort4Short4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUshortShort { |
| public short inV; |
| public short out; |
| } |
| |
| private void checkConvertUshort2Short2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xc36a02cb6e1d9cf7l, false, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); |
| script.forEach_testConvertShort2Ushort2Short2(inV, out); |
| verifyResultsConvertUshort2Short2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Ushort2Short2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort2Ushort2Short2(inV, out); |
| verifyResultsConvertUshort2Short2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Ushort2Short2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort2Short2(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortShort args = new ArgumentsUshortShort(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUshort2Short2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUshort3Short3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xc36bcbe66438bdd5l, false, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); |
| script.forEach_testConvertShort3Ushort3Short3(inV, out); |
| verifyResultsConvertUshort3Short3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Ushort3Short3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort3Ushort3Short3(inV, out); |
| verifyResultsConvertUshort3Short3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Ushort3Short3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort3Short3(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortShort args = new ArgumentsUshortShort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUshort3Short3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUshort4Short4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xc36d95015a53deb3l, false, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); |
| script.forEach_testConvertShort4Ushort4Short4(inV, out); |
| verifyResultsConvertUshort4Short4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Ushort4Short4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort4Ushort4Short4(inV, out); |
| verifyResultsConvertUshort4Short4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Ushort4Short4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort4Short4(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortShort args = new ArgumentsUshortShort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUshort4Short4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsIntShort { |
| public int inV; |
| public short out; |
| } |
| |
| private void checkConvertInt2Short2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x2a535120b5b27b91l, true, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); |
| script.forEach_testConvertShort2Int2Short2(inV, out); |
| verifyResultsConvertInt2Short2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Int2Short2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort2Int2Short2(inV, out); |
| verifyResultsConvertInt2Short2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Int2Short2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt2Short2(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntShort args = new ArgumentsIntShort(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertInt2Short2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertInt3Short3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x2a551a3babcd9c6fl, true, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); |
| script.forEach_testConvertShort3Int3Short3(inV, out); |
| verifyResultsConvertInt3Short3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Int3Short3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort3Int3Short3(inV, out); |
| verifyResultsConvertInt3Short3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Int3Short3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt3Short3(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntShort args = new ArgumentsIntShort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertInt3Short3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertInt4Short4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x2a56e356a1e8bd4dl, true, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); |
| script.forEach_testConvertShort4Int4Short4(inV, out); |
| verifyResultsConvertInt4Short4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Int4Short4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort4Int4Short4(inV, out); |
| verifyResultsConvertInt4Short4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Int4Short4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt4Short4(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntShort args = new ArgumentsIntShort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertInt4Short4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUintShort { |
| public int inV; |
| public short out; |
| } |
| |
| private void checkConvertUint2Short2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xd1e10a6e48348812l, false, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); |
| script.forEach_testConvertShort2Uint2Short2(inV, out); |
| verifyResultsConvertUint2Short2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Uint2Short2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort2Uint2Short2(inV, out); |
| verifyResultsConvertUint2Short2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Uint2Short2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint2Short2(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintShort args = new ArgumentsUintShort(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUint2Short2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUint3Short3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xd1e2d3893e4fa8f0l, false, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); |
| script.forEach_testConvertShort3Uint3Short3(inV, out); |
| verifyResultsConvertUint3Short3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Uint3Short3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort3Uint3Short3(inV, out); |
| verifyResultsConvertUint3Short3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Uint3Short3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint3Short3(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintShort args = new ArgumentsUintShort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUint3Short3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUint4Short4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xd1e49ca4346ac9cel, false, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); |
| script.forEach_testConvertShort4Uint4Short4(inV, out); |
| verifyResultsConvertUint4Short4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Uint4Short4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort4Uint4Short4(inV, out); |
| verifyResultsConvertUint4Short4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Uint4Short4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint4Short4(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintShort args = new ArgumentsUintShort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUint4Short4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsFloatUshort { |
| public float inV; |
| public short out; |
| } |
| |
| private void checkConvertFloat2Ushort2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x36e4b950b708416fl, 0.0000000000000000000e+00, 6.5535000000000000000e+04); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); |
| script.forEach_testConvertUshort2Float2Ushort2(inV, out); |
| verifyResultsConvertFloat2Ushort2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Float2Ushort2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort2Float2Ushort2(inV, out); |
| verifyResultsConvertFloat2Ushort2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Float2Ushort2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat2Ushort2(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatUshort args = new ArgumentsFloatUshort(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != 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(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertFloat2Ushort2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertFloat3Ushort3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x373180d80d63d29bl, 0.0000000000000000000e+00, 6.5535000000000000000e+04); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); |
| script.forEach_testConvertUshort3Float3Ushort3(inV, out); |
| verifyResultsConvertFloat3Ushort3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Float3Ushort3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort3Float3Ushort3(inV, out); |
| verifyResultsConvertFloat3Ushort3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Float3Ushort3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat3Ushort3(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatUshort args = new ArgumentsFloatUshort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != 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(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertFloat3Ushort3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertFloat4Ushort4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x377e485f63bf63c7l, 0.0000000000000000000e+00, 6.5535000000000000000e+04); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); |
| script.forEach_testConvertUshort4Float4Ushort4(inV, out); |
| verifyResultsConvertFloat4Ushort4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Float4Ushort4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort4Float4Ushort4(inV, out); |
| verifyResultsConvertFloat4Ushort4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Float4Ushort4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat4Ushort4(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatUshort args = new ArgumentsFloatUshort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != 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(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertFloat4Ushort4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsCharUshort { |
| public byte inV; |
| public short out; |
| } |
| |
| private void checkConvertChar2Ushort2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xd88c0b0ed8f1eeafl, false, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); |
| script.forEach_testConvertUshort2Char2Ushort2(inV, out); |
| verifyResultsConvertChar2Ushort2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Char2Ushort2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort2Char2Ushort2(inV, out); |
| verifyResultsConvertChar2Ushort2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Char2Ushort2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar2Ushort2(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharUshort args = new ArgumentsCharUshort(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertChar2Ushort2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertChar3Ushort3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xd8d8d2962f4d7fdbl, false, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); |
| script.forEach_testConvertUshort3Char3Ushort3(inV, out); |
| verifyResultsConvertChar3Ushort3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Char3Ushort3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort3Char3Ushort3(inV, out); |
| verifyResultsConvertChar3Ushort3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Char3Ushort3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar3Ushort3(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharUshort args = new ArgumentsCharUshort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertChar3Ushort3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertChar4Ushort4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xd9259a1d85a91107l, false, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); |
| script.forEach_testConvertUshort4Char4Ushort4(inV, out); |
| verifyResultsConvertChar4Ushort4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Char4Ushort4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort4Char4Ushort4(inV, out); |
| verifyResultsConvertChar4Ushort4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Char4Ushort4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar4Ushort4(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharUshort args = new ArgumentsCharUshort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertChar4Ushort4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUcharUshort { |
| public byte inV; |
| public short out; |
| } |
| |
| private void checkConvertUchar2Ushort2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x72b6c56063e3e68l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); |
| script.forEach_testConvertUshort2Uchar2Ushort2(inV, out); |
| verifyResultsConvertUchar2Ushort2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Uchar2Ushort2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort2Uchar2Ushort2(inV, out); |
| verifyResultsConvertUchar2Ushort2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Uchar2Ushort2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar2Ushort2(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharUshort args = new ArgumentsUcharUshort(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUchar2Ushort2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUchar3Ushort3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x77833dd5c99cf94l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); |
| script.forEach_testConvertUshort3Uchar3Ushort3(inV, out); |
| verifyResultsConvertUchar3Ushort3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Uchar3Ushort3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort3Uchar3Ushort3(inV, out); |
| verifyResultsConvertUchar3Ushort3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Uchar3Ushort3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar3Ushort3(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharUshort args = new ArgumentsUcharUshort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUchar3Ushort3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUchar4Ushort4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7c4fb64b2f560c0l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); |
| script.forEach_testConvertUshort4Uchar4Ushort4(inV, out); |
| verifyResultsConvertUchar4Ushort4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Uchar4Ushort4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort4Uchar4Ushort4(inV, out); |
| verifyResultsConvertUchar4Ushort4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Uchar4Ushort4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar4Ushort4(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharUshort args = new ArgumentsUcharUshort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUchar4Ushort4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsShortUshort { |
| public short inV; |
| public short out; |
| } |
| |
| private void checkConvertShort2Ushort2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0xfe0d269c7264c053l, false, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); |
| script.forEach_testConvertUshort2Short2Ushort2(inV, out); |
| verifyResultsConvertShort2Ushort2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Short2Ushort2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort2Short2Ushort2(inV, out); |
| verifyResultsConvertShort2Ushort2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Short2Ushort2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort2Ushort2(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortUshort args = new ArgumentsShortUshort(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertShort2Ushort2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertShort3Ushort3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xfe59ee23c8c0517fl, false, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); |
| script.forEach_testConvertUshort3Short3Ushort3(inV, out); |
| verifyResultsConvertShort3Ushort3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Short3Ushort3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort3Short3Ushort3(inV, out); |
| verifyResultsConvertShort3Ushort3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Short3Ushort3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort3Ushort3(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortUshort args = new ArgumentsShortUshort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertShort3Ushort3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertShort4Ushort4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xfea6b5ab1f1be2abl, false, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); |
| script.forEach_testConvertUshort4Short4Ushort4(inV, out); |
| verifyResultsConvertShort4Ushort4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Short4Ushort4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort4Short4Ushort4(inV, out); |
| verifyResultsConvertShort4Ushort4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Short4Ushort4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort4Ushort4(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortUshort args = new ArgumentsShortUshort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertShort4Ushort4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUshortUshort { |
| public short inV; |
| public short out; |
| } |
| |
| private void checkConvertUshort2Ushort2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xd2d27d910e362466l, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); |
| script.forEach_testConvertUshort2Ushort2Ushort2(inV, out); |
| verifyResultsConvertUshort2Ushort2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Ushort2Ushort2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort2Ushort2Ushort2(inV, out); |
| verifyResultsConvertUshort2Ushort2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Ushort2Ushort2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort2Ushort2(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortUshort args = new ArgumentsUshortUshort(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUshort2Ushort2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUshort3Ushort3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xd31f45186491b592l, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); |
| script.forEach_testConvertUshort3Ushort3Ushort3(inV, out); |
| verifyResultsConvertUshort3Ushort3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Ushort3Ushort3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort3Ushort3Ushort3(inV, out); |
| verifyResultsConvertUshort3Ushort3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Ushort3Ushort3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort3Ushort3(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortUshort args = new ArgumentsUshortUshort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUshort3Ushort3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUshort4Ushort4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xd36c0c9fbaed46bel, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); |
| script.forEach_testConvertUshort4Ushort4Ushort4(inV, out); |
| verifyResultsConvertUshort4Ushort4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Ushort4Ushort4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort4Ushort4Ushort4(inV, out); |
| verifyResultsConvertUshort4Ushort4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Ushort4Ushort4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort4Ushort4(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortUshort args = new ArgumentsUshortUshort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUshort4Ushort4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsIntUshort { |
| public int inV; |
| public short out; |
| } |
| |
| private void checkConvertInt2Ushort2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x1c02a5e414378844l, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); |
| script.forEach_testConvertUshort2Int2Ushort2(inV, out); |
| verifyResultsConvertInt2Ushort2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Int2Ushort2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort2Int2Ushort2(inV, out); |
| verifyResultsConvertInt2Ushort2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Int2Ushort2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt2Ushort2(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntUshort args = new ArgumentsIntUshort(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertInt2Ushort2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertInt3Ushort3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x1c4f6d6b6a931970l, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); |
| script.forEach_testConvertUshort3Int3Ushort3(inV, out); |
| verifyResultsConvertInt3Ushort3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Int3Ushort3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort3Int3Ushort3(inV, out); |
| verifyResultsConvertInt3Ushort3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Int3Ushort3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt3Ushort3(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntUshort args = new ArgumentsIntUshort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertInt3Ushort3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertInt4Ushort4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x1c9c34f2c0eeaa9cl, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); |
| script.forEach_testConvertUshort4Int4Ushort4(inV, out); |
| verifyResultsConvertInt4Ushort4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Int4Ushort4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort4Int4Ushort4(inV, out); |
| verifyResultsConvertInt4Ushort4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Int4Ushort4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt4Ushort4(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntUshort args = new ArgumentsIntUshort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertInt4Ushort4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUintUshort { |
| public int inV; |
| public short out; |
| } |
| |
| private void checkConvertUint2Ushort2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x40d0c5ebb00fa1efl, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); |
| script.forEach_testConvertUshort2Uint2Ushort2(inV, out); |
| verifyResultsConvertUint2Ushort2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Uint2Ushort2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort2Uint2Ushort2(inV, out); |
| verifyResultsConvertUint2Ushort2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Uint2Ushort2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint2Ushort2(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintUshort args = new ArgumentsUintUshort(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUint2Ushort2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUint3Ushort3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x411d8d73066b331bl, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); |
| script.forEach_testConvertUshort3Uint3Ushort3(inV, out); |
| verifyResultsConvertUint3Ushort3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Uint3Ushort3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort3Uint3Ushort3(inV, out); |
| verifyResultsConvertUint3Ushort3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Uint3Ushort3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint3Ushort3(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintUshort args = new ArgumentsUintUshort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUint3Ushort3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUint4Ushort4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x416a54fa5cc6c447l, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); |
| script.forEach_testConvertUshort4Uint4Ushort4(inV, out); |
| verifyResultsConvertUint4Ushort4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Uint4Ushort4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort4Uint4Ushort4(inV, out); |
| verifyResultsConvertUint4Ushort4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Uint4Ushort4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint4Ushort4(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintUshort args = new ArgumentsUintUshort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUint4Ushort4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsFloatInt { |
| public float inV; |
| public int out; |
| } |
| |
| private void checkConvertFloat2Int2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x8fb63fb7c069dd5dl, -2.1474835210000000000e+09, 2.1474835200000000000e+09); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); |
| script.forEach_testConvertInt2Float2Int2(inV, out); |
| verifyResultsConvertFloat2Int2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Float2Int2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt2Float2Int2(inV, out); |
| verifyResultsConvertFloat2Int2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Float2Int2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat2Int2(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatInt args = new ArgumentsFloatInt(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != 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(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertFloat2Int2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertFloat3Int3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x8fb63ff70a11ed93l, -2.1474835210000000000e+09, 2.1474835200000000000e+09); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); |
| script.forEach_testConvertInt3Float3Int3(inV, out); |
| verifyResultsConvertFloat3Int3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Float3Int3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt3Float3Int3(inV, out); |
| verifyResultsConvertFloat3Int3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Float3Int3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat3Int3(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatInt args = new ArgumentsFloatInt(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != 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(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertFloat3Int3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertFloat4Int4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8fb6403653b9fdc9l, -2.1474835210000000000e+09, 2.1474835200000000000e+09); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); |
| script.forEach_testConvertInt4Float4Int4(inV, out); |
| verifyResultsConvertFloat4Int4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Float4Int4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt4Float4Int4(inV, out); |
| verifyResultsConvertFloat4Int4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Float4Int4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat4Int4(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatInt args = new ArgumentsFloatInt(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != 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(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertFloat4Int4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsCharInt { |
| public byte inV; |
| public int out; |
| } |
| |
| private void checkConvertChar2Int2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x880244ac94c6831dl, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); |
| script.forEach_testConvertInt2Char2Int2(inV, out); |
| verifyResultsConvertChar2Int2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Char2Int2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt2Char2Int2(inV, out); |
| verifyResultsConvertChar2Int2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Char2Int2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar2Int2(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharInt args = new ArgumentsCharInt(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertChar2Int2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertChar3Int3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x880244ebde6e9353l, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); |
| script.forEach_testConvertInt3Char3Int3(inV, out); |
| verifyResultsConvertChar3Int3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Char3Int3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt3Char3Int3(inV, out); |
| verifyResultsConvertChar3Int3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Char3Int3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar3Int3(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharInt args = new ArgumentsCharInt(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertChar3Int3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertChar4Int4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x8802452b2816a389l, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); |
| script.forEach_testConvertInt4Char4Int4(inV, out); |
| verifyResultsConvertChar4Int4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Char4Int4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt4Char4Int4(inV, out); |
| verifyResultsConvertChar4Int4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Char4Int4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar4Int4(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharInt args = new ArgumentsCharInt(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertChar4Int4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUcharInt { |
| public byte inV; |
| public int out; |
| } |
| |
| private void checkConvertUchar2Int2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x97cffb96923aa720l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); |
| script.forEach_testConvertInt2Uchar2Int2(inV, out); |
| verifyResultsConvertUchar2Int2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Uchar2Int2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt2Uchar2Int2(inV, out); |
| verifyResultsConvertUchar2Int2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Uchar2Int2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar2Int2(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharInt args = new ArgumentsUcharInt(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUchar2Int2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUchar3Int3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x97cffbd5dbe2b756l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); |
| script.forEach_testConvertInt3Uchar3Int3(inV, out); |
| verifyResultsConvertUchar3Int3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Uchar3Int3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt3Uchar3Int3(inV, out); |
| verifyResultsConvertUchar3Int3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Uchar3Int3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar3Int3(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharInt args = new ArgumentsUcharInt(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUchar3Int3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUchar4Int4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x97cffc15258ac78cl, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); |
| script.forEach_testConvertInt4Uchar4Int4(inV, out); |
| verifyResultsConvertUchar4Int4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Uchar4Int4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt4Uchar4Int4(inV, out); |
| verifyResultsConvertUchar4Int4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Uchar4Int4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar4Int4(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharInt args = new ArgumentsUcharInt(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUchar4Int4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsShortInt { |
| public short inV; |
| public int out; |
| } |
| |
| private void checkConvertShort2Int2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x85693203252a2d69l, true, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); |
| script.forEach_testConvertInt2Short2Int2(inV, out); |
| verifyResultsConvertShort2Int2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Short2Int2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt2Short2Int2(inV, out); |
| verifyResultsConvertShort2Int2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Short2Int2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort2Int2(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortInt args = new ArgumentsShortInt(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertShort2Int2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertShort3Int3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x856932426ed23d9fl, true, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); |
| script.forEach_testConvertInt3Short3Int3(inV, out); |
| verifyResultsConvertShort3Int3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Short3Int3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt3Short3Int3(inV, out); |
| verifyResultsConvertShort3Int3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Short3Int3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort3Int3(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortInt args = new ArgumentsShortInt(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertShort3Int3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertShort4Int4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x85693281b87a4dd5l, true, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); |
| script.forEach_testConvertInt4Short4Int4(inV, out); |
| verifyResultsConvertShort4Int4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Short4Int4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt4Short4Int4(inV, out); |
| verifyResultsConvertShort4Int4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Short4Int4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort4Int4(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortInt args = new ArgumentsShortInt(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertShort4Int4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUshortInt { |
| public short inV; |
| public int out; |
| } |
| |
| private void checkConvertUshort2Int2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x2cf6eb50b7ac39eal, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); |
| script.forEach_testConvertInt2Ushort2Int2(inV, out); |
| verifyResultsConvertUshort2Int2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Ushort2Int2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt2Ushort2Int2(inV, out); |
| verifyResultsConvertUshort2Int2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Ushort2Int2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort2Int2(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortInt args = new ArgumentsUshortInt(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUshort2Int2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUshort3Int3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x2cf6eb9001544a20l, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); |
| script.forEach_testConvertInt3Ushort3Int3(inV, out); |
| verifyResultsConvertUshort3Int3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Ushort3Int3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt3Ushort3Int3(inV, out); |
| verifyResultsConvertUshort3Int3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Ushort3Int3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort3Int3(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortInt args = new ArgumentsUshortInt(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUshort3Int3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUshort4Int4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x2cf6ebcf4afc5a56l, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); |
| script.forEach_testConvertInt4Ushort4Int4(inV, out); |
| verifyResultsConvertUshort4Int4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Ushort4Int4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt4Ushort4Int4(inV, out); |
| verifyResultsConvertUshort4Int4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Ushort4Int4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort4Int4(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortInt args = new ArgumentsUshortInt(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUshort4Int4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsIntInt { |
| public int inV; |
| public int out; |
| } |
| |
| private void checkConvertInt2Int2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x501d84049a42354l, true, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); |
| script.forEach_testConvertInt2Int2Int2(inV, out); |
| verifyResultsConvertInt2Int2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Int2Int2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt2Int2Int2(inV, out); |
| verifyResultsConvertInt2Int2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Int2Int2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt2Int2(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntInt args = new ArgumentsIntInt(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertInt2Int2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertInt3Int3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x501d87f934c338al, true, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); |
| script.forEach_testConvertInt3Int3Int3(inV, out); |
| verifyResultsConvertInt3Int3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Int3Int3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt3Int3Int3(inV, out); |
| verifyResultsConvertInt3Int3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Int3Int3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt3Int3(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntInt args = new ArgumentsIntInt(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertInt3Int3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertInt4Int4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x501d8bedcf443c0l, true, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); |
| script.forEach_testConvertInt4Int4Int4(inV, out); |
| verifyResultsConvertInt4Int4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Int4Int4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt4Int4Int4(inV, out); |
| verifyResultsConvertInt4Int4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Int4Int4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt4Int4(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntInt args = new ArgumentsIntInt(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertInt4Int4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUintInt { |
| public int inV; |
| public int out; |
| } |
| |
| private void checkConvertUint2Int2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x70899b043daccaddl, false, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); |
| script.forEach_testConvertInt2Uint2Int2(inV, out); |
| verifyResultsConvertUint2Int2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Uint2Int2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt2Uint2Int2(inV, out); |
| verifyResultsConvertUint2Int2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Uint2Int2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint2Int2(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintInt args = new ArgumentsUintInt(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUint2Int2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUint3Int3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x70899b438754db13l, false, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); |
| script.forEach_testConvertInt3Uint3Int3(inV, out); |
| verifyResultsConvertUint3Int3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Uint3Int3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt3Uint3Int3(inV, out); |
| verifyResultsConvertUint3Int3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Uint3Int3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint3Int3(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintInt args = new ArgumentsUintInt(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUint3Int3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUint4Int4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x70899b82d0fceb49l, false, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); |
| script.forEach_testConvertInt4Uint4Int4(inV, out); |
| verifyResultsConvertUint4Int4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Uint4Int4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt4Uint4Int4(inV, out); |
| verifyResultsConvertUint4Int4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Uint4Int4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint4Int4(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintInt args = new ArgumentsUintInt(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUint4Int4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsFloatUint { |
| public float inV; |
| public int out; |
| } |
| |
| private void checkConvertFloat2Uint2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x239cb6cd424dca22l, 0.0000000000000000000e+00, 4.2949670400000000000e+09); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); |
| script.forEach_testConvertUint2Float2Uint2(inV, out); |
| verifyResultsConvertFloat2Uint2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Float2Uint2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint2Float2Uint2(inV, out); |
| verifyResultsConvertFloat2Uint2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Float2Uint2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat2Uint2(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatUint args = new ArgumentsFloatUint(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != 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(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertFloat2Uint2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertFloat3Uint3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x239cc16ea1558f16l, 0.0000000000000000000e+00, 4.2949670400000000000e+09); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); |
| script.forEach_testConvertUint3Float3Uint3(inV, out); |
| verifyResultsConvertFloat3Uint3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Float3Uint3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint3Float3Uint3(inV, out); |
| verifyResultsConvertFloat3Uint3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Float3Uint3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat3Uint3(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatUint args = new ArgumentsFloatUint(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != 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(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertFloat3Uint3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertFloat4Uint4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x239ccc10005d540al, 0.0000000000000000000e+00, 4.2949670400000000000e+09); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); |
| script.forEach_testConvertUint4Float4Uint4(inV, out); |
| verifyResultsConvertFloat4Uint4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Float4Uint4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint4Float4Uint4(inV, out); |
| verifyResultsConvertFloat4Uint4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Float4Uint4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat4Uint4(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatUint args = new ArgumentsFloatUint(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != 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(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertFloat4Uint4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsCharUint { |
| public byte inV; |
| public int out; |
| } |
| |
| private void checkConvertChar2Uint2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xd8618beceddda162l, false, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); |
| script.forEach_testConvertUint2Char2Uint2(inV, out); |
| verifyResultsConvertChar2Uint2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Char2Uint2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint2Char2Uint2(inV, out); |
| verifyResultsConvertChar2Uint2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Char2Uint2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar2Uint2(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharUint args = new ArgumentsCharUint(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertChar2Uint2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertChar3Uint3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xd861968e4ce56656l, false, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); |
| script.forEach_testConvertUint3Char3Uint3(inV, out); |
| verifyResultsConvertChar3Uint3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Char3Uint3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint3Char3Uint3(inV, out); |
| verifyResultsConvertChar3Uint3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Char3Uint3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar3Uint3(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharUint args = new ArgumentsCharUint(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertChar3Uint3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertChar4Uint4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xd861a12fabed2b4al, false, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); |
| script.forEach_testConvertUint4Char4Uint4(inV, out); |
| verifyResultsConvertChar4Uint4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Char4Uint4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint4Char4Uint4(inV, out); |
| verifyResultsConvertChar4Uint4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Char4Uint4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar4Uint4(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharUint args = new ArgumentsCharUint(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertChar4Uint4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUcharUint { |
| public byte inV; |
| public int out; |
| } |
| |
| private void checkConvertUchar2Uint2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x7fef453a805fade3l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); |
| script.forEach_testConvertUint2Uchar2Uint2(inV, out); |
| verifyResultsConvertUchar2Uint2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Uchar2Uint2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint2Uchar2Uint2(inV, out); |
| verifyResultsConvertUchar2Uint2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Uchar2Uint2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar2Uint2(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharUint args = new ArgumentsUcharUint(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUchar2Uint2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUchar3Uint3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x7fef4fdbdf6772d7l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); |
| script.forEach_testConvertUint3Uchar3Uint3(inV, out); |
| verifyResultsConvertUchar3Uint3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Uchar3Uint3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint3Uchar3Uint3(inV, out); |
| verifyResultsConvertUchar3Uint3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Uchar3Uint3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar3Uint3(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharUint args = new ArgumentsUcharUint(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUchar3Uint3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUchar4Uint4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7fef5a7d3e6f37cbl, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); |
| script.forEach_testConvertUint4Uchar4Uint4(inV, out); |
| verifyResultsConvertUchar4Uint4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Uchar4Uint4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint4Uchar4Uint4(inV, out); |
| verifyResultsConvertUchar4Uint4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Uchar4Uint4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar4Uint4(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharUint args = new ArgumentsUcharUint(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUchar4Uint4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsShortUint { |
| public short inV; |
| public int out; |
| } |
| |
| private void checkConvertShort2Uint2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x68ab69772e9b3c26l, false, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); |
| script.forEach_testConvertUint2Short2Uint2(inV, out); |
| verifyResultsConvertShort2Uint2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Short2Uint2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint2Short2Uint2(inV, out); |
| verifyResultsConvertShort2Uint2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Short2Uint2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort2Uint2(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortUint args = new ArgumentsShortUint(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertShort2Uint2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertShort3Uint3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x68ab74188da3011al, false, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); |
| script.forEach_testConvertUint3Short3Uint3(inV, out); |
| verifyResultsConvertShort3Uint3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Short3Uint3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint3Short3Uint3(inV, out); |
| verifyResultsConvertShort3Uint3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Short3Uint3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort3Uint3(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortUint args = new ArgumentsShortUint(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertShort3Uint3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertShort4Uint4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x68ab7eb9ecaac60el, false, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); |
| script.forEach_testConvertUint4Short4Uint4(inV, out); |
| verifyResultsConvertShort4Uint4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Short4Uint4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint4Short4Uint4(inV, out); |
| verifyResultsConvertShort4Uint4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Short4Uint4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort4Uint4(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortUint args = new ArgumentsShortUint(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertShort4Uint4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUshortUint { |
| public short inV; |
| public int out; |
| } |
| |
| private void checkConvertUshort2Uint2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x8d79897eca7355d1l, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); |
| script.forEach_testConvertUint2Ushort2Uint2(inV, out); |
| verifyResultsConvertUshort2Uint2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Ushort2Uint2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint2Ushort2Uint2(inV, out); |
| verifyResultsConvertUshort2Uint2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Ushort2Uint2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort2Uint2(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortUint args = new ArgumentsUshortUint(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUshort2Uint2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUshort3Uint3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x8d799420297b1ac5l, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); |
| script.forEach_testConvertUint3Ushort3Uint3(inV, out); |
| verifyResultsConvertUshort3Uint3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Ushort3Uint3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint3Ushort3Uint3(inV, out); |
| verifyResultsConvertUshort3Uint3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Ushort3Uint3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort3Uint3(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortUint args = new ArgumentsUshortUint(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUshort3Uint3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUshort4Uint4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x8d799ec18882dfb9l, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); |
| script.forEach_testConvertUint4Ushort4Uint4(inV, out); |
| verifyResultsConvertUshort4Uint4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Ushort4Uint4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint4Ushort4Uint4(inV, out); |
| verifyResultsConvertUshort4Uint4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Ushort4Uint4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort4Uint4(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortUint args = new ArgumentsUshortUint(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUshort4Uint4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsIntUint { |
| public int inV; |
| public int out; |
| } |
| |
| private void checkConvertInt2Uint2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xd74f55bc4f178a9fl, false, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); |
| script.forEach_testConvertUint2Int2Uint2(inV, out); |
| verifyResultsConvertInt2Uint2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Int2Uint2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint2Int2Uint2(inV, out); |
| verifyResultsConvertInt2Uint2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Int2Uint2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt2Uint2(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntUint args = new ArgumentsIntUint(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertInt2Uint2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertInt3Uint3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xd74f605dae1f4f93l, false, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); |
| script.forEach_testConvertUint3Int3Uint3(inV, out); |
| verifyResultsConvertInt3Uint3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Int3Uint3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint3Int3Uint3(inV, out); |
| verifyResultsConvertInt3Uint3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Int3Uint3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt3Uint3(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntUint args = new ArgumentsIntUint(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertInt3Uint3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertInt4Uint4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xd74f6aff0d271487l, false, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); |
| script.forEach_testConvertUint4Int4Uint4(inV, out); |
| verifyResultsConvertInt4Uint4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Int4Uint4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint4Int4Uint4(inV, out); |
| verifyResultsConvertInt4Uint4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Int4Uint4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt4Uint4(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntUint args = new ArgumentsIntUint(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertInt4Uint4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUintUint { |
| public int inV; |
| public int out; |
| } |
| |
| private void checkConvertUint2Uint2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xe71d0ca64c8baea2l, false, 32); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); |
| script.forEach_testConvertUint2Uint2Uint2(inV, out); |
| verifyResultsConvertUint2Uint2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Uint2Uint2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint2Uint2Uint2(inV, out); |
| verifyResultsConvertUint2Uint2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Uint2Uint2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint2Uint2(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintUint args = new ArgumentsUintUint(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUint2Uint2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUint3Uint3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xe71d1747ab937396l, false, 32); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); |
| script.forEach_testConvertUint3Uint3Uint3(inV, out); |
| verifyResultsConvertUint3Uint3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Uint3Uint3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint3Uint3Uint3(inV, out); |
| verifyResultsConvertUint3Uint3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Uint3Uint3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint3Uint3(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintUint args = new ArgumentsUintUint(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUint3Uint3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUint4Uint4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xe71d21e90a9b388al, false, 32); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); |
| script.forEach_testConvertUint4Uint4Uint4(inV, out); |
| verifyResultsConvertUint4Uint4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Uint4Uint4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint4Uint4Uint4(inV, out); |
| verifyResultsConvertUint4Uint4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Uint4Uint4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint4Uint4(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintUint args = new ArgumentsUintUint(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUint4Uint4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsDoubleDouble { |
| public double inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertDouble2Double2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x345b4a823902786el, -8.5390423905960001625e+307, 8.5390423905960001625e+307); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); |
| script.forEach_testConvertDouble2Double2Double2(inV, out); |
| verifyResultsConvertDouble2Double2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Double2Double2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble2Double2Double2(inV, out); |
| verifyResultsConvertDouble2Double2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Double2Double2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble2Double2(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleDouble args = new ArgumentsDoubleDouble(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(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("%24.8g {%16x} %31a", |
| arrayOut[i * 2 + j], Double.doubleToRawLongBits(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 checkConvertDouble2Double2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertDouble3Double3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x34a812098f5e099al, -8.5390423905960001625e+307, 8.5390423905960001625e+307); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); |
| script.forEach_testConvertDouble3Double3Double3(inV, out); |
| verifyResultsConvertDouble3Double3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Double3Double3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble3Double3Double3(inV, out); |
| verifyResultsConvertDouble3Double3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Double3Double3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble3Double3(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleDouble args = new ArgumentsDoubleDouble(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(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("%24.8g {%16x} %31a", |
| arrayOut[i * 4 + j], Double.doubleToRawLongBits(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 checkConvertDouble3Double3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertDouble4Double4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x34f4d990e5b99ac6l, -8.5390423905960001625e+307, 8.5390423905960001625e+307); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); |
| script.forEach_testConvertDouble4Double4Double4(inV, out); |
| verifyResultsConvertDouble4Double4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Double4Double4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble4Double4Double4(inV, out); |
| verifyResultsConvertDouble4Double4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Double4Double4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble4Double4(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleDouble args = new ArgumentsDoubleDouble(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(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("%24.8g {%16x} %31a", |
| arrayOut[i * 4 + j], Double.doubleToRawLongBits(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 checkConvertDouble4Double4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsLongDouble { |
| public long inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertLong2Double2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x7b7807124c70299bl, true, 63); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); |
| script.forEach_testConvertDouble2Long2Double2(inV, out); |
| verifyResultsConvertLong2Double2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Long2Double2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble2Long2Double2(inV, out); |
| verifyResultsConvertLong2Double2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Long2Double2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong2Double2(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongDouble args = new ArgumentsLongDouble(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%d", 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("%24.8g {%16x} %31a", |
| arrayOut[i * 2 + j], Double.doubleToRawLongBits(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 checkConvertLong2Double2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertLong3Double3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x7bc4ce99a2cbbac7l, true, 63); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); |
| script.forEach_testConvertDouble3Long3Double3(inV, out); |
| verifyResultsConvertLong3Double3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Long3Double3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble3Long3Double3(inV, out); |
| verifyResultsConvertLong3Double3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Long3Double3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong3Double3(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongDouble args = new ArgumentsLongDouble(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%d", 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("%24.8g {%16x} %31a", |
| arrayOut[i * 4 + j], Double.doubleToRawLongBits(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 checkConvertLong3Double3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertLong4Double4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x7c119620f9274bf3l, true, 63); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); |
| script.forEach_testConvertDouble4Long4Double4(inV, out); |
| verifyResultsConvertLong4Double4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Long4Double4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble4Long4Double4(inV, out); |
| verifyResultsConvertLong4Double4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Long4Double4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong4Double4(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongDouble args = new ArgumentsLongDouble(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%d", 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("%24.8g {%16x} %31a", |
| arrayOut[i * 4 + j], Double.doubleToRawLongBits(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 checkConvertLong4Double4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUlongDouble { |
| public long inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertUlong2Double2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xaa17685979bc7954l, false, 64); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); |
| script.forEach_testConvertDouble2Ulong2Double2(inV, out); |
| verifyResultsConvertUlong2Double2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Ulong2Double2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble2Ulong2Double2(inV, out); |
| verifyResultsConvertUlong2Double2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Ulong2Double2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong2Double2(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongDouble args = new ArgumentsUlongDouble(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("0x%x", 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("%24.8g {%16x} %31a", |
| arrayOut[i * 2 + j], Double.doubleToRawLongBits(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 checkConvertUlong2Double2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUlong3Double3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0xaa642fe0d0180a80l, false, 64); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); |
| script.forEach_testConvertDouble3Ulong3Double3(inV, out); |
| verifyResultsConvertUlong3Double3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Ulong3Double3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble3Ulong3Double3(inV, out); |
| verifyResultsConvertUlong3Double3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Ulong3Double3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong3Double3(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongDouble args = new ArgumentsUlongDouble(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("0x%x", 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("%24.8g {%16x} %31a", |
| arrayOut[i * 4 + j], Double.doubleToRawLongBits(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 checkConvertUlong3Double3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUlong4Double4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0xaab0f76826739bacl, false, 64); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); |
| script.forEach_testConvertDouble4Ulong4Double4(inV, out); |
| verifyResultsConvertUlong4Double4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Ulong4Double4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble4Ulong4Double4(inV, out); |
| verifyResultsConvertUlong4Double4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Ulong4Double4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong4Double4(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongDouble args = new ArgumentsUlongDouble(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("0x%x", 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("%24.8g {%16x} %31a", |
| arrayOut[i * 4 + j], Double.doubleToRawLongBits(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 checkConvertUlong4Double4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsDoubleLong { |
| public double inV; |
| public long out; |
| } |
| |
| private void checkConvertDouble2Long2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xcbf84dc0430cbe95l, -9.2233720368547747840e+18, 9.2233720368547747840e+18); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); |
| script.forEach_testConvertLong2Double2Long2(inV, out); |
| verifyResultsConvertDouble2Long2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Double2Long2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong2Double2Long2(inV, out); |
| verifyResultsConvertDouble2Long2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Double2Long2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble2Long2(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleLong args = new ArgumentsDoubleLong(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(args.inV), args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertDouble2Long2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertDouble3Long3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0xcbf85861a2148389l, -9.2233720368547747840e+18, 9.2233720368547747840e+18); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); |
| script.forEach_testConvertLong3Double3Long3(inV, out); |
| verifyResultsConvertDouble3Long3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Double3Long3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong3Double3Long3(inV, out); |
| verifyResultsConvertDouble3Long3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Double3Long3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble3Long3(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleLong args = new ArgumentsDoubleLong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(args.inV), args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertDouble3Long3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertDouble4Long4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xcbf86303011c487dl, -9.2233720368547747840e+18, 9.2233720368547747840e+18); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); |
| script.forEach_testConvertLong4Double4Long4(inV, out); |
| verifyResultsConvertDouble4Long4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Double4Long4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong4Double4Long4(inV, out); |
| verifyResultsConvertDouble4Long4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Double4Long4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble4Long4(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleLong args = new ArgumentsDoubleLong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(args.inV), args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertDouble4Long4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsLongLong { |
| public long inV; |
| public long out; |
| } |
| |
| private void checkConvertLong2Long2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xb570c607c81d242al, true, 63); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); |
| script.forEach_testConvertLong2Long2Long2(inV, out); |
| verifyResultsConvertLong2Long2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Long2Long2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong2Long2Long2(inV, out); |
| verifyResultsConvertLong2Long2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Long2Long2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong2Long2(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongLong args = new ArgumentsLongLong(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertLong2Long2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertLong3Long3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xb570d0a92724e91el, true, 63); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); |
| script.forEach_testConvertLong3Long3Long3(inV, out); |
| verifyResultsConvertLong3Long3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Long3Long3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong3Long3Long3(inV, out); |
| verifyResultsConvertLong3Long3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Long3Long3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong3Long3(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongLong args = new ArgumentsLongLong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertLong3Long3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertLong4Long4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xb570db4a862cae12l, true, 63); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); |
| script.forEach_testConvertLong4Long4Long4(inV, out); |
| verifyResultsConvertLong4Long4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Long4Long4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong4Long4Long4(inV, out); |
| verifyResultsConvertLong4Long4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Long4Long4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong4Long4(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongLong args = new ArgumentsLongLong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertLong4Long4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUlongLong { |
| public long inV; |
| public long out; |
| } |
| |
| private void checkConvertUlong2Long2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x5cfe7f555a9f30abl, false, 63); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); |
| script.forEach_testConvertLong2Ulong2Long2(inV, out); |
| verifyResultsConvertUlong2Long2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Ulong2Long2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong2Ulong2Long2(inV, out); |
| verifyResultsConvertUlong2Long2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Ulong2Long2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong2Long2(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongLong args = new ArgumentsUlongLong(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUlong2Long2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUlong3Long3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x5cfe89f6b9a6f59fl, false, 63); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); |
| script.forEach_testConvertLong3Ulong3Long3(inV, out); |
| verifyResultsConvertUlong3Long3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Ulong3Long3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong3Ulong3Long3(inV, out); |
| verifyResultsConvertUlong3Long3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Ulong3Long3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong3Long3(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongLong args = new ArgumentsUlongLong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUlong3Long3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUlong4Long4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x5cfe949818aeba93l, false, 63); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); |
| script.forEach_testConvertLong4Ulong4Long4(inV, out); |
| verifyResultsConvertUlong4Long4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Ulong4Long4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong4Ulong4Long4(inV, out); |
| verifyResultsConvertUlong4Long4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Ulong4Long4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong4Long4(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongLong args = new ArgumentsUlongLong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUlong4Long4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsDoubleUlong { |
| public double inV; |
| public long out; |
| } |
| |
| private void checkConvertDouble2Ulong2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x42b56e3b7e12ff5el, 0.0000000000000000000e+00, 1.8446744073709549568e+19); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); |
| script.forEach_testConvertUlong2Double2Ulong2(inV, out); |
| verifyResultsConvertDouble2Ulong2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Double2Ulong2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong2Double2Ulong2(inV, out); |
| verifyResultsConvertDouble2Ulong2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Double2Ulong2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble2Ulong2(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleUlong args = new ArgumentsDoubleUlong(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(args.inV), args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertDouble2Ulong2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertDouble3Ulong3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x42b73756742e203cl, 0.0000000000000000000e+00, 1.8446744073709549568e+19); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); |
| script.forEach_testConvertUlong3Double3Ulong3(inV, out); |
| verifyResultsConvertDouble3Ulong3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Double3Ulong3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong3Double3Ulong3(inV, out); |
| verifyResultsConvertDouble3Ulong3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Double3Ulong3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble3Ulong3(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleUlong args = new ArgumentsDoubleUlong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(args.inV), args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertDouble3Ulong3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertDouble4Ulong4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x42b900716a49411al, 0.0000000000000000000e+00, 1.8446744073709549568e+19); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); |
| script.forEach_testConvertUlong4Double4Ulong4(inV, out); |
| verifyResultsConvertDouble4Ulong4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Double4Ulong4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong4Double4Ulong4(inV, out); |
| verifyResultsConvertDouble4Ulong4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Double4Ulong4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble4Ulong4(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleUlong args = new ArgumentsDoubleUlong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(args.inV), args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertDouble4Ulong4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsLongUlong { |
| public long inV; |
| public long out; |
| } |
| |
| private void checkConvertLong2Ulong2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x79f1a23ed7d40f65l, false, 63); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); |
| script.forEach_testConvertUlong2Long2Ulong2(inV, out); |
| verifyResultsConvertLong2Ulong2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Long2Ulong2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong2Long2Ulong2(inV, out); |
| verifyResultsConvertLong2Ulong2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Long2Ulong2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong2Ulong2(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongUlong args = new ArgumentsLongUlong(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertLong2Ulong2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertLong3Ulong3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x79f36b59cdef3043l, false, 63); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); |
| script.forEach_testConvertUlong3Long3Ulong3(inV, out); |
| verifyResultsConvertLong3Ulong3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Long3Ulong3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong3Long3Ulong3(inV, out); |
| verifyResultsConvertLong3Ulong3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Long3Ulong3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong3Ulong3(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongUlong args = new ArgumentsLongUlong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertLong3Ulong3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertLong4Ulong4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x79f53474c40a5121l, false, 63); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); |
| script.forEach_testConvertUlong4Long4Ulong4(inV, out); |
| verifyResultsConvertLong4Ulong4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Long4Ulong4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong4Long4Ulong4(inV, out); |
| verifyResultsConvertLong4Ulong4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Long4Ulong4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong4Ulong4(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongUlong args = new ArgumentsLongUlong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertLong4Ulong4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUlongUlong { |
| public long inV; |
| public long out; |
| } |
| |
| private void checkConvertUlong2Ulong2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x9ebfc24673ac2910l, false, 64); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); |
| script.forEach_testConvertUlong2Ulong2Ulong2(inV, out); |
| verifyResultsConvertUlong2Ulong2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Ulong2Ulong2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong2Ulong2Ulong2(inV, out); |
| verifyResultsConvertUlong2Ulong2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Ulong2Ulong2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong2Ulong2(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongUlong args = new ArgumentsUlongUlong(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUlong2Ulong2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUlong3Ulong3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x9ec18b6169c749eel, false, 64); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); |
| script.forEach_testConvertUlong3Ulong3Ulong3(inV, out); |
| verifyResultsConvertUlong3Ulong3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Ulong3Ulong3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong3Ulong3Ulong3(inV, out); |
| verifyResultsConvertUlong3Ulong3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Ulong3Ulong3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong3Ulong3(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongUlong args = new ArgumentsUlongUlong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUlong3Ulong3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUlong4Ulong4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x9ec3547c5fe26accl, false, 64); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); |
| script.forEach_testConvertUlong4Ulong4Ulong4(inV, out); |
| verifyResultsConvertUlong4Ulong4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Ulong4Ulong4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong4Ulong4Ulong4(inV, out); |
| verifyResultsConvertUlong4Ulong4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Ulong4Ulong4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong4Ulong4(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongUlong args = new ArgumentsUlongUlong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUlong4Ulong4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsDoubleFloat { |
| public double inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertDouble2Float2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x42b4cec67d6d9a2dl, -1.6163412428744576259e+38, 1.6163412428744576259e+38); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| script.forEach_testConvertFloat2Double2Float2(inV, out); |
| verifyResultsConvertDouble2Float2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Double2Float2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat2Double2Float2(inV, out); |
| verifyResultsConvertDouble2Float2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Double2Float2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble2Float2(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[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. |
| ArgumentsDoubleFloat args = new ArgumentsDoubleFloat(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(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 checkConvertDouble2Float2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertDouble3Float3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x42b697e17388bb0bl, -1.6163412428744576259e+38, 1.6163412428744576259e+38); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| script.forEach_testConvertFloat3Double3Float3(inV, out); |
| verifyResultsConvertDouble3Float3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Double3Float3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat3Double3Float3(inV, out); |
| verifyResultsConvertDouble3Float3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Double3Float3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble3Float3(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[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. |
| ArgumentsDoubleFloat args = new ArgumentsDoubleFloat(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(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 checkConvertDouble3Float3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertDouble4Float4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x42b860fc69a3dbe9l, -1.6163412428744576259e+38, 1.6163412428744576259e+38); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| script.forEach_testConvertFloat4Double4Float4(inV, out); |
| verifyResultsConvertDouble4Float4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Double4Float4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat4Double4Float4(inV, out); |
| verifyResultsConvertDouble4Float4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Double4Float4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble4Float4(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[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. |
| ArgumentsDoubleFloat args = new ArgumentsDoubleFloat(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(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 checkConvertDouble4Float4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsLongFloat { |
| public long inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertLong2Float2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x79f102c9d72eaa34l, true, 63); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| script.forEach_testConvertFloat2Long2Float2(inV, out); |
| verifyResultsConvertLong2Float2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Long2Float2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat2Long2Float2(inV, out); |
| verifyResultsConvertLong2Float2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Long2Float2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong2Float2(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[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. |
| ArgumentsLongFloat args = new ArgumentsLongFloat(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%d", 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 checkConvertLong2Float2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertLong3Float3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x79f2cbe4cd49cb12l, true, 63); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| script.forEach_testConvertFloat3Long3Float3(inV, out); |
| verifyResultsConvertLong3Float3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Long3Float3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat3Long3Float3(inV, out); |
| verifyResultsConvertLong3Float3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Long3Float3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong3Float3(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[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. |
| ArgumentsLongFloat args = new ArgumentsLongFloat(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%d", 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 checkConvertLong3Float3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertLong4Float4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x79f494ffc364ebf0l, true, 63); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| script.forEach_testConvertFloat4Long4Float4(inV, out); |
| verifyResultsConvertLong4Float4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Long4Float4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat4Long4Float4(inV, out); |
| verifyResultsConvertLong4Float4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Long4Float4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong4Float4(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[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. |
| ArgumentsLongFloat args = new ArgumentsLongFloat(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%d", 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 checkConvertLong4Float4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUlongFloat { |
| public long inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertUlong2Float2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x9ebf22d17306c3dfl, false, 64); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| script.forEach_testConvertFloat2Ulong2Float2(inV, out); |
| verifyResultsConvertUlong2Float2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Ulong2Float2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat2Ulong2Float2(inV, out); |
| verifyResultsConvertUlong2Float2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat2Ulong2Float2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong2Float2(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[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. |
| ArgumentsUlongFloat args = new ArgumentsUlongFloat(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("0x%x", 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 checkConvertUlong2Float2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUlong3Float3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x9ec0ebec6921e4bdl, false, 64); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| script.forEach_testConvertFloat3Ulong3Float3(inV, out); |
| verifyResultsConvertUlong3Float3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Ulong3Float3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat3Ulong3Float3(inV, out); |
| verifyResultsConvertUlong3Float3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat3Ulong3Float3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong3Float3(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[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. |
| ArgumentsUlongFloat args = new ArgumentsUlongFloat(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("0x%x", 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 checkConvertUlong3Float3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUlong4Float4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x9ec2b5075f3d059bl, false, 64); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| script.forEach_testConvertFloat4Ulong4Float4(inV, out); |
| verifyResultsConvertUlong4Float4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Ulong4Float4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertFloat4Ulong4Float4(inV, out); |
| verifyResultsConvertUlong4Float4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertFloat4Ulong4Float4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong4Float4(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[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. |
| ArgumentsUlongFloat args = new ArgumentsUlongFloat(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("0x%x", 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 checkConvertUlong4Float4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsDoubleChar { |
| public double inV; |
| public byte out; |
| } |
| |
| private void checkConvertDouble2Char2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xcbf84b7bef094a17l, -1.2800000000000000000e+02, 1.2700000000000000000e+02); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); |
| script.forEach_testConvertChar2Double2Char2(inV, out); |
| verifyResultsConvertDouble2Char2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Double2Char2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar2Double2Char2(inV, out); |
| verifyResultsConvertDouble2Char2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Double2Char2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble2Char2(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleChar args = new ArgumentsDoubleChar(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(args.inV), args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertDouble2Char2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertDouble3Char3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0xcbf8561d4e110f0bl, -1.2800000000000000000e+02, 1.2700000000000000000e+02); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); |
| script.forEach_testConvertChar3Double3Char3(inV, out); |
| verifyResultsConvertDouble3Char3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Double3Char3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar3Double3Char3(inV, out); |
| verifyResultsConvertDouble3Char3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Double3Char3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble3Char3(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleChar args = new ArgumentsDoubleChar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(args.inV), args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertDouble3Char3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertDouble4Char4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xcbf860bead18d3ffl, -1.2800000000000000000e+02, 1.2700000000000000000e+02); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); |
| script.forEach_testConvertChar4Double4Char4(inV, out); |
| verifyResultsConvertDouble4Char4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Double4Char4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar4Double4Char4(inV, out); |
| verifyResultsConvertDouble4Char4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Double4Char4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble4Char4(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleChar args = new ArgumentsDoubleChar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(args.inV), args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertDouble4Char4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsLongChar { |
| public long inV; |
| public byte out; |
| } |
| |
| private void checkConvertLong2Char2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xb570c3c37419afacl, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); |
| script.forEach_testConvertChar2Long2Char2(inV, out); |
| verifyResultsConvertLong2Char2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Long2Char2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar2Long2Char2(inV, out); |
| verifyResultsConvertLong2Char2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Long2Char2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong2Char2(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongChar args = new ArgumentsLongChar(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertLong2Char2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertLong3Char3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xb570ce64d32174a0l, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); |
| script.forEach_testConvertChar3Long3Char3(inV, out); |
| verifyResultsConvertLong3Char3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Long3Char3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar3Long3Char3(inV, out); |
| verifyResultsConvertLong3Char3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Long3Char3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong3Char3(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongChar args = new ArgumentsLongChar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertLong3Char3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertLong4Char4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xb570d90632293994l, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); |
| script.forEach_testConvertChar4Long4Char4(inV, out); |
| verifyResultsConvertLong4Char4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Long4Char4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar4Long4Char4(inV, out); |
| verifyResultsConvertLong4Char4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Long4Char4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong4Char4(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongChar args = new ArgumentsLongChar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertLong4Char4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUlongChar { |
| public long inV; |
| public byte out; |
| } |
| |
| private void checkConvertUlong2Char2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x5cfe7d11069bbc2dl, false, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); |
| script.forEach_testConvertChar2Ulong2Char2(inV, out); |
| verifyResultsConvertUlong2Char2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Ulong2Char2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar2Ulong2Char2(inV, out); |
| verifyResultsConvertUlong2Char2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar2Ulong2Char2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong2Char2(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongChar args = new ArgumentsUlongChar(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUlong2Char2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUlong3Char3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x5cfe87b265a38121l, false, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); |
| script.forEach_testConvertChar3Ulong3Char3(inV, out); |
| verifyResultsConvertUlong3Char3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Ulong3Char3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar3Ulong3Char3(inV, out); |
| verifyResultsConvertUlong3Char3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar3Ulong3Char3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong3Char3(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongChar args = new ArgumentsUlongChar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUlong3Char3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUlong4Char4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x5cfe9253c4ab4615l, false, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); |
| script.forEach_testConvertChar4Ulong4Char4(inV, out); |
| verifyResultsConvertUlong4Char4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Ulong4Char4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_8, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertChar4Ulong4Char4(inV, out); |
| verifyResultsConvertUlong4Char4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertChar4Ulong4Char4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong4Char4(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongChar args = new ArgumentsUlongChar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUlong4Char4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsDoubleUchar { |
| public double inV; |
| public byte out; |
| } |
| |
| private void checkConvertDouble2Uchar2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x42b56bf72a0f8ae0l, 0.0000000000000000000e+00, 2.5500000000000000000e+02); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); |
| script.forEach_testConvertUchar2Double2Uchar2(inV, out); |
| verifyResultsConvertDouble2Uchar2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Double2Uchar2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar2Double2Uchar2(inV, out); |
| verifyResultsConvertDouble2Uchar2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Double2Uchar2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble2Uchar2(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleUchar args = new ArgumentsDoubleUchar(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(args.inV), args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertDouble2Uchar2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertDouble3Uchar3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x42b73512202aabbel, 0.0000000000000000000e+00, 2.5500000000000000000e+02); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); |
| script.forEach_testConvertUchar3Double3Uchar3(inV, out); |
| verifyResultsConvertDouble3Uchar3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Double3Uchar3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar3Double3Uchar3(inV, out); |
| verifyResultsConvertDouble3Uchar3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Double3Uchar3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble3Uchar3(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleUchar args = new ArgumentsDoubleUchar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(args.inV), args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertDouble3Uchar3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertDouble4Uchar4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x42b8fe2d1645cc9cl, 0.0000000000000000000e+00, 2.5500000000000000000e+02); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); |
| script.forEach_testConvertUchar4Double4Uchar4(inV, out); |
| verifyResultsConvertDouble4Uchar4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Double4Uchar4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar4Double4Uchar4(inV, out); |
| verifyResultsConvertDouble4Uchar4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Double4Uchar4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble4Uchar4(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleUchar args = new ArgumentsDoubleUchar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(args.inV), args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertDouble4Uchar4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsLongUchar { |
| public long inV; |
| public byte out; |
| } |
| |
| private void checkConvertLong2Uchar2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x79f19ffa83d09ae7l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); |
| script.forEach_testConvertUchar2Long2Uchar2(inV, out); |
| verifyResultsConvertLong2Uchar2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Long2Uchar2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar2Long2Uchar2(inV, out); |
| verifyResultsConvertLong2Uchar2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Long2Uchar2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong2Uchar2(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongUchar args = new ArgumentsLongUchar(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertLong2Uchar2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertLong3Uchar3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x79f3691579ebbbc5l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); |
| script.forEach_testConvertUchar3Long3Uchar3(inV, out); |
| verifyResultsConvertLong3Uchar3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Long3Uchar3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar3Long3Uchar3(inV, out); |
| verifyResultsConvertLong3Uchar3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Long3Uchar3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong3Uchar3(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongUchar args = new ArgumentsLongUchar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertLong3Uchar3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertLong4Uchar4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x79f532307006dca3l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); |
| script.forEach_testConvertUchar4Long4Uchar4(inV, out); |
| verifyResultsConvertLong4Uchar4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Long4Uchar4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar4Long4Uchar4(inV, out); |
| verifyResultsConvertLong4Uchar4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Long4Uchar4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong4Uchar4(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongUchar args = new ArgumentsLongUchar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertLong4Uchar4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUlongUchar { |
| public long inV; |
| public byte out; |
| } |
| |
| private void checkConvertUlong2Uchar2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x9ebfc0021fa8b492l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); |
| script.forEach_testConvertUchar2Ulong2Uchar2(inV, out); |
| verifyResultsConvertUlong2Uchar2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Ulong2Uchar2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar2Ulong2Uchar2(inV, out); |
| verifyResultsConvertUlong2Uchar2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar2Ulong2Uchar2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong2Uchar2(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongUchar args = new ArgumentsUlongUchar(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUlong2Uchar2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUlong3Uchar3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x9ec1891d15c3d570l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); |
| script.forEach_testConvertUchar3Ulong3Uchar3(inV, out); |
| verifyResultsConvertUlong3Uchar3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Ulong3Uchar3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar3Ulong3Uchar3(inV, out); |
| verifyResultsConvertUlong3Uchar3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar3Ulong3Uchar3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong3Uchar3(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongUchar args = new ArgumentsUlongUchar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUlong3Uchar3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUlong4Uchar4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x9ec352380bdef64el, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); |
| script.forEach_testConvertUchar4Ulong4Uchar4(inV, out); |
| verifyResultsConvertUlong4Uchar4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Ulong4Uchar4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_8, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUchar4Ulong4Uchar4(inV, out); |
| verifyResultsConvertUlong4Uchar4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUchar4Ulong4Uchar4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong4Uchar4(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongUchar args = new ArgumentsUlongUchar(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUlong4Uchar4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsDoubleShort { |
| public double inV; |
| public short out; |
| } |
| |
| private void checkConvertDouble2Short2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x42b557fbbf1d55f9l, -3.2768000000000000000e+04, 3.2767000000000000000e+04); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); |
| script.forEach_testConvertShort2Double2Short2(inV, out); |
| verifyResultsConvertDouble2Short2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Double2Short2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort2Double2Short2(inV, out); |
| verifyResultsConvertDouble2Short2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Double2Short2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble2Short2(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleShort args = new ArgumentsDoubleShort(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(args.inV), args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertDouble2Short2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertDouble3Short3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x42b72116b53876d7l, -3.2768000000000000000e+04, 3.2767000000000000000e+04); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); |
| script.forEach_testConvertShort3Double3Short3(inV, out); |
| verifyResultsConvertDouble3Short3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Double3Short3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort3Double3Short3(inV, out); |
| verifyResultsConvertDouble3Short3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Double3Short3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble3Short3(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleShort args = new ArgumentsDoubleShort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(args.inV), args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertDouble3Short3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertDouble4Short4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x42b8ea31ab5397b5l, -3.2768000000000000000e+04, 3.2767000000000000000e+04); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); |
| script.forEach_testConvertShort4Double4Short4(inV, out); |
| verifyResultsConvertDouble4Short4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Double4Short4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort4Double4Short4(inV, out); |
| verifyResultsConvertDouble4Short4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Double4Short4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble4Short4(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleShort args = new ArgumentsDoubleShort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(args.inV), args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertDouble4Short4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsLongShort { |
| public long inV; |
| public short out; |
| } |
| |
| private void checkConvertLong2Short2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x79f18bff18de6600l, true, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); |
| script.forEach_testConvertShort2Long2Short2(inV, out); |
| verifyResultsConvertLong2Short2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Long2Short2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort2Long2Short2(inV, out); |
| verifyResultsConvertLong2Short2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Long2Short2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong2Short2(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongShort args = new ArgumentsLongShort(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertLong2Short2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertLong3Short3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x79f3551a0ef986del, true, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); |
| script.forEach_testConvertShort3Long3Short3(inV, out); |
| verifyResultsConvertLong3Short3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Long3Short3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort3Long3Short3(inV, out); |
| verifyResultsConvertLong3Short3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Long3Short3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong3Short3(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongShort args = new ArgumentsLongShort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertLong3Short3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertLong4Short4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x79f51e350514a7bcl, true, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); |
| script.forEach_testConvertShort4Long4Short4(inV, out); |
| verifyResultsConvertLong4Short4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Long4Short4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort4Long4Short4(inV, out); |
| verifyResultsConvertLong4Short4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Long4Short4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong4Short4(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongShort args = new ArgumentsLongShort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertLong4Short4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUlongShort { |
| public long inV; |
| public short out; |
| } |
| |
| private void checkConvertUlong2Short2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x9ebfac06b4b67fabl, false, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); |
| script.forEach_testConvertShort2Ulong2Short2(inV, out); |
| verifyResultsConvertUlong2Short2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Ulong2Short2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort2Ulong2Short2(inV, out); |
| verifyResultsConvertUlong2Short2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort2Ulong2Short2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong2Short2(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongShort args = new ArgumentsUlongShort(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUlong2Short2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUlong3Short3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x9ec17521aad1a089l, false, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); |
| script.forEach_testConvertShort3Ulong3Short3(inV, out); |
| verifyResultsConvertUlong3Short3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Ulong3Short3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort3Ulong3Short3(inV, out); |
| verifyResultsConvertUlong3Short3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort3Ulong3Short3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong3Short3(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongShort args = new ArgumentsUlongShort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUlong3Short3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUlong4Short4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x9ec33e3ca0ecc167l, false, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); |
| script.forEach_testConvertShort4Ulong4Short4(inV, out); |
| verifyResultsConvertUlong4Short4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Ulong4Short4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_16, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertShort4Ulong4Short4(inV, out); |
| verifyResultsConvertUlong4Short4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertShort4Ulong4Short4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong4Short4(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongShort args = new ArgumentsUlongShort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUlong4Short4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsDoubleUshort { |
| public double inV; |
| public short out; |
| } |
| |
| private void checkConvertDouble2Ushort2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x3479ccaea92a37bcl, 0.0000000000000000000e+00, 6.5535000000000000000e+04); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); |
| script.forEach_testConvertUshort2Double2Ushort2(inV, out); |
| verifyResultsConvertDouble2Ushort2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Double2Ushort2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort2Double2Ushort2(inV, out); |
| verifyResultsConvertDouble2Ushort2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Double2Ushort2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble2Ushort2(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleUshort args = new ArgumentsDoubleUshort(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(args.inV), args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertDouble2Ushort2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertDouble3Ushort3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x34c69435ff85c8e8l, 0.0000000000000000000e+00, 6.5535000000000000000e+04); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); |
| script.forEach_testConvertUshort3Double3Ushort3(inV, out); |
| verifyResultsConvertDouble3Ushort3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Double3Ushort3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort3Double3Ushort3(inV, out); |
| verifyResultsConvertDouble3Ushort3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Double3Ushort3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble3Ushort3(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleUshort args = new ArgumentsDoubleUshort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(args.inV), args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertDouble3Ushort3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertDouble4Ushort4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x35135bbd55e15a14l, 0.0000000000000000000e+00, 6.5535000000000000000e+04); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); |
| script.forEach_testConvertUshort4Double4Ushort4(inV, out); |
| verifyResultsConvertDouble4Ushort4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Double4Ushort4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort4Double4Ushort4(inV, out); |
| verifyResultsConvertDouble4Ushort4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Double4Ushort4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble4Ushort4(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleUshort args = new ArgumentsDoubleUshort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(args.inV), args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertDouble4Ushort4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsLongUshort { |
| public long inV; |
| public short out; |
| } |
| |
| private void checkConvertLong2Ushort2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x7b96893ebc97e8e9l, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); |
| script.forEach_testConvertUshort2Long2Ushort2(inV, out); |
| verifyResultsConvertLong2Ushort2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Long2Ushort2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort2Long2Ushort2(inV, out); |
| verifyResultsConvertLong2Ushort2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Long2Ushort2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong2Ushort2(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongUshort args = new ArgumentsLongUshort(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertLong2Ushort2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertLong3Ushort3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x7be350c612f37a15l, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); |
| script.forEach_testConvertUshort3Long3Ushort3(inV, out); |
| verifyResultsConvertLong3Ushort3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Long3Ushort3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort3Long3Ushort3(inV, out); |
| verifyResultsConvertLong3Ushort3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Long3Ushort3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong3Ushort3(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongUshort args = new ArgumentsLongUshort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertLong3Ushort3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertLong4Ushort4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x7c30184d694f0b41l, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); |
| script.forEach_testConvertUshort4Long4Ushort4(inV, out); |
| verifyResultsConvertLong4Ushort4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Long4Ushort4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort4Long4Ushort4(inV, out); |
| verifyResultsConvertLong4Ushort4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Long4Ushort4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong4Ushort4(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongUshort args = new ArgumentsLongUshort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertLong4Ushort4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUlongUshort { |
| public long inV; |
| public short out; |
| } |
| |
| private void checkConvertUlong2Ushort2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xaa35ea85e9e438a2l, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); |
| script.forEach_testConvertUshort2Ulong2Ushort2(inV, out); |
| verifyResultsConvertUlong2Ushort2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Ulong2Ushort2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort2Ulong2Ushort2(inV, out); |
| verifyResultsConvertUlong2Ushort2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort2Ulong2Ushort2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong2Ushort2(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongUshort args = new ArgumentsUlongUshort(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUlong2Ushort2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUlong3Ushort3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0xaa82b20d403fc9cel, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); |
| script.forEach_testConvertUshort3Ulong3Ushort3(inV, out); |
| verifyResultsConvertUlong3Ushort3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Ulong3Ushort3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort3Ulong3Ushort3(inV, out); |
| verifyResultsConvertUlong3Ushort3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort3Ulong3Ushort3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong3Ushort3(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongUshort args = new ArgumentsUlongUshort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUlong3Ushort3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUlong4Ushort4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0xaacf7994969b5afal, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); |
| script.forEach_testConvertUshort4Ulong4Ushort4(inV, out); |
| verifyResultsConvertUlong4Ushort4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Ulong4Ushort4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_16, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUshort4Ulong4Ushort4(inV, out); |
| verifyResultsConvertUlong4Ushort4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUshort4Ulong4Ushort4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong4Ushort4(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongUshort args = new ArgumentsUlongUshort(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUlong4Ushort4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsDoubleInt { |
| public double inV; |
| public int out; |
| } |
| |
| private void checkConvertDouble2Int2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xa57cd81dcaf628fcl, -2.1474836480000000000e+09, 2.1474836470000000000e+09); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); |
| script.forEach_testConvertInt2Double2Int2(inV, out); |
| verifyResultsConvertDouble2Int2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Double2Int2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt2Double2Int2(inV, out); |
| verifyResultsConvertDouble2Int2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Double2Int2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble2Int2(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleInt args = new ArgumentsDoubleInt(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(args.inV), args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertDouble2Int2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertDouble3Int3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0xa57cd85d149e3932l, -2.1474836480000000000e+09, 2.1474836470000000000e+09); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); |
| script.forEach_testConvertInt3Double3Int3(inV, out); |
| verifyResultsConvertDouble3Int3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Double3Int3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt3Double3Int3(inV, out); |
| verifyResultsConvertDouble3Int3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Double3Int3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble3Int3(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleInt args = new ArgumentsDoubleInt(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(args.inV), args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertDouble3Int3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertDouble4Int4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xa57cd89c5e464968l, -2.1474836480000000000e+09, 2.1474836470000000000e+09); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); |
| script.forEach_testConvertInt4Double4Int4(inV, out); |
| verifyResultsConvertDouble4Int4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Double4Int4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt4Double4Int4(inV, out); |
| verifyResultsConvertDouble4Int4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Double4Int4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble4Int4(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleInt args = new ArgumentsDoubleInt(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(args.inV), args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertDouble4Int4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsLongInt { |
| public long inV; |
| public int out; |
| } |
| |
| private void checkConvertLong2Int2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xfe441c66e5deba3bl, true, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); |
| script.forEach_testConvertInt2Long2Int2(inV, out); |
| verifyResultsConvertLong2Int2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Long2Int2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt2Long2Int2(inV, out); |
| verifyResultsConvertLong2Int2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Long2Int2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong2Int2(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongInt args = new ArgumentsLongInt(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertLong2Int2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertLong3Int3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xfe441ca62f86ca71l, true, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); |
| script.forEach_testConvertInt3Long3Int3(inV, out); |
| verifyResultsConvertLong3Int3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Long3Int3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt3Long3Int3(inV, out); |
| verifyResultsConvertLong3Int3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Long3Int3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong3Int3(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongInt args = new ArgumentsLongInt(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertLong3Int3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertLong4Int4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xfe441ce5792edaa7l, true, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); |
| script.forEach_testConvertInt4Long4Int4(inV, out); |
| verifyResultsConvertLong4Int4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Long4Int4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt4Long4Int4(inV, out); |
| verifyResultsConvertLong4Int4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Long4Int4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong4Int4(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongInt args = new ArgumentsLongInt(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertLong4Int4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUlongInt { |
| public long inV; |
| public int out; |
| } |
| |
| private void checkConvertUlong2Int2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xe11d350e352de3el, false, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); |
| script.forEach_testConvertInt2Ulong2Int2(inV, out); |
| verifyResultsConvertUlong2Int2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Ulong2Int2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt2Ulong2Int2(inV, out); |
| verifyResultsConvertUlong2Int2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt2Ulong2Int2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong2Int2(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongInt args = new ArgumentsUlongInt(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUlong2Int2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUlong3Int3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0xe11d3902cfaee74l, false, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); |
| script.forEach_testConvertInt3Ulong3Int3(inV, out); |
| verifyResultsConvertUlong3Int3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Ulong3Int3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt3Ulong3Int3(inV, out); |
| verifyResultsConvertUlong3Int3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt3Ulong3Int3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong3Int3(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongInt args = new ArgumentsUlongInt(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUlong3Int3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUlong4Int4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0xe11d3cf76a2feaal, false, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); |
| script.forEach_testConvertInt4Ulong4Int4(inV, out); |
| verifyResultsConvertUlong4Int4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Ulong4Int4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertInt4Ulong4Int4(inV, out); |
| verifyResultsConvertUlong4Int4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertInt4Ulong4Int4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong4Int4(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongInt args = new ArgumentsUlongInt(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUlong4Int4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsDoubleUint { |
| public double inV; |
| public int out; |
| } |
| |
| private void checkConvertDouble2Uint2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xcbf84ff107de7dd7l, 0.0000000000000000000e+00, 4.2949672950000000000e+09); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); |
| script.forEach_testConvertUint2Double2Uint2(inV, out); |
| verifyResultsConvertDouble2Uint2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Double2Uint2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint2Double2Uint2(inV, out); |
| verifyResultsConvertDouble2Uint2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Double2Uint2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble2Uint2(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleUint args = new ArgumentsDoubleUint(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(args.inV), args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertDouble2Uint2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertDouble3Uint3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0xcbf85a9266e642cbl, 0.0000000000000000000e+00, 4.2949672950000000000e+09); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); |
| script.forEach_testConvertUint3Double3Uint3(inV, out); |
| verifyResultsConvertDouble3Uint3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Double3Uint3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint3Double3Uint3(inV, out); |
| verifyResultsConvertDouble3Uint3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Double3Uint3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble3Uint3(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleUint args = new ArgumentsDoubleUint(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(args.inV), args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertDouble3Uint3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertDouble4Uint4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xcbf86533c5ee07bfl, 0.0000000000000000000e+00, 4.2949672950000000000e+09); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); |
| script.forEach_testConvertUint4Double4Uint4(inV, out); |
| verifyResultsConvertDouble4Uint4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Double4Uint4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint4Double4Uint4(inV, out); |
| verifyResultsConvertDouble4Uint4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Double4Uint4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertDouble4Uint4(Allocation inV, Allocation out, boolean relaxed) { |
| double[] arrayInV = new double[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsDoubleUint args = new ArgumentsDoubleUint(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%24.8g {%16x} %31a", |
| args.inV, Double.doubleToRawLongBits(args.inV), args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertDouble4Uint4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsLongUint { |
| public long inV; |
| public int out; |
| } |
| |
| private void checkConvertLong2Uint2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xb570c8388ceee36cl, false, 32); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); |
| script.forEach_testConvertUint2Long2Uint2(inV, out); |
| verifyResultsConvertLong2Uint2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Long2Uint2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint2Long2Uint2(inV, out); |
| verifyResultsConvertLong2Uint2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Long2Uint2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong2Uint2(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongUint args = new ArgumentsLongUint(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertLong2Uint2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertLong3Uint3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xb570d2d9ebf6a860l, false, 32); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); |
| script.forEach_testConvertUint3Long3Uint3(inV, out); |
| verifyResultsConvertLong3Uint3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Long3Uint3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint3Long3Uint3(inV, out); |
| verifyResultsConvertLong3Uint3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Long3Uint3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong3Uint3(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongUint args = new ArgumentsLongUint(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertLong3Uint3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertLong4Uint4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xb570dd7b4afe6d54l, false, 32); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); |
| script.forEach_testConvertUint4Long4Uint4(inV, out); |
| verifyResultsConvertLong4Uint4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Long4Uint4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint4Long4Uint4(inV, out); |
| verifyResultsConvertLong4Uint4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Long4Uint4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertLong4Uint4(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsLongUint args = new ArgumentsLongUint(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertLong4Uint4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUlongUint { |
| public long inV; |
| public int out; |
| } |
| |
| private void checkConvertUlong2Uint2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x5cfe81861f70efedl, false, 32); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); |
| script.forEach_testConvertUint2Ulong2Uint2(inV, out); |
| verifyResultsConvertUlong2Uint2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Ulong2Uint2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint2Ulong2Uint2(inV, out); |
| verifyResultsConvertUlong2Uint2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint2Ulong2Uint2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong2Uint2(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongUint args = new ArgumentsUlongUint(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUlong2Uint2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUlong3Uint3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x5cfe8c277e78b4e1l, false, 32); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); |
| script.forEach_testConvertUint3Ulong3Uint3(inV, out); |
| verifyResultsConvertUlong3Uint3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Ulong3Uint3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint3Ulong3Uint3(inV, out); |
| verifyResultsConvertUlong3Uint3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint3Ulong3Uint3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong3Uint3(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongUint args = new ArgumentsUlongUint(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUlong3Uint3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUlong4Uint4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x5cfe96c8dd8079d5l, false, 32); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); |
| script.forEach_testConvertUint4Ulong4Uint4(inV, out); |
| verifyResultsConvertUlong4Uint4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Ulong4Uint4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_32, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUint4Ulong4Uint4(inV, out); |
| verifyResultsConvertUlong4Uint4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUint4Ulong4Uint4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUlong4Uint4(Allocation inV, Allocation out, boolean relaxed) { |
| long[] arrayInV = new long[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUlongUint args = new ArgumentsUlongUint(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUlong4Uint4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsFloatDouble { |
| public float inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertFloat2Double2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x36c6372446e08221l, -1.6163412428744576259e+38, 1.6163412428744576259e+38); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); |
| script.forEach_testConvertDouble2Float2Double2(inV, out); |
| verifyResultsConvertFloat2Double2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Float2Double2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble2Float2Double2(inV, out); |
| verifyResultsConvertFloat2Double2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Float2Double2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat2Double2(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatDouble args = new ArgumentsFloatDouble(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%24.8g {%16x} %31a", |
| arrayOut[i * 2 + j], Double.doubleToRawLongBits(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 checkConvertFloat2Double2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertFloat3Double3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x3712feab9d3c134dl, -1.6163412428744576259e+38, 1.6163412428744576259e+38); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); |
| script.forEach_testConvertDouble3Float3Double3(inV, out); |
| verifyResultsConvertFloat3Double3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Float3Double3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble3Float3Double3(inV, out); |
| verifyResultsConvertFloat3Double3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Float3Double3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat3Double3(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatDouble args = new ArgumentsFloatDouble(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%24.8g {%16x} %31a", |
| arrayOut[i * 4 + j], Double.doubleToRawLongBits(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 checkConvertFloat3Double3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertFloat4Double4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x375fc632f397a479l, -1.6163412428744576259e+38, 1.6163412428744576259e+38); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); |
| script.forEach_testConvertDouble4Float4Double4(inV, out); |
| verifyResultsConvertFloat4Double4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Float4Double4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble4Float4Double4(inV, out); |
| verifyResultsConvertFloat4Double4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Float4Double4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat4Double4(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatDouble args = new ArgumentsFloatDouble(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%24.8g {%16x} %31a", |
| arrayOut[i * 4 + j], Double.doubleToRawLongBits(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 checkConvertFloat4Double4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsCharDouble { |
| public byte inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertChar2Double2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xd86d88e268ca2f61l, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); |
| script.forEach_testConvertDouble2Char2Double2(inV, out); |
| verifyResultsConvertChar2Double2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Char2Double2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble2Char2Double2(inV, out); |
| verifyResultsConvertChar2Double2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Char2Double2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar2Double2(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharDouble args = new ArgumentsCharDouble(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%d", 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("%24.8g {%16x} %31a", |
| arrayOut[i * 2 + j], Double.doubleToRawLongBits(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 checkConvertChar2Double2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertChar3Double3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xd8ba5069bf25c08dl, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); |
| script.forEach_testConvertDouble3Char3Double3(inV, out); |
| verifyResultsConvertChar3Double3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Char3Double3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble3Char3Double3(inV, out); |
| verifyResultsConvertChar3Double3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Char3Double3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar3Double3(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharDouble args = new ArgumentsCharDouble(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%d", 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("%24.8g {%16x} %31a", |
| arrayOut[i * 4 + j], Double.doubleToRawLongBits(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 checkConvertChar3Double3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertChar4Double4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xd90717f1158151b9l, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); |
| script.forEach_testConvertDouble4Char4Double4(inV, out); |
| verifyResultsConvertChar4Double4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Char4Double4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble4Char4Double4(inV, out); |
| verifyResultsConvertChar4Double4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Char4Double4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar4Double4(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharDouble args = new ArgumentsCharDouble(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%d", 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("%24.8g {%16x} %31a", |
| arrayOut[i * 4 + j], Double.doubleToRawLongBits(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 checkConvertChar4Double4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUcharDouble { |
| public byte inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertUchar2Double2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x70cea2996167f1al, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); |
| script.forEach_testConvertDouble2Uchar2Double2(inV, out); |
| verifyResultsConvertUchar2Double2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Uchar2Double2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble2Uchar2Double2(inV, out); |
| verifyResultsConvertUchar2Double2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Uchar2Double2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar2Double2(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharDouble args = new ArgumentsUcharDouble(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("0x%x", 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("%24.8g {%16x} %31a", |
| arrayOut[i * 2 + j], Double.doubleToRawLongBits(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 checkConvertUchar2Double2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUchar3Double3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x759b1b0ec721046l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); |
| script.forEach_testConvertDouble3Uchar3Double3(inV, out); |
| verifyResultsConvertUchar3Double3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Uchar3Double3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble3Uchar3Double3(inV, out); |
| verifyResultsConvertUchar3Double3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Uchar3Double3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar3Double3(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharDouble args = new ArgumentsUcharDouble(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("0x%x", 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("%24.8g {%16x} %31a", |
| arrayOut[i * 4 + j], Double.doubleToRawLongBits(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 checkConvertUchar3Double3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUchar4Double4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7a6793842cda172l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); |
| script.forEach_testConvertDouble4Uchar4Double4(inV, out); |
| verifyResultsConvertUchar4Double4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Uchar4Double4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble4Uchar4Double4(inV, out); |
| verifyResultsConvertUchar4Double4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Uchar4Double4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar4Double4(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharDouble args = new ArgumentsUcharDouble(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("0x%x", 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("%24.8g {%16x} %31a", |
| arrayOut[i * 4 + j], Double.doubleToRawLongBits(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 checkConvertUchar4Double4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsShortDouble { |
| public short inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertShort2Double2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0xfdeea470023d0105l, true, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); |
| script.forEach_testConvertDouble2Short2Double2(inV, out); |
| verifyResultsConvertShort2Double2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Short2Double2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble2Short2Double2(inV, out); |
| verifyResultsConvertShort2Double2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Short2Double2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort2Double2(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortDouble args = new ArgumentsShortDouble(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%d", 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("%24.8g {%16x} %31a", |
| arrayOut[i * 2 + j], Double.doubleToRawLongBits(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 checkConvertShort2Double2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertShort3Double3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xfe3b6bf758989231l, true, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); |
| script.forEach_testConvertDouble3Short3Double3(inV, out); |
| verifyResultsConvertShort3Double3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Short3Double3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble3Short3Double3(inV, out); |
| verifyResultsConvertShort3Double3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Short3Double3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort3Double3(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortDouble args = new ArgumentsShortDouble(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%d", 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("%24.8g {%16x} %31a", |
| arrayOut[i * 4 + j], Double.doubleToRawLongBits(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 checkConvertShort3Double3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertShort4Double4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xfe88337eaef4235dl, true, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); |
| script.forEach_testConvertDouble4Short4Double4(inV, out); |
| verifyResultsConvertShort4Double4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Short4Double4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble4Short4Double4(inV, out); |
| verifyResultsConvertShort4Double4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Short4Double4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort4Double4(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortDouble args = new ArgumentsShortDouble(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%d", 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("%24.8g {%16x} %31a", |
| arrayOut[i * 4 + j], Double.doubleToRawLongBits(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 checkConvertShort4Double4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUshortDouble { |
| public short inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertUshort2Double2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xd2b3fb649e0e6518l, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); |
| script.forEach_testConvertDouble2Ushort2Double2(inV, out); |
| verifyResultsConvertUshort2Double2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Ushort2Double2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble2Ushort2Double2(inV, out); |
| verifyResultsConvertUshort2Double2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Ushort2Double2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort2Double2(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortDouble args = new ArgumentsUshortDouble(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("0x%x", 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("%24.8g {%16x} %31a", |
| arrayOut[i * 2 + j], Double.doubleToRawLongBits(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 checkConvertUshort2Double2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUshort3Double3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xd300c2ebf469f644l, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); |
| script.forEach_testConvertDouble3Ushort3Double3(inV, out); |
| verifyResultsConvertUshort3Double3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Ushort3Double3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble3Ushort3Double3(inV, out); |
| verifyResultsConvertUshort3Double3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Ushort3Double3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort3Double3(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortDouble args = new ArgumentsUshortDouble(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("0x%x", 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("%24.8g {%16x} %31a", |
| arrayOut[i * 4 + j], Double.doubleToRawLongBits(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 checkConvertUshort3Double3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUshort4Double4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xd34d8a734ac58770l, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); |
| script.forEach_testConvertDouble4Ushort4Double4(inV, out); |
| verifyResultsConvertUshort4Double4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Ushort4Double4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble4Ushort4Double4(inV, out); |
| verifyResultsConvertUshort4Double4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Ushort4Double4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort4Double4(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortDouble args = new ArgumentsUshortDouble(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("0x%x", 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("%24.8g {%16x} %31a", |
| arrayOut[i * 4 + j], Double.doubleToRawLongBits(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 checkConvertUshort4Double4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsIntDouble { |
| public int inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertInt2Double2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x1be423b7a40fc8f6l, true, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); |
| script.forEach_testConvertDouble2Int2Double2(inV, out); |
| verifyResultsConvertInt2Double2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Int2Double2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble2Int2Double2(inV, out); |
| verifyResultsConvertInt2Double2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Int2Double2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt2Double2(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntDouble args = new ArgumentsIntDouble(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%d", 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("%24.8g {%16x} %31a", |
| arrayOut[i * 2 + j], Double.doubleToRawLongBits(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 checkConvertInt2Double2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertInt3Double3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x1c30eb3efa6b5a22l, true, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); |
| script.forEach_testConvertDouble3Int3Double3(inV, out); |
| verifyResultsConvertInt3Double3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Int3Double3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble3Int3Double3(inV, out); |
| verifyResultsConvertInt3Double3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Int3Double3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt3Double3(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntDouble args = new ArgumentsIntDouble(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%d", 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("%24.8g {%16x} %31a", |
| arrayOut[i * 4 + j], Double.doubleToRawLongBits(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 checkConvertInt3Double3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertInt4Double4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x1c7db2c650c6eb4el, true, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); |
| script.forEach_testConvertDouble4Int4Double4(inV, out); |
| verifyResultsConvertInt4Double4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Int4Double4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble4Int4Double4(inV, out); |
| verifyResultsConvertInt4Double4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Int4Double4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt4Double4(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntDouble args = new ArgumentsIntDouble(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("%d", 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("%24.8g {%16x} %31a", |
| arrayOut[i * 4 + j], Double.doubleToRawLongBits(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 checkConvertInt4Double4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUintDouble { |
| public int inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertUint2Double2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x40b243bf3fe7e2a1l, false, 32); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); |
| script.forEach_testConvertDouble2Uint2Double2(inV, out); |
| verifyResultsConvertUint2Double2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Uint2Double2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble2Uint2Double2(inV, out); |
| verifyResultsConvertUint2Double2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble2Uint2Double2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint2Double2(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintDouble args = new ArgumentsUintDouble(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("0x%x", 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("%24.8g {%16x} %31a", |
| arrayOut[i * 2 + j], Double.doubleToRawLongBits(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 checkConvertUint2Double2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUint3Double3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x40ff0b46964373cdl, false, 32); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); |
| script.forEach_testConvertDouble3Uint3Double3(inV, out); |
| verifyResultsConvertUint3Double3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Uint3Double3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble3Uint3Double3(inV, out); |
| verifyResultsConvertUint3Double3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble3Uint3Double3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint3Double3(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintDouble args = new ArgumentsUintDouble(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("0x%x", 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("%24.8g {%16x} %31a", |
| arrayOut[i * 4 + j], Double.doubleToRawLongBits(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 checkConvertUint3Double3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUint4Double4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x414bd2cdec9f04f9l, false, 32); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); |
| script.forEach_testConvertDouble4Uint4Double4(inV, out); |
| verifyResultsConvertUint4Double4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Uint4Double4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertDouble4Uint4Double4(inV, out); |
| verifyResultsConvertUint4Double4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertDouble4Uint4Double4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint4Double4(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintDouble args = new ArgumentsUintDouble(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| Target target = new Target(relaxed); |
| CoreMathVerifier.computeConvert(args, target); |
| // 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("0x%x", 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("%24.8g {%16x} %31a", |
| arrayOut[i * 4 + j], Double.doubleToRawLongBits(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 checkConvertUint4Double4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsFloatLong { |
| public float inV; |
| public long out; |
| } |
| |
| private void checkConvertFloat2Long2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x239cb49c7d7c0ae0l, -9.2233714870989619200e+18, 9.2233714870989619200e+18); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); |
| script.forEach_testConvertLong2Float2Long2(inV, out); |
| verifyResultsConvertFloat2Long2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Float2Long2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong2Float2Long2(inV, out); |
| verifyResultsConvertFloat2Long2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Float2Long2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat2Long2(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatLong args = new ArgumentsFloatLong(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != 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(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertFloat2Long2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertFloat3Long3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x239cbf3ddc83cfd4l, -9.2233714870989619200e+18, 9.2233714870989619200e+18); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); |
| script.forEach_testConvertLong3Float3Long3(inV, out); |
| verifyResultsConvertFloat3Long3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Float3Long3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong3Float3Long3(inV, out); |
| verifyResultsConvertFloat3Long3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Float3Long3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat3Long3(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatLong args = new ArgumentsFloatLong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != 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(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertFloat3Long3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertFloat4Long4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x239cc9df3b8b94c8l, -9.2233714870989619200e+18, 9.2233714870989619200e+18); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); |
| script.forEach_testConvertLong4Float4Long4(inV, out); |
| verifyResultsConvertFloat4Long4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Float4Long4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong4Float4Long4(inV, out); |
| verifyResultsConvertFloat4Long4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Float4Long4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat4Long4(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatLong args = new ArgumentsFloatLong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != 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(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertFloat4Long4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsCharLong { |
| public byte inV; |
| public long out; |
| } |
| |
| private void checkConvertChar2Long2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xd86189bc290be220l, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); |
| script.forEach_testConvertLong2Char2Long2(inV, out); |
| verifyResultsConvertChar2Long2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Char2Long2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong2Char2Long2(inV, out); |
| verifyResultsConvertChar2Long2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Char2Long2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar2Long2(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharLong args = new ArgumentsCharLong(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertChar2Long2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertChar3Long3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xd861945d8813a714l, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); |
| script.forEach_testConvertLong3Char3Long3(inV, out); |
| verifyResultsConvertChar3Long3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Char3Long3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong3Char3Long3(inV, out); |
| verifyResultsConvertChar3Long3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Char3Long3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar3Long3(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharLong args = new ArgumentsCharLong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertChar3Long3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertChar4Long4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xd8619efee71b6c08l, true, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); |
| script.forEach_testConvertLong4Char4Long4(inV, out); |
| verifyResultsConvertChar4Long4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Char4Long4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong4Char4Long4(inV, out); |
| verifyResultsConvertChar4Long4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Char4Long4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar4Long4(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharLong args = new ArgumentsCharLong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertChar4Long4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUcharLong { |
| public byte inV; |
| public long out; |
| } |
| |
| private void checkConvertUchar2Long2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x7fef4309bb8deea1l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); |
| script.forEach_testConvertLong2Uchar2Long2(inV, out); |
| verifyResultsConvertUchar2Long2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Uchar2Long2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong2Uchar2Long2(inV, out); |
| verifyResultsConvertUchar2Long2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Uchar2Long2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar2Long2(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharLong args = new ArgumentsUcharLong(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUchar2Long2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUchar3Long3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x7fef4dab1a95b395l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); |
| script.forEach_testConvertLong3Uchar3Long3(inV, out); |
| verifyResultsConvertUchar3Long3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Uchar3Long3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong3Uchar3Long3(inV, out); |
| verifyResultsConvertUchar3Long3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Uchar3Long3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar3Long3(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharLong args = new ArgumentsUcharLong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUchar3Long3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUchar4Long4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7fef584c799d7889l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); |
| script.forEach_testConvertLong4Uchar4Long4(inV, out); |
| verifyResultsConvertUchar4Long4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Uchar4Long4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong4Uchar4Long4(inV, out); |
| verifyResultsConvertUchar4Long4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Uchar4Long4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar4Long4(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharLong args = new ArgumentsUcharLong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUchar4Long4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsShortLong { |
| public short inV; |
| public long out; |
| } |
| |
| private void checkConvertShort2Long2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x68ab674669c97ce4l, true, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); |
| script.forEach_testConvertLong2Short2Long2(inV, out); |
| verifyResultsConvertShort2Long2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Short2Long2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong2Short2Long2(inV, out); |
| verifyResultsConvertShort2Long2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Short2Long2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort2Long2(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortLong args = new ArgumentsShortLong(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertShort2Long2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertShort3Long3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x68ab71e7c8d141d8l, true, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); |
| script.forEach_testConvertLong3Short3Long3(inV, out); |
| verifyResultsConvertShort3Long3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Short3Long3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong3Short3Long3(inV, out); |
| verifyResultsConvertShort3Long3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Short3Long3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort3Long3(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortLong args = new ArgumentsShortLong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertShort3Long3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertShort4Long4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x68ab7c8927d906ccl, true, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); |
| script.forEach_testConvertLong4Short4Long4(inV, out); |
| verifyResultsConvertShort4Long4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Short4Long4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong4Short4Long4(inV, out); |
| verifyResultsConvertShort4Long4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Short4Long4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort4Long4(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortLong args = new ArgumentsShortLong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertShort4Long4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUshortLong { |
| public short inV; |
| public long out; |
| } |
| |
| private void checkConvertUshort2Long2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x8d79874e05a1968fl, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); |
| script.forEach_testConvertLong2Ushort2Long2(inV, out); |
| verifyResultsConvertUshort2Long2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Ushort2Long2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong2Ushort2Long2(inV, out); |
| verifyResultsConvertUshort2Long2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Ushort2Long2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort2Long2(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortLong args = new ArgumentsUshortLong(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUshort2Long2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUshort3Long3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x8d7991ef64a95b83l, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); |
| script.forEach_testConvertLong3Ushort3Long3(inV, out); |
| verifyResultsConvertUshort3Long3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Ushort3Long3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong3Ushort3Long3(inV, out); |
| verifyResultsConvertUshort3Long3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Ushort3Long3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort3Long3(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortLong args = new ArgumentsUshortLong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUshort3Long3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUshort4Long4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x8d799c90c3b12077l, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); |
| script.forEach_testConvertLong4Ushort4Long4(inV, out); |
| verifyResultsConvertUshort4Long4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Ushort4Long4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong4Ushort4Long4(inV, out); |
| verifyResultsConvertUshort4Long4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Ushort4Long4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort4Long4(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortLong args = new ArgumentsUshortLong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUshort4Long4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsIntLong { |
| public int inV; |
| public long out; |
| } |
| |
| private void checkConvertInt2Long2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xd74f538b8a45cb5dl, true, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); |
| script.forEach_testConvertLong2Int2Long2(inV, out); |
| verifyResultsConvertInt2Long2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Int2Long2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong2Int2Long2(inV, out); |
| verifyResultsConvertInt2Long2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Int2Long2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt2Long2(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntLong args = new ArgumentsIntLong(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertInt2Long2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertInt3Long3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xd74f5e2ce94d9051l, true, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); |
| script.forEach_testConvertLong3Int3Long3(inV, out); |
| verifyResultsConvertInt3Long3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Int3Long3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong3Int3Long3(inV, out); |
| verifyResultsConvertInt3Long3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Int3Long3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt3Long3(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntLong args = new ArgumentsIntLong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertInt3Long3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertInt4Long4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xd74f68ce48555545l, true, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); |
| script.forEach_testConvertLong4Int4Long4(inV, out); |
| verifyResultsConvertInt4Long4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Int4Long4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong4Int4Long4(inV, out); |
| verifyResultsConvertInt4Long4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Int4Long4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt4Long4(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntLong args = new ArgumentsIntLong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertInt4Long4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUintLong { |
| public int inV; |
| public long out; |
| } |
| |
| private void checkConvertUint2Long2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xe71d0a7587b9ef60l, false, 32); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); |
| script.forEach_testConvertLong2Uint2Long2(inV, out); |
| verifyResultsConvertUint2Long2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Uint2Long2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong2Uint2Long2(inV, out); |
| verifyResultsConvertUint2Long2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong2Uint2Long2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint2Long2(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintLong args = new ArgumentsUintLong(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUint2Long2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUint3Long3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xe71d1516e6c1b454l, false, 32); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); |
| script.forEach_testConvertLong3Uint3Long3(inV, out); |
| verifyResultsConvertUint3Long3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Uint3Long3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong3Uint3Long3(inV, out); |
| verifyResultsConvertUint3Long3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong3Uint3Long3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint3Long3(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintLong args = new ArgumentsUintLong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUint3Long3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUint4Long4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xe71d1fb845c97948l, false, 32); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); |
| script.forEach_testConvertLong4Uint4Long4(inV, out); |
| verifyResultsConvertUint4Long4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Uint4Long4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertLong4Uint4Long4(inV, out); |
| verifyResultsConvertUint4Long4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertLong4Uint4Long4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint4Long4(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintLong args = new ArgumentsUintLong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("%d", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("%d", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUint4Long4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsFloatUlong { |
| public float inV; |
| public long out; |
| } |
| |
| private void checkConvertFloat2Ulong2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xfb52b5394ec4cff7l, 0.0000000000000000000e+00, 1.8446742974197923840e+19); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); |
| script.forEach_testConvertUlong2Float2Ulong2(inV, out); |
| verifyResultsConvertFloat2Ulong2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Float2Ulong2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong2Float2Ulong2(inV, out); |
| verifyResultsConvertFloat2Ulong2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Float2Ulong2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat2Ulong2(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatUlong args = new ArgumentsFloatUlong(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != 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(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertFloat2Ulong2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertFloat3Ulong3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xfb547e5444dff0d5l, 0.0000000000000000000e+00, 1.8446742974197923840e+19); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); |
| script.forEach_testConvertUlong3Float3Ulong3(inV, out); |
| verifyResultsConvertFloat3Ulong3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Float3Ulong3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong3Float3Ulong3(inV, out); |
| verifyResultsConvertFloat3Ulong3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Float3Ulong3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat3Ulong3(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatUlong args = new ArgumentsFloatUlong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != 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(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertFloat3Ulong3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertFloat4Ulong4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xfb56476f3afb11b3l, 0.0000000000000000000e+00, 1.8446742974197923840e+19); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); |
| script.forEach_testConvertUlong4Float4Ulong4(inV, out); |
| verifyResultsConvertFloat4Ulong4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Float4Ulong4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong4Float4Ulong4(inV, out); |
| verifyResultsConvertFloat4Ulong4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Float4Ulong4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertFloat4Ulong4(Allocation inV, Allocation out, boolean relaxed) { |
| float[] arrayInV = new float[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsFloatUlong args = new ArgumentsFloatUlong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != 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(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertFloat4Ulong4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsCharUlong { |
| public byte inV; |
| public long out; |
| } |
| |
| private void checkConvertChar2Ulong2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x5862818b1fedf7b7l, false, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); |
| script.forEach_testConvertUlong2Char2Ulong2(inV, out); |
| verifyResultsConvertChar2Ulong2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Char2Ulong2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong2Char2Ulong2(inV, out); |
| verifyResultsConvertChar2Ulong2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Char2Ulong2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar2Ulong2(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharUlong args = new ArgumentsCharUlong(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertChar2Ulong2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertChar3Ulong3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x58644aa616091895l, false, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); |
| script.forEach_testConvertUlong3Char3Ulong3(inV, out); |
| verifyResultsConvertChar3Ulong3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Char3Ulong3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong3Char3Ulong3(inV, out); |
| verifyResultsConvertChar3Ulong3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Char3Ulong3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar3Ulong3(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharUlong args = new ArgumentsCharUlong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertChar3Ulong3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertChar4Ulong4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x586613c10c243973l, false, 7); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); |
| script.forEach_testConvertUlong4Char4Ulong4(inV, out); |
| verifyResultsConvertChar4Ulong4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Char4Ulong4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong4Char4Ulong4(inV, out); |
| verifyResultsConvertChar4Ulong4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Char4Ulong4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertChar4Ulong4(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsCharUlong args = new ArgumentsCharUlong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertChar4Ulong4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUcharUlong { |
| public byte inV; |
| public long out; |
| } |
| |
| private void checkConvertUchar2Ulong2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x7d30a192bbc61162l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); |
| script.forEach_testConvertUlong2Uchar2Ulong2(inV, out); |
| verifyResultsConvertUchar2Ulong2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Uchar2Ulong2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong2Uchar2Ulong2(inV, out); |
| verifyResultsConvertUchar2Ulong2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Uchar2Ulong2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar2Ulong2(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharUlong args = new ArgumentsUcharUlong(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUchar2Ulong2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUchar3Ulong3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x7d326aadb1e13240l, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); |
| script.forEach_testConvertUlong3Uchar3Ulong3(inV, out); |
| verifyResultsConvertUchar3Ulong3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Uchar3Ulong3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong3Uchar3Ulong3(inV, out); |
| verifyResultsConvertUchar3Ulong3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Uchar3Ulong3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar3Ulong3(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharUlong args = new ArgumentsUcharUlong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUchar3Ulong3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUchar4Ulong4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x7d3433c8a7fc531el, false, 8); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); |
| script.forEach_testConvertUlong4Uchar4Ulong4(inV, out); |
| verifyResultsConvertUchar4Ulong4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Uchar4Ulong4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong4Uchar4Ulong4(inV, out); |
| verifyResultsConvertUchar4Ulong4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Uchar4Ulong4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUchar4Ulong4(Allocation inV, Allocation out, boolean relaxed) { |
| byte[] arrayInV = new byte[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUcharUlong args = new ArgumentsUcharUlong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUchar4Ulong4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsShortUlong { |
| public short inV; |
| public long out; |
| } |
| |
| private void checkConvertShort2Ulong2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x94cab7c3ffc6f6a3l, false, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); |
| script.forEach_testConvertUlong2Short2Ulong2(inV, out); |
| verifyResultsConvertShort2Ulong2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Short2Ulong2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong2Short2Ulong2(inV, out); |
| verifyResultsConvertShort2Ulong2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Short2Ulong2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort2Ulong2(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortUlong args = new ArgumentsShortUlong(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertShort2Ulong2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertShort3Ulong3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x94cc80def5e21781l, false, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); |
| script.forEach_testConvertUlong3Short3Ulong3(inV, out); |
| verifyResultsConvertShort3Ulong3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Short3Ulong3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong3Short3Ulong3(inV, out); |
| verifyResultsConvertShort3Ulong3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Short3Ulong3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort3Ulong3(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortUlong args = new ArgumentsShortUlong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertShort3Ulong3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertShort4Ulong4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x94ce49f9ebfd385fl, false, 15); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); |
| script.forEach_testConvertUlong4Short4Ulong4(inV, out); |
| verifyResultsConvertShort4Ulong4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Short4Ulong4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong4Short4Ulong4(inV, out); |
| verifyResultsConvertShort4Ulong4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Short4Ulong4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertShort4Ulong4(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsShortUlong args = new ArgumentsShortUlong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertShort4Ulong4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUshortUlong { |
| public short inV; |
| public long out; |
| } |
| |
| private void checkConvertUshort2Ulong2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xc36a190b2d13465cl, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); |
| script.forEach_testConvertUlong2Ushort2Ulong2(inV, out); |
| verifyResultsConvertUshort2Ulong2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Ushort2Ulong2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong2Ushort2Ulong2(inV, out); |
| verifyResultsConvertUshort2Ulong2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Ushort2Ulong2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort2Ulong2(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortUlong args = new ArgumentsUshortUlong(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUshort2Ulong2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUshort3Ulong3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xc36be226232e673al, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); |
| script.forEach_testConvertUlong3Ushort3Ulong3(inV, out); |
| verifyResultsConvertUshort3Ulong3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Ushort3Ulong3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong3Ushort3Ulong3(inV, out); |
| verifyResultsConvertUshort3Ulong3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Ushort3Ulong3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort3Ulong3(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortUlong args = new ArgumentsUshortUlong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUshort3Ulong3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUshort4Ulong4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xc36dab4119498818l, false, 16); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); |
| script.forEach_testConvertUlong4Ushort4Ulong4(inV, out); |
| verifyResultsConvertUshort4Ulong4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Ushort4Ulong4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong4Ushort4Ulong4(inV, out); |
| verifyResultsConvertUshort4Ulong4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Ushort4Ulong4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUshort4Ulong4(Allocation inV, Allocation out, boolean relaxed) { |
| short[] arrayInV = new short[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUshortUlong args = new ArgumentsUshortUlong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUshort4Ulong4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsIntUlong { |
| public int inV; |
| public long out; |
| } |
| |
| private void checkConvertInt2Ulong2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x2a53676074a824f6l, false, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); |
| script.forEach_testConvertUlong2Int2Ulong2(inV, out); |
| verifyResultsConvertInt2Ulong2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Int2Ulong2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong2Int2Ulong2(inV, out); |
| verifyResultsConvertInt2Ulong2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Int2Ulong2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt2Ulong2(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntUlong args = new ArgumentsIntUlong(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertInt2Ulong2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertInt3Ulong3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x2a55307b6ac345d4l, false, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); |
| script.forEach_testConvertUlong3Int3Ulong3(inV, out); |
| verifyResultsConvertInt3Ulong3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Int3Ulong3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong3Int3Ulong3(inV, out); |
| verifyResultsConvertInt3Ulong3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Int3Ulong3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt3Ulong3(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntUlong args = new ArgumentsIntUlong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertInt3Ulong3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertInt4Ulong4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x2a56f99660de66b2l, false, 31); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); |
| script.forEach_testConvertUlong4Int4Ulong4(inV, out); |
| verifyResultsConvertInt4Ulong4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Int4Ulong4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong4Int4Ulong4(inV, out); |
| verifyResultsConvertInt4Ulong4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Int4Ulong4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertInt4Ulong4(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsIntUlong args = new ArgumentsIntUlong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("%d", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertInt4Ulong4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public class ArgumentsUintUlong { |
| public int inV; |
| public long out; |
| } |
| |
| private void checkConvertUint2Ulong2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xd1e120ae072a3177l, false, 32); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); |
| script.forEach_testConvertUlong2Uint2Ulong2(inV, out); |
| verifyResultsConvertUint2Ulong2(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Uint2Ulong2: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 2), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong2Uint2Ulong2(inV, out); |
| verifyResultsConvertUint2Ulong2(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong2Uint2Ulong2: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint2Ulong2(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 2]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 2 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintUlong args = new ArgumentsUintUlong(); |
| args.inV = arrayInV[i * 2 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 2 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 2 + j])); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUint2Ulong2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUint3Ulong3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xd1e2e9c8fd455255l, false, 32); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); |
| script.forEach_testConvertUlong3Uint3Ulong3(inV, out); |
| verifyResultsConvertUint3Ulong3(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Uint3Ulong3: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 3), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong3Uint3Ulong3(inV, out); |
| verifyResultsConvertUint3Ulong3(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong3Uint3Ulong3: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint3Ulong3(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 3 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintUlong args = new ArgumentsUintUlong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUint3Ulong3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| private void checkConvertUint4Ulong4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xd1e4b2e3f3607333l, false, 32); |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); |
| script.forEach_testConvertUlong4Uint4Ulong4(inV, out); |
| verifyResultsConvertUint4Ulong4(inV, out, false); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Uint4Ulong4: " + e.toString()); |
| } |
| try { |
| Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.UNSIGNED_64, 4), INPUTSIZE); |
| scriptRelaxed.forEach_testConvertUlong4Uint4Ulong4(inV, out); |
| verifyResultsConvertUint4Ulong4(inV, out, true); |
| } catch (Exception e) { |
| throw new RSRuntimeException("RenderScript. Can't invoke forEach_testConvertUlong4Uint4Ulong4: " + e.toString()); |
| } |
| } |
| |
| private void verifyResultsConvertUint4Ulong4(Allocation inV, Allocation out, boolean relaxed) { |
| int[] arrayInV = new int[INPUTSIZE * 4]; |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| out.copyTo(arrayOut); |
| for (int i = 0; i < INPUTSIZE; i++) { |
| for (int j = 0; j < 4 ; j++) { |
| // Extract the inputs. |
| ArgumentsUintUlong args = new ArgumentsUintUlong(); |
| args.inV = arrayInV[i * 4 + j]; |
| // Figure out what the outputs should have been. |
| CoreMathVerifier.computeConvert(args); |
| // Validate the outputs. |
| boolean valid = true; |
| if (args.out != arrayOut[i * 4 + j]) { |
| valid = false; |
| } |
| if (!valid) { |
| StringBuilder message = new StringBuilder(); |
| message.append("Input inV: "); |
| message.append(String.format("0x%x", args.inV)); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| message.append(String.format("0x%x", args.out)); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| message.append(String.format("0x%x", arrayOut[i * 4 + j])); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| assertTrue("Incorrect output for checkConvertUint4Ulong4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid); |
| } |
| } |
| } |
| } |
| |
| public void testConvert() { |
| checkConvertFloat2Float2(); |
| checkConvertFloat3Float3(); |
| checkConvertFloat4Float4(); |
| checkConvertChar2Float2(); |
| checkConvertChar3Float3(); |
| checkConvertChar4Float4(); |
| checkConvertUchar2Float2(); |
| checkConvertUchar3Float3(); |
| checkConvertUchar4Float4(); |
| checkConvertShort2Float2(); |
| checkConvertShort3Float3(); |
| checkConvertShort4Float4(); |
| checkConvertUshort2Float2(); |
| checkConvertUshort3Float3(); |
| checkConvertUshort4Float4(); |
| checkConvertInt2Float2(); |
| checkConvertInt3Float3(); |
| checkConvertInt4Float4(); |
| checkConvertUint2Float2(); |
| checkConvertUint3Float3(); |
| checkConvertUint4Float4(); |
| checkConvertFloat2Char2(); |
| checkConvertFloat3Char3(); |
| checkConvertFloat4Char4(); |
| checkConvertChar2Char2(); |
| checkConvertChar3Char3(); |
| checkConvertChar4Char4(); |
| checkConvertUchar2Char2(); |
| checkConvertUchar3Char3(); |
| checkConvertUchar4Char4(); |
| checkConvertShort2Char2(); |
| checkConvertShort3Char3(); |
| checkConvertShort4Char4(); |
| checkConvertUshort2Char2(); |
| checkConvertUshort3Char3(); |
| checkConvertUshort4Char4(); |
| checkConvertInt2Char2(); |
| checkConvertInt3Char3(); |
| checkConvertInt4Char4(); |
| checkConvertUint2Char2(); |
| checkConvertUint3Char3(); |
| checkConvertUint4Char4(); |
| checkConvertFloat2Uchar2(); |
| checkConvertFloat3Uchar3(); |
| checkConvertFloat4Uchar4(); |
| checkConvertChar2Uchar2(); |
| checkConvertChar3Uchar3(); |
| checkConvertChar4Uchar4(); |
| checkConvertUchar2Uchar2(); |
| checkConvertUchar3Uchar3(); |
| checkConvertUchar4Uchar4(); |
| checkConvertShort2Uchar2(); |
| checkConvertShort3Uchar3(); |
| checkConvertShort4Uchar4(); |
| checkConvertUshort2Uchar2(); |
| checkConvertUshort3Uchar3(); |
| checkConvertUshort4Uchar4(); |
| checkConvertInt2Uchar2(); |
| checkConvertInt3Uchar3(); |
| checkConvertInt4Uchar4(); |
| checkConvertUint2Uchar2(); |
| checkConvertUint3Uchar3(); |
| checkConvertUint4Uchar4(); |
| checkConvertFloat2Short2(); |
| checkConvertFloat3Short3(); |
| checkConvertFloat4Short4(); |
| checkConvertChar2Short2(); |
| checkConvertChar3Short3(); |
| checkConvertChar4Short4(); |
| checkConvertUchar2Short2(); |
| checkConvertUchar3Short3(); |
| checkConvertUchar4Short4(); |
| checkConvertShort2Short2(); |
| checkConvertShort3Short3(); |
| checkConvertShort4Short4(); |
| checkConvertUshort2Short2(); |
| checkConvertUshort3Short3(); |
| checkConvertUshort4Short4(); |
| checkConvertInt2Short2(); |
| checkConvertInt3Short3(); |
| checkConvertInt4Short4(); |
| checkConvertUint2Short2(); |
| checkConvertUint3Short3(); |
| checkConvertUint4Short4(); |
| checkConvertFloat2Ushort2(); |
| checkConvertFloat3Ushort3(); |
| checkConvertFloat4Ushort4(); |
| checkConvertChar2Ushort2(); |
| checkConvertChar3Ushort3(); |
| checkConvertChar4Ushort4(); |
| checkConvertUchar2Ushort2(); |
| checkConvertUchar3Ushort3(); |
| checkConvertUchar4Ushort4(); |
| checkConvertShort2Ushort2(); |
| checkConvertShort3Ushort3(); |
| checkConvertShort4Ushort4(); |
| checkConvertUshort2Ushort2(); |
| checkConvertUshort3Ushort3(); |
| checkConvertUshort4Ushort4(); |
| checkConvertInt2Ushort2(); |
| checkConvertInt3Ushort3(); |
| checkConvertInt4Ushort4(); |
| checkConvertUint2Ushort2(); |
| checkConvertUint3Ushort3(); |
| checkConvertUint4Ushort4(); |
| checkConvertFloat2Int2(); |
| checkConvertFloat3Int3(); |
| checkConvertFloat4Int4(); |
| checkConvertChar2Int2(); |
| checkConvertChar3Int3(); |
| checkConvertChar4Int4(); |
| checkConvertUchar2Int2(); |
| checkConvertUchar3Int3(); |
| checkConvertUchar4Int4(); |
| checkConvertShort2Int2(); |
| checkConvertShort3Int3(); |
| checkConvertShort4Int4(); |
| checkConvertUshort2Int2(); |
| checkConvertUshort3Int3(); |
| checkConvertUshort4Int4(); |
| checkConvertInt2Int2(); |
| checkConvertInt3Int3(); |
| checkConvertInt4Int4(); |
| checkConvertUint2Int2(); |
| checkConvertUint3Int3(); |
| checkConvertUint4Int4(); |
| checkConvertFloat2Uint2(); |
| checkConvertFloat3Uint3(); |
| checkConvertFloat4Uint4(); |
| checkConvertChar2Uint2(); |
| checkConvertChar3Uint3(); |
| checkConvertChar4Uint4(); |
| checkConvertUchar2Uint2(); |
| checkConvertUchar3Uint3(); |
| checkConvertUchar4Uint4(); |
| checkConvertShort2Uint2(); |
| checkConvertShort3Uint3(); |
| checkConvertShort4Uint4(); |
| checkConvertUshort2Uint2(); |
| checkConvertUshort3Uint3(); |
| checkConvertUshort4Uint4(); |
| checkConvertInt2Uint2(); |
| checkConvertInt3Uint3(); |
| checkConvertInt4Uint4(); |
| checkConvertUint2Uint2(); |
| checkConvertUint3Uint3(); |
| checkConvertUint4Uint4(); |
| checkConvertDouble2Double2(); |
| checkConvertDouble3Double3(); |
| checkConvertDouble4Double4(); |
| checkConvertLong2Double2(); |
| checkConvertLong3Double3(); |
| checkConvertLong4Double4(); |
| checkConvertUlong2Double2(); |
| checkConvertUlong3Double3(); |
| checkConvertUlong4Double4(); |
| checkConvertDouble2Long2(); |
| checkConvertDouble3Long3(); |
| checkConvertDouble4Long4(); |
| checkConvertLong2Long2(); |
| checkConvertLong3Long3(); |
| checkConvertLong4Long4(); |
| checkConvertUlong2Long2(); |
| checkConvertUlong3Long3(); |
| checkConvertUlong4Long4(); |
| checkConvertDouble2Ulong2(); |
| checkConvertDouble3Ulong3(); |
| checkConvertDouble4Ulong4(); |
| checkConvertLong2Ulong2(); |
| checkConvertLong3Ulong3(); |
| checkConvertLong4Ulong4(); |
| checkConvertUlong2Ulong2(); |
| checkConvertUlong3Ulong3(); |
| checkConvertUlong4Ulong4(); |
| checkConvertDouble2Float2(); |
| checkConvertDouble3Float3(); |
| checkConvertDouble4Float4(); |
| checkConvertLong2Float2(); |
| checkConvertLong3Float3(); |
| checkConvertLong4Float4(); |
| checkConvertUlong2Float2(); |
| checkConvertUlong3Float3(); |
| checkConvertUlong4Float4(); |
| checkConvertDouble2Char2(); |
| checkConvertDouble3Char3(); |
| checkConvertDouble4Char4(); |
| checkConvertLong2Char2(); |
| checkConvertLong3Char3(); |
| checkConvertLong4Char4(); |
| checkConvertUlong2Char2(); |
| checkConvertUlong3Char3(); |
| checkConvertUlong4Char4(); |
| checkConvertDouble2Uchar2(); |
| checkConvertDouble3Uchar3(); |
| checkConvertDouble4Uchar4(); |
| checkConvertLong2Uchar2(); |
| checkConvertLong3Uchar3(); |
| checkConvertLong4Uchar4(); |
| checkConvertUlong2Uchar2(); |
| checkConvertUlong3Uchar3(); |
| checkConvertUlong4Uchar4(); |
| checkConvertDouble2Short2(); |
| checkConvertDouble3Short3(); |
| checkConvertDouble4Short4(); |
| checkConvertLong2Short2(); |
| checkConvertLong3Short3(); |
| checkConvertLong4Short4(); |
| checkConvertUlong2Short2(); |
| checkConvertUlong3Short3(); |
| checkConvertUlong4Short4(); |
| checkConvertDouble2Ushort2(); |
| checkConvertDouble3Ushort3(); |
| checkConvertDouble4Ushort4(); |
| checkConvertLong2Ushort2(); |
| checkConvertLong3Ushort3(); |
| checkConvertLong4Ushort4(); |
| checkConvertUlong2Ushort2(); |
| checkConvertUlong3Ushort3(); |
| checkConvertUlong4Ushort4(); |
| checkConvertDouble2Int2(); |
| checkConvertDouble3Int3(); |
| checkConvertDouble4Int4(); |
| checkConvertLong2Int2(); |
| checkConvertLong3Int3(); |
| checkConvertLong4Int4(); |
| checkConvertUlong2Int2(); |
| checkConvertUlong3Int3(); |
| checkConvertUlong4Int4(); |
| checkConvertDouble2Uint2(); |
| checkConvertDouble3Uint3(); |
| checkConvertDouble4Uint4(); |
| checkConvertLong2Uint2(); |
| checkConvertLong3Uint3(); |
| checkConvertLong4Uint4(); |
| checkConvertUlong2Uint2(); |
| checkConvertUlong3Uint3(); |
| checkConvertUlong4Uint4(); |
| checkConvertFloat2Double2(); |
| checkConvertFloat3Double3(); |
| checkConvertFloat4Double4(); |
| checkConvertChar2Double2(); |
| checkConvertChar3Double3(); |
| checkConvertChar4Double4(); |
| checkConvertUchar2Double2(); |
| checkConvertUchar3Double3(); |
| checkConvertUchar4Double4(); |
| checkConvertShort2Double2(); |
| checkConvertShort3Double3(); |
| checkConvertShort4Double4(); |
| checkConvertUshort2Double2(); |
| checkConvertUshort3Double3(); |
| checkConvertUshort4Double4(); |
| checkConvertInt2Double2(); |
| checkConvertInt3Double3(); |
| checkConvertInt4Double4(); |
| checkConvertUint2Double2(); |
| checkConvertUint3Double3(); |
| checkConvertUint4Double4(); |
| checkConvertFloat2Long2(); |
| checkConvertFloat3Long3(); |
| checkConvertFloat4Long4(); |
| checkConvertChar2Long2(); |
| checkConvertChar3Long3(); |
| checkConvertChar4Long4(); |
| checkConvertUchar2Long2(); |
| checkConvertUchar3Long3(); |
| checkConvertUchar4Long4(); |
| checkConvertShort2Long2(); |
| checkConvertShort3Long3(); |
| checkConvertShort4Long4(); |
| checkConvertUshort2Long2(); |
| checkConvertUshort3Long3(); |
| checkConvertUshort4Long4(); |
| checkConvertInt2Long2(); |
| checkConvertInt3Long3(); |
| checkConvertInt4Long4(); |
| checkConvertUint2Long2(); |
| checkConvertUint3Long3(); |
| checkConvertUint4Long4(); |
| checkConvertFloat2Ulong2(); |
| checkConvertFloat3Ulong3(); |
| checkConvertFloat4Ulong4(); |
| checkConvertChar2Ulong2(); |
| checkConvertChar3Ulong3(); |
| checkConvertChar4Ulong4(); |
| checkConvertUchar2Ulong2(); |
| checkConvertUchar3Ulong3(); |
| checkConvertUchar4Ulong4(); |
| checkConvertShort2Ulong2(); |
| checkConvertShort3Ulong3(); |
| checkConvertShort4Ulong4(); |
| checkConvertUshort2Ulong2(); |
| checkConvertUshort3Ulong3(); |
| checkConvertUshort4Ulong4(); |
| checkConvertInt2Ulong2(); |
| checkConvertInt3Ulong3(); |
| checkConvertInt4Ulong4(); |
| checkConvertUint2Ulong2(); |
| checkConvertUint3Ulong3(); |
| checkConvertUint4Ulong4(); |
| } |
| } |