| /* |
| * Copyright (C) 2015 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/generate.sh. |
| |
| package android.renderscript.cts; |
| |
| import android.renderscript.Allocation; |
| import android.renderscript.RSRuntimeException; |
| import android.renderscript.Element; |
| |
| import java.util.Arrays; |
| |
| 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, 0x4e1f6ac6l, -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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat2Float2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertFloat3Float3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x443a8ba4l, -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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat3Float3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertFloat4Float4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3a55ac82l, -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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat4Float4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsCharFloat { |
| public byte inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertChar2Float2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x1f489286l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar2Float2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertChar3Float3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x1563b364l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar3Float3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertChar4Float4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xb7ed442l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar4Float4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUcharFloat { |
| public byte inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertUchar2Float2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xbb20ac31l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar2Float2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUchar3Float3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xb13bcd0fl, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar3Float3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUchar4Float4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xa756ededl, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar4Float4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsShortFloat { |
| public short inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertShort2Float2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0xff219172l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort2Float2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertShort3Float3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xf53cb250l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort3Float3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertShort4Float4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xeb57d32el, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort4Float4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUshortFloat { |
| public short inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertUshort2Float2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x2c6de12bl, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort2Float2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUshort3Float3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x22890209l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort3Float3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUshort4Float4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x18a422e7l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort4Float4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsIntFloat { |
| public int inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertInt2Float2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x7402bfc5l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt2Float2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertInt3Float3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x6a1de0a3l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt3Float3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertInt4Float4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x60390181l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt4Float4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUintFloat { |
| public int inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertUint2Float2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x684cc46l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint2Float2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUint3Float3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xfc9fed24l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint3Float3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUint4Float4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xf2bb0e02l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint4Float4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsFloatChar { |
| public float inV; |
| public byte out; |
| } |
| |
| private void checkConvertFloat2Char2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x29789662l, -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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat2Char2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertFloat3Char3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x88805b56l, -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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat3Char3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertFloat4Char4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xe788204al, -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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat4Char4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsCharChar { |
| public byte inV; |
| public byte out; |
| } |
| |
| private void checkConvertChar2Char2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xd5086da2l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar2Char2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertChar3Char3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x34103296l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar3Char3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertChar4Char4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x9317f78al, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar4Char4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUcharChar { |
| public byte inV; |
| public byte out; |
| } |
| |
| private void checkConvertUchar2Char2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x678a7a23l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar2Char2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUchar3Char3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xc6923f17l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar3Char3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUchar4Char4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x259a040bl, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar4Char4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsShortChar { |
| public short inV; |
| public byte out; |
| } |
| |
| private void checkConvertShort2Char2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x15c60866l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort2Char2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertShort3Char3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x74cdcd5al, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort3Char3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertShort4Char4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xd3d5924el, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort4Char4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUshortChar { |
| public short inV; |
| public byte out; |
| } |
| |
| private void checkConvertUshort2Char2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xb19e2211l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort2Char2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUshort3Char3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x10a5e705l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort3Char3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUshort4Char4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x6fadabf9l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort4Char4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsIntChar { |
| public int inV; |
| public byte out; |
| } |
| |
| private void checkConvertInt2Char2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x364256dfl, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt2Char2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertInt3Char3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x954a1bd3l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt3Char3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertInt4Char4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xf451e0c7l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt4Char4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUintChar { |
| public int inV; |
| public byte out; |
| } |
| |
| private void checkConvertUint2Char2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x33b67ae2l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint2Char2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUint3Char3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x92be3fd6l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint3Char3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUint4Char4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xf1c604cal, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint4Char4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsFloatUchar { |
| public float inV; |
| public byte out; |
| } |
| |
| private void checkConvertFloat2Uchar2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xfac15b79l, 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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat2Uchar2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertFloat3Uchar3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xf0dc7c57l, 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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat3Uchar3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertFloat4Uchar4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xe6f79d35l, 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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat4Uchar4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsCharUchar { |
| public byte inV; |
| public byte out; |
| } |
| |
| private void checkConvertChar2Uchar2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xcbea8339l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar2Uchar2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertChar3Uchar3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xc205a417l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar3Uchar3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertChar4Uchar4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xb820c4f5l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar4Uchar4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUcharUchar { |
| public byte inV; |
| public byte out; |
| } |
| |
| private void checkConvertUchar2Uchar2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x67c29ce4l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar2Uchar2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUchar3Uchar3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x5dddbdc2l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar3Uchar3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUchar4Uchar4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x53f8dea0l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar4Uchar4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsShortUchar { |
| public short inV; |
| public byte out; |
| } |
| |
| private void checkConvertShort2Uchar2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0xabc38225l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort2Uchar2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertShort3Uchar3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xa1dea303l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort3Uchar3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertShort4Uchar4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x97f9c3e1l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort4Uchar4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUshortUchar { |
| public short inV; |
| public byte out; |
| } |
| |
| private void checkConvertUshort2Uchar2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xd90fd1del, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort2Uchar2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUshort3Uchar3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xcf2af2bcl, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort3Uchar3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUshort4Uchar4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xc546139al, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort4Uchar4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsIntUchar { |
| public int inV; |
| public byte out; |
| } |
| |
| private void checkConvertInt2Uchar2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x20a4b078l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt2Uchar2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertInt3Uchar3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x16bfd156l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt3Uchar3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertInt4Uchar4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xcdaf234l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt4Uchar4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUintUchar { |
| public int inV; |
| public byte out; |
| } |
| |
| private void checkConvertUint2Uchar2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xb326bcf9l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint2Uchar2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUint3Uchar3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xa941ddd7l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint3Uchar3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUint4Uchar4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x9f5cfeb5l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint4Uchar4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsFloatShort { |
| public float inV; |
| public short out; |
| } |
| |
| private void checkConvertFloat2Short2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x8fcf2692l, -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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat2Short2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertFloat3Short3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x85ea4770l, -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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat3Short3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertFloat4Short4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x7c05684el, -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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat4Short4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsCharShort { |
| public byte inV; |
| public short out; |
| } |
| |
| private void checkConvertChar2Short2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x60f84e52l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar2Short2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertChar3Short3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x57136f30l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar3Short3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertChar4Short4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x4d2e900el, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar4Short4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUcharShort { |
| public byte inV; |
| public short out; |
| } |
| |
| private void checkConvertUchar2Short2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xfcd067fdl, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar2Short2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUchar3Short3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xf2eb88dbl, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar3Short3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUchar4Short4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xe906a9b9l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar4Short4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsShortShort { |
| public short inV; |
| public short out; |
| } |
| |
| private void checkConvertShort2Short2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x40d14d3el, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort2Short2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertShort3Short3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x36ec6e1cl, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort3Short3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertShort4Short4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x2d078efal, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort4Short4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUshortShort { |
| public short inV; |
| public short out; |
| } |
| |
| private void checkConvertUshort2Short2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x6e1d9cf7l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort2Short2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUshort3Short3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x6438bdd5l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort3Short3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUshort4Short4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x5a53deb3l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort4Short4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsIntShort { |
| public int inV; |
| public short out; |
| } |
| |
| private void checkConvertInt2Short2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xb5b27b91l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt2Short2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertInt3Short3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xabcd9c6fl, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt3Short3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertInt4Short4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xa1e8bd4dl, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt4Short4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUintShort { |
| public int inV; |
| public short out; |
| } |
| |
| private void checkConvertUint2Short2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x48348812l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint2Short2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUint3Short3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x3e4fa8f0l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint3Short3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUint4Short4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x346ac9cel, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint4Short4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsFloatUshort { |
| public float inV; |
| public short out; |
| } |
| |
| private void checkConvertFloat2Ushort2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xb708416fl, 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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat2Ushort2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertFloat3Ushort3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xd63d29bl, 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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat3Ushort3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertFloat4Ushort4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x63bf63c7l, 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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat4Ushort4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsCharUshort { |
| public byte inV; |
| public short out; |
| } |
| |
| private void checkConvertChar2Ushort2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xd8f1eeafl, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar2Ushort2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertChar3Ushort3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x2f4d7fdbl, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar3Ushort3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertChar4Ushort4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x85a91107l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar4Ushort4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUcharUshort { |
| public byte inV; |
| public short out; |
| } |
| |
| private void checkConvertUchar2Ushort2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x63e3e68l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar2Ushort2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUchar3Ushort3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x5c99cf94l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar3Ushort3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUchar4Ushort4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xb2f560c0l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar4Ushort4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsShortUshort { |
| public short inV; |
| public short out; |
| } |
| |
| private void checkConvertShort2Ushort2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x7264c053l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort2Ushort2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertShort3Ushort3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xc8c0517fl, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort3Ushort3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertShort4Ushort4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x1f1be2abl, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort4Ushort4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUshortUshort { |
| public short inV; |
| public short out; |
| } |
| |
| private void checkConvertUshort2Ushort2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xe362466l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort2Ushort2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUshort3Ushort3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x6491b592l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort3Ushort3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUshort4Ushort4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xbaed46bel, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort4Ushort4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsIntUshort { |
| public int inV; |
| public short out; |
| } |
| |
| private void checkConvertInt2Ushort2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x14378844l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt2Ushort2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertInt3Ushort3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x6a931970l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt3Ushort3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertInt4Ushort4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xc0eeaa9cl, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt4Ushort4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUintUshort { |
| public int inV; |
| public short out; |
| } |
| |
| private void checkConvertUint2Ushort2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0xb00fa1efl, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint2Ushort2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUint3Ushort3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x66b331bl, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint3Ushort3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUint4Ushort4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x5cc6c447l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint4Ushort4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsFloatInt { |
| public float inV; |
| public int out; |
| } |
| |
| private void checkConvertFloat2Int2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xc069dd5dl, -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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat2Int2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertFloat3Int3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xa11ed93l, -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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat3Int3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertFloat4Int4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x53b9fdc9l, -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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat4Int4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsCharInt { |
| public byte inV; |
| public int out; |
| } |
| |
| private void checkConvertChar2Int2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x94c6831dl, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar2Int2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertChar3Int3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xde6e9353l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar3Int3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertChar4Int4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x2816a389l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar4Int4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUcharInt { |
| public byte inV; |
| public int out; |
| } |
| |
| private void checkConvertUchar2Int2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x923aa720l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar2Int2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUchar3Int3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xdbe2b756l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar3Int3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUchar4Int4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x258ac78cl, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar4Int4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsShortInt { |
| public short inV; |
| public int out; |
| } |
| |
| private void checkConvertShort2Int2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x252a2d69l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort2Int2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertShort3Int3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x6ed23d9fl, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort3Int3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertShort4Int4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xb87a4dd5l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort4Int4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUshortInt { |
| public short inV; |
| public int out; |
| } |
| |
| private void checkConvertUshort2Int2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xb7ac39eal, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort2Int2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUshort3Int3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x1544a20l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort3Int3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUshort4Int4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x4afc5a56l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort4Int4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsIntInt { |
| public int inV; |
| public int out; |
| } |
| |
| private void checkConvertInt2Int2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x49a42354l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt2Int2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertInt3Int3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x934c338al, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt3Int3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertInt4Int4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xdcf443c0l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt4Int4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUintInt { |
| public int inV; |
| public int out; |
| } |
| |
| private void checkConvertUint2Int2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x3daccaddl, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint2Int2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUint3Int3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x8754db13l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint3Int3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUint4Int4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xd0fceb49l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint4Int4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsFloatUint { |
| public float inV; |
| public int out; |
| } |
| |
| private void checkConvertFloat2Uint2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x424dca22l, 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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat2Uint2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertFloat3Uint3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xa1558f16l, 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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat3Uint3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertFloat4Uint4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x5d540al, 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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat4Uint4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsCharUint { |
| public byte inV; |
| public int out; |
| } |
| |
| private void checkConvertChar2Uint2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0xeddda162l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar2Uint2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertChar3Uint3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x4ce56656l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar3Uint3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertChar4Uint4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xabed2b4al, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar4Uint4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUcharUint { |
| public byte inV; |
| public int out; |
| } |
| |
| private void checkConvertUchar2Uint2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x805fade3l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar2Uint2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUchar3Uint3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xdf6772d7l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar3Uint3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUchar4Uint4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x3e6f37cbl, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar4Uint4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsShortUint { |
| public short inV; |
| public int out; |
| } |
| |
| private void checkConvertShort2Uint2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x2e9b3c26l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort2Uint2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertShort3Uint3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x8da3011al, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort3Uint3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertShort4Uint4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xecaac60el, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort4Uint4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUshortUint { |
| public short inV; |
| public int out; |
| } |
| |
| private void checkConvertUshort2Uint2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0xca7355d1l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort2Uint2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUshort3Uint3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x297b1ac5l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort3Uint3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUshort4Uint4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x8882dfb9l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort4Uint4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsIntUint { |
| public int inV; |
| public int out; |
| } |
| |
| private void checkConvertInt2Uint2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x4f178a9fl, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt2Uint2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertInt3Uint3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xae1f4f93l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt3Uint3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertInt4Uint4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0xd271487l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt4Uint4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUintUint { |
| public int inV; |
| public int out; |
| } |
| |
| private void checkConvertUint2Uint2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x4c8baea2l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint2Uint2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUint3Uint3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xab937396l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint3Uint3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUint4Uint4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xa9b388al, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint4Uint4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsDoubleDouble { |
| public double inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertDouble2Double2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x3902786el, -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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble2Double2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertDouble3Double3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x8f5e099al, -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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble3Double3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertDouble4Double4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xe5b99ac6l, -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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble4Double4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsLongDouble { |
| public long inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertLong2Double2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x4c70299bl, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong2Double2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertLong3Double3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xa2cbbac7l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong3Double3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertLong4Double4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xf9274bf3l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong4Double4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUlongDouble { |
| public long inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertUlong2Double2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x79bc7954l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong2Double2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUlong3Double3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0xd0180a80l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong3Double3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUlong4Double4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x26739bacl, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong4Double4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsDoubleLong { |
| public double inV; |
| public long out; |
| } |
| |
| private void checkConvertDouble2Long2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x430cbe95l, -4.2949662730000000000e+09, 4.2949662720000000000e+09); |
| 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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble2Long2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertDouble3Long3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0xa2148389l, -4.2949662730000000000e+09, 4.2949662720000000000e+09); |
| 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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble3Long3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertDouble4Long4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x11c487dl, -4.2949662730000000000e+09, 4.2949662720000000000e+09); |
| 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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble4Long4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsLongLong { |
| public long inV; |
| public long out; |
| } |
| |
| private void checkConvertLong2Long2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xc81d242al, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong2Long2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertLong3Long3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x2724e91el, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong3Long3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertLong4Long4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x862cae12l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong4Long4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUlongLong { |
| public long inV; |
| public long out; |
| } |
| |
| private void checkConvertUlong2Long2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x5a9f30abl, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong2Long2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUlong3Long3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0xb9a6f59fl, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong3Long3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUlong4Long4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x18aeba93l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong4Long4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsDoubleUlong { |
| public double inV; |
| public long out; |
| } |
| |
| private void checkConvertDouble2Ulong2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x7e12ff5el, 0.0000000000000000000e+00, 4.2949652480000000000e+09); |
| 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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble2Ulong2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertDouble3Ulong3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x742e203cl, 0.0000000000000000000e+00, 4.2949652480000000000e+09); |
| 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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble3Ulong3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertDouble4Ulong4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x6a49411al, 0.0000000000000000000e+00, 4.2949652480000000000e+09); |
| 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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble4Ulong4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsLongUlong { |
| public long inV; |
| public long out; |
| } |
| |
| private void checkConvertLong2Ulong2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xd7d40f65l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong2Ulong2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertLong3Ulong3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xcdef3043l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong3Ulong3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertLong4Ulong4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xc40a5121l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong4Ulong4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUlongUlong { |
| public long inV; |
| public long out; |
| } |
| |
| private void checkConvertUlong2Ulong2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x73ac2910l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong2Ulong2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUlong3Ulong3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x69c749eel, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong3Ulong3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUlong4Ulong4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x5fe26accl, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong4Ulong4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsDoubleFloat { |
| public double inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertDouble2Float2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x7d6d9a2dl, -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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble2Float2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertDouble3Float3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x7388bb0bl, -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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble3Float3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertDouble4Float4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x69a3dbe9l, -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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble4Float4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsLongFloat { |
| public long inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertLong2Float2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xd72eaa34l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong2Float2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertLong3Float3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xcd49cb12l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong3Float3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertLong4Float4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0xc364ebf0l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong4Float4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUlongFloat { |
| public long inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertUlong2Float2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x7306c3dfl, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong2Float2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUlong3Float3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x6921e4bdl, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong3Float3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUlong4Float4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x5f3d059bl, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| float[] arrayOut = new float[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (float) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong4Float4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsDoubleChar { |
| public double inV; |
| public byte out; |
| } |
| |
| private void checkConvertDouble2Char2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xef094a17l, -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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble2Char2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertDouble3Char3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x4e110f0bl, -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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble3Char3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertDouble4Char4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xad18d3ffl, -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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble4Char4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsLongChar { |
| public long inV; |
| public byte out; |
| } |
| |
| private void checkConvertLong2Char2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x7419afacl, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong2Char2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertLong3Char3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xd32174a0l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong3Char3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertLong4Char4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x32293994l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong4Char4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUlongChar { |
| public long inV; |
| public byte out; |
| } |
| |
| private void checkConvertUlong2Char2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x69bbc2dl, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong2Char2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUlong3Char3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x65a38121l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong3Char3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUlong4Char4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0xc4ab4615l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong4Char4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsDoubleUchar { |
| public double inV; |
| public byte out; |
| } |
| |
| private void checkConvertDouble2Uchar2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x2a0f8ae0l, 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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble2Uchar2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertDouble3Uchar3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x202aabbel, 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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble3Uchar3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertDouble4Uchar4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x1645cc9cl, 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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble4Uchar4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsLongUchar { |
| public long inV; |
| public byte out; |
| } |
| |
| private void checkConvertLong2Uchar2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x83d09ae7l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong2Uchar2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertLong3Uchar3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x79ebbbc5l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong3Uchar3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertLong4Uchar4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x7006dca3l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong4Uchar4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUlongUchar { |
| public long inV; |
| public byte out; |
| } |
| |
| private void checkConvertUlong2Uchar2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x1fa8b492l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong2Uchar2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUlong3Uchar3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x15c3d570l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong3Uchar3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUlong4Uchar4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0xbdef64el, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| byte[] arrayOut = new byte[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (byte) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong4Uchar4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsDoubleShort { |
| public double inV; |
| public short out; |
| } |
| |
| private void checkConvertDouble2Short2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xbf1d55f9l, -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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble2Short2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertDouble3Short3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0xb53876d7l, -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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble3Short3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertDouble4Short4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xab5397b5l, -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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble4Short4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsLongShort { |
| public long inV; |
| public short out; |
| } |
| |
| private void checkConvertLong2Short2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x18de6600l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong2Short2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertLong3Short3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xef986del, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong3Short3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertLong4Short4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x514a7bcl, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong4Short4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUlongShort { |
| public long inV; |
| public short out; |
| } |
| |
| private void checkConvertUlong2Short2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xb4b67fabl, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong2Short2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUlong3Short3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0xaad1a089l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong3Short3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUlong4Short4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0xa0ecc167l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong4Short4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsDoubleUshort { |
| public double inV; |
| public short out; |
| } |
| |
| private void checkConvertDouble2Ushort2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xa92a37bcl, 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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble2Ushort2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertDouble3Ushort3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0xff85c8e8l, 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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble3Ushort3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertDouble4Ushort4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x55e15a14l, 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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble4Ushort4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsLongUshort { |
| public long inV; |
| public short out; |
| } |
| |
| private void checkConvertLong2Ushort2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xbc97e8e9l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong2Ushort2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertLong3Ushort3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x12f37a15l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong3Ushort3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertLong4Ushort4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x694f0b41l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong4Ushort4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUlongUshort { |
| public long inV; |
| public short out; |
| } |
| |
| private void checkConvertUlong2Ushort2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xe9e438a2l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong2Ushort2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUlong3Ushort3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x403fc9cel, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong3Ushort3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUlong4Ushort4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x969b5afal, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| short[] arrayOut = new short[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (short) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong4Ushort4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsDoubleInt { |
| public double inV; |
| public int out; |
| } |
| |
| private void checkConvertDouble2Int2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0xcaf628fcl, -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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble2Int2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertDouble3Int3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x149e3932l, -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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble3Int3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertDouble4Int4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0x5e464968l, -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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble4Int4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsLongInt { |
| public long inV; |
| public int out; |
| } |
| |
| private void checkConvertLong2Int2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0xe5deba3bl, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong2Int2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertLong3Int3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0x2f86ca71l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong3Int3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertLong4Int4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x792edaa7l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong4Int4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUlongInt { |
| public long inV; |
| public int out; |
| } |
| |
| private void checkConvertUlong2Int2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0xe352de3el, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong2Int2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUlong3Int3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x2cfaee74l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong3Int3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUlong4Int4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0x76a2feaal, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong4Int4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsDoubleUint { |
| public double inV; |
| public int out; |
| } |
| |
| private void checkConvertDouble2Uint2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 2, 0x7de7dd7l, 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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble2Uint2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertDouble3Uint3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 3, 0x66e642cbl, 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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble3Uint3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertDouble4Uint4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_64, 4, 0xc5ee07bfl, 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]; |
| Arrays.fill(arrayInV, (double) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertDouble4Uint4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsLongUint { |
| public long inV; |
| public int out; |
| } |
| |
| private void checkConvertLong2Uint2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 2, 0x8ceee36cl, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong2Uint2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertLong3Uint3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 3, 0xebf6a860l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong3Uint3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertLong4Uint4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_64, 4, 0x4afe6d54l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertLong4Uint4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUlongUint { |
| public long inV; |
| public int out; |
| } |
| |
| private void checkConvertUlong2Uint2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 2, 0x1f70efedl, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong2Uint2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUlong3Uint3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 3, 0x7e78b4e1l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong3Uint3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUlong4Uint4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_64, 4, 0xdd8079d5l, 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]; |
| Arrays.fill(arrayInV, (long) 42); |
| inV.copyTo(arrayInV); |
| int[] arrayOut = new int[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (int) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUlong4Uint4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsFloatDouble { |
| public float inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertFloat2Double2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x46e08221l, -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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat2Double2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertFloat3Double3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x9d3c134dl, -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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat3Double3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertFloat4Double4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xf397a479l, -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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat4Double4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsCharDouble { |
| public byte inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertChar2Double2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x68ca2f61l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar2Double2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertChar3Double3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0xbf25c08dl, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar3Double3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertChar4Double4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0x158151b9l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar4Double4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUcharDouble { |
| public byte inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertUchar2Double2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0x96167f1al, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar2Double2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUchar3Double3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xec721046l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar3Double3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUchar4Double4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x42cda172l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar4Double4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsShortDouble { |
| public short inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertShort2Double2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x23d0105l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort2Double2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertShort3Double3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0x58989231l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort3Double3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertShort4Double4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xaef4235dl, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort4Double4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUshortDouble { |
| public short inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertUshort2Double2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x9e0e6518l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort2Double2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUshort3Double3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0xf469f644l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort3Double3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUshort4Double4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x4ac58770l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort4Double4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsIntDouble { |
| public int inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertInt2Double2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0xa40fc8f6l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt2Double2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertInt3Double3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xfa6b5a22l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt3Double3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertInt4Double4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x50c6eb4el, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt4Double4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUintDouble { |
| public int inV; |
| public Target.Floaty out; |
| } |
| |
| private void checkConvertUint2Double2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x3fe7e2a1l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (!args.out.couldBe(arrayOut[i * 2 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint2Double2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUint3Double3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0x964373cdl, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint3Double3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUint4Double4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xec9f04f9l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| double[] arrayOut = new double[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (double) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (!args.out.couldBe(arrayOut[i * 4 + j])) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint4Double4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsFloatLong { |
| public float inV; |
| public long out; |
| } |
| |
| private void checkConvertFloat2Long2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x7d7c0ae0l, -1.0000000000000000000e+00, 0.0000000000000000000e+00); |
| 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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat2Long2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertFloat3Long3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xdc83cfd4l, -1.0000000000000000000e+00, 0.0000000000000000000e+00); |
| 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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat3Long3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertFloat4Long4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3b8b94c8l, -1.0000000000000000000e+00, 0.0000000000000000000e+00); |
| 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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat4Long4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsCharLong { |
| public byte inV; |
| public long out; |
| } |
| |
| private void checkConvertChar2Long2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x290be220l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar2Long2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertChar3Long3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x8813a714l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar3Long3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertChar4Long4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xe71b6c08l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar4Long4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUcharLong { |
| public byte inV; |
| public long out; |
| } |
| |
| private void checkConvertUchar2Long2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xbb8deea1l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar2Long2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUchar3Long3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0x1a95b395l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar3Long3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUchar4Long4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0x799d7889l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar4Long4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsShortLong { |
| public short inV; |
| public long out; |
| } |
| |
| private void checkConvertShort2Long2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0x69c97ce4l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort2Long2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertShort3Long3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xc8d141d8l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort3Long3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertShort4Long4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0x27d906ccl, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort4Long4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUshortLong { |
| public short inV; |
| public long out; |
| } |
| |
| private void checkConvertUshort2Long2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x5a1968fl, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort2Long2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUshort3Long3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x64a95b83l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort3Long3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUshort4Long4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0xc3b12077l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort4Long4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsIntLong { |
| public int inV; |
| public long out; |
| } |
| |
| private void checkConvertInt2Long2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x8a45cb5dl, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt2Long2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertInt3Long3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0xe94d9051l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt3Long3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertInt4Long4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x48555545l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt4Long4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUintLong { |
| public int inV; |
| public long out; |
| } |
| |
| private void checkConvertUint2Long2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x87b9ef60l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint2Long2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUint3Long3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xe6c1b454l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint3Long3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUint4Long4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0x45c97948l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint4Long4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsFloatUlong { |
| public float inV; |
| public long out; |
| } |
| |
| private void checkConvertFloat2Ulong2() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x4ec4cff7l, 0.0000000000000000000e+00, 0.0000000000000000000e+00); |
| 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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat2Ulong2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertFloat3Ulong3() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x44dff0d5l, 0.0000000000000000000e+00, 0.0000000000000000000e+00); |
| 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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat3Ulong3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertFloat4Ulong4() { |
| Allocation inV = createRandomFloatAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x3afb11b3l, 0.0000000000000000000e+00, 0.0000000000000000000e+00); |
| 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]; |
| Arrays.fill(arrayInV, (float) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertFloat4Ulong4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsCharUlong { |
| public byte inV; |
| public long out; |
| } |
| |
| private void checkConvertChar2Ulong2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 2, 0x1fedf7b7l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar2Ulong2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertChar3Ulong3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 3, 0x16091895l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar3Ulong3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertChar4Ulong4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_8, 4, 0xc243973l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertChar4Ulong4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUcharUlong { |
| public byte inV; |
| public long out; |
| } |
| |
| private void checkConvertUchar2Ulong2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 2, 0xbbc61162l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar2Ulong2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUchar3Ulong3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 3, 0xb1e13240l, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar3Ulong3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUchar4Ulong4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_8, 4, 0xa7fc531el, 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]; |
| Arrays.fill(arrayInV, (byte) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUchar4Ulong4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsShortUlong { |
| public short inV; |
| public long out; |
| } |
| |
| private void checkConvertShort2Ulong2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 2, 0xffc6f6a3l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort2Ulong2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertShort3Ulong3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 3, 0xf5e21781l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort3Ulong3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertShort4Ulong4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_16, 4, 0xebfd385fl, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertShort4Ulong4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUshortUlong { |
| public short inV; |
| public long out; |
| } |
| |
| private void checkConvertUshort2Ulong2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 2, 0x2d13465cl, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort2Ulong2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUshort3Ulong3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 3, 0x232e673al, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort3Ulong3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUshort4Ulong4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_16, 4, 0x19498818l, 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]; |
| Arrays.fill(arrayInV, (short) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUshort4Ulong4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsIntUlong { |
| public int inV; |
| public long out; |
| } |
| |
| private void checkConvertInt2Ulong2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 2, 0x74a824f6l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt2Ulong2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertInt3Ulong3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 3, 0x6ac345d4l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt3Ulong3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertInt4Ulong4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.SIGNED_32, 4, 0x60de66b2l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertInt4Ulong4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| public class ArgumentsUintUlong { |
| public int inV; |
| public long out; |
| } |
| |
| private void checkConvertUint2Ulong2() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 2, 0x72a3177l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 2]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 2 + j]); |
| if (args.out != arrayOut[i * 2 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint2Ulong2" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUint3Ulong3() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 3, 0xfd455255l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint3Ulong3" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| private void checkConvertUint4Ulong4() { |
| Allocation inV = createRandomIntegerAllocation(mRS, Element.DataType.UNSIGNED_32, 4, 0xf3607333l, 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]; |
| Arrays.fill(arrayInV, (int) 42); |
| inV.copyTo(arrayInV); |
| long[] arrayOut = new long[INPUTSIZE * 4]; |
| Arrays.fill(arrayOut, (long) 42); |
| out.copyTo(arrayOut); |
| StringBuilder message = new StringBuilder(); |
| boolean errorFound = false; |
| 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) { |
| if (!errorFound) { |
| errorFound = true; |
| message.append("Input inV: "); |
| appendVariableToMessage(message, args.inV); |
| message.append("\n"); |
| message.append("Expected output out: "); |
| appendVariableToMessage(message, args.out); |
| message.append("\n"); |
| message.append("Actual output out: "); |
| appendVariableToMessage(message, arrayOut[i * 4 + j]); |
| if (args.out != arrayOut[i * 4 + j]) { |
| message.append(" FAIL"); |
| } |
| message.append("\n"); |
| message.append("Errors at"); |
| } |
| message.append(" ["); |
| message.append(Integer.toString(i)); |
| message.append(", "); |
| message.append(Integer.toString(j)); |
| message.append("]"); |
| } |
| } |
| } |
| assertFalse("Incorrect output for checkConvertUint4Ulong4" + |
| (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound); |
| } |
| |
| 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(); |
| } |
| } |