125430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams/*
26a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * Copyright (C) 2013 The Android Open Source Project
325430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams *
425430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams * Licensed under the Apache License, Version 2.0 (the "License");
525430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams * you may not use this file except in compliance with the License.
625430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams * You may obtain a copy of the License at
725430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams *
825430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams *      http://www.apache.org/licenses/LICENSE-2.0
925430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams *
1025430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams * Unless required by applicable law or agreed to in writing, software
1125430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams * distributed under the License is distributed on an "AS IS" BASIS,
1225430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1325430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams * See the License for the specific language governing permissions and
1425430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams * limitations under the License.
1525430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams */
1625430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams
1725430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Samspackage android.renderscript;
1825430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams
199c9ad3f8c218954e46aab81f9af7834cea5675caStephen Hines/**
206a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * Vector version of the basic short type.
216a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye * Provides four short fields packed.
226a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye */
23a70f416c9cf2fc6cc5e132c1d656ce07441d6b82Jason Samspublic class Short4 {
246a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public short x;
256a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public short y;
266a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public short z;
276a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public short w;
286a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
29a70f416c9cf2fc6cc5e132c1d656ce07441d6b82Jason Sams    public Short4() {
3025430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams    }
3125430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams
326a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide */
336a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public Short4(short i) {
346a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.x = this.y = this.z = this.w = i;
356cc888e77e17ac522f75bf61403307de8ace2ef3Jason Sams    }
366cc888e77e17ac522f75bf61403307de8ace2ef3Jason Sams
376a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public Short4(short x, short y, short z, short w) {
386a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.x = x;
396a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.y = y;
406a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.z = z;
416a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.w = w;
426a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
4325430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams
446a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide */
456a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public Short4(Short4 source) {
466a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.x = source.x;
476a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.y = source.y;
486a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.z = source.z;
496a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.w = source.w;
506a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
516a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
526a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
536a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * Vector add
546a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
556a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param a
566a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
576a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public void add(Short4 a) {
586a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.x += a.x;
596a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.y += a.y;
606a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.z += a.z;
616a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.w += a.w;
626a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
636a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
646a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
656a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * Vector add
666a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
676a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param a
686a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param b
696a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @return
706a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
716a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public static Short4 add(Short4 a, Short4 b) {
726a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        Short4 result = new Short4();
736a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.x = (short)(a.x + b.x);
746a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.y = (short)(a.y + b.y);
756a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.z = (short)(a.z + b.z);
766a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.w = (short)(a.w + b.w);
776a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
786a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        return result;
796a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
806a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
816a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
826a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * Vector add
836a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
846a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param value
856a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
866a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public void add(short value) {
876a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        x += value;
886a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        y += value;
896a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        z += value;
906a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        w += value;
916a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
9225430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams
936a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
946a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * Vector add
956a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
966a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param a
976a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param b
986a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @return
996a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
1006a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public static Short4 add(Short4 a, short b) {
1016a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        Short4 result = new Short4();
1026a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.x = (short)(a.x + b);
1036a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.y = (short)(a.y + b);
1046a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.z = (short)(a.z + b);
1056a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.w = (short)(a.w + b);
1066a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
1076a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        return result;
1086a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
1096a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
1106a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
1116a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * Vector subtraction
1126a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
1136a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param a
1146a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
1156a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public void sub(Short4 a) {
1166a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.x -= a.x;
1176a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.y -= a.y;
1186a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.z -= a.z;
1196a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.w -= a.w;
1206a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
1216a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
1226a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
1236a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * Vector subtraction
1246a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
1256a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param a
1266a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param b
1276a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @return
1286a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
1296a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public static Short4 sub(Short4 a, Short4 b) {
1306a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        Short4 result = new Short4();
1316a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.x = (short)(a.x - b.x);
1326a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.y = (short)(a.y - b.y);
1336a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.z = (short)(a.z - b.z);
1346a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.w = (short)(a.w - b.w);
1356a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
1366a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        return result;
1376a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
1386a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
1396a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
1406a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * Vector subtraction
1416a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
1426a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param value
1436a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
1446a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public void sub(short value) {
1456a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        x -= value;
1466a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        y -= value;
1476a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        z -= value;
1486a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        w -= value;
1496a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
1506a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
1516a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
1526a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * Vector subtraction
1536a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
1546a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param a
1556a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param b
1566a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @return
1576a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
1586a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public static Short4 sub(Short4 a, short b) {
1596a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        Short4 result = new Short4();
1606a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.x = (short)(a.x - b);
1616a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.y = (short)(a.y - b);
1626a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.z = (short)(a.z - b);
1636a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.w = (short)(a.w - b);
1646a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
1656a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        return result;
1666a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
1676a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
1686a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
1696a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * Vector multiplication
1706a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
1716a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param a
1726a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
1736a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public void mul(Short4 a) {
1746a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.x *= a.x;
1756a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.y *= a.y;
1766a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.z *= a.z;
1776a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.w *= a.w;
1786a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
1796a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
1806a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
1816a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * Vector multiplication
1826a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
1836a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param a
1846a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param b
1856a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @return
1866a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
1876a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public static Short4 mul(Short4 a, Short4 b) {
1886a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        Short4 result = new Short4();
1896a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.x = (short)(a.x * b.x);
1906a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.y = (short)(a.y * b.y);
1916a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.z = (short)(a.z * b.z);
1926a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.w = (short)(a.w * b.w);
1936a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
1946a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        return result;
1956a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
1966a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
1976a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
1986a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * Vector multiplication
1996a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
2006a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param value
2016a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
2026a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public void mul(short value) {
2036a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        x *= value;
2046a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        y *= value;
2056a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        z *= value;
2066a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        w *= value;
2076a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
2086a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
2096a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
2106a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * Vector multiplication
2116a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
2126a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param a
2136a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param b
2146a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @return
2156a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
2166a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public static Short4 mul(Short4 a, short b) {
2176a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        Short4 result = new Short4();
2186a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.x = (short)(a.x * b);
2196a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.y = (short)(a.y * b);
2206a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.z = (short)(a.z * b);
2216a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.w = (short)(a.w * b);
2226a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
2236a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        return result;
2246a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
22525430d0734d12d12ca2d2d7a9d18c0cf3c5bdc4eJason Sams
2266a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
2276a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * Vector division
2286a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
2296a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param a
2306a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
2316a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public void div(Short4 a) {
2326a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.x /= a.x;
2336a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.y /= a.y;
2346a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.z /= a.z;
2356a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.w /= a.w;
2366a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
2376a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
2386a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
2396a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * Vector division
2406a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
2416a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param a
2426a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param b
2436a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @return
2446a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
2456a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public static Short4 div(Short4 a, Short4 b) {
2466a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        Short4 result = new Short4();
2476a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.x = (short)(a.x / b.x);
2486a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.y = (short)(a.y / b.y);
2496a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.z = (short)(a.z / b.z);
2506a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.w = (short)(a.w / b.w);
2516a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
2526a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        return result;
2536a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
2546a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
2556a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
2566a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * Vector division
2576a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
2586a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param value
2596a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
2606a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public void div(short value) {
2616a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        x /= value;
2626a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        y /= value;
2636a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        z /= value;
2646a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        w /= value;
2656a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
2666a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
2676a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
2686a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * Vector division
2696a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
2706a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param a
2716a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param b
2726a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @return
2736a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
2746a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public static Short4 div(Short4 a, short b) {
2756a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        Short4 result = new Short4();
2766a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.x = (short)(a.x / b);
2776a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.y = (short)(a.y / b);
2786a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.z = (short)(a.z / b);
2796a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.w = (short)(a.w / b);
2806a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
2816a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        return result;
2826a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
2836a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
2846a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
2856a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * Vector Modulo
2866a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
2876a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param a
2886a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
2896a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public void mod(Short4 a) {
2906a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.x %= a.x;
2916a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.y %= a.y;
2926a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.z %= a.z;
2936a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.w %= a.w;
2946a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
2956a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
2966a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
2976a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * Vector Modulo
2986a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
2996a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param a
3006a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param b
3016a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @return
3026a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
3036a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public static Short4 mod(Short4 a, Short4 b) {
3046a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        Short4 result = new Short4();
3056a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.x = (short)(a.x % b.x);
3066a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.y = (short)(a.y % b.y);
3076a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.z = (short)(a.z % b.z);
3086a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.w = (short)(a.w % b.w);
3096a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
3106a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        return result;
3116a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
3126a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
3136a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
3146a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * Vector Modulo
3156a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
3166a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param value
3176a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
3186a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public void mod(short value) {
3196a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        x %= value;
3206a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        y %= value;
3216a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        z %= value;
3226a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        w %= value;
3236a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
3246a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
3256a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
3266a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * Vector Modulo
3276a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
3286a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param a
3296a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param b
3306a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @return
3316a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
3326a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public static Short4 mod(Short4 a, short b) {
3336a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        Short4 result = new Short4();
3346a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.x = (short)(a.x % b);
3356a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.y = (short)(a.y % b);
3366a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.z = (short)(a.z % b);
3376a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        result.w = (short)(a.w % b);
3386a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
3396a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        return result;
3406a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
3416a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
3426a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
3436a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * get vector length
3446a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
3456a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @return
3466a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
3476a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public short length() {
3486a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        return 4;
3496a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
3506a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
3516a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
3526a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * set vector negate
3536a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
3546a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public void negate() {
3556a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.x = (short)(-x);
3566a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.y = (short)(-y);
3576a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.z = (short)(-z);
3586a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.w = (short)(-w);
3596a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
3606a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
3616a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
3626a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * Vector dot Product
3636a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
3646a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param a
3656a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @return
3666a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
3676a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public short dotProduct(Short4 a) {
3686a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        return (short)((x * a.x) + (y * a.y) + (z * a.z) + (w * a.w));
3696a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
3706a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
3716a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
3726a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * Vector dot Product
3736a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
3746a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param a
3756a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param b
3766a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @return
3776a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
3786a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public static short dotProduct(Short4 a, Short4 b) {
3796a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        return (short)((b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w));
3806a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
3816a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
3826a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
3836a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * Vector add Multiple
3846a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
3856a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param a
3866a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param factor
3876a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
3886a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public void addMultiple(Short4 a, short factor) {
3896a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        x += a.x * factor;
3906a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        y += a.y * factor;
3916a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        z += a.z * factor;
3926a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        w += a.w * factor;
3936a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
3946a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
3956a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
3966a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * set vector value by Short4
3976a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
3986a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param a
3996a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
4006a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public void set(Short4 a) {
4016a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.x = a.x;
4026a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.y = a.y;
4036a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.z = a.z;
4046a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.w = a.w;
4056a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
4066a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
4076a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
4086a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * set the vector field value by Short
4096a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
4106a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param a
4116a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param b
4126a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param c
4136a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param d
4146a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
4156a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public void setValues(short a, short b, short c, short d) {
4166a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.x = a;
4176a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.y = b;
4186a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.z = c;
4196a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        this.w = d;
4206a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
4216a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
4226a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
4236a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * return the element sum of vector
4246a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
4256a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @return
4266a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
4276a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public short elementSum() {
4286a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        return (short)(x + y + z + w);
4296a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
4306a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
4316a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
4326a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * get the vector field value by index
4336a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
4346a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param i
4356a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @return
4366a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
4376a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public short get(int i) {
4386a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        switch (i) {
4396a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        case 0:
4406a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye            return (short)(x);
4416a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        case 1:
4426a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye            return (short)(y);
4436a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        case 2:
4446a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye            return (short)(z);
4456a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        case 3:
4466a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye            return (short)(w);
4476a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        default:
4486a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye            throw new IndexOutOfBoundsException("Index: i");
4496a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        }
4506a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
4516a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
4526a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
4536a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * set the vector field value by index
4546a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
4556a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param i
4566a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param value
4576a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
4586a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public void setAt(int i, short value) {
4596a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        switch (i) {
4606a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        case 0:
4616a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye            x = value;
4626a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye            return;
4636a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        case 1:
4646a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye            y = value;
4656a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye            return;
4666a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        case 2:
4676a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye            z = value;
4686a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye            return;
4696a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        case 3:
4706a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye            w = value;
4716a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye            return;
4726a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        default:
4736a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye            throw new IndexOutOfBoundsException("Index: i");
4746a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        }
4756a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
4766a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
4776a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
4786a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * add the vector field value by index
4796a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
4806a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param i
4816a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param value
4826a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
4836a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public void addAt(int i, short value) {
4846a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        switch (i) {
4856a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        case 0:
4866a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye            x += value;
4876a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye            return;
4886a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        case 1:
4896a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye            y += value;
4906a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye            return;
4916a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        case 2:
4926a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye            z += value;
4936a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye            return;
4946a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        case 3:
4956a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye            w += value;
4966a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye            return;
4976a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        default:
4986a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye            throw new IndexOutOfBoundsException("Index: i");
4996a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        }
5006a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
5016a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye
5026a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    /** @hide
5036a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * copy the vector to short array
5046a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     *
5056a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param data
5066a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     * @param offset
5076a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye     */
5086a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    public void copyTo(short[] data, int offset) {
5096a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        data[offset] = (short)(x);
5106a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        data[offset + 1] = (short)(y);
5116a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        data[offset + 2] = (short)(z);
5126a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye        data[offset + 3] = (short)(w);
5136a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye    }
5146a5875cf96a6eebf4ef2e176176868ecbf17122fMatthieu Delahaye}
515