Home | History | Annotate | Download | only in generated
      1 /*
      2  * Copyright (C) 2016 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 // Don't edit this file!  It is auto-generated by frameworks/rs/api/generate.sh.
     18 
     19 package android.renderscript.cts;
     20 
     21 import android.renderscript.Allocation;
     22 import android.renderscript.RSRuntimeException;
     23 import android.renderscript.Element;
     24 import android.renderscript.cts.Target;
     25 
     26 import java.util.Arrays;
     27 
     28 public class TestLgamma extends RSBaseCompute {
     29 
     30     private ScriptC_TestLgamma script;
     31     private ScriptC_TestLgammaRelaxed scriptRelaxed;
     32 
     33     @Override
     34     protected void setUp() throws Exception {
     35         super.setUp();
     36         script = new ScriptC_TestLgamma(mRS);
     37         scriptRelaxed = new ScriptC_TestLgammaRelaxed(mRS);
     38     }
     39 
     40     @Override
     41     protected void tearDown() throws Exception {
     42         script.destroy();
     43         scriptRelaxed.destroy();
     44         super.tearDown();
     45     }
     46 
     47     public class ArgumentsFloatFloat {
     48         public float inV;
     49         public Target.Floaty out;
     50     }
     51 
     52     private void checkLgammaFloatFloat() {
     53         Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xd9395583050bc4bel, false);
     54         try {
     55             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
     56             script.forEach_testLgammaFloatFloat(inV, out);
     57             verifyResultsLgammaFloatFloat(inV, out, false);
     58             out.destroy();
     59         } catch (Exception e) {
     60             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloatFloat: " + e.toString());
     61         }
     62         try {
     63             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
     64             scriptRelaxed.forEach_testLgammaFloatFloat(inV, out);
     65             verifyResultsLgammaFloatFloat(inV, out, true);
     66             out.destroy();
     67         } catch (Exception e) {
     68             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloatFloat: " + e.toString());
     69         }
     70         inV.destroy();
     71     }
     72 
     73     private void verifyResultsLgammaFloatFloat(Allocation inV, Allocation out, boolean relaxed) {
     74         float[] arrayInV = new float[INPUTSIZE * 1];
     75         Arrays.fill(arrayInV, (float) 42);
     76         inV.copyTo(arrayInV);
     77         float[] arrayOut = new float[INPUTSIZE * 1];
     78         Arrays.fill(arrayOut, (float) 42);
     79         out.copyTo(arrayOut);
     80         StringBuilder message = new StringBuilder();
     81         boolean errorFound = false;
     82         for (int i = 0; i < INPUTSIZE; i++) {
     83             for (int j = 0; j < 1 ; j++) {
     84                 // Extract the inputs.
     85                 ArgumentsFloatFloat args = new ArgumentsFloatFloat();
     86                 args.inV = arrayInV[i];
     87                 // Figure out what the outputs should have been.
     88                 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed);
     89                 CoreMathVerifier.computeLgamma(args, target);
     90                 // Validate the outputs.
     91                 boolean valid = true;
     92                 if (!args.out.couldBe(arrayOut[i * 1 + j])) {
     93                     valid = false;
     94                 }
     95                 if (!valid) {
     96                     if (!errorFound) {
     97                         errorFound = true;
     98                         message.append("Input inV: ");
     99                         appendVariableToMessage(message, args.inV);
    100                         message.append("\n");
    101                         message.append("Expected output out: ");
    102                         appendVariableToMessage(message, args.out);
    103                         message.append("\n");
    104                         message.append("Actual   output out: ");
    105                         appendVariableToMessage(message, arrayOut[i * 1 + j]);
    106                         if (!args.out.couldBe(arrayOut[i * 1 + j])) {
    107                             message.append(" FAIL");
    108                         }
    109                         message.append("\n");
    110                         message.append("Errors at");
    111                     }
    112                     message.append(" [");
    113                     message.append(Integer.toString(i));
    114                     message.append(", ");
    115                     message.append(Integer.toString(j));
    116                     message.append("]");
    117                 }
    118             }
    119         }
    120         assertFalse("Incorrect output for checkLgammaFloatFloat" +
    121                 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
    122     }
    123 
    124     private void checkLgammaFloat2Float2() {
    125         Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0xeef55496367a4132l, false);
    126         try {
    127             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
    128             script.forEach_testLgammaFloat2Float2(inV, out);
    129             verifyResultsLgammaFloat2Float2(inV, out, false);
    130             out.destroy();
    131         } catch (Exception e) {
    132             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat2Float2: " + e.toString());
    133         }
    134         try {
    135             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
    136             scriptRelaxed.forEach_testLgammaFloat2Float2(inV, out);
    137             verifyResultsLgammaFloat2Float2(inV, out, true);
    138             out.destroy();
    139         } catch (Exception e) {
    140             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat2Float2: " + e.toString());
    141         }
    142         inV.destroy();
    143     }
    144 
    145     private void verifyResultsLgammaFloat2Float2(Allocation inV, Allocation out, boolean relaxed) {
    146         float[] arrayInV = new float[INPUTSIZE * 2];
    147         Arrays.fill(arrayInV, (float) 42);
    148         inV.copyTo(arrayInV);
    149         float[] arrayOut = new float[INPUTSIZE * 2];
    150         Arrays.fill(arrayOut, (float) 42);
    151         out.copyTo(arrayOut);
    152         StringBuilder message = new StringBuilder();
    153         boolean errorFound = false;
    154         for (int i = 0; i < INPUTSIZE; i++) {
    155             for (int j = 0; j < 2 ; j++) {
    156                 // Extract the inputs.
    157                 ArgumentsFloatFloat args = new ArgumentsFloatFloat();
    158                 args.inV = arrayInV[i * 2 + j];
    159                 // Figure out what the outputs should have been.
    160                 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed);
    161                 CoreMathVerifier.computeLgamma(args, target);
    162                 // Validate the outputs.
    163                 boolean valid = true;
    164                 if (!args.out.couldBe(arrayOut[i * 2 + j])) {
    165                     valid = false;
    166                 }
    167                 if (!valid) {
    168                     if (!errorFound) {
    169                         errorFound = true;
    170                         message.append("Input inV: ");
    171                         appendVariableToMessage(message, args.inV);
    172                         message.append("\n");
    173                         message.append("Expected output out: ");
    174                         appendVariableToMessage(message, args.out);
    175                         message.append("\n");
    176                         message.append("Actual   output out: ");
    177                         appendVariableToMessage(message, arrayOut[i * 2 + j]);
    178                         if (!args.out.couldBe(arrayOut[i * 2 + j])) {
    179                             message.append(" FAIL");
    180                         }
    181                         message.append("\n");
    182                         message.append("Errors at");
    183                     }
    184                     message.append(" [");
    185                     message.append(Integer.toString(i));
    186                     message.append(", ");
    187                     message.append(Integer.toString(j));
    188                     message.append("]");
    189                 }
    190             }
    191         }
    192         assertFalse("Incorrect output for checkLgammaFloat2Float2" +
    193                 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
    194     }
    195 
    196     private void checkLgammaFloat3Float3() {
    197         Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0xeef71db12c956210l, false);
    198         try {
    199             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
    200             script.forEach_testLgammaFloat3Float3(inV, out);
    201             verifyResultsLgammaFloat3Float3(inV, out, false);
    202             out.destroy();
    203         } catch (Exception e) {
    204             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat3Float3: " + e.toString());
    205         }
    206         try {
    207             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
    208             scriptRelaxed.forEach_testLgammaFloat3Float3(inV, out);
    209             verifyResultsLgammaFloat3Float3(inV, out, true);
    210             out.destroy();
    211         } catch (Exception e) {
    212             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat3Float3: " + e.toString());
    213         }
    214         inV.destroy();
    215     }
    216 
    217     private void verifyResultsLgammaFloat3Float3(Allocation inV, Allocation out, boolean relaxed) {
    218         float[] arrayInV = new float[INPUTSIZE * 4];
    219         Arrays.fill(arrayInV, (float) 42);
    220         inV.copyTo(arrayInV);
    221         float[] arrayOut = new float[INPUTSIZE * 4];
    222         Arrays.fill(arrayOut, (float) 42);
    223         out.copyTo(arrayOut);
    224         StringBuilder message = new StringBuilder();
    225         boolean errorFound = false;
    226         for (int i = 0; i < INPUTSIZE; i++) {
    227             for (int j = 0; j < 3 ; j++) {
    228                 // Extract the inputs.
    229                 ArgumentsFloatFloat args = new ArgumentsFloatFloat();
    230                 args.inV = arrayInV[i * 4 + j];
    231                 // Figure out what the outputs should have been.
    232                 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed);
    233                 CoreMathVerifier.computeLgamma(args, target);
    234                 // Validate the outputs.
    235                 boolean valid = true;
    236                 if (!args.out.couldBe(arrayOut[i * 4 + j])) {
    237                     valid = false;
    238                 }
    239                 if (!valid) {
    240                     if (!errorFound) {
    241                         errorFound = true;
    242                         message.append("Input inV: ");
    243                         appendVariableToMessage(message, args.inV);
    244                         message.append("\n");
    245                         message.append("Expected output out: ");
    246                         appendVariableToMessage(message, args.out);
    247                         message.append("\n");
    248                         message.append("Actual   output out: ");
    249                         appendVariableToMessage(message, arrayOut[i * 4 + j]);
    250                         if (!args.out.couldBe(arrayOut[i * 4 + j])) {
    251                             message.append(" FAIL");
    252                         }
    253                         message.append("\n");
    254                         message.append("Errors at");
    255                     }
    256                     message.append(" [");
    257                     message.append(Integer.toString(i));
    258                     message.append(", ");
    259                     message.append(Integer.toString(j));
    260                     message.append("]");
    261                 }
    262             }
    263         }
    264         assertFalse("Incorrect output for checkLgammaFloat3Float3" +
    265                 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
    266     }
    267 
    268     private void checkLgammaFloat4Float4() {
    269         Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0xeef8e6cc22b082eel, false);
    270         try {
    271             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
    272             script.forEach_testLgammaFloat4Float4(inV, out);
    273             verifyResultsLgammaFloat4Float4(inV, out, false);
    274             out.destroy();
    275         } catch (Exception e) {
    276             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat4Float4: " + e.toString());
    277         }
    278         try {
    279             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
    280             scriptRelaxed.forEach_testLgammaFloat4Float4(inV, out);
    281             verifyResultsLgammaFloat4Float4(inV, out, true);
    282             out.destroy();
    283         } catch (Exception e) {
    284             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat4Float4: " + e.toString());
    285         }
    286         inV.destroy();
    287     }
    288 
    289     private void verifyResultsLgammaFloat4Float4(Allocation inV, Allocation out, boolean relaxed) {
    290         float[] arrayInV = new float[INPUTSIZE * 4];
    291         Arrays.fill(arrayInV, (float) 42);
    292         inV.copyTo(arrayInV);
    293         float[] arrayOut = new float[INPUTSIZE * 4];
    294         Arrays.fill(arrayOut, (float) 42);
    295         out.copyTo(arrayOut);
    296         StringBuilder message = new StringBuilder();
    297         boolean errorFound = false;
    298         for (int i = 0; i < INPUTSIZE; i++) {
    299             for (int j = 0; j < 4 ; j++) {
    300                 // Extract the inputs.
    301                 ArgumentsFloatFloat args = new ArgumentsFloatFloat();
    302                 args.inV = arrayInV[i * 4 + j];
    303                 // Figure out what the outputs should have been.
    304                 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed);
    305                 CoreMathVerifier.computeLgamma(args, target);
    306                 // Validate the outputs.
    307                 boolean valid = true;
    308                 if (!args.out.couldBe(arrayOut[i * 4 + j])) {
    309                     valid = false;
    310                 }
    311                 if (!valid) {
    312                     if (!errorFound) {
    313                         errorFound = true;
    314                         message.append("Input inV: ");
    315                         appendVariableToMessage(message, args.inV);
    316                         message.append("\n");
    317                         message.append("Expected output out: ");
    318                         appendVariableToMessage(message, args.out);
    319                         message.append("\n");
    320                         message.append("Actual   output out: ");
    321                         appendVariableToMessage(message, arrayOut[i * 4 + j]);
    322                         if (!args.out.couldBe(arrayOut[i * 4 + j])) {
    323                             message.append(" FAIL");
    324                         }
    325                         message.append("\n");
    326                         message.append("Errors at");
    327                     }
    328                     message.append(" [");
    329                     message.append(Integer.toString(i));
    330                     message.append(", ");
    331                     message.append(Integer.toString(j));
    332                     message.append("]");
    333                 }
    334             }
    335         }
    336         assertFalse("Incorrect output for checkLgammaFloat4Float4" +
    337                 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
    338     }
    339 
    340     public class ArgumentsFloatIntFloat {
    341         public float inV;
    342         public int outSignOfGamma;
    343         public float out;
    344     }
    345 
    346     private void checkLgammaFloatIntFloat() {
    347         Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x2a62d992979c4bb7l, false);
    348         try {
    349             Allocation outSignOfGamma = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 1), INPUTSIZE);
    350             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
    351             script.set_gAllocOutSignOfGamma(outSignOfGamma);
    352             script.forEach_testLgammaFloatIntFloat(inV, out);
    353             verifyResultsLgammaFloatIntFloat(inV, outSignOfGamma, out, false);
    354             outSignOfGamma.destroy();
    355             out.destroy();
    356         } catch (Exception e) {
    357             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloatIntFloat: " + e.toString());
    358         }
    359         try {
    360             Allocation outSignOfGamma = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 1), INPUTSIZE);
    361             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
    362             scriptRelaxed.set_gAllocOutSignOfGamma(outSignOfGamma);
    363             scriptRelaxed.forEach_testLgammaFloatIntFloat(inV, out);
    364             verifyResultsLgammaFloatIntFloat(inV, outSignOfGamma, out, true);
    365             outSignOfGamma.destroy();
    366             out.destroy();
    367         } catch (Exception e) {
    368             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloatIntFloat: " + e.toString());
    369         }
    370         inV.destroy();
    371     }
    372 
    373     private void verifyResultsLgammaFloatIntFloat(Allocation inV, Allocation outSignOfGamma, Allocation out, boolean relaxed) {
    374         float[] arrayInV = new float[INPUTSIZE * 1];
    375         Arrays.fill(arrayInV, (float) 42);
    376         inV.copyTo(arrayInV);
    377         int[] arrayOutSignOfGamma = new int[INPUTSIZE * 1];
    378         Arrays.fill(arrayOutSignOfGamma, (int) 42);
    379         outSignOfGamma.copyTo(arrayOutSignOfGamma);
    380         float[] arrayOut = new float[INPUTSIZE * 1];
    381         Arrays.fill(arrayOut, (float) 42);
    382         out.copyTo(arrayOut);
    383         StringBuilder message = new StringBuilder();
    384         boolean errorFound = false;
    385         for (int i = 0; i < INPUTSIZE; i++) {
    386             for (int j = 0; j < 1 ; j++) {
    387                 // Extract the inputs.
    388                 ArgumentsFloatIntFloat args = new ArgumentsFloatIntFloat();
    389                 args.inV = arrayInV[i];
    390                 // Extract the outputs.
    391                 args.outSignOfGamma = arrayOutSignOfGamma[i * 1 + j];
    392                 args.out = arrayOut[i * 1 + j];
    393                 // Ask the CoreMathVerifier to validate.
    394                 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed);
    395                 String errorMessage = CoreMathVerifier.verifyLgamma(args, target);
    396                 boolean valid = errorMessage == null;
    397                 if (!valid) {
    398                     if (!errorFound) {
    399                         errorFound = true;
    400                         message.append("Input inV: ");
    401                         appendVariableToMessage(message, args.inV);
    402                         message.append("\n");
    403                         message.append("Output outSignOfGamma: ");
    404                         appendVariableToMessage(message, args.outSignOfGamma);
    405                         message.append("\n");
    406                         message.append("Output out: ");
    407                         appendVariableToMessage(message, args.out);
    408                         message.append("\n");
    409                         message.append(errorMessage);
    410                         message.append("Errors at");
    411                     }
    412                     message.append(" [");
    413                     message.append(Integer.toString(i));
    414                     message.append(", ");
    415                     message.append(Integer.toString(j));
    416                     message.append("]");
    417                 }
    418             }
    419         }
    420         assertFalse("Incorrect output for checkLgammaFloatIntFloat" +
    421                 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
    422     }
    423 
    424     private void checkLgammaFloat2Int2Float2() {
    425         Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x409fb9a5984bcf7fl, false);
    426         try {
    427             Allocation outSignOfGamma = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
    428             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
    429             script.set_gAllocOutSignOfGamma(outSignOfGamma);
    430             script.forEach_testLgammaFloat2Int2Float2(inV, out);
    431             verifyResultsLgammaFloat2Int2Float2(inV, outSignOfGamma, out, false);
    432             outSignOfGamma.destroy();
    433             out.destroy();
    434         } catch (Exception e) {
    435             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat2Int2Float2: " + e.toString());
    436         }
    437         try {
    438             Allocation outSignOfGamma = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
    439             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
    440             scriptRelaxed.set_gAllocOutSignOfGamma(outSignOfGamma);
    441             scriptRelaxed.forEach_testLgammaFloat2Int2Float2(inV, out);
    442             verifyResultsLgammaFloat2Int2Float2(inV, outSignOfGamma, out, true);
    443             outSignOfGamma.destroy();
    444             out.destroy();
    445         } catch (Exception e) {
    446             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat2Int2Float2: " + e.toString());
    447         }
    448         inV.destroy();
    449     }
    450 
    451     private void verifyResultsLgammaFloat2Int2Float2(Allocation inV, Allocation outSignOfGamma, Allocation out, boolean relaxed) {
    452         float[] arrayInV = new float[INPUTSIZE * 2];
    453         Arrays.fill(arrayInV, (float) 42);
    454         inV.copyTo(arrayInV);
    455         int[] arrayOutSignOfGamma = new int[INPUTSIZE * 2];
    456         Arrays.fill(arrayOutSignOfGamma, (int) 42);
    457         outSignOfGamma.copyTo(arrayOutSignOfGamma);
    458         float[] arrayOut = new float[INPUTSIZE * 2];
    459         Arrays.fill(arrayOut, (float) 42);
    460         out.copyTo(arrayOut);
    461         StringBuilder message = new StringBuilder();
    462         boolean errorFound = false;
    463         for (int i = 0; i < INPUTSIZE; i++) {
    464             for (int j = 0; j < 2 ; j++) {
    465                 // Extract the inputs.
    466                 ArgumentsFloatIntFloat args = new ArgumentsFloatIntFloat();
    467                 args.inV = arrayInV[i * 2 + j];
    468                 // Extract the outputs.
    469                 args.outSignOfGamma = arrayOutSignOfGamma[i * 2 + j];
    470                 args.out = arrayOut[i * 2 + j];
    471                 // Ask the CoreMathVerifier to validate.
    472                 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed);
    473                 String errorMessage = CoreMathVerifier.verifyLgamma(args, target);
    474                 boolean valid = errorMessage == null;
    475                 if (!valid) {
    476                     if (!errorFound) {
    477                         errorFound = true;
    478                         message.append("Input inV: ");
    479                         appendVariableToMessage(message, args.inV);
    480                         message.append("\n");
    481                         message.append("Output outSignOfGamma: ");
    482                         appendVariableToMessage(message, args.outSignOfGamma);
    483                         message.append("\n");
    484                         message.append("Output out: ");
    485                         appendVariableToMessage(message, args.out);
    486                         message.append("\n");
    487                         message.append(errorMessage);
    488                         message.append("Errors at");
    489                     }
    490                     message.append(" [");
    491                     message.append(Integer.toString(i));
    492                     message.append(", ");
    493                     message.append(Integer.toString(j));
    494                     message.append("]");
    495                 }
    496             }
    497         }
    498         assertFalse("Incorrect output for checkLgammaFloat2Int2Float2" +
    499                 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
    500     }
    501 
    502     private void checkLgammaFloat3Int3Float3() {
    503         Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x6655f8088dfe3c38l, false);
    504         try {
    505             Allocation outSignOfGamma = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
    506             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
    507             script.set_gAllocOutSignOfGamma(outSignOfGamma);
    508             script.forEach_testLgammaFloat3Int3Float3(inV, out);
    509             verifyResultsLgammaFloat3Int3Float3(inV, outSignOfGamma, out, false);
    510             outSignOfGamma.destroy();
    511             out.destroy();
    512         } catch (Exception e) {
    513             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat3Int3Float3: " + e.toString());
    514         }
    515         try {
    516             Allocation outSignOfGamma = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
    517             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
    518             scriptRelaxed.set_gAllocOutSignOfGamma(outSignOfGamma);
    519             scriptRelaxed.forEach_testLgammaFloat3Int3Float3(inV, out);
    520             verifyResultsLgammaFloat3Int3Float3(inV, outSignOfGamma, out, true);
    521             outSignOfGamma.destroy();
    522             out.destroy();
    523         } catch (Exception e) {
    524             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat3Int3Float3: " + e.toString());
    525         }
    526         inV.destroy();
    527     }
    528 
    529     private void verifyResultsLgammaFloat3Int3Float3(Allocation inV, Allocation outSignOfGamma, Allocation out, boolean relaxed) {
    530         float[] arrayInV = new float[INPUTSIZE * 4];
    531         Arrays.fill(arrayInV, (float) 42);
    532         inV.copyTo(arrayInV);
    533         int[] arrayOutSignOfGamma = new int[INPUTSIZE * 4];
    534         Arrays.fill(arrayOutSignOfGamma, (int) 42);
    535         outSignOfGamma.copyTo(arrayOutSignOfGamma);
    536         float[] arrayOut = new float[INPUTSIZE * 4];
    537         Arrays.fill(arrayOut, (float) 42);
    538         out.copyTo(arrayOut);
    539         StringBuilder message = new StringBuilder();
    540         boolean errorFound = false;
    541         for (int i = 0; i < INPUTSIZE; i++) {
    542             for (int j = 0; j < 3 ; j++) {
    543                 // Extract the inputs.
    544                 ArgumentsFloatIntFloat args = new ArgumentsFloatIntFloat();
    545                 args.inV = arrayInV[i * 4 + j];
    546                 // Extract the outputs.
    547                 args.outSignOfGamma = arrayOutSignOfGamma[i * 4 + j];
    548                 args.out = arrayOut[i * 4 + j];
    549                 // Ask the CoreMathVerifier to validate.
    550                 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed);
    551                 String errorMessage = CoreMathVerifier.verifyLgamma(args, target);
    552                 boolean valid = errorMessage == null;
    553                 if (!valid) {
    554                     if (!errorFound) {
    555                         errorFound = true;
    556                         message.append("Input inV: ");
    557                         appendVariableToMessage(message, args.inV);
    558                         message.append("\n");
    559                         message.append("Output outSignOfGamma: ");
    560                         appendVariableToMessage(message, args.outSignOfGamma);
    561                         message.append("\n");
    562                         message.append("Output out: ");
    563                         appendVariableToMessage(message, args.out);
    564                         message.append("\n");
    565                         message.append(errorMessage);
    566                         message.append("Errors at");
    567                     }
    568                     message.append(" [");
    569                     message.append(Integer.toString(i));
    570                     message.append(", ");
    571                     message.append(Integer.toString(j));
    572                     message.append("]");
    573                 }
    574             }
    575         }
    576         assertFalse("Incorrect output for checkLgammaFloat3Int3Float3" +
    577                 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
    578     }
    579 
    580     private void checkLgammaFloat4Int4Float4() {
    581         Allocation inV = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8c0c366b83b0a8f1l, false);
    582         try {
    583             Allocation outSignOfGamma = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
    584             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
    585             script.set_gAllocOutSignOfGamma(outSignOfGamma);
    586             script.forEach_testLgammaFloat4Int4Float4(inV, out);
    587             verifyResultsLgammaFloat4Int4Float4(inV, outSignOfGamma, out, false);
    588             outSignOfGamma.destroy();
    589             out.destroy();
    590         } catch (Exception e) {
    591             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat4Int4Float4: " + e.toString());
    592         }
    593         try {
    594             Allocation outSignOfGamma = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
    595             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
    596             scriptRelaxed.set_gAllocOutSignOfGamma(outSignOfGamma);
    597             scriptRelaxed.forEach_testLgammaFloat4Int4Float4(inV, out);
    598             verifyResultsLgammaFloat4Int4Float4(inV, outSignOfGamma, out, true);
    599             outSignOfGamma.destroy();
    600             out.destroy();
    601         } catch (Exception e) {
    602             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat4Int4Float4: " + e.toString());
    603         }
    604         inV.destroy();
    605     }
    606 
    607     private void verifyResultsLgammaFloat4Int4Float4(Allocation inV, Allocation outSignOfGamma, Allocation out, boolean relaxed) {
    608         float[] arrayInV = new float[INPUTSIZE * 4];
    609         Arrays.fill(arrayInV, (float) 42);
    610         inV.copyTo(arrayInV);
    611         int[] arrayOutSignOfGamma = new int[INPUTSIZE * 4];
    612         Arrays.fill(arrayOutSignOfGamma, (int) 42);
    613         outSignOfGamma.copyTo(arrayOutSignOfGamma);
    614         float[] arrayOut = new float[INPUTSIZE * 4];
    615         Arrays.fill(arrayOut, (float) 42);
    616         out.copyTo(arrayOut);
    617         StringBuilder message = new StringBuilder();
    618         boolean errorFound = false;
    619         for (int i = 0; i < INPUTSIZE; i++) {
    620             for (int j = 0; j < 4 ; j++) {
    621                 // Extract the inputs.
    622                 ArgumentsFloatIntFloat args = new ArgumentsFloatIntFloat();
    623                 args.inV = arrayInV[i * 4 + j];
    624                 // Extract the outputs.
    625                 args.outSignOfGamma = arrayOutSignOfGamma[i * 4 + j];
    626                 args.out = arrayOut[i * 4 + j];
    627                 // Ask the CoreMathVerifier to validate.
    628                 Target target = new Target(Target.FunctionType.NORMAL, Target.ReturnType.FLOAT, relaxed);
    629                 String errorMessage = CoreMathVerifier.verifyLgamma(args, target);
    630                 boolean valid = errorMessage == null;
    631                 if (!valid) {
    632                     if (!errorFound) {
    633                         errorFound = true;
    634                         message.append("Input inV: ");
    635                         appendVariableToMessage(message, args.inV);
    636                         message.append("\n");
    637                         message.append("Output outSignOfGamma: ");
    638                         appendVariableToMessage(message, args.outSignOfGamma);
    639                         message.append("\n");
    640                         message.append("Output out: ");
    641                         appendVariableToMessage(message, args.out);
    642                         message.append("\n");
    643                         message.append(errorMessage);
    644                         message.append("Errors at");
    645                     }
    646                     message.append(" [");
    647                     message.append(Integer.toString(i));
    648                     message.append(", ");
    649                     message.append(Integer.toString(j));
    650                     message.append("]");
    651                 }
    652             }
    653         }
    654         assertFalse("Incorrect output for checkLgammaFloat4Int4Float4" +
    655                 (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), errorFound);
    656     }
    657 
    658     public void testLgamma() {
    659         checkLgammaFloatFloat();
    660         checkLgammaFloat2Float2();
    661         checkLgammaFloat3Float3();
    662         checkLgammaFloat4Float4();
    663         checkLgammaFloatIntFloat();
    664         checkLgammaFloat2Int2Float2();
    665         checkLgammaFloat3Int3Float3();
    666         checkLgammaFloat4Int4Float4();
    667     }
    668 }
    669