Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright (C) 2014 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/gen_runtime.
     18 
     19 package android.renderscript.cts;
     20 
     21 import android.renderscript.Allocation;
     22 import android.renderscript.RSRuntimeException;
     23 import android.renderscript.Element;
     24 
     25 public class TestLgamma extends RSBaseCompute {
     26 
     27     private ScriptC_TestLgamma script;
     28     private ScriptC_TestLgammaRelaxed scriptRelaxed;
     29 
     30     @Override
     31     protected void setUp() throws Exception {
     32         super.setUp();
     33         script = new ScriptC_TestLgamma(mRS);
     34         scriptRelaxed = new ScriptC_TestLgammaRelaxed(mRS);
     35     }
     36 
     37     public class ArgumentsFloatFloat {
     38         public float in;
     39         public Target.Floaty out;
     40     }
     41 
     42     private void checkLgammaFloatFloat() {
     43         Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0xe748c67429cab138l, false);
     44         try {
     45             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
     46             script.forEach_testLgammaFloatFloat(in, out);
     47             verifyResultsLgammaFloatFloat(in, out, false);
     48         } catch (Exception e) {
     49             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloatFloat: " + e.toString());
     50         }
     51         try {
     52             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
     53             scriptRelaxed.forEach_testLgammaFloatFloat(in, out);
     54             verifyResultsLgammaFloatFloat(in, out, true);
     55         } catch (Exception e) {
     56             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloatFloat: " + e.toString());
     57         }
     58     }
     59 
     60     private void verifyResultsLgammaFloatFloat(Allocation in, Allocation out, boolean relaxed) {
     61         float[] arrayIn = new float[INPUTSIZE * 1];
     62         in.copyTo(arrayIn);
     63         float[] arrayOut = new float[INPUTSIZE * 1];
     64         out.copyTo(arrayOut);
     65         for (int i = 0; i < INPUTSIZE; i++) {
     66             for (int j = 0; j < 1 ; j++) {
     67                 // Extract the inputs.
     68                 ArgumentsFloatFloat args = new ArgumentsFloatFloat();
     69                 args.in = arrayIn[i];
     70                 // Figure out what the outputs should have been.
     71                 Target target = new Target(relaxed);
     72                 CoreMathVerifier.computeLgamma(args, target);
     73                 // Validate the outputs.
     74                 boolean valid = true;
     75                 if (!args.out.couldBe(arrayOut[i * 1 + j])) {
     76                     valid = false;
     77                 }
     78                 if (!valid) {
     79                     StringBuilder message = new StringBuilder();
     80                     message.append("Input in: ");
     81                     message.append(String.format("%14.8g {%8x} %15a",
     82                             args.in, Float.floatToRawIntBits(args.in), args.in));
     83                     message.append("\n");
     84                     message.append("Expected output out: ");
     85                     message.append(args.out.toString());
     86                     message.append("\n");
     87                     message.append("Actual   output out: ");
     88                     message.append(String.format("%14.8g {%8x} %15a",
     89                             arrayOut[i * 1 + j], Float.floatToRawIntBits(arrayOut[i * 1 + j]), arrayOut[i * 1 + j]));
     90                     if (!args.out.couldBe(arrayOut[i * 1 + j])) {
     91                         message.append(" FAIL");
     92                     }
     93                     message.append("\n");
     94                     assertTrue("Incorrect output for checkLgammaFloatFloat" +
     95                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
     96                 }
     97             }
     98         }
     99     }
    100 
    101     private void checkLgammaFloat2Float2() {
    102         Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x7ca07efd8a327894l, false);
    103         try {
    104             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
    105             script.forEach_testLgammaFloat2Float2(in, out);
    106             verifyResultsLgammaFloat2Float2(in, out, false);
    107         } catch (Exception e) {
    108             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat2Float2: " + e.toString());
    109         }
    110         try {
    111             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
    112             scriptRelaxed.forEach_testLgammaFloat2Float2(in, out);
    113             verifyResultsLgammaFloat2Float2(in, out, true);
    114         } catch (Exception e) {
    115             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat2Float2: " + e.toString());
    116         }
    117     }
    118 
    119     private void verifyResultsLgammaFloat2Float2(Allocation in, Allocation out, boolean relaxed) {
    120         float[] arrayIn = new float[INPUTSIZE * 2];
    121         in.copyTo(arrayIn);
    122         float[] arrayOut = new float[INPUTSIZE * 2];
    123         out.copyTo(arrayOut);
    124         for (int i = 0; i < INPUTSIZE; i++) {
    125             for (int j = 0; j < 2 ; j++) {
    126                 // Extract the inputs.
    127                 ArgumentsFloatFloat args = new ArgumentsFloatFloat();
    128                 args.in = arrayIn[i * 2 + j];
    129                 // Figure out what the outputs should have been.
    130                 Target target = new Target(relaxed);
    131                 CoreMathVerifier.computeLgamma(args, target);
    132                 // Validate the outputs.
    133                 boolean valid = true;
    134                 if (!args.out.couldBe(arrayOut[i * 2 + j])) {
    135                     valid = false;
    136                 }
    137                 if (!valid) {
    138                     StringBuilder message = new StringBuilder();
    139                     message.append("Input in: ");
    140                     message.append(String.format("%14.8g {%8x} %15a",
    141                             args.in, Float.floatToRawIntBits(args.in), args.in));
    142                     message.append("\n");
    143                     message.append("Expected output out: ");
    144                     message.append(args.out.toString());
    145                     message.append("\n");
    146                     message.append("Actual   output out: ");
    147                     message.append(String.format("%14.8g {%8x} %15a",
    148                             arrayOut[i * 2 + j], Float.floatToRawIntBits(arrayOut[i * 2 + j]), arrayOut[i * 2 + j]));
    149                     if (!args.out.couldBe(arrayOut[i * 2 + j])) {
    150                         message.append(" FAIL");
    151                     }
    152                     message.append("\n");
    153                     assertTrue("Incorrect output for checkLgammaFloat2Float2" +
    154                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
    155                 }
    156             }
    157         }
    158     }
    159 
    160     private void checkLgammaFloat3Float3() {
    161         Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x7ca0899ee9390e2el, false);
    162         try {
    163             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
    164             script.forEach_testLgammaFloat3Float3(in, out);
    165             verifyResultsLgammaFloat3Float3(in, out, false);
    166         } catch (Exception e) {
    167             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat3Float3: " + e.toString());
    168         }
    169         try {
    170             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
    171             scriptRelaxed.forEach_testLgammaFloat3Float3(in, out);
    172             verifyResultsLgammaFloat3Float3(in, out, true);
    173         } catch (Exception e) {
    174             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat3Float3: " + e.toString());
    175         }
    176     }
    177 
    178     private void verifyResultsLgammaFloat3Float3(Allocation in, Allocation out, boolean relaxed) {
    179         float[] arrayIn = new float[INPUTSIZE * 4];
    180         in.copyTo(arrayIn);
    181         float[] arrayOut = new float[INPUTSIZE * 4];
    182         out.copyTo(arrayOut);
    183         for (int i = 0; i < INPUTSIZE; i++) {
    184             for (int j = 0; j < 3 ; j++) {
    185                 // Extract the inputs.
    186                 ArgumentsFloatFloat args = new ArgumentsFloatFloat();
    187                 args.in = arrayIn[i * 4 + j];
    188                 // Figure out what the outputs should have been.
    189                 Target target = new Target(relaxed);
    190                 CoreMathVerifier.computeLgamma(args, target);
    191                 // Validate the outputs.
    192                 boolean valid = true;
    193                 if (!args.out.couldBe(arrayOut[i * 4 + j])) {
    194                     valid = false;
    195                 }
    196                 if (!valid) {
    197                     StringBuilder message = new StringBuilder();
    198                     message.append("Input in: ");
    199                     message.append(String.format("%14.8g {%8x} %15a",
    200                             args.in, Float.floatToRawIntBits(args.in), args.in));
    201                     message.append("\n");
    202                     message.append("Expected output out: ");
    203                     message.append(args.out.toString());
    204                     message.append("\n");
    205                     message.append("Actual   output out: ");
    206                     message.append(String.format("%14.8g {%8x} %15a",
    207                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
    208                     if (!args.out.couldBe(arrayOut[i * 4 + j])) {
    209                         message.append(" FAIL");
    210                     }
    211                     message.append("\n");
    212                     assertTrue("Incorrect output for checkLgammaFloat3Float3" +
    213                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
    214                 }
    215             }
    216         }
    217     }
    218 
    219     private void checkLgammaFloat4Float4() {
    220         Allocation in = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x7ca09440483fa3c8l, false);
    221         try {
    222             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
    223             script.forEach_testLgammaFloat4Float4(in, out);
    224             verifyResultsLgammaFloat4Float4(in, out, false);
    225         } catch (Exception e) {
    226             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat4Float4: " + e.toString());
    227         }
    228         try {
    229             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
    230             scriptRelaxed.forEach_testLgammaFloat4Float4(in, out);
    231             verifyResultsLgammaFloat4Float4(in, out, true);
    232         } catch (Exception e) {
    233             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat4Float4: " + e.toString());
    234         }
    235     }
    236 
    237     private void verifyResultsLgammaFloat4Float4(Allocation in, Allocation out, boolean relaxed) {
    238         float[] arrayIn = new float[INPUTSIZE * 4];
    239         in.copyTo(arrayIn);
    240         float[] arrayOut = new float[INPUTSIZE * 4];
    241         out.copyTo(arrayOut);
    242         for (int i = 0; i < INPUTSIZE; i++) {
    243             for (int j = 0; j < 4 ; j++) {
    244                 // Extract the inputs.
    245                 ArgumentsFloatFloat args = new ArgumentsFloatFloat();
    246                 args.in = arrayIn[i * 4 + j];
    247                 // Figure out what the outputs should have been.
    248                 Target target = new Target(relaxed);
    249                 CoreMathVerifier.computeLgamma(args, target);
    250                 // Validate the outputs.
    251                 boolean valid = true;
    252                 if (!args.out.couldBe(arrayOut[i * 4 + j])) {
    253                     valid = false;
    254                 }
    255                 if (!valid) {
    256                     StringBuilder message = new StringBuilder();
    257                     message.append("Input in: ");
    258                     message.append(String.format("%14.8g {%8x} %15a",
    259                             args.in, Float.floatToRawIntBits(args.in), args.in));
    260                     message.append("\n");
    261                     message.append("Expected output out: ");
    262                     message.append(args.out.toString());
    263                     message.append("\n");
    264                     message.append("Actual   output out: ");
    265                     message.append(String.format("%14.8g {%8x} %15a",
    266                             arrayOut[i * 4 + j], Float.floatToRawIntBits(arrayOut[i * 4 + j]), arrayOut[i * 4 + j]));
    267                     if (!args.out.couldBe(arrayOut[i * 4 + j])) {
    268                         message.append(" FAIL");
    269                     }
    270                     message.append("\n");
    271                     assertTrue("Incorrect output for checkLgammaFloat4Float4" +
    272                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
    273                 }
    274             }
    275         }
    276     }
    277 
    278     public class ArgumentsFloatIntFloat {
    279         public float inX;
    280         public int outY;
    281         public float out;
    282     }
    283 
    284     private void checkLgammaFloatIntFloat() {
    285         Allocation inX = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 1, 0x2a62d992979c4bb9l, false);
    286         try {
    287             Allocation outY = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 1), INPUTSIZE);
    288             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
    289             script.set_gAllocOutY(outY);
    290             script.forEach_testLgammaFloatIntFloat(inX, out);
    291             verifyResultsLgammaFloatIntFloat(inX, outY, out, false);
    292         } catch (Exception e) {
    293             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloatIntFloat: " + e.toString());
    294         }
    295         try {
    296             Allocation outY = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 1), INPUTSIZE);
    297             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 1), INPUTSIZE);
    298             scriptRelaxed.set_gAllocOutY(outY);
    299             scriptRelaxed.forEach_testLgammaFloatIntFloat(inX, out);
    300             verifyResultsLgammaFloatIntFloat(inX, outY, out, true);
    301         } catch (Exception e) {
    302             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloatIntFloat: " + e.toString());
    303         }
    304     }
    305 
    306     private void verifyResultsLgammaFloatIntFloat(Allocation inX, Allocation outY, Allocation out, boolean relaxed) {
    307         float[] arrayInX = new float[INPUTSIZE * 1];
    308         inX.copyTo(arrayInX);
    309         int[] arrayOutY = new int[INPUTSIZE * 1];
    310         outY.copyTo(arrayOutY);
    311         float[] arrayOut = new float[INPUTSIZE * 1];
    312         out.copyTo(arrayOut);
    313         for (int i = 0; i < INPUTSIZE; i++) {
    314             for (int j = 0; j < 1 ; j++) {
    315                 // Extract the inputs.
    316                 ArgumentsFloatIntFloat args = new ArgumentsFloatIntFloat();
    317                 args.inX = arrayInX[i];
    318                 // Extract the outputs.
    319                 args.outY = arrayOutY[i * 1 + j];
    320                 args.out = arrayOut[i * 1 + j];
    321                 // Ask the CoreMathVerifier to validate.
    322                 Target target = new Target(relaxed);
    323                 String errorMessage = CoreMathVerifier.verifyLgamma(args, target);
    324                 boolean valid = errorMessage == null;
    325                 if (!valid) {
    326                     StringBuilder message = new StringBuilder();
    327                     message.append("Input inX: ");
    328                     message.append(String.format("%14.8g {%8x} %15a",
    329                             args.inX, Float.floatToRawIntBits(args.inX), args.inX));
    330                     message.append("\n");
    331                     message.append("Output outY: ");
    332                     message.append(String.format("%d", args.outY));
    333                     message.append("\n");
    334                     message.append("Output out: ");
    335                     message.append(Float.toString(args.out));
    336                     message.append("\n");
    337                     message.append(errorMessage);
    338                     assertTrue("Incorrect output for checkLgammaFloatIntFloat" +
    339                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
    340                 }
    341             }
    342         }
    343     }
    344 
    345     private void checkLgammaFloat2Int2Float2() {
    346         Allocation inX = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 2, 0x409fb9a5984bcf81l, false);
    347         try {
    348             Allocation outY = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
    349             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
    350             script.set_gAllocOutY(outY);
    351             script.forEach_testLgammaFloat2Int2Float2(inX, out);
    352             verifyResultsLgammaFloat2Int2Float2(inX, outY, out, false);
    353         } catch (Exception e) {
    354             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat2Int2Float2: " + e.toString());
    355         }
    356         try {
    357             Allocation outY = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 2), INPUTSIZE);
    358             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 2), INPUTSIZE);
    359             scriptRelaxed.set_gAllocOutY(outY);
    360             scriptRelaxed.forEach_testLgammaFloat2Int2Float2(inX, out);
    361             verifyResultsLgammaFloat2Int2Float2(inX, outY, out, true);
    362         } catch (Exception e) {
    363             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat2Int2Float2: " + e.toString());
    364         }
    365     }
    366 
    367     private void verifyResultsLgammaFloat2Int2Float2(Allocation inX, Allocation outY, Allocation out, boolean relaxed) {
    368         float[] arrayInX = new float[INPUTSIZE * 2];
    369         inX.copyTo(arrayInX);
    370         int[] arrayOutY = new int[INPUTSIZE * 2];
    371         outY.copyTo(arrayOutY);
    372         float[] arrayOut = new float[INPUTSIZE * 2];
    373         out.copyTo(arrayOut);
    374         for (int i = 0; i < INPUTSIZE; i++) {
    375             for (int j = 0; j < 2 ; j++) {
    376                 // Extract the inputs.
    377                 ArgumentsFloatIntFloat args = new ArgumentsFloatIntFloat();
    378                 args.inX = arrayInX[i * 2 + j];
    379                 // Extract the outputs.
    380                 args.outY = arrayOutY[i * 2 + j];
    381                 args.out = arrayOut[i * 2 + j];
    382                 // Ask the CoreMathVerifier to validate.
    383                 Target target = new Target(relaxed);
    384                 String errorMessage = CoreMathVerifier.verifyLgamma(args, target);
    385                 boolean valid = errorMessage == null;
    386                 if (!valid) {
    387                     StringBuilder message = new StringBuilder();
    388                     message.append("Input inX: ");
    389                     message.append(String.format("%14.8g {%8x} %15a",
    390                             args.inX, Float.floatToRawIntBits(args.inX), args.inX));
    391                     message.append("\n");
    392                     message.append("Output outY: ");
    393                     message.append(String.format("%d", args.outY));
    394                     message.append("\n");
    395                     message.append("Output out: ");
    396                     message.append(Float.toString(args.out));
    397                     message.append("\n");
    398                     message.append(errorMessage);
    399                     assertTrue("Incorrect output for checkLgammaFloat2Int2Float2" +
    400                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
    401                 }
    402             }
    403         }
    404     }
    405 
    406     private void checkLgammaFloat3Int3Float3() {
    407         Allocation inX = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 3, 0x6655f8088dfe3c3al, false);
    408         try {
    409             Allocation outY = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
    410             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
    411             script.set_gAllocOutY(outY);
    412             script.forEach_testLgammaFloat3Int3Float3(inX, out);
    413             verifyResultsLgammaFloat3Int3Float3(inX, outY, out, false);
    414         } catch (Exception e) {
    415             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat3Int3Float3: " + e.toString());
    416         }
    417         try {
    418             Allocation outY = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 3), INPUTSIZE);
    419             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 3), INPUTSIZE);
    420             scriptRelaxed.set_gAllocOutY(outY);
    421             scriptRelaxed.forEach_testLgammaFloat3Int3Float3(inX, out);
    422             verifyResultsLgammaFloat3Int3Float3(inX, outY, out, true);
    423         } catch (Exception e) {
    424             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat3Int3Float3: " + e.toString());
    425         }
    426     }
    427 
    428     private void verifyResultsLgammaFloat3Int3Float3(Allocation inX, Allocation outY, Allocation out, boolean relaxed) {
    429         float[] arrayInX = new float[INPUTSIZE * 4];
    430         inX.copyTo(arrayInX);
    431         int[] arrayOutY = new int[INPUTSIZE * 4];
    432         outY.copyTo(arrayOutY);
    433         float[] arrayOut = new float[INPUTSIZE * 4];
    434         out.copyTo(arrayOut);
    435         for (int i = 0; i < INPUTSIZE; i++) {
    436             for (int j = 0; j < 3 ; j++) {
    437                 // Extract the inputs.
    438                 ArgumentsFloatIntFloat args = new ArgumentsFloatIntFloat();
    439                 args.inX = arrayInX[i * 4 + j];
    440                 // Extract the outputs.
    441                 args.outY = arrayOutY[i * 4 + j];
    442                 args.out = arrayOut[i * 4 + j];
    443                 // Ask the CoreMathVerifier to validate.
    444                 Target target = new Target(relaxed);
    445                 String errorMessage = CoreMathVerifier.verifyLgamma(args, target);
    446                 boolean valid = errorMessage == null;
    447                 if (!valid) {
    448                     StringBuilder message = new StringBuilder();
    449                     message.append("Input inX: ");
    450                     message.append(String.format("%14.8g {%8x} %15a",
    451                             args.inX, Float.floatToRawIntBits(args.inX), args.inX));
    452                     message.append("\n");
    453                     message.append("Output outY: ");
    454                     message.append(String.format("%d", args.outY));
    455                     message.append("\n");
    456                     message.append("Output out: ");
    457                     message.append(Float.toString(args.out));
    458                     message.append("\n");
    459                     message.append(errorMessage);
    460                     assertTrue("Incorrect output for checkLgammaFloat3Int3Float3" +
    461                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
    462                 }
    463             }
    464         }
    465     }
    466 
    467     private void checkLgammaFloat4Int4Float4() {
    468         Allocation inX = createRandomAllocation(mRS, Element.DataType.FLOAT_32, 4, 0x8c0c366b83b0a8f3l, false);
    469         try {
    470             Allocation outY = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
    471             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
    472             script.set_gAllocOutY(outY);
    473             script.forEach_testLgammaFloat4Int4Float4(inX, out);
    474             verifyResultsLgammaFloat4Int4Float4(inX, outY, out, false);
    475         } catch (Exception e) {
    476             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat4Int4Float4: " + e.toString());
    477         }
    478         try {
    479             Allocation outY = Allocation.createSized(mRS, getElement(mRS, Element.DataType.SIGNED_32, 4), INPUTSIZE);
    480             Allocation out = Allocation.createSized(mRS, getElement(mRS, Element.DataType.FLOAT_32, 4), INPUTSIZE);
    481             scriptRelaxed.set_gAllocOutY(outY);
    482             scriptRelaxed.forEach_testLgammaFloat4Int4Float4(inX, out);
    483             verifyResultsLgammaFloat4Int4Float4(inX, outY, out, true);
    484         } catch (Exception e) {
    485             throw new RSRuntimeException("RenderScript. Can't invoke forEach_testLgammaFloat4Int4Float4: " + e.toString());
    486         }
    487     }
    488 
    489     private void verifyResultsLgammaFloat4Int4Float4(Allocation inX, Allocation outY, Allocation out, boolean relaxed) {
    490         float[] arrayInX = new float[INPUTSIZE * 4];
    491         inX.copyTo(arrayInX);
    492         int[] arrayOutY = new int[INPUTSIZE * 4];
    493         outY.copyTo(arrayOutY);
    494         float[] arrayOut = new float[INPUTSIZE * 4];
    495         out.copyTo(arrayOut);
    496         for (int i = 0; i < INPUTSIZE; i++) {
    497             for (int j = 0; j < 4 ; j++) {
    498                 // Extract the inputs.
    499                 ArgumentsFloatIntFloat args = new ArgumentsFloatIntFloat();
    500                 args.inX = arrayInX[i * 4 + j];
    501                 // Extract the outputs.
    502                 args.outY = arrayOutY[i * 4 + j];
    503                 args.out = arrayOut[i * 4 + j];
    504                 // Ask the CoreMathVerifier to validate.
    505                 Target target = new Target(relaxed);
    506                 String errorMessage = CoreMathVerifier.verifyLgamma(args, target);
    507                 boolean valid = errorMessage == null;
    508                 if (!valid) {
    509                     StringBuilder message = new StringBuilder();
    510                     message.append("Input inX: ");
    511                     message.append(String.format("%14.8g {%8x} %15a",
    512                             args.inX, Float.floatToRawIntBits(args.inX), args.inX));
    513                     message.append("\n");
    514                     message.append("Output outY: ");
    515                     message.append(String.format("%d", args.outY));
    516                     message.append("\n");
    517                     message.append("Output out: ");
    518                     message.append(Float.toString(args.out));
    519                     message.append("\n");
    520                     message.append(errorMessage);
    521                     assertTrue("Incorrect output for checkLgammaFloat4Int4Float4" +
    522                             (relaxed ? "_relaxed" : "") + ":\n" + message.toString(), valid);
    523                 }
    524             }
    525         }
    526     }
    527 
    528     public void testLgamma() {
    529         checkLgammaFloatFloat();
    530         checkLgammaFloat2Float2();
    531         checkLgammaFloat3Float3();
    532         checkLgammaFloat4Float4();
    533         checkLgammaFloatIntFloat();
    534         checkLgammaFloat2Int2Float2();
    535         checkLgammaFloat3Int3Float3();
    536         checkLgammaFloat4Int4Float4();
    537     }
    538 }
    539