ScriptC_reduce_general_examples.java.expect revision 1381ae7c081ab151e78184501f757f517fe6c2a9
1/*
2 * Copyright (C) 2011-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/*
18 * This file is auto-generated. DO NOT MODIFY!
19 * The source Renderscript file: reduce_general_examples.rs
20 */
21
22package examples;
23
24import android.renderscript.*;
25import examples.reduce_general_examplesBitCode;
26
27/**
28 * @hide
29 */
30public class ScriptC_reduce_general_examples extends ScriptC {
31    private static final String __rs_resource_name = "reduce_general_examples";
32    // Constructor
33    public  ScriptC_reduce_general_examples(RenderScript rs) {
34        super(rs,
35              __rs_resource_name,
36              reduce_general_examplesBitCode.getBitCode32(),
37              reduce_general_examplesBitCode.getBitCode64());
38        mRSLocal = rs;
39        __I32 = Element.I32(rs);
40        __F32 = Element.F32(rs);
41        __I32_2 = Element.I32_2(rs);
42        __U32 = Element.U32(rs);
43        __U8 = Element.U8(rs);
44    }
45
46    private Element __F32;
47    private Element __I32;
48    private Element __I32_2;
49    private Element __U32;
50    private Element __U8;
51    private RenderScript mRSLocal;
52    // To obtain the result, invoke get(), which blocks
53    // until the asynchronously-launched operation has completed.
54    public static class resultArray256_uint {
55        public long[] get() {
56            int[] outArray = new int[256];
57            mOut.copyTo(outArray);
58            long[] result = new long[256];
59            for (int Idx = 0; Idx < 256; ++Idx) {
60                result[Idx] = ((long) ((outArray[Idx]) & 0xffffffffL));
61            }
62
63            return result;
64        }
65
66        private  resultArray256_uint(Allocation out) {
67            mOut = out;
68        }
69
70        private Allocation mOut;
71    }
72
73    // To obtain the result, invoke get(), which blocks
74    // until the asynchronously-launched operation has completed.
75    public static class result_float {
76        public float get() {
77            float[] outArray = new float[1];
78            mOut.copyTo(outArray);
79            return outArray[0];
80        }
81
82        private  result_float(Allocation out) {
83            mOut = out;
84        }
85
86        private Allocation mOut;
87    }
88
89    // To obtain the result, invoke get(), which blocks
90    // until the asynchronously-launched operation has completed.
91    public static class result_int {
92        public int get() {
93            int[] outArray = new int[1];
94            mOut.copyTo(outArray);
95            return outArray[0];
96        }
97
98        private  result_int(Allocation out) {
99            mOut = out;
100        }
101
102        private Allocation mOut;
103    }
104
105    // To obtain the result, invoke get(), which blocks
106    // until the asynchronously-launched operation has completed.
107    public static class result_int2 {
108        public Int2 get() {
109            int[] outArray = new int[2];
110            mOut.copyTo(outArray);
111            return new Int2(outArray[0], outArray[1]);
112        }
113
114        private  result_int2(Allocation out) {
115            mOut = out;
116        }
117
118        private Allocation mOut;
119    }
120
121    private final static int mExportReduceNewIdx_addint = 0;
122    // in1 = "val"
123    public result_int reduce_addint(int[] in1) {
124        // Verify that "in1" is non-null.
125        if (in1 == null) {
126            throw new RSIllegalArgumentException("Array \"in1\" is null!");
127        }
128        Allocation ain1 = Allocation.createSized(mRSLocal, __I32, in1.length);
129        ain1.setAutoPadding(true);
130        ain1.copyFrom(in1);
131
132        return reduce_addint(ain1, null);
133    }
134
135    // ain1 = "int val"
136    public result_int reduce_addint(Allocation ain1) {
137        return reduce_addint(ain1, null);
138    }
139
140    // ain1 = "int val"
141    public result_int reduce_addint(Allocation ain1, Script.LaunchOptions sc) {
142        // check ain1
143        if (!ain1.getType().getElement().isCompatible(__I32)) {
144            throw new RSRuntimeException("Type mismatch with I32!");
145        }
146        Allocation aout = Allocation.createSized(mRSLocal, __I32, 1);
147        aout.setAutoPadding(true);
148        reduce(mExportReduceNewIdx_addint, new Allocation[]{ain1}, aout, sc);
149        return new result_int(aout);
150    }
151
152    private final static int mExportReduceNewIdx_mpyint = 1;
153    // in1 = "val"
154    public result_int reduce_mpyint(int[] in1) {
155        // Verify that "in1" is non-null.
156        if (in1 == null) {
157            throw new RSIllegalArgumentException("Array \"in1\" is null!");
158        }
159        Allocation ain1 = Allocation.createSized(mRSLocal, __I32, in1.length);
160        ain1.setAutoPadding(true);
161        ain1.copyFrom(in1);
162
163        return reduce_mpyint(ain1, null);
164    }
165
166    // ain1 = "int val"
167    public result_int reduce_mpyint(Allocation ain1) {
168        return reduce_mpyint(ain1, null);
169    }
170
171    // ain1 = "int val"
172    public result_int reduce_mpyint(Allocation ain1, Script.LaunchOptions sc) {
173        // check ain1
174        if (!ain1.getType().getElement().isCompatible(__I32)) {
175            throw new RSRuntimeException("Type mismatch with I32!");
176        }
177        Allocation aout = Allocation.createSized(mRSLocal, __I32, 1);
178        aout.setAutoPadding(true);
179        reduce(mExportReduceNewIdx_mpyint, new Allocation[]{ain1}, aout, sc);
180        return new result_int(aout);
181    }
182
183    private final static int mExportReduceNewIdx_dp = 2;
184    // in1 = "in1"
185    // in2 = "in2"
186    public result_float reduce_dp(float[] in1, float[] in2) {
187        // Verify that "in1" is non-null.
188        if (in1 == null) {
189            throw new RSIllegalArgumentException("Array \"in1\" is null!");
190        }
191        Allocation ain1 = Allocation.createSized(mRSLocal, __F32, in1.length);
192        ain1.setAutoPadding(true);
193        ain1.copyFrom(in1);
194        // Verify that "in2" is non-null.
195        if (in2 == null) {
196            throw new RSIllegalArgumentException("Array \"in2\" is null!");
197        }
198        // Verify that input array lengths are the same.
199        if (in1.length != in2.length) {
200            throw new RSRuntimeException("Array length mismatch between parameters \"in1\" and \"in2\"!");
201        }
202        Allocation ain2 = Allocation.createSized(mRSLocal, __F32, in2.length);
203        ain2.setAutoPadding(true);
204        ain2.copyFrom(in2);
205
206        return reduce_dp(ain1, ain2, null);
207    }
208
209    // ain1 = "float in1"
210    // ain2 = "float in2"
211    public result_float reduce_dp(Allocation ain1, Allocation ain2) {
212        return reduce_dp(ain1, ain2, null);
213    }
214
215    // ain1 = "float in1"
216    // ain2 = "float in2"
217    public result_float reduce_dp(Allocation ain1, Allocation ain2, Script.LaunchOptions sc) {
218        Type t0, t1;
219        // check ain1
220        if (!ain1.getType().getElement().isCompatible(__F32)) {
221            throw new RSRuntimeException("Type mismatch with F32!");
222        }
223        // check ain2
224        if (!ain2.getType().getElement().isCompatible(__F32)) {
225            throw new RSRuntimeException("Type mismatch with F32!");
226        }
227        // Verify dimensions
228        t0 = ain1.getType();
229        t1 = ain2.getType();
230        if ((t0.getCount() != t1.getCount()) ||
231            (t0.getX() != t1.getX()) ||
232            (t0.getY() != t1.getY()) ||
233            (t0.getZ() != t1.getZ()) ||
234            (t0.hasFaces()   != t1.hasFaces()) ||
235            (t0.hasMipmaps() != t1.hasMipmaps())) {
236            throw new RSRuntimeException("Dimension mismatch between parameters ain1 and ain2!");
237        }
238
239        Allocation aout = Allocation.createSized(mRSLocal, __F32, 1);
240        aout.setAutoPadding(true);
241        reduce(mExportReduceNewIdx_dp, new Allocation[]{ain1, ain2}, aout, sc);
242        return new result_float(aout);
243    }
244
245    private final static int mExportReduceNewIdx_findMinAndMax = 3;
246    // in1 = "in"
247    public result_int2 reduce_findMinAndMax(float[] in1) {
248        // Verify that "in1" is non-null.
249        if (in1 == null) {
250            throw new RSIllegalArgumentException("Array \"in1\" is null!");
251        }
252        Allocation ain1 = Allocation.createSized(mRSLocal, __F32, in1.length);
253        ain1.setAutoPadding(true);
254        ain1.copyFrom(in1);
255
256        return reduce_findMinAndMax(ain1, null);
257    }
258
259    // ain1 = "float in"
260    public result_int2 reduce_findMinAndMax(Allocation ain1) {
261        return reduce_findMinAndMax(ain1, null);
262    }
263
264    // ain1 = "float in"
265    public result_int2 reduce_findMinAndMax(Allocation ain1, Script.LaunchOptions sc) {
266        // check ain1
267        if (!ain1.getType().getElement().isCompatible(__F32)) {
268            throw new RSRuntimeException("Type mismatch with F32!");
269        }
270        Allocation aout = Allocation.createSized(mRSLocal, __I32_2, 1);
271        aout.setAutoPadding(true);
272        reduce(mExportReduceNewIdx_findMinAndMax, new Allocation[]{ain1}, aout, sc);
273        return new result_int2(aout);
274    }
275
276    private final static int mExportReduceNewIdx_fz = 4;
277    // in1 = "inVal"
278    public result_int reduce_fz(int[] in1) {
279        // Verify that "in1" is non-null.
280        if (in1 == null) {
281            throw new RSIllegalArgumentException("Array \"in1\" is null!");
282        }
283        Allocation ain1 = Allocation.createSized(mRSLocal, __I32, in1.length);
284        ain1.setAutoPadding(true);
285        ain1.copyFrom(in1);
286
287        return reduce_fz(ain1, null);
288    }
289
290    // ain1 = "int inVal"
291    public result_int reduce_fz(Allocation ain1) {
292        return reduce_fz(ain1, null);
293    }
294
295    // ain1 = "int inVal"
296    public result_int reduce_fz(Allocation ain1, Script.LaunchOptions sc) {
297        // check ain1
298        if (!ain1.getType().getElement().isCompatible(__I32)) {
299            throw new RSRuntimeException("Type mismatch with I32!");
300        }
301        Allocation aout = Allocation.createSized(mRSLocal, __I32, 1);
302        aout.setAutoPadding(true);
303        reduce(mExportReduceNewIdx_fz, new Allocation[]{ain1}, aout, sc);
304        return new result_int(aout);
305    }
306
307    private final static int mExportReduceNewIdx_fz2 = 5;
308    // in1 = "inVal"
309    public result_int2 reduce_fz2(int[] in1) {
310        // Verify that "in1" is non-null.
311        if (in1 == null) {
312            throw new RSIllegalArgumentException("Array \"in1\" is null!");
313        }
314        Allocation ain1 = Allocation.createSized(mRSLocal, __I32, in1.length);
315        ain1.setAutoPadding(true);
316        ain1.copyFrom(in1);
317
318        return reduce_fz2(ain1, null);
319    }
320
321    // ain1 = "int inVal"
322    public result_int2 reduce_fz2(Allocation ain1) {
323        return reduce_fz2(ain1, null);
324    }
325
326    // ain1 = "int inVal"
327    public result_int2 reduce_fz2(Allocation ain1, Script.LaunchOptions sc) {
328        // check ain1
329        if (!ain1.getType().getElement().isCompatible(__I32)) {
330            throw new RSRuntimeException("Type mismatch with I32!");
331        }
332        Allocation aout = Allocation.createSized(mRSLocal, __I32_2, 1);
333        aout.setAutoPadding(true);
334        reduce(mExportReduceNewIdx_fz2, new Allocation[]{ain1}, aout, sc);
335        return new result_int2(aout);
336    }
337
338    private final static int mExportReduceNewIdx_histogram = 6;
339    // in1 = "in"
340    public resultArray256_uint reduce_histogram(byte[] in1) {
341        // Verify that "in1" is non-null.
342        if (in1 == null) {
343            throw new RSIllegalArgumentException("Array \"in1\" is null!");
344        }
345        Allocation ain1 = Allocation.createSized(mRSLocal, __U8, in1.length);
346        ain1.setAutoPadding(true);
347        ain1.copyFrom(in1);
348
349        return reduce_histogram(ain1, null);
350    }
351
352    // ain1 = "uchar in"
353    public resultArray256_uint reduce_histogram(Allocation ain1) {
354        return reduce_histogram(ain1, null);
355    }
356
357    // ain1 = "uchar in"
358    public resultArray256_uint reduce_histogram(Allocation ain1, Script.LaunchOptions sc) {
359        // check ain1
360        if (!ain1.getType().getElement().isCompatible(__U8)) {
361            throw new RSRuntimeException("Type mismatch with U8!");
362        }
363        Allocation aout = Allocation.createSized(mRSLocal, __U32, 256);
364        aout.setAutoPadding(true);
365        reduce(mExportReduceNewIdx_histogram, new Allocation[]{ain1}, aout, sc);
366        return new resultArray256_uint(aout);
367    }
368
369    private final static int mExportReduceNewIdx_mode = 7;
370    // in1 = "in"
371    public result_int2 reduce_mode(byte[] in1) {
372        // Verify that "in1" is non-null.
373        if (in1 == null) {
374            throw new RSIllegalArgumentException("Array \"in1\" is null!");
375        }
376        Allocation ain1 = Allocation.createSized(mRSLocal, __U8, in1.length);
377        ain1.setAutoPadding(true);
378        ain1.copyFrom(in1);
379
380        return reduce_mode(ain1, null);
381    }
382
383    // ain1 = "uchar in"
384    public result_int2 reduce_mode(Allocation ain1) {
385        return reduce_mode(ain1, null);
386    }
387
388    // ain1 = "uchar in"
389    public result_int2 reduce_mode(Allocation ain1, Script.LaunchOptions sc) {
390        // check ain1
391        if (!ain1.getType().getElement().isCompatible(__U8)) {
392            throw new RSRuntimeException("Type mismatch with U8!");
393        }
394        Allocation aout = Allocation.createSized(mRSLocal, __I32_2, 1);
395        aout.setAutoPadding(true);
396        reduce(mExportReduceNewIdx_mode, new Allocation[]{ain1}, aout, sc);
397        return new result_int2(aout);
398    }
399
400}
401
402