diff --git a/graphics/java/android/renderscript/Byte2.java b/graphics/java/android/renderscript/Byte2.java
index cf34f3a..f796de3 100644
--- a/graphics/java/android/renderscript/Byte2.java
+++ b/graphics/java/android/renderscript/Byte2.java
@@ -25,6 +25,9 @@
  *
  **/
 public class Byte2 {
+    public byte x;
+    public byte y;
+
     public Byte2() {
     }
 
@@ -33,8 +36,357 @@
         y = initY;
     }
 
-    public byte x;
-    public byte y;
+    /** @hide */
+    public Byte2(Byte2 source) {
+        this.x = source.x;
+        this.y = source.y;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     */
+    public void add(Byte2 a) {
+        this.x += a.x;
+        this.y += a.y;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Byte2 add(Byte2 a, Byte2 b) {
+        Byte2 result = new Byte2();
+        result.x = (byte)(a.x + b.x);
+        result.y = (byte)(a.y + b.y);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param value
+     */
+    public void add(byte value) {
+        x += value;
+        y += value;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Byte2 add(Byte2 a, byte b) {
+        Byte2 result = new Byte2();
+        result.x = (byte)(a.x + b);
+        result.y = (byte)(a.y + b);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     */
+    public void sub(Byte2 a) {
+        this.x -= a.x;
+        this.y -= a.y;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Byte2 sub(Byte2 a, Byte2 b) {
+        Byte2 result = new Byte2();
+        result.x = (byte)(a.x - b.x);
+        result.y = (byte)(a.y - b.y);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param value
+     */
+    public void sub(byte value) {
+        x -= value;
+        y -= value;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Byte2 sub(Byte2 a, byte b) {
+        Byte2 result = new Byte2();
+        result.x = (byte)(a.x - b);
+        result.y = (byte)(a.y - b);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     */
+    public void mul(Byte2 a) {
+        this.x *= a.x;
+        this.y *= a.y;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Byte2 mul(Byte2 a, Byte2 b) {
+        Byte2 result = new Byte2();
+        result.x = (byte)(a.x * b.x);
+        result.y = (byte)(a.y * b.y);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param value
+     */
+    public void mul(byte value) {
+        x *= value;
+        y *= value;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Byte2 mul(Byte2 a, byte b) {
+        Byte2 result = new Byte2();
+        result.x = (byte)(a.x * b);
+        result.y = (byte)(a.y * b);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     */
+    public void div(Byte2 a) {
+        this.x /= a.x;
+        this.y /= a.y;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Byte2 div(Byte2 a, Byte2 b) {
+        Byte2 result = new Byte2();
+        result.x = (byte)(a.x / b.x);
+        result.y = (byte)(a.y / b.y);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param value
+     */
+    public void div(byte value) {
+        x /= value;
+        y /= value;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Byte2 div(Byte2 a, byte b) {
+        Byte2 result = new Byte2();
+        result.x = (byte)(a.x / b);
+        result.y = (byte)(a.y / b);
+
+        return result;
+    }
+
+    /** @hide
+     * get vector length
+     *
+     * @return
+     */
+    public byte length() {
+        return 2;
+    }
+
+    /** @hide
+     * set vector negate
+     */
+    public void negate() {
+        this.x = (byte)(-x);
+        this.y = (byte)(-y);
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @return
+     */
+    public byte dotProduct(Byte2 a) {
+        return (byte)((x * a.x) + (y * a.y));
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static byte dotProduct(Byte2 a, Byte2 b) {
+        return (byte)((b.x * a.x) + (b.y * a.y));
+    }
+
+    /** @hide
+     * Vector add Multiple
+     *
+     * @param a
+     * @param factor
+     */
+    public void addMultiple(Byte2 a, byte factor) {
+        x += a.x * factor;
+        y += a.y * factor;
+    }
+
+    /** @hide
+     * set vector value by Byte2
+     *
+     * @param a
+     */
+    public void set(Byte2 a) {
+        this.x = a.x;
+        this.y = a.y;
+    }
+
+    /** @hide
+     * set the vector field value by Char
+     *
+     * @param a
+     * @param b
+     */
+    public void setValues(byte a, byte b) {
+        this.x = a;
+        this.y = b;
+    }
+
+    /** @hide
+     * return the element sum of vector
+     *
+     * @return
+     */
+    public byte elementSum() {
+        return (byte)(x + y);
+    }
+
+    /** @hide
+     * get the vector field value by index
+     *
+     * @param i
+     * @return
+     */
+    public byte get(int i) {
+        switch (i) {
+        case 0:
+            return x;
+        case 1:
+            return y;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * set the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void setAt(int i, byte value) {
+        switch (i) {
+        case 0:
+            x = value;
+            return;
+        case 1:
+            y = value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * add the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void addAt(int i, byte value) {
+        switch (i) {
+        case 0:
+            x += value;
+            return;
+        case 1:
+            y += value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * copy the vector to Char array
+     *
+     * @param data
+     * @param offset
+     */
+    public void copyTo(byte[] data, int offset) {
+        data[offset] = x;
+        data[offset + 1] = y;
+    }
+
 }
 
 
diff --git a/graphics/java/android/renderscript/Byte3.java b/graphics/java/android/renderscript/Byte3.java
index 266e94d..f2a95ac 100644
--- a/graphics/java/android/renderscript/Byte3.java
+++ b/graphics/java/android/renderscript/Byte3.java
@@ -25,6 +25,10 @@
  *
  **/
 public class Byte3 {
+    public byte x;
+    public byte y;
+    public byte z;
+
     public Byte3() {
     }
 
@@ -34,9 +38,387 @@
         z = initZ;
     }
 
-    public byte x;
-    public byte y;
-    public byte z;
+    /** @hide */
+    public Byte3(Byte3 source) {
+        this.x = source.x;
+        this.y = source.y;
+        this.z = source.z;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     */
+    public void add(Byte3 a) {
+        this.x += a.x;
+        this.y += a.y;
+        this.z += a.z;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Byte3 add(Byte3 a, Byte3 b) {
+        Byte3 result = new Byte3();
+        result.x = (byte)(a.x + b.x);
+        result.y = (byte)(a.y + b.y);
+        result.z = (byte)(a.z + b.z);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param value
+     */
+    public void add(byte value) {
+        x += value;
+        y += value;
+        z += value;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Byte3 add(Byte3 a, byte b) {
+        Byte3 result = new Byte3();
+        result.x = (byte)(a.x + b);
+        result.y = (byte)(a.y + b);
+        result.z = (byte)(a.z + b);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     */
+    public void sub(Byte3 a) {
+        this.x -= a.x;
+        this.y -= a.y;
+        this.z -= a.z;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Byte3 sub(Byte3 a, Byte3 b) {
+        Byte3 result = new Byte3();
+        result.x = (byte)(a.x - b.x);
+        result.y = (byte)(a.y - b.y);
+        result.z = (byte)(a.z - b.z);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param value
+     */
+    public void sub(byte value) {
+        x -= value;
+        y -= value;
+        z -= value;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Byte3 sub(Byte3 a, byte b) {
+        Byte3 result = new Byte3();
+        result.x = (byte)(a.x - b);
+        result.y = (byte)(a.y - b);
+        result.z = (byte)(a.z - b);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     */
+    public void mul(Byte3 a) {
+        this.x *= a.x;
+        this.y *= a.y;
+        this.z *= a.z;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Byte3 mul(Byte3 a, Byte3 b) {
+        Byte3 result = new Byte3();
+        result.x = (byte)(a.x * b.x);
+        result.y = (byte)(a.y * b.y);
+        result.z = (byte)(a.z * b.z);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param value
+     */
+    public void mul(byte value) {
+        x *= value;
+        y *= value;
+        z *= value;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Byte3 mul(Byte3 a, byte b) {
+        Byte3 result = new Byte3();
+        result.x = (byte)(a.x * b);
+        result.y = (byte)(a.y * b);
+        result.z = (byte)(a.z * b);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     */
+    public void div(Byte3 a) {
+        this.x /= a.x;
+        this.y /= a.y;
+        this.z /= a.z;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Byte3 div(Byte3 a, Byte3 b) {
+        Byte3 result = new Byte3();
+        result.x = (byte)(a.x / b.x);
+        result.y = (byte)(a.y / b.y);
+        result.z = (byte)(a.z / b.z);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param value
+     */
+    public void div(byte value) {
+        x /= value;
+        y /= value;
+        z /= value;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Byte3 div(Byte3 a, byte b) {
+        Byte3 result = new Byte3();
+        result.x = (byte)(a.x / b);
+        result.y = (byte)(a.y / b);
+        result.z = (byte)(a.z / b);
+
+        return result;
+    }
+
+    /** @hide
+     * get vector length
+     *
+     * @return
+     */
+    public byte length() {
+        return 3;
+    }
+
+    /** @hide
+     * set vector negate
+     */
+    public void negate() {
+        this.x = (byte)(-x);
+        this.y = (byte)(-y);
+        this.z = (byte)(-z);
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @return
+     */
+    public byte dotProduct(Byte3 a) {
+        return (byte)((byte)((byte)(x * a.x) + (byte)(y * a.y)) + (byte)(z * a.z));
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static byte dotProduct(Byte3 a, Byte3 b) {
+        return (byte)((byte)((byte)(b.x * a.x) + (byte)(b.y * a.y)) + (byte)(b.z * a.z));
+    }
+
+    /** @hide
+     * Vector add Multiple
+     *
+     * @param a
+     * @param factor
+     */
+    public void addMultiple(Byte3 a, byte factor) {
+        x += a.x * factor;
+        y += a.y * factor;
+        z += a.z * factor;
+    }
+
+    /** @hide
+     * set vector value by Byte3
+     *
+     * @param a
+     */
+    public void set(Byte3 a) {
+        this.x = a.x;
+        this.y = a.y;
+        this.z = a.z;
+    }
+
+    /** @hide
+     * set the vector field value by Char
+     *
+     * @param a
+     * @param b
+     * @param c
+     */
+    public void setValues(byte a, byte b, byte c) {
+        this.x = a;
+        this.y = b;
+        this.z = c;
+    }
+
+    /** @hide
+     * return the element sum of vector
+     *
+     * @return
+     */
+    public byte elementSum() {
+        return (byte)(x + y + z);
+    }
+
+    /** @hide
+     * get the vector field value by index
+     *
+     * @param i
+     * @return
+     */
+    public byte get(int i) {
+        switch (i) {
+        case 0:
+            return x;
+        case 1:
+            return y;
+        case 2:
+            return z;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * set the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void setAt(int i, byte value) {
+        switch (i) {
+        case 0:
+            x = value;
+            return;
+        case 1:
+            y = value;
+            return;
+        case 2:
+            z = value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * add the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void addAt(int i, byte value) {
+        switch (i) {
+        case 0:
+            x += value;
+            return;
+        case 1:
+            y += value;
+            return;
+        case 2:
+            z += value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * copy the vector to Char array
+     *
+     * @param data
+     * @param offset
+     */
+    public void copyTo(byte[] data, int offset) {
+        data[offset] = x;
+        data[offset + 1] = y;
+        data[offset + 2] = z;
+    }
 }
 
 
diff --git a/graphics/java/android/renderscript/Byte4.java b/graphics/java/android/renderscript/Byte4.java
index 68c8f52..b8a8a6b 100644
--- a/graphics/java/android/renderscript/Byte4.java
+++ b/graphics/java/android/renderscript/Byte4.java
@@ -25,6 +25,11 @@
  *
  **/
 public class Byte4 {
+    public byte x;
+    public byte y;
+    public byte z;
+    public byte w;
+
     public Byte4() {
     }
 
@@ -34,11 +39,418 @@
         z = initZ;
         w = initW;
     }
+    /** @hide */
+    public Byte4(Byte4 source) {
+        this.x = source.x;
+        this.y = source.y;
+        this.z = source.z;
+        this.w = source.w;
+    }
 
-    public byte x;
-    public byte y;
-    public byte z;
-    public byte w;
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     */
+    public void add(Byte4 a) {
+        this.x += a.x;
+        this.y += a.y;
+        this.z += a.z;
+        this.w += a.w;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Byte4 add(Byte4 a, Byte4 b) {
+        Byte4 result = new Byte4();
+        result.x = (byte)(a.x + b.x);
+        result.y = (byte)(a.y + b.y);
+        result.z = (byte)(a.z + b.z);
+        result.w = (byte)(a.w + b.w);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param value
+     */
+    public void add(byte value) {
+        x += value;
+        y += value;
+        z += value;
+        w += value;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Byte4 add(Byte4 a, byte b) {
+        Byte4 result = new Byte4();
+        result.x = (byte)(a.x + b);
+        result.y = (byte)(a.y + b);
+        result.z = (byte)(a.z + b);
+        result.w = (byte)(a.w + b);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     */
+    public void sub(Byte4 a) {
+        this.x -= a.x;
+        this.y -= a.y;
+        this.z -= a.z;
+        this.w -= a.w;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Byte4 sub(Byte4 a, Byte4 b) {
+        Byte4 result = new Byte4();
+        result.x = (byte)(a.x - b.x);
+        result.y = (byte)(a.y - b.y);
+        result.z = (byte)(a.z - b.z);
+        result.w = (byte)(a.w - b.w);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param value
+     */
+    public void sub(byte value) {
+        x -= value;
+        y -= value;
+        z -= value;
+        w -= value;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Byte4 sub(Byte4 a, byte b) {
+        Byte4 result = new Byte4();
+        result.x = (byte)(a.x - b);
+        result.y = (byte)(a.y - b);
+        result.z = (byte)(a.z - b);
+        result.w = (byte)(a.w - b);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     */
+    public void mul(Byte4 a) {
+        this.x *= a.x;
+        this.y *= a.y;
+        this.z *= a.z;
+        this.w *= a.w;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Byte4 mul(Byte4 a, Byte4 b) {
+        Byte4 result = new Byte4();
+        result.x = (byte)(a.x * b.x);
+        result.y = (byte)(a.y * b.y);
+        result.z = (byte)(a.z * b.z);
+        result.w = (byte)(a.w * b.w);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param value
+     */
+    public void mul(byte value) {
+        x *= value;
+        y *= value;
+        z *= value;
+        w *= value;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Byte4 mul(Byte4 a, byte b) {
+        Byte4 result = new Byte4();
+        result.x = (byte)(a.x * b);
+        result.y = (byte)(a.y * b);
+        result.z = (byte)(a.z * b);
+        result.w = (byte)(a.w * b);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     */
+    public void div(Byte4 a) {
+        this.x /= a.x;
+        this.y /= a.y;
+        this.z /= a.z;
+        this.w /= a.w;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Byte4 div(Byte4 a, Byte4 b) {
+        Byte4 result = new Byte4();
+        result.x = (byte)(a.x / b.x);
+        result.y = (byte)(a.y / b.y);
+        result.z = (byte)(a.z / b.z);
+        result.w = (byte)(a.w / b.w);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param value
+     */
+    public void div(byte value) {
+        x /= value;
+        y /= value;
+        z /= value;
+        w /= value;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Byte4 div(Byte4 a, byte b) {
+        Byte4 result = new Byte4();
+        result.x = (byte)(a.x / b);
+        result.y = (byte)(a.y / b);
+        result.z = (byte)(a.z / b);
+        result.w = (byte)(a.w / b);
+
+        return result;
+    }
+
+    /** @hide
+     * get vector length
+     *
+     * @return
+     */
+    public byte length() {
+        return 4;
+    }
+
+    /** @hide
+     * set vector negate
+     */
+    public void negate() {
+        this.x = (byte)(-x);
+        this.y = (byte)(-y);
+        this.z = (byte)(-z);
+        this.w = (byte)(-w);
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @return
+     */
+    public byte dotProduct(Byte4 a) {
+        return (byte)((x * a.x) + (y * a.y) + (z * a.z) + (w * a.w));
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static byte dotProduct(Byte4 a, Byte4 b) {
+        return (byte)((b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w));
+    }
+
+    /** @hide
+     * Vector add Multiple
+     *
+     * @param a
+     * @param factor
+     */
+    public void addMultiple(Byte4 a, byte factor) {
+        x += a.x * factor;
+        y += a.y * factor;
+        z += a.z * factor;
+        w += a.w * factor;
+    }
+
+    /** @hide
+     * set vector value by Byte4
+     *
+     * @param a
+     */
+    public void set(Byte4 a) {
+        this.x = a.x;
+        this.y = a.y;
+        this.z = a.z;
+        this.w = a.w;
+    }
+
+    /** @hide
+     * set the vector field values
+     *
+     * @param a
+     * @param b
+     * @param c
+     * @param d
+     */
+    public void setValues(byte a, byte b, byte c, byte d) {
+        this.x = a;
+        this.y = b;
+        this.z = c;
+        this.w = d;
+    }
+
+    /** @hide
+     * return the element sum of vector
+     *
+     * @return
+     */
+    public byte elementSum() {
+        return (byte)(x + y + z + w);
+    }
+
+    /** @hide
+     * get the vector field value by index
+     *
+     * @param i
+     * @return
+     */
+    public byte get(int i) {
+        switch (i) {
+        case 0:
+            return x;
+        case 1:
+            return y;
+        case 2:
+            return z;
+        case 3:
+            return w;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * set the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void setAt(int i, byte value) {
+        switch (i) {
+        case 0:
+            x = value;
+            return;
+        case 1:
+            y = value;
+            return;
+        case 2:
+            z = value;
+            return;
+        case 3:
+            w = value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * add the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void addAt(int i, byte value) {
+        switch (i) {
+        case 0:
+            x += value;
+            return;
+        case 1:
+            y += value;
+            return;
+        case 2:
+            z += value;
+            return;
+        case 3:
+            w += value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * copy the vector to Char array
+     *
+     * @param data
+     * @param offset
+     */
+    public void copyTo(byte[] data, int offset) {
+        data[offset] = x;
+        data[offset + 1] = y;
+        data[offset + 2] = z;
+        data[offset + 3] = w;
+    }
 }
 
 
diff --git a/graphics/java/android/renderscript/Double2.java b/graphics/java/android/renderscript/Double2.java
index 29fd515..4c7319d 100644
--- a/graphics/java/android/renderscript/Double2.java
+++ b/graphics/java/android/renderscript/Double2.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,28 +16,370 @@
 
 package android.renderscript;
 
-import java.lang.Math;
-import android.util.Log;
-
-
 /**
- * Class for exposing the native RenderScript double2 type back
- * to the Android system.
- *
- **/
+ * Vector version of the basic double type.
+ * Provides two double fields packed.
+ */
 public class Double2 {
+    public double x;
+    public double y;
+
     public Double2() {
     }
 
-    public Double2(double initX, double initY) {
-        x = initX;
-        y = initY;
+    /** @hide */
+    public Double2(Double2 data) {
+        this.x = data.x;
+        this.y = data.y;
     }
 
-    public double x;
-    public double y;
+    public Double2(double x, double y) {
+        this.x = x;
+        this.y = y;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Double2 add(Double2 a, Double2 b) {
+        Double2 res = new Double2();
+        res.x = a.x + b.x;
+        res.y = a.y + b.y;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param value
+     */
+    public void add(Double2 value) {
+        x += value.x;
+        y += value.y;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param value
+     */
+    public void add(double value) {
+        x += value;
+        y += value;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Double2 add(Double2 a, double b) {
+        Double2 res = new Double2();
+        res.x = a.x + b;
+        res.y = a.y + b;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param value
+     */
+    public void sub(Double2 value) {
+        x -= value.x;
+        y -= value.y;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Double2 sub(Double2 a, Double2 b) {
+        Double2 res = new Double2();
+        res.x = a.x - b.x;
+        res.y = a.y - b.y;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param value
+     */
+    public void sub(double value) {
+        x -= value;
+        y -= value;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Double2 sub(Double2 a, double b) {
+        Double2 res = new Double2();
+        res.x = a.x - b;
+        res.y = a.y - b;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param value
+     */
+    public void mul(Double2 value) {
+        x *= value.x;
+        y *= value.y;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Double2 mul(Double2 a, Double2 b) {
+        Double2 res = new Double2();
+        res.x = a.x * b.x;
+        res.y = a.y * b.y;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param value
+     */
+    public void mul(double value) {
+        x *= value;
+        y *= value;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Double2 mul(Double2 a, double b) {
+        Double2 res = new Double2();
+        res.x = a.x * b;
+        res.y = a.y * b;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param value
+     */
+    public void div(Double2 value) {
+        x /= value.x;
+        y /= value.y;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Double2 div(Double2 a, Double2 b) {
+        Double2 res = new Double2();
+        res.x = a.x / b.x;
+        res.y = a.y / b.y;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param value
+     */
+    public void div(double value) {
+        x /= value;
+        y /= value;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Double2 div(Double2 a, double b) {
+        Double2 res = new Double2();
+        res.x = a.x / b;
+        res.y = a.y / b;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @return
+     */
+    public double dotProduct(Double2 a) {
+        return (x * a.x) + (y * a.y);
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Double dotProduct(Double2 a, Double2 b) {
+        return (b.x * a.x) + (b.y * a.y);
+    }
+
+    /** @hide
+     * Vector add Multiple
+     *
+     * @param a
+     * @param factor
+     */
+    public void addMultiple(Double2 a, double factor) {
+        x += a.x * factor;
+        y += a.y * factor;
+    }
+
+    /** @hide
+     * Set vector value by double2
+     *
+     * @param a
+     */
+    public void set(Double2 a) {
+        this.x = a.x;
+        this.y = a.y;
+    }
+
+    /** @hide
+     * Set vector negate
+     */
+    public void negate() {
+        x = -x;
+        y = -y;
+    }
+
+    /** @hide
+     * Get vector length
+     *
+     * @return
+     */
+    public int length() {
+        return 2;
+    }
+
+    /** @hide
+     * Return the element sum of vector
+     *
+     * @return
+     */
+    public double elementSum() {
+        return x + y;
+    }
+
+    /** @hide
+     * Get the vector field value by index
+     *
+     * @param i
+     * @return
+     */
+    public double get(int i) {
+        switch (i) {
+        case 0:
+            return x;
+        case 1:
+            return y;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * Set the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void setAt(int i, double value) {
+        switch (i) {
+        case 0:
+            x = value;
+            return;
+        case 1:
+            y = value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * Add the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void addAt(int i, double value) {
+        switch (i) {
+        case 0:
+            x += value;
+            return;
+        case 1:
+            y += value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * Set the vector field value
+     *
+     * @param x
+     * @param y
+     */
+    public void setValues(double x, double y) {
+        this.x = x;
+        this.y = y;
+    }
+
+    /** @hide
+     * Copy the vector to double array
+     *
+     * @param data
+     * @param offset
+     */
+    public void copyTo(double[] data, int offset) {
+        data[offset] = x;
+        data[offset + 1] = y;
+    }
 }
-
-
-
-
diff --git a/graphics/java/android/renderscript/Double3.java b/graphics/java/android/renderscript/Double3.java
index 818952e..b819716 100644
--- a/graphics/java/android/renderscript/Double3.java
+++ b/graphics/java/android/renderscript/Double3.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,30 +16,402 @@
 
 package android.renderscript;
 
-import java.lang.Math;
-import android.util.Log;
-
-
 /**
- * Class for exposing the native RenderScript double3 type back
- * to the Android system.
- *
- **/
+ * Vector version of the basic double type.
+ * Provides three double fields packed.
+ */
 public class Double3 {
-    public Double3() {
-    }
-
-    public Double3(double initX, double initY, double initZ) {
-        x = initX;
-        y = initY;
-        z = initZ;
-    }
-
     public double x;
     public double y;
     public double z;
+
+    public Double3() {
+    }
+    /** @hide */
+    public Double3(Double3 data) {
+        this.x = data.x;
+        this.y = data.y;
+        this.z = data.z;
+    }
+
+    public Double3(double x, double y, double z) {
+        this.x = x;
+        this.y = y;
+        this.z = z;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Double3 add(Double3 a, Double3 b) {
+        Double3 res = new Double3();
+        res.x = a.x + b.x;
+        res.y = a.y + b.y;
+        res.z = a.z + b.z;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param value
+     */
+    public void add(Double3 value) {
+        x += value.x;
+        y += value.y;
+        z += value.z;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param value
+     */
+    public void add(double value) {
+        x += value;
+        y += value;
+        z += value;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Double3 add(Double3 a, double b) {
+        Double3 res = new Double3();
+        res.x = a.x + b;
+        res.y = a.y + b;
+        res.z = a.z + b;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param value
+     */
+    public void sub(Double3 value) {
+        x -= value.x;
+        y -= value.y;
+        z -= value.z;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Double3 sub(Double3 a, Double3 b) {
+        Double3 res = new Double3();
+        res.x = a.x - b.x;
+        res.y = a.y - b.y;
+        res.z = a.z - b.z;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param value
+     */
+    public void sub(double value) {
+        x -= value;
+        y -= value;
+        z -= value;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Double3 sub(Double3 a, double b) {
+        Double3 res = new Double3();
+        res.x = a.x - b;
+        res.y = a.y - b;
+        res.z = a.z - b;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param value
+     */
+    public void mul(Double3 value) {
+        x *= value.x;
+        y *= value.y;
+        z *= value.z;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Double3 mul(Double3 a, Double3 b) {
+        Double3 res = new Double3();
+        res.x = a.x * b.x;
+        res.y = a.y * b.y;
+        res.z = a.z * b.z;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param value
+     */
+    public void mul(double value) {
+        x *= value;
+        y *= value;
+        z *= value;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Double3 mul(Double3 a, double b) {
+        Double3 res = new Double3();
+        res.x = a.x * b;
+        res.y = a.y * b;
+        res.z = a.z * b;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param value
+     */
+    public void div(Double3 value) {
+        x /= value.x;
+        y /= value.y;
+        z /= value.z;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Double3 div(Double3 a, Double3 b) {
+        Double3 res = new Double3();
+        res.x = a.x / b.x;
+        res.y = a.y / b.y;
+        res.z = a.z / b.z;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param value
+     */
+    public void div(double value) {
+        x /= value;
+        y /= value;
+        z /= value;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Double3 div(Double3 a, double b) {
+        Double3 res = new Double3();
+        res.x = a.x / b;
+        res.y = a.y / b;
+        res.z = a.z / b;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @return
+     */
+    public double dotProduct(Double3 a) {
+        return (x * a.x) + (y * a.y) + (z * a.z);
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static double dotProduct(Double3 a, Double3 b) {
+        return (b.x * a.x) + (b.y * a.y) + (b.z * a.z);
+    }
+
+    /** @hide
+     * Vector add Multiple
+     *
+     * @param a
+     * @param factor
+     */
+    public void addMultiple(Double3 a, double factor) {
+        x += a.x * factor;
+        y += a.y * factor;
+        z += a.z * factor;
+    }
+
+    /** @hide
+     * Set vector value by double3
+     *
+     * @param a
+     */
+    public void set(Double3 a) {
+        this.x = a.x;
+        this.y = a.y;
+        this.z = a.z;
+    }
+
+    /** @hide
+     * Set vector negate
+     */
+    public void negate() {
+        x = -x;
+        y = -y;
+        z = -z;
+    }
+
+    /** @hide
+     * Get vector length
+     *
+     * @return
+     */
+    public int length() {
+        return 3;
+    }
+
+    /** @hide
+     * Return the element sum of vector
+     *
+     * @return
+     */
+    public double elementSum() {
+        return x + y + z;
+    }
+
+    /** @hide
+     * Get the vector field value by index
+     *
+     * @param i
+     * @return
+     */
+    public double get(int i) {
+        switch (i) {
+        case 0:
+            return x;
+        case 1:
+            return y;
+        case 2:
+            return z;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * Set the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void setAt(int i, double value) {
+        switch (i) {
+        case 0:
+            x = value;
+            return;
+        case 1:
+            y = value;
+            return;
+        case 2:
+            z = value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * Add the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void addAt(int i, double value) {
+        switch (i) {
+        case 0:
+            x += value;
+            return;
+        case 1:
+            y += value;
+            return;
+        case 2:
+            z += value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * Set the vector field value
+     *
+     * @param x
+     * @param y
+     * @param z
+     */
+    public void setValues(double x, double y, double z) {
+        this.x = x;
+        this.y = y;
+        this.z = z;
+    }
+
+    /** @hide
+     * Copy the vector to double array
+     *
+     * @param data
+     * @param offset
+     */
+    public void copyTo(double[] data, int offset) {
+        data[offset] = x;
+        data[offset + 1] = y;
+        data[offset + 2] = z;
+    }
 }
-
-
-
-
diff --git a/graphics/java/android/renderscript/Double4.java b/graphics/java/android/renderscript/Double4.java
index 7775ab7..e4829f7 100644
--- a/graphics/java/android/renderscript/Double4.java
+++ b/graphics/java/android/renderscript/Double4.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,31 +16,435 @@
 
 package android.renderscript;
 
-import java.lang.Math;
-import android.util.Log;
-
-
 /**
- * Class for exposing the native RenderScript double4 type back
- * to the Android system.
- *
- **/
+ * Vector version of the basic double type.
+ * Provides four double fields packed.
+ */
 public class Double4 {
-    public Double4() {
-    }
-
-    public Double4(double initX, double initY, double initZ, double initW) {
-        x = initX;
-        y = initY;
-        z = initZ;
-        w = initW;
-    }
-
     public double x;
     public double y;
     public double z;
     public double w;
+
+    public Double4() {
+    }
+    /** @hide */
+    public Double4(Double4 data) {
+        this.x = data.x;
+        this.y = data.y;
+        this.z = data.z;
+        this.w = data.w;
+    }
+
+    public Double4(double x, double y, double z, double w) {
+        this.x = x;
+        this.y = y;
+        this.z = z;
+        this.w = w;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Double4 add(Double4 a, Double4 b) {
+        Double4 res = new Double4();
+        res.x = a.x + b.x;
+        res.y = a.y + b.y;
+        res.z = a.z + b.z;
+        res.w = a.w + b.w;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param value
+     */
+    public void add(Double4 value) {
+        x += value.x;
+        y += value.y;
+        z += value.z;
+        w += value.w;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param value
+     */
+    public void add(double value) {
+        x += value;
+        y += value;
+        z += value;
+        w += value;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Double4 add(Double4 a, double b) {
+        Double4 res = new Double4();
+        res.x = a.x + b;
+        res.y = a.y + b;
+        res.z = a.z + b;
+        res.w = a.w + b;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param value
+     */
+    public void sub(Double4 value) {
+        x -= value.x;
+        y -= value.y;
+        z -= value.z;
+        w -= value.w;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param value
+     */
+    public void sub(double value) {
+        x -= value;
+        y -= value;
+        z -= value;
+        w -= value;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Double4 sub(Double4 a, double b) {
+        Double4 res = new Double4();
+        res.x = a.x - b;
+        res.y = a.y - b;
+        res.z = a.z - b;
+        res.w = a.w - b;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Double4 sub(Double4 a, Double4 b) {
+        Double4 res = new Double4();
+        res.x = a.x - b.x;
+        res.y = a.y - b.y;
+        res.z = a.z - b.z;
+        res.w = a.w - b.w;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param value
+     */
+    public void mul(Double4 value) {
+        x *= value.x;
+        y *= value.y;
+        z *= value.z;
+        w *= value.w;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param value
+     */
+    public void mul(double value) {
+        x *= value;
+        y *= value;
+        z *= value;
+        w *= value;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Double4 mul(Double4 a, Double4 b) {
+        Double4 res = new Double4();
+        res.x = a.x * b.x;
+        res.y = a.y * b.y;
+        res.z = a.z * b.z;
+        res.w = a.w * b.w;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Double4 mul(Double4 a, double b) {
+        Double4 res = new Double4();
+        res.x = a.x * b;
+        res.y = a.y * b;
+        res.z = a.z * b;
+        res.w = a.w * b;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param value
+     */
+    public void div(Double4 value) {
+        x /= value.x;
+        y /= value.y;
+        z /= value.z;
+        w /= value.w;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param value
+     */
+    public void div(double value) {
+        x /= value;
+        y /= value;
+        z /= value;
+        w /= value;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Double4 div(Double4 a, double b) {
+        Double4 res = new Double4();
+        res.x = a.x / b;
+        res.y = a.y / b;
+        res.z = a.z / b;
+        res.w = a.w / b;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Double4 div(Double4 a, Double4 b) {
+        Double4 res = new Double4();
+        res.x = a.x / b.x;
+        res.y = a.y / b.y;
+        res.z = a.z / b.z;
+        res.w = a.w / b.w;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @return
+     */
+    public double dotProduct(Double4 a) {
+        return (x * a.x) + (y * a.y) + (z * a.z) + (w * a.w);
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static double dotProduct(Double4 a, Double4 b) {
+        return (b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w);
+    }
+
+    /** @hide
+     * Vector add Multiple
+     *
+     * @param a
+     * @param factor
+     */
+    public void addMultiple(Double4 a, double factor) {
+        x += a.x * factor;
+        y += a.y * factor;
+        z += a.z * factor;
+        w += a.w * factor;
+    }
+
+    /** @hide
+     * Set vector value by double4
+     *
+     * @param a
+     */
+    public void set(Double4 a) {
+        this.x = a.x;
+        this.y = a.y;
+        this.z = a.z;
+        this.w = a.w;
+    }
+
+    /** @hide
+     * Set vector negate
+     */
+    public void negate() {
+        x = -x;
+        y = -y;
+        z = -z;
+        w = -w;
+    }
+
+    /** @hide
+     * Get vector length
+     *
+     * @return
+     */
+    public int length() {
+        return 4;
+    }
+
+    /** @hide
+     * Return the element sum of vector
+     *
+     * @return
+     */
+    public double elementSum() {
+        return x + y + z + w;
+    }
+
+    /** @hide
+     * Get the vector field value by index
+     *
+     * @param i
+     * @return
+     */
+    public double get(int i) {
+        switch (i) {
+        case 0:
+            return x;
+        case 1:
+            return y;
+        case 2:
+            return z;
+        case 3:
+            return w;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * Set the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void setAt(int i, double value) {
+        switch (i) {
+        case 0:
+            x = value;
+            return;
+        case 1:
+            y = value;
+            return;
+        case 2:
+            z = value;
+            return;
+        case 3:
+            w = value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * Add the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void addAt(int i, double value) {
+        switch (i) {
+        case 0:
+            x += value;
+            return;
+        case 1:
+            y += value;
+            return;
+        case 2:
+            z += value;
+            return;
+        case 3:
+            w += value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * Set the vector field value
+     *
+     * @param x
+     * @param y
+     * @param z
+     * @param w
+     */
+    public void setValues(double x, double y, double z, double w) {
+        this.x = x;
+        this.y = y;
+        this.z = z;
+        this.w = w;
+    }
+
+    /** @hide
+     * Copy the vector to double array
+     *
+     * @param data
+     * @param offset
+     */
+    public void copyTo(double[] data, int offset) {
+        data[offset] = x;
+        data[offset + 1] = y;
+        data[offset + 2] = z;
+        data[offset + 3] = w;
+    }
 }
-
-
-
diff --git a/graphics/java/android/renderscript/Float2.java b/graphics/java/android/renderscript/Float2.java
index 0f730fe..26193d2 100644
--- a/graphics/java/android/renderscript/Float2.java
+++ b/graphics/java/android/renderscript/Float2.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,27 +16,369 @@
 
 package android.renderscript;
 
-import java.lang.Math;
-import android.util.Log;
-
-
 /**
- * Class for exposing the native RenderScript float2 type back to the Android system.
- *
- **/
-public class Float2 {
-    public Float2() {
-    }
-
-    public Float2(float initX, float initY) {
-        x = initX;
-        y = initY;
-    }
-
+ * Vector version of the basic float type.
+ * Provides two float fields packed.
+ */
+public  class Float2 {
     public float x;
     public float y;
+
+    public Float2() {
+    }
+    /** @hide */ 
+    public Float2(Float2 data) {
+        this.x = data.x;
+        this.y = data.y;
+    }
+
+    public Float2(float x, float y) {
+        this.x = x;
+        this.y = y;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Float2 add(Float2 a, Float2 b) {
+        Float2 res = new Float2();
+        res.x = a.x + b.x;
+        res.y = a.y + b.y;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param value
+     */
+    public void add(Float2 value) {
+        x += value.x;
+        y += value.y;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param value
+     */
+    public void add(float value) {
+        x += value;
+        y += value;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Float2 add(Float2 a, float b) {
+        Float2 res = new Float2();
+        res.x = a.x + b;
+        res.y = a.y + b;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param value
+     */
+    public void sub(Float2 value) {
+        x -= value.x;
+        y -= value.y;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Float2 sub(Float2 a, Float2 b) {
+        Float2 res = new Float2();
+        res.x = a.x - b.x;
+        res.y = a.y - b.y;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param value
+     */
+    public void sub(float value) {
+        x -= value;
+        y -= value;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Float2 sub(Float2 a, float b) {
+        Float2 res = new Float2();
+        res.x = a.x - b;
+        res.y = a.y - b;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param value
+     */
+    public void mul(Float2 value) {
+        x *= value.x;
+        y *= value.y;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Float2 mul(Float2 a, Float2 b) {
+        Float2 res = new Float2();
+        res.x = a.x * b.x;
+        res.y = a.y * b.y;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param value
+     */
+    public void mul(float value) {
+        x *= value;
+        y *= value;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Float2 mul(Float2 a, float b) {
+        Float2 res = new Float2();
+        res.x = a.x * b;
+        res.y = a.y * b;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param value
+     */
+    public void div(Float2 value) {
+        x /= value.x;
+        y /= value.y;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Float2 div(Float2 a, Float2 b) {
+        Float2 res = new Float2();
+        res.x = a.x / b.x;
+        res.y = a.y / b.y;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param value
+     */
+    public void div(float value) {
+        x /= value;
+        y /= value;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Float2 div(Float2 a, float b) {
+        Float2 res = new Float2();
+        res.x = a.x / b;
+        res.y = a.y / b;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @return
+     */
+    public float dotProduct(Float2 a) {
+        return (x * a.x) + (y * a.y);
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static float dotProduct(Float2 a, Float2 b) {
+        return (b.x * a.x) + (b.y * a.y);
+    }
+
+    /** @hide
+     * Vector add Multiple
+     *
+     * @param a
+     * @param factor
+     */
+    public void addMultiple(Float2 a, float factor) {
+        x += a.x * factor;
+        y += a.y * factor;
+    }
+
+    /** @hide
+     * set vector value by float2
+     *
+     * @param a
+     */
+    public void set(Float2 a) {
+        this.x = a.x;
+        this.y = a.y;
+    }
+
+    /** @hide
+     * set vector negate
+     */
+    public void negate() {
+        x = -x;
+        y = -y;
+    }
+
+    /** @hide
+     * get vector length
+     *
+     * @return
+     */
+    public int length() {
+        return 2;
+    }
+
+    /** @hide
+     * return the element sum of vector
+     *
+     * @return
+     */
+    public float elementSum() {
+        return x + y;
+    }
+
+    /** @hide
+     * get the vector field value by index
+     *
+     * @param i
+     * @return
+     */
+    public float get(int i) {
+        switch (i) {
+        case 0:
+            return x;
+        case 1:
+            return y;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * set the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void setAt(int i, float value) {
+        switch (i) {
+        case 0:
+            x = value;
+            return;
+        case 1:
+            y = value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * add the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void addAt(int i, float value) {
+        switch (i) {
+        case 0:
+            x += value;
+            return;
+        case 1:
+            y += value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * set the vector field value
+     *
+     * @param x
+     * @param y
+     */
+    public void setValues(float x, float y) {
+        this.x = x;
+        this.y = y;
+    }
+
+    /** @hide
+     * copy the vector to float array
+     *
+     * @param data
+     * @param offset
+     */
+    public void copyTo(float[] data, int offset) {
+        data[offset] = x;
+        data[offset + 1] = y;
+    }
 }
-
-
-
-
diff --git a/graphics/java/android/renderscript/Float3.java b/graphics/java/android/renderscript/Float3.java
index 749865f1..555bdf6 100644
--- a/graphics/java/android/renderscript/Float3.java
+++ b/graphics/java/android/renderscript/Float3.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,28 +16,402 @@
 
 package android.renderscript;
 
-import java.lang.Math;
-import android.util.Log;
-
-
 /**
- * Class for exposing the native RenderScript float2 type back to the Android system.
- *
- **/
+ * Vector version of the basic float type.
+ * Provides three float fields packed.
+ */
 public class Float3 {
-    public Float3() {
-    }
-    public Float3(float initX, float initY, float initZ) {
-        x = initX;
-        y = initY;
-        z = initZ;
-    }
-
     public float x;
     public float y;
     public float z;
+
+    public Float3() {
+    }
+    /** @hide */
+    public Float3(Float3 data) {
+        this.x = data.x;
+        this.y = data.y;
+        this.z = data.z;
+    }
+
+    public Float3(float x, float y, float z) {
+        this.x = x;
+        this.y = y;
+        this.z = z;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Float3 add(Float3 a, Float3 b) {
+        Float3 res = new Float3();
+        res.x = a.x + b.x;
+        res.y = a.y + b.y;
+        res.z = a.z + b.z;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param value
+     */
+    public void add(Float3 value) {
+        x += value.x;
+        y += value.y;
+        z += value.z;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param value
+     */
+    public void add(float value) {
+        x += value;
+        y += value;
+        z += value;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Float3 add(Float3 a, float b) {
+        Float3 res = new Float3();
+        res.x = a.x + b;
+        res.y = a.y + b;
+        res.z = a.z + b;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param value
+     */
+    public void sub(Float3 value) {
+        x -= value.x;
+        y -= value.y;
+        z -= value.z;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Float3 sub(Float3 a, Float3 b) {
+        Float3 res = new Float3();
+        res.x = a.x - b.x;
+        res.y = a.y - b.y;
+        res.z = a.z - b.z;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param value
+     */
+    public void sub(float value) {
+        x -= value;
+        y -= value;
+        z -= value;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Float3 sub(Float3 a, float b) {
+        Float3 res = new Float3();
+        res.x = a.x - b;
+        res.y = a.y - b;
+        res.z = a.z - b;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param value
+     */
+    public void mul(Float3 value) {
+        x *= value.x;
+        y *= value.y;
+        z *= value.z;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Float3 mul(Float3 a, Float3 b) {
+        Float3 res = new Float3();
+        res.x = a.x * b.x;
+        res.y = a.y * b.y;
+        res.z = a.z * b.z;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param value
+     */
+    public void mul(float value) {
+        x *= value;
+        y *= value;
+        z *= value;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Float3 mul(Float3 a, float b) {
+        Float3 res = new Float3();
+        res.x = a.x * b;
+        res.y = a.y * b;
+        res.z = a.z * b;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param value
+     */
+    public void div(Float3 value) {
+        x /= value.x;
+        y /= value.y;
+        z /= value.z;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Float3 div(Float3 a, Float3 b) {
+        Float3 res = new Float3();
+        res.x = a.x / b.x;
+        res.y = a.y / b.y;
+        res.z = a.z / b.z;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param value
+     */
+    public void div(float value) {
+        x /= value;
+        y /= value;
+        z /= value;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Float3 div(Float3 a, float b) {
+        Float3 res = new Float3();
+        res.x = a.x / b;
+        res.y = a.y / b;
+        res.z = a.z / b;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @return
+     */
+    public Float dotProduct(Float3 a) {
+        return new Float((x * a.x) + (y * a.y) + (z * a.z));
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Float dotProduct(Float3 a, Float3 b) {
+        return new Float((b.x * a.x) + (b.y * a.y) + (b.z * a.z));
+    }
+
+    /** @hide
+     * Vector add Multiple
+     *
+     * @param a
+     * @param factor
+     */
+    public void addMultiple(Float3 a, float factor) {
+        x += a.x * factor;
+        y += a.y * factor;
+        z += a.z * factor;
+    }
+
+    /** @hide
+     * set vector value by float3
+     *
+     * @param a
+     */
+    public void set(Float3 a) {
+        this.x = a.x;
+        this.y = a.y;
+        this.z = a.z;
+    }
+
+    /** @hide
+     * set vector negate
+     */
+    public void negate() {
+        x = -x;
+        y = -y;
+        z = -z;
+    }
+
+    /** @hide
+     * get vector length
+     *
+     * @return
+     */
+    public int length() {
+        return 3;
+    }
+
+    /** @hide
+     * return the element sum of vector
+     *
+     * @return
+     */
+    public Float elementSum() {
+        return new Float(x + y + z);
+    }
+
+    /** @hide
+     * get the vector field value by index
+     *
+     * @param i
+     * @return
+     */
+    public float get(int i) {
+        switch (i) {
+        case 0:
+            return x;
+        case 1:
+            return y;
+        case 2:
+            return z;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * set the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void setAt(int i, float value) {
+        switch (i) {
+        case 0:
+            x = value;
+            return;
+        case 1:
+            y = value;
+            return;
+        case 2:
+            z = value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * add the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void addAt(int i, float value) {
+        switch (i) {
+        case 0:
+            x += value;
+            return;
+        case 1:
+            y += value;
+            return;
+        case 2:
+            z += value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * set the vector field value
+     *
+     * @param x
+     * @param y
+     * @param z
+     */
+    public void setValues(float x, float y, float z) {
+        this.x = x;
+        this.y = y;
+        this.z = z;
+    }
+
+    /** @hide
+     * copy the vector to float array
+     *
+     * @param data
+     * @param offset
+     */
+    public void copyTo(float[] data, int offset) {
+        data[offset] = x;
+        data[offset + 1] = y;
+        data[offset + 2] = z;
+    }
 }
-
-
-
-
diff --git a/graphics/java/android/renderscript/Float4.java b/graphics/java/android/renderscript/Float4.java
index 7ddf6aa..6541b2e 100644
--- a/graphics/java/android/renderscript/Float4.java
+++ b/graphics/java/android/renderscript/Float4.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,30 +16,435 @@
 
 package android.renderscript;
 
-import java.lang.Math;
-import android.util.Log;
-
-
 /**
- * Class for exposing the native RenderScript float2 type back to the Android system.
- *
- **/
+ * Vector version of the basic float type.
+ * Provides four float fields packed.
+ */
 public class Float4 {
-    public Float4() {
-    }
-
-    public Float4(float initX, float initY, float initZ, float initW) {
-        x = initX;
-        y = initY;
-        z = initZ;
-        w = initW;
-    }
-
     public float x;
     public float y;
     public float z;
     public float w;
+
+    public Float4() {
+    }
+    /** @hide */
+    public Float4(Float4 data) {
+        this.x = data.x;
+        this.y = data.y;
+        this.z = data.z;
+        this.w = data.w;
+    }
+
+    public Float4(float x, float y, float z, float w) {
+        this.x = x;
+        this.y = y;
+        this.z = z;
+        this.w = w;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Float4 add(Float4 a, Float4 b) {
+        Float4 res = new Float4();
+        res.x = a.x + b.x;
+        res.y = a.y + b.y;
+        res.z = a.z + b.z;
+        res.w = a.w + b.w;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param value
+     */
+    public void add(Float4 value) {
+        x += value.x;
+        y += value.y;
+        z += value.z;
+        w += value.w;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param value
+     */
+    public void add(float value) {
+        x += value;
+        y += value;
+        z += value;
+        w += value;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Float4 add(Float4 a, float b) {
+        Float4 res = new Float4();
+        res.x = a.x + b;
+        res.y = a.y + b;
+        res.z = a.z + b;
+        res.w = a.w + b;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param value
+     */
+    public void sub(Float4 value) {
+        x -= value.x;
+        y -= value.y;
+        z -= value.z;
+        w -= value.w;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param value
+     */
+    public void sub(float value) {
+        x -= value;
+        y -= value;
+        z -= value;
+        w -= value;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Float4 sub(Float4 a, float b) {
+        Float4 res = new Float4();
+        res.x = a.x - b;
+        res.y = a.y - b;
+        res.z = a.z - b;
+        res.w = a.w - b;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Float4 sub(Float4 a, Float4 b) {
+        Float4 res = new Float4();
+        res.x = a.x - b.x;
+        res.y = a.y - b.y;
+        res.z = a.z - b.z;
+        res.w = a.w - b.w;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param value
+     */
+    public void mul(Float4 value) {
+        x *= value.x;
+        y *= value.y;
+        z *= value.z;
+        w *= value.w;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param value
+     */
+    public void mul(float value) {
+        x *= value;
+        y *= value;
+        z *= value;
+        w *= value;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Float4 mul(Float4 a, Float4 b) {
+        Float4 res = new Float4();
+        res.x = a.x * b.x;
+        res.y = a.y * b.y;
+        res.z = a.z * b.z;
+        res.w = a.w * b.w;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Float4 mul(Float4 a, float b) {
+        Float4 res = new Float4();
+        res.x = a.x * b;
+        res.y = a.y * b;
+        res.z = a.z * b;
+        res.w = a.w * b;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param value
+     */
+    public void div(Float4 value) {
+        x /= value.x;
+        y /= value.y;
+        z /= value.z;
+        w /= value.w;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param value
+     */
+    public void div(float value) {
+        x /= value;
+        y /= value;
+        z /= value;
+        w /= value;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Float4 div(Float4 a, float b) {
+        Float4 res = new Float4();
+        res.x = a.x / b;
+        res.y = a.y / b;
+        res.z = a.z / b;
+        res.w = a.w / b;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Float4 div(Float4 a, Float4 b) {
+        Float4 res = new Float4();
+        res.x = a.x / b.x;
+        res.y = a.y / b.y;
+        res.z = a.z / b.z;
+        res.w = a.w / b.w;
+
+        return res;
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @return
+     */
+    public float dotProduct(Float4 a) {
+        return (x * a.x) + (y * a.y) + (z * a.z) + (w * a.w);
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static float dotProduct(Float4 a, Float4 b) {
+        return (b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w);
+    }
+
+    /** @hide
+     * Vector add Multiple
+     *
+     * @param a
+     * @param factor
+     */
+    public void addMultiple(Float4 a, float factor) {
+        x += a.x * factor;
+        y += a.y * factor;
+        z += a.z * factor;
+        w += a.w * factor;
+    }
+
+    /** @hide
+     * set vector value by float4
+     *
+     * @param a
+     */
+    public void set(Float4 a) {
+        this.x = a.x;
+        this.y = a.y;
+        this.z = a.z;
+        this.w = a.w;
+    }
+
+    /** @hide
+     * set vector negate
+     */
+    public void negate() {
+        x = -x;
+        y = -y;
+        z = -z;
+        w = -w;
+    }
+
+    /** @hide
+     * get vector length
+     *
+     * @return
+     */
+    public int length() {
+        return 4;
+    }
+
+    /** @hide
+     * return the element sum of vector
+     *
+     * @return
+     */
+    public float elementSum() {
+        return x + y + z + w;
+    }
+
+    /** @hide
+     * get the vector field value by index
+     *
+     * @param i
+     * @return
+     */
+    public float get(int i) {
+        switch (i) {
+        case 0:
+            return x;
+        case 1:
+            return y;
+        case 2:
+            return z;
+        case 3:
+            return w;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * set the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void setAt(int i, float value) {
+        switch (i) {
+        case 0:
+            x = value;
+            return;
+        case 1:
+            y = value;
+            return;
+        case 2:
+            z = value;
+            return;
+        case 3:
+            w = value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * add the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void addAt(int i, float value) {
+        switch (i) {
+        case 0:
+            x += value;
+            return;
+        case 1:
+            y += value;
+            return;
+        case 2:
+            z += value;
+            return;
+        case 3:
+            w += value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * set the vector field value
+     *
+     * @param x
+     * @param y
+     * @param z
+     * @param w
+     */
+    public void setValues(float x, float y, float z, float w) {
+        this.x = x;
+        this.y = y;
+        this.z = z;
+        this.w = w;
+    }
+
+    /** @hide
+     * copy the vector to float array
+     *
+     * @param data
+     * @param offset
+     */
+    public void copyTo(float[] data, int offset) {
+        data[offset] = x;
+        data[offset + 1] = y;
+        data[offset + 2] = z;
+        data[offset + 3] = w;
+    }
 }
-
-
-
diff --git a/graphics/java/android/renderscript/Int2.java b/graphics/java/android/renderscript/Int2.java
index 71b5dd5..120957b 100644
--- a/graphics/java/android/renderscript/Int2.java
+++ b/graphics/java/android/renderscript/Int2.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,27 +16,425 @@
 
 package android.renderscript;
 
-import java.lang.Math;
-import android.util.Log;
-
-
 /**
- * Class for exposing the native RenderScript int2 type back to the Android system.
- *
- **/
+ * Vector version of the basic int type.
+ * Provides two int fields packed.
+ */
 public class Int2 {
+    public int x;
+    public int y;
+
     public Int2() {
     }
 
-    public Int2(int initX, int initY) {
-        x = initX;
-        y = initY;
+    /** @hide */
+    public Int2(int i) {
+        this.x = this.y = i;
     }
 
-    public int x;
-    public int y;
+    public Int2(int x, int y) {
+        this.x = x;
+        this.y = y;
+    }
+
+    /** @hide */
+    public Int2(Int2 source) {
+        this.x = source.x;
+        this.y = source.y;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     */
+    public void add(Int2 a) {
+        this.x += a.x;
+        this.y += a.y;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int2 add(Int2 a, Int2 b) {
+        Int2 result = new Int2();
+        result.x = a.x + b.x;
+        result.y = a.y + b.y;
+
+        return result;
+    }
+
+    /**  @hide
+     * Vector add
+     *
+     * @param value
+     */
+    public void add(int value) {
+        x += value;
+        y += value;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int2 add(Int2 a, int b) {
+        Int2 result = new Int2();
+        result.x = a.x + b;
+        result.y = a.y + b;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     */
+    public void sub(Int2 a) {
+        this.x -= a.x;
+        this.y -= a.y;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int2 sub(Int2 a, Int2 b) {
+        Int2 result = new Int2();
+        result.x = a.x - b.x;
+        result.y = a.y - b.y;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param value
+     */
+    public void sub(int value) {
+        x -= value;
+        y -= value;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int2 sub(Int2 a, int b) {
+        Int2 result = new Int2();
+        result.x = a.x - b;
+        result.y = a.y - b;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     */
+    public void mul(Int2 a) {
+        this.x *= a.x;
+        this.y *= a.y;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int2 mul(Int2 a, Int2 b) {
+        Int2 result = new Int2();
+        result.x = a.x * b.x;
+        result.y = a.y * b.y;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param value
+     */
+    public void mul(int value) {
+        x *= value;
+        y *= value;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int2 mul(Int2 a, int b) {
+        Int2 result = new Int2();
+        result.x = a.x * b;
+        result.y = a.y * b;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     */
+    public void div(Int2 a) {
+        this.x /= a.x;
+        this.y /= a.y;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int2 div(Int2 a, Int2 b) {
+        Int2 result = new Int2();
+        result.x = a.x / b.x;
+        result.y = a.y / b.y;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param value
+     */
+    public void div(int value) {
+        x /= value;
+        y /= value;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int2 div(Int2 a, int b) {
+        Int2 result = new Int2();
+        result.x = a.x / b;
+        result.y = a.y / b;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     */
+    public void mod(Int2 a) {
+        this.x %= a.x;
+        this.y %= a.y;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int2 mod(Int2 a, Int2 b) {
+        Int2 result = new Int2();
+        result.x = a.x % b.x;
+        result.y = a.y % b.y;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param value
+     */
+    public void mod(int value) {
+        x %= value;
+        y %= value;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int2 mod(Int2 a, int b) {
+        Int2 result = new Int2();
+        result.x = a.x % b;
+        result.y = a.y % b;
+
+        return result;
+    }
+
+    /** @hide
+     * get vector length
+     *
+     * @return
+     */
+    public int length() {
+        return 2;
+    }
+
+    /** @hide
+     * set vector negate
+     */
+    public void negate() {
+        this.x = -x;
+        this.y = -y;
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @return
+     */
+    public int dotProduct(Int2 a) {
+        return (int)((x * a.x) + (y * a.y));
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static int dotProduct(Int2 a, Int2 b) {
+        return (int)((b.x * a.x) + (b.y * a.y));
+    }
+
+    /** @hide
+     * Vector add Multiple
+     *
+     * @param a
+     * @param factor
+     */
+    public void addMultiple(Int2 a, int factor) {
+        x += a.x * factor;
+        y += a.y * factor;
+    }
+
+    /** @hide
+     * set vector value by Int2
+     *
+     * @param a
+     */
+    public void set(Int2 a) {
+        this.x = a.x;
+        this.y = a.y;
+    }
+
+    /** @hide
+     * set the vector field value by Int
+     *
+     * @param a
+     * @param b
+     */
+    public void setValues(int a, int b) {
+        this.x = a;
+        this.y = b;
+    }
+
+    /** @hide
+     * return the element sum of vector
+     *
+     * @return
+     */
+    public int elementSum() {
+        return (int)(x + y);
+    }
+
+    /** @hide
+     * get the vector field value by index
+     *
+     * @param i
+     * @return
+     */
+    public int get(int i) {
+        switch (i) {
+        case 0:
+            return (int)(x);
+        case 1:
+            return (int)(y);
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * set the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void setAt(int i, int value) {
+        switch (i) {
+        case 0:
+            x = value;
+            return;
+        case 1:
+            y = value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * add the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void addAt(int i, int value) {
+        switch (i) {
+        case 0:
+            x += value;
+            return;
+        case 1:
+            y += value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * copy the vector to int array
+     *
+     * @param data
+     * @param offset
+     */
+    public void copyTo(int[] data, int offset) {
+        data[offset] = (int)(x);
+        data[offset + 1] = (int)(y);
+    }
 }
-
-
-
-
diff --git a/graphics/java/android/renderscript/Int3.java b/graphics/java/android/renderscript/Int3.java
index 719c908..c770395 100644
--- a/graphics/java/android/renderscript/Int3.java
+++ b/graphics/java/android/renderscript/Int3.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,29 +16,462 @@
 
 package android.renderscript;
 
-import java.lang.Math;
-import android.util.Log;
-
-
 /**
- * Class for exposing the native RenderScript int3 type back to the Android system.
- *
- **/
+ * Vector version of the basic int type.
+ * Provides three int fields packed.
+ */
 public class Int3 {
-    public Int3() {
-    }
-
-    public Int3(int initX, int initY, int initZ) {
-        x = initX;
-        y = initY;
-        z = initZ;
-    }
-
     public int x;
     public int y;
     public int z;
+
+    public Int3() {
+    }
+    
+    /** @hide */
+    public Int3(int i) {
+        this.x = this.y = this.z = i;
+    }
+
+    public Int3(int x, int y, int z) {
+        this.x = x;
+        this.y = y;
+        this.z = z;
+    }
+
+    /** @hide */
+    public Int3(Int3 source) {
+        this.x = source.x;
+        this.y = source.y;
+        this.z = source.z;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     */
+    public void add(Int3 a) {
+        this.x += a.x;
+        this.y += a.y;
+        this.z += a.z;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int3 add(Int3 a, Int3 b) {
+        Int3 result = new Int3();
+        result.x = a.x + b.x;
+        result.y = a.y + b.y;
+        result.z = a.z + b.z;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param value
+     */
+    public void add(int value) {
+        x += value;
+        y += value;
+        z += value;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int3 add(Int3 a, int b) {
+        Int3 result = new Int3();
+        result.x = a.x + b;
+        result.y = a.y + b;
+        result.z = a.z + b;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     */
+    public void sub(Int3 a) {
+        this.x -= a.x;
+        this.y -= a.y;
+        this.z -= a.z;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int3 sub(Int3 a, Int3 b) {
+        Int3 result = new Int3();
+        result.x = a.x - b.x;
+        result.y = a.y - b.y;
+        result.z = a.z - b.z;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param value
+     */
+    public void sub(int value) {
+        x -= value;
+        y -= value;
+        z -= value;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int3 sub(Int3 a, int b) {
+        Int3 result = new Int3();
+        result.x = a.x - b;
+        result.y = a.y - b;
+        result.z = a.z - b;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     */
+    public void mul(Int3 a) {
+        this.x *= a.x;
+        this.y *= a.y;
+        this.z *= a.z;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int3 mul(Int3 a, Int3 b) {
+        Int3 result = new Int3();
+        result.x = a.x * b.x;
+        result.y = a.y * b.y;
+        result.z = a.z * b.z;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param value
+     */
+    public void mul(int value) {
+        x *= value;
+        y *= value;
+        z *= value;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int3 mul(Int3 a, int b) {
+        Int3 result = new Int3();
+        result.x = a.x * b;
+        result.y = a.y * b;
+        result.z = a.z * b;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     */
+    public void div(Int3 a) {
+        this.x /= a.x;
+        this.y /= a.y;
+        this.z /= a.z;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int3 div(Int3 a, Int3 b) {
+        Int3 result = new Int3();
+        result.x = a.x / b.x;
+        result.y = a.y / b.y;
+        result.z = a.z / b.z;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param value
+     */
+    public void div(int value) {
+        x /= value;
+        y /= value;
+        z /= value;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int3 div(Int3 a, int b) {
+        Int3 result = new Int3();
+        result.x = a.x / b;
+        result.y = a.y / b;
+        result.z = a.z / b;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     */
+    public void mod(Int3 a) {
+        this.x %= a.x;
+        this.y %= a.y;
+        this.z %= a.z;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int3 mod(Int3 a, Int3 b) {
+        Int3 result = new Int3();
+        result.x = a.x % b.x;
+        result.y = a.y % b.y;
+        result.z = a.z % b.z;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param value
+     */
+    public void mod(int value) {
+        x %= value;
+        y %= value;
+        z %= value;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int3 mod(Int3 a, int b) {
+        Int3 result = new Int3();
+        result.x = a.x % b;
+        result.y = a.y % b;
+        result.z = a.z % b;
+
+        return result;
+    }
+
+    /** @hide
+     * get vector length
+     *
+     * @return
+     */
+    public int length() {
+        return 3;
+    }
+
+    /** @hide
+     * set vector negate
+     */
+    public void negate() {
+        this.x = -x;
+        this.y = -y;
+        this.z = -z;
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @return
+     */
+    public int dotProduct(Int3 a) {
+        return (int)((x * a.x) + (y * a.y) + (z * a.z));
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static int dotProduct(Int3 a, Int3 b) {
+        return (int)((b.x * a.x) + (b.y * a.y) + (b.z * a.z));
+    }
+
+    /** @hide
+     * Vector add Multiple
+     *
+     * @param a
+     * @param factor
+     */
+    public void addMultiple(Int3 a, int factor) {
+        x += a.x * factor;
+        y += a.y * factor;
+        z += a.z * factor;
+    }
+
+    /** @hide
+     * set vector value by Int3
+     *
+     * @param a
+     */
+    public void set(Int3 a) {
+        this.x = a.x;
+        this.y = a.y;
+        this.z = a.z;
+    }
+
+    /** @hide
+     * set the vector field value by Int
+     *
+     * @param a
+     * @param b
+     * @param c
+     */
+    public void setValues(int a, int b, int c) {
+        this.x = a;
+        this.y = b;
+        this.z = c;
+    }
+
+    /** @hide
+     * return the element sum of vector
+     *
+     * @return
+     */
+    public int elementSum() {
+        return (int)(x + y + z);
+    }
+
+    /** @hide
+     * get the vector field value by index
+     *
+     * @param i
+     * @return
+     */
+    public int get(int i) {
+        switch (i) {
+        case 0:
+            return (int)(x);
+        case 1:
+            return (int)(y);
+        case 2:
+            return (int)(z);
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * set the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void setAt(int i, int value) {
+        switch (i) {
+        case 0:
+            x = value;
+            return;
+        case 1:
+            y = value;
+            return;
+        case 2:
+            z = value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * add the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void addAt(int i, int value) {
+        switch (i) {
+        case 0:
+            x += value;
+            return;
+        case 1:
+            y += value;
+            return;
+        case 2:
+            z += value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * copy the vector to int array
+     *
+     * @param data
+     * @param offset
+     */
+    public void copyTo(int[] data, int offset) {
+        data[offset] = (int)(x);
+        data[offset + 1] = (int)(y);
+        data[offset + 2] = (int)(z);
+    }
 }
-
-
-
-
diff --git a/graphics/java/android/renderscript/Int4.java b/graphics/java/android/renderscript/Int4.java
index eefb349..1c0e2e2 100644
--- a/graphics/java/android/renderscript/Int4.java
+++ b/graphics/java/android/renderscript/Int4.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,30 +16,499 @@
 
 package android.renderscript;
 
-import java.lang.Math;
-import android.util.Log;
-
-
 /**
- * Class for exposing the native RenderScript int4 type back to the Android system.
- *
- **/
+ * Vector version of the basic int type.
+ * Provides four int fields packed.
+ */
 public class Int4 {
-    public Int4() {
-    }
-
-    public Int4(int initX, int initY, int initZ, int initW) {
-        x = initX;
-        y = initY;
-        z = initZ;
-        w = initW;
-    }
-
     public int x;
     public int y;
     public int z;
     public int w;
+
+    public Int4() {
+    }
+
+    /** @hide */
+    public Int4(int i) {
+        this.x = this.y = this.z = this.w = i;
+    }
+
+    public Int4(int x, int y, int z, int w) {
+        this.x = x;
+        this.y = y;
+        this.z = z;
+        this.w = w;
+    }
+
+    /** @hide */
+    public Int4(Int4 source) {
+        this.x = source.x;
+        this.y = source.y;
+        this.z = source.z;
+        this.w = source.w;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     */
+    public void add(Int4 a) {
+        this.x += a.x;
+        this.y += a.y;
+        this.z += a.z;
+        this.w += a.w;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int4 add(Int4 a, Int4 b) {
+        Int4 result = new Int4();
+        result.x = a.x + b.x;
+        result.y = a.y + b.y;
+        result.z = a.z + b.z;
+        result.w = a.w + b.w;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param value
+     */
+    public void add(int value) {
+        x += value;
+        y += value;
+        z += value;
+        w += value;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int4 add(Int4 a, int b) {
+        Int4 result = new Int4();
+        result.x = a.x + b;
+        result.y = a.y + b;
+        result.z = a.z + b;
+        result.w = a.w + b;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     */
+    public void sub(Int4 a) {
+        this.x -= a.x;
+        this.y -= a.y;
+        this.z -= a.z;
+        this.w -= a.w;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int4 sub(Int4 a, Int4 b) {
+        Int4 result = new Int4();
+        result.x = a.x - b.x;
+        result.y = a.y - b.y;
+        result.z = a.z - b.z;
+        result.w = a.w - b.w;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param value
+     */
+    public void sub(int value) {
+        x -= value;
+        y -= value;
+        z -= value;
+        w -= value;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int4 sub(Int4 a, int b) {
+        Int4 result = new Int4();
+        result.x = a.x - b;
+        result.y = a.y - b;
+        result.z = a.z - b;
+        result.w = a.w - b;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     */
+    public void mul(Int4 a) {
+        this.x *= a.x;
+        this.y *= a.y;
+        this.z *= a.z;
+        this.w *= a.w;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int4 mul(Int4 a, Int4 b) {
+        Int4 result = new Int4();
+        result.x = a.x * b.x;
+        result.y = a.y * b.y;
+        result.z = a.z * b.z;
+        result.w = a.w * b.w;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param value
+     */
+    public void mul(int value) {
+        x *= value;
+        y *= value;
+        z *= value;
+        w *= value;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int4 mul(Int4 a, int b) {
+        Int4 result = new Int4();
+        result.x = a.x * b;
+        result.y = a.y * b;
+        result.z = a.z * b;
+        result.w = a.w * b;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     */
+    public void div(Int4 a) {
+        this.x /= a.x;
+        this.y /= a.y;
+        this.z /= a.z;
+        this.w /= a.w;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int4 div(Int4 a, Int4 b) {
+        Int4 result = new Int4();
+        result.x = a.x / b.x;
+        result.y = a.y / b.y;
+        result.z = a.z / b.z;
+        result.w = a.w / b.w;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param value
+     */
+    public void div(int value) {
+        x /= value;
+        y /= value;
+        z /= value;
+        w /= value;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int4 div(Int4 a, int b) {
+        Int4 result = new Int4();
+        result.x = a.x / b;
+        result.y = a.y / b;
+        result.z = a.z / b;
+        result.w = a.w / b;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     */
+    public void mod(Int4 a) {
+        this.x %= a.x;
+        this.y %= a.y;
+        this.z %= a.z;
+        this.w %= a.w;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int4 mod(Int4 a, Int4 b) {
+        Int4 result = new Int4();
+        result.x = a.x % b.x;
+        result.y = a.y % b.y;
+        result.z = a.z % b.z;
+        result.w = a.w % b.w;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param value
+     */
+    public void mod(int value) {
+        x %= value;
+        y %= value;
+        z %= value;
+        w %= value;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Int4 mod(Int4 a, int b) {
+        Int4 result = new Int4();
+        result.x = a.x % b;
+        result.y = a.y % b;
+        result.z = a.z % b;
+        result.w = a.w % b;
+
+        return result;
+    }
+
+    /** @hide
+     * get vector length
+     *
+     * @return
+     */
+    public int length() {
+        return 4;
+    }
+
+    /** @hide
+     * set vector negate
+     */
+    public void negate() {
+        this.x = -x;
+        this.y = -y;
+        this.z = -z;
+        this.w = -w;
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @return
+     */
+    public int dotProduct(Int4 a) {
+        return (int)((x * a.x) + (y * a.y) + (z * a.z) + (w * a.w));
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static int dotProduct(Int4 a, Int4 b) {
+        return (int)((b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w));
+    }
+
+    /** @hide
+     * Vector add Multiple
+     *
+     * @param a
+     * @param factor
+     */
+    public void addMultiple(Int4 a, int factor) {
+        x += a.x * factor;
+        y += a.y * factor;
+        z += a.z * factor;
+        w += a.w * factor;
+    }
+
+    /** @hide
+     * set vector value by Int4
+     *
+     * @param a
+     */
+    public void set(Int4 a) {
+        this.x = a.x;
+        this.y = a.y;
+        this.z = a.z;
+        this.w = a.w;
+    }
+
+    /** @hide
+     * set the vector field value by Int
+     *
+     * @param a
+     * @param b
+     * @param c
+     * @param d
+     */
+    public void setValues(int a, int b, int c, int d) {
+        this.x = a;
+        this.y = b;
+        this.z = c;
+        this.w = d;
+    }
+
+    /** @hide
+     * return the element sum of vector
+     *
+     * @return
+     */
+    public int elementSum() {
+        return (int)(x + y + z + w);
+    }
+
+    /** @hide
+     * get the vector field value by index
+     *
+     * @param i
+     * @return
+     */
+    public int get(int i) {
+        switch (i) {
+        case 0:
+            return (int)(x);
+        case 1:
+            return (int)(y);
+        case 2:
+            return (int)(z);
+        case 3:
+            return (int)(w);
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * set the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void setAt(int i, int value) {
+        switch (i) {
+        case 0:
+            x = value;
+            return;
+        case 1:
+            y = value;
+            return;
+        case 2:
+            z = value;
+            return;
+        case 3:
+            w = value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * add the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void addAt(int i, int value) {
+        switch (i) {
+        case 0:
+            x += value;
+            return;
+        case 1:
+            y += value;
+            return;
+        case 2:
+            z += value;
+            return;
+        case 3:
+            w += value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * copy the vector to int array
+     *
+     * @param data
+     * @param offset
+     */
+    public void copyTo(int[] data, int offset) {
+        data[offset] = (int)(x);
+        data[offset + 1] = (int)(y);
+        data[offset + 2] = (int)(z);
+        data[offset + 3] = (int)(w);
+    }
 }
-
-
-
diff --git a/graphics/java/android/renderscript/Long2.java b/graphics/java/android/renderscript/Long2.java
index bd8382d..fabf204 100644
--- a/graphics/java/android/renderscript/Long2.java
+++ b/graphics/java/android/renderscript/Long2.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,26 +16,425 @@
 
 package android.renderscript;
 
-import java.lang.Math;
-import android.util.Log;
-
-
 /**
- * Class for exposing the native RenderScript long2 type back to the Android system.
- **/
+ * Vector version of the basic long type.
+ * Provides two long fields packed.
+ */
 public class Long2 {
+    public long x;
+    public long y;
+
     public Long2() {
     }
 
-    public Long2(long initX, long initY) {
-        x = initX;
-        y = initY;
+    /** @hide */
+    public Long2(long i) {
+        this.x = this.y = i;
     }
 
-    public long x;
-    public long y;
+    public Long2(long x, long y) {
+        this.x = x;
+        this.y = y;
+    }
+
+    /** @hide */
+    public Long2(Long2 source) {
+        this.x = source.x;
+        this.y = source.y;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     */
+    public void add(Long2 a) {
+        this.x += a.x;
+        this.y += a.y;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long2 add(Long2 a, Long2 b) {
+        Long2 result = new Long2();
+        result.x = a.x + b.x;
+        result.y = a.y + b.y;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param value
+     */
+    public void add(long value) {
+        x += value;
+        y += value;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long2 add(Long2 a, long b) {
+        Long2 result = new Long2();
+        result.x = a.x + b;
+        result.y = a.y + b;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     */
+    public void sub(Long2 a) {
+        this.x -= a.x;
+        this.y -= a.y;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long2 sub(Long2 a, Long2 b) {
+        Long2 result = new Long2();
+        result.x = a.x - b.x;
+        result.y = a.y - b.y;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param value
+     */
+    public void sub(long value) {
+        x -= value;
+        y -= value;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long2 sub(Long2 a, long b) {
+        Long2 result = new Long2();
+        result.x = a.x - b;
+        result.y = a.y - b;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     */
+    public void mul(Long2 a) {
+        this.x *= a.x;
+        this.y *= a.y;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long2 mul(Long2 a, Long2 b) {
+        Long2 result = new Long2();
+        result.x = a.x * b.x;
+        result.y = a.y * b.y;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param value
+     */
+    public void mul(long value) {
+        x *= value;
+        y *= value;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long2 mul(Long2 a, long b) {
+        Long2 result = new Long2();
+        result.x = a.x * b;
+        result.y = a.y * b;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     */
+    public void div(Long2 a) {
+        this.x /= a.x;
+        this.y /= a.y;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long2 div(Long2 a, Long2 b) {
+        Long2 result = new Long2();
+        result.x = a.x / b.x;
+        result.y = a.y / b.y;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param value
+     */
+    public void div(long value) {
+        x /= value;
+        y /= value;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long2 div(Long2 a, long b) {
+        Long2 result = new Long2();
+        result.x = a.x / b;
+        result.y = a.y / b;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     */
+    public void mod(Long2 a) {
+        this.x %= a.x;
+        this.y %= a.y;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long2 mod(Long2 a, Long2 b) {
+        Long2 result = new Long2();
+        result.x = a.x % b.x;
+        result.y = a.y % b.y;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param value
+     */
+    public void mod(long value) {
+        x %= value;
+        y %= value;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long2 mod(Long2 a, long b) {
+        Long2 result = new Long2();
+        result.x = a.x % b;
+        result.y = a.y % b;
+
+        return result;
+    }
+
+    /** @hide
+     * get vector length
+     *
+     * @return
+     */
+    public long length() {
+        return 2;
+    }
+
+    /** @hide
+     * set vector negate
+     */
+    public void negate() {
+        this.x = -x;
+        this.y = -y;
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @return
+     */
+    public long dotProduct(Long2 a) {
+        return (long)((x * a.x) + (y * a.y));
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static long dotProduct(Long2 a, Long2 b) {
+        return (long)((b.x * a.x) + (b.y * a.y));
+    }
+
+    /** @hide
+     * Vector add Multiple
+     *
+     * @param a
+     * @param factor
+     */
+    public void addMultiple(Long2 a, long factor) {
+        x += a.x * factor;
+        y += a.y * factor;
+    }
+
+    /** @hide
+     * set vector value by Long2
+     *
+     * @param a
+     */
+    public void set(Long2 a) {
+        this.x = a.x;
+        this.y = a.y;
+    }
+
+    /** @hide
+     * set the vector field value by Long
+     *
+     * @param a
+     * @param b
+     */
+    public void setValues(long a, long b) {
+        this.x = a;
+        this.y = b;
+    }
+
+    /** @hide
+     * return the element sum of vector
+     *
+     * @return
+     */
+    public long elementSum() {
+        return (long)(x + y);
+    }
+
+    /** @hide
+     * get the vector field value by index
+     *
+     * @param i
+     * @return
+     */
+    public long get(int i) {
+        switch (i) {
+        case 0:
+            return (long)(x);
+        case 1:
+            return (long)(y);
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * set the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void setAt(int i, long value) {
+        switch (i) {
+        case 0:
+            x = value;
+            return;
+        case 1:
+            y = value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * add the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void addAt(int i, long value) {
+        switch (i) {
+        case 0:
+            x += value;
+            return;
+        case 1:
+            y += value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * copy the vector to long array
+     *
+     * @param data
+     * @param offset
+     */
+    public void copyTo(long[] data, int offset) {
+        data[offset] = (long)(x);
+        data[offset + 1] = (long)(y);
+    }
 }
-
-
-
-
diff --git a/graphics/java/android/renderscript/Long3.java b/graphics/java/android/renderscript/Long3.java
index 3e94942..88ff855 100644
--- a/graphics/java/android/renderscript/Long3.java
+++ b/graphics/java/android/renderscript/Long3.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,28 +16,462 @@
 
 package android.renderscript;
 
-import java.lang.Math;
-import android.util.Log;
-
-
 /**
- * Class for exposing the native RenderScript long3 type back to the Android system.
- **/
+ * Vector version of the basic long type.
+ * Provides three long fields packed.
+ */
 public class Long3 {
-    public Long3() {
-    }
-
-    public Long3(long initX, long initY, long initZ) {
-        x = initX;
-        y = initY;
-        z = initZ;
-    }
-
     public long x;
     public long y;
     public long z;
+
+    public Long3() {
+    }
+    
+    /** @hide */
+    public Long3(long i) {
+        this.x = this.y = this.z = i;
+    }
+
+    public Long3(long x, long y, long z) {
+        this.x = x;
+        this.y = y;
+        this.z = z;
+    }
+
+    /** @hide */
+    public Long3(Long3 source) {
+        this.x = source.x;
+        this.y = source.y;
+        this.z = source.z;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     */
+    public void add(Long3 a) {
+        this.x += a.x;
+        this.y += a.y;
+        this.z += a.z;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long3 add(Long3 a, Long3 b) {
+        Long3 result = new Long3();
+        result.x = a.x + b.x;
+        result.y = a.y + b.y;
+        result.z = a.z + b.z;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param value
+     */
+    public void add(long value) {
+        x += value;
+        y += value;
+        z += value;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long3 add(Long3 a, long b) {
+        Long3 result = new Long3();
+        result.x = a.x + b;
+        result.y = a.y + b;
+        result.z = a.z + b;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     */
+    public void sub(Long3 a) {
+        this.x -= a.x;
+        this.y -= a.y;
+        this.z -= a.z;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long3 sub(Long3 a, Long3 b) {
+        Long3 result = new Long3();
+        result.x = a.x - b.x;
+        result.y = a.y - b.y;
+        result.z = a.z - b.z;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param value
+     */
+    public void sub(long value) {
+        x -= value;
+        y -= value;
+        z -= value;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long3 sub(Long3 a, long b) {
+        Long3 result = new Long3();
+        result.x = a.x - b;
+        result.y = a.y - b;
+        result.z = a.z - b;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     */
+    public void mul(Long3 a) {
+        this.x *= a.x;
+        this.y *= a.y;
+        this.z *= a.z;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long3 mul(Long3 a, Long3 b) {
+        Long3 result = new Long3();
+        result.x = a.x * b.x;
+        result.y = a.y * b.y;
+        result.z = a.z * b.z;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param value
+     */
+    public void mul(long value) {
+        x *= value;
+        y *= value;
+        z *= value;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long3 mul(Long3 a, long b) {
+        Long3 result = new Long3();
+        result.x = a.x * b;
+        result.y = a.y * b;
+        result.z = a.z * b;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     */
+    public void div(Long3 a) {
+        this.x /= a.x;
+        this.y /= a.y;
+        this.z /= a.z;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long3 div(Long3 a, Long3 b) {
+        Long3 result = new Long3();
+        result.x = a.x / b.x;
+        result.y = a.y / b.y;
+        result.z = a.z / b.z;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param value
+     */
+    public void div(long value) {
+        x /= value;
+        y /= value;
+        z /= value;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long3 div(Long3 a, long b) {
+        Long3 result = new Long3();
+        result.x = a.x / b;
+        result.y = a.y / b;
+        result.z = a.z / b;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     */
+    public void mod(Long3 a) {
+        this.x %= a.x;
+        this.y %= a.y;
+        this.z %= a.z;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long3 mod(Long3 a, Long3 b) {
+        Long3 result = new Long3();
+        result.x = a.x % b.x;
+        result.y = a.y % b.y;
+        result.z = a.z % b.z;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param value
+     */
+    public void mod(long value) {
+        x %= value;
+        y %= value;
+        z %= value;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long3 mod(Long3 a, long b) {
+        Long3 result = new Long3();
+        result.x = a.x % b;
+        result.y = a.y % b;
+        result.z = a.z % b;
+
+        return result;
+    }
+
+    /** @hide
+     * get vector length
+     *
+     * @return
+     */
+    public long length() {
+        return 3;
+    }
+
+    /** @hide
+     * set vector negate
+     */
+    public void negate() {
+        this.x = -x;
+        this.y = -y;
+        this.z = -z;
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @return
+     */
+    public long dotProduct(Long3 a) {
+        return (long)((x * a.x) + (y * a.y) + (z * a.z));
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static long dotProduct(Long3 a, Long3 b) {
+        return (long)((b.x * a.x) + (b.y * a.y) + (b.z * a.z));
+    }
+
+    /** @hide
+     * Vector add Multiple
+     *
+     * @param a
+     * @param factor
+     */
+    public void addMultiple(Long3 a, long factor) {
+        x += a.x * factor;
+        y += a.y * factor;
+        z += a.z * factor;
+    }
+
+    /** @hide
+     * set vector value by Long3
+     *
+     * @param a
+     */
+    public void set(Long3 a) {
+        this.x = a.x;
+        this.y = a.y;
+        this.z = a.z;
+    }
+
+    /** @hide
+     * set the vector field value by Long
+     *
+     * @param a
+     * @param b
+     * @param c
+     */
+    public void setValues(long a, long b, long c) {
+        this.x = a;
+        this.y = b;
+        this.z = c;
+    }
+
+    /** @hide
+     * return the element sum of vector
+     *
+     * @return
+     */
+    public long elementSum() {
+        return (long)(x + y + z);
+    }
+
+    /** @hide
+     * get the vector field value by index
+     *
+     * @param i
+     * @return
+     */
+    public long get(int i) {
+        switch (i) {
+        case 0:
+            return (long)(x);
+        case 1:
+            return (long)(y);
+        case 2:
+            return (long)(z);
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * set the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void setAt(int i, long value) {
+        switch (i) {
+        case 0:
+            x = value;
+            return;
+        case 1:
+            y = value;
+            return;
+        case 2:
+            z = value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * add the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void addAt(int i, long value) {
+        switch (i) {
+        case 0:
+            x += value;
+            return;
+        case 1:
+            y += value;
+            return;
+        case 2:
+            z += value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * copy the vector to long array
+     *
+     * @param data
+     * @param offset
+     */
+    public void copyTo(long[] data, int offset) {
+        data[offset] = (long)(x);
+        data[offset + 1] = (long)(y);
+        data[offset + 2] = (long)(z);
+    }
 }
-
-
-
-
diff --git a/graphics/java/android/renderscript/Long4.java b/graphics/java/android/renderscript/Long4.java
index 00fb7e6..757b910 100644
--- a/graphics/java/android/renderscript/Long4.java
+++ b/graphics/java/android/renderscript/Long4.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,29 +16,499 @@
 
 package android.renderscript;
 
-import java.lang.Math;
-import android.util.Log;
-
-
 /**
- * Class for exposing the native RenderScript long4 type back to the Android system.
- **/
+ * Vector version of the basic long type.
+ * Provides four long fields packed.
+ */
 public class Long4 {
-    public Long4() {
-    }
-
-    public Long4(long initX, long initY, long initZ, long initW) {
-        x = initX;
-        y = initY;
-        z = initZ;
-        w = initW;
-    }
-
     public long x;
     public long y;
     public long z;
     public long w;
+
+    public Long4() {
+    }
+
+    /** @hide */
+    public Long4(long i) {
+        this.x = this.y = this.z = this.w = i;
+    }
+
+    public Long4(long x, long y, long z, long w) {
+        this.x = x;
+        this.y = y;
+        this.z = z;
+        this.w = w;
+    }
+
+    /** @hide */
+    public Long4(Long4 source) {
+        this.x = source.x;
+        this.y = source.y;
+        this.z = source.z;
+        this.w = source.w;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     */
+    public void add(Long4 a) {
+        this.x += a.x;
+        this.y += a.y;
+        this.z += a.z;
+        this.w += a.w;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long4 add(Long4 a, Long4 b) {
+        Long4 result = new Long4();
+        result.x = a.x + b.x;
+        result.y = a.y + b.y;
+        result.z = a.z + b.z;
+        result.w = a.w + b.w;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param value
+     */
+    public void add(long value) {
+        x += value;
+        y += value;
+        z += value;
+        w += value;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long4 add(Long4 a, long b) {
+        Long4 result = new Long4();
+        result.x = a.x + b;
+        result.y = a.y + b;
+        result.z = a.z + b;
+        result.w = a.w + b;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     */
+    public void sub(Long4 a) {
+        this.x -= a.x;
+        this.y -= a.y;
+        this.z -= a.z;
+        this.w -= a.w;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long4 sub(Long4 a, Long4 b) {
+        Long4 result = new Long4();
+        result.x = a.x - b.x;
+        result.y = a.y - b.y;
+        result.z = a.z - b.z;
+        result.w = a.w - b.w;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param value
+     */
+    public void sub(long value) {
+        x -= value;
+        y -= value;
+        z -= value;
+        w -= value;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long4 sub(Long4 a, long b) {
+        Long4 result = new Long4();
+        result.x = a.x - b;
+        result.y = a.y - b;
+        result.z = a.z - b;
+        result.w = a.w - b;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     */
+    public void mul(Long4 a) {
+        this.x *= a.x;
+        this.y *= a.y;
+        this.z *= a.z;
+        this.w *= a.w;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long4 mul(Long4 a, Long4 b) {
+        Long4 result = new Long4();
+        result.x = a.x * b.x;
+        result.y = a.y * b.y;
+        result.z = a.z * b.z;
+        result.w = a.w * b.w;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param value
+     */
+    public void mul(long value) {
+        x *= value;
+        y *= value;
+        z *= value;
+        w *= value;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long4 mul(Long4 a, long b) {
+        Long4 result = new Long4();
+        result.x = a.x * b;
+        result.y = a.y * b;
+        result.z = a.z * b;
+        result.w = a.w * b;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     */
+    public void div(Long4 a) {
+        this.x /= a.x;
+        this.y /= a.y;
+        this.z /= a.z;
+        this.w /= a.w;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long4 div(Long4 a, Long4 b) {
+        Long4 result = new Long4();
+        result.x = a.x / b.x;
+        result.y = a.y / b.y;
+        result.z = a.z / b.z;
+        result.w = a.w / b.w;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param value
+     */
+    public void div(long value) {
+        x /= value;
+        y /= value;
+        z /= value;
+        w /= value;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long4 div(Long4 a, long b) {
+        Long4 result = new Long4();
+        result.x = a.x / b;
+        result.y = a.y / b;
+        result.z = a.z / b;
+        result.w = a.w / b;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     */
+    public void mod(Long4 a) {
+        this.x %= a.x;
+        this.y %= a.y;
+        this.z %= a.z;
+        this.w %= a.w;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long4 mod(Long4 a, Long4 b) {
+        Long4 result = new Long4();
+        result.x = a.x % b.x;
+        result.y = a.y % b.y;
+        result.z = a.z % b.z;
+        result.w = a.w % b.w;
+
+        return result;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param value
+     */
+    public void mod(long value) {
+        x %= value;
+        y %= value;
+        z %= value;
+        w %= value;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Long4 mod(Long4 a, long b) {
+        Long4 result = new Long4();
+        result.x = a.x % b;
+        result.y = a.y % b;
+        result.z = a.z % b;
+        result.w = a.w % b;
+
+        return result;
+    }
+
+    /** @hide
+     * get vector length
+     *
+     * @return
+     */
+    public long length() {
+        return 4;
+    }
+
+    /** @hide
+     * set vector negate
+     */
+    public void negate() {
+        this.x = -x;
+        this.y = -y;
+        this.z = -z;
+        this.w = -w;
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @return
+     */
+    public long dotProduct(Long4 a) {
+        return (long)((x * a.x) + (y * a.y) + (z * a.z) + (w * a.w));
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static long dotProduct(Long4 a, Long4 b) {
+        return (long)((b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w));
+    }
+
+    /** @hide
+     * Vector add Multiple
+     *
+     * @param a
+     * @param factor
+     */
+    public void addMultiple(Long4 a, long factor) {
+        x += a.x * factor;
+        y += a.y * factor;
+        z += a.z * factor;
+        w += a.w * factor;
+    }
+
+    /** @hide
+     * set vector value by Long4
+     *
+     * @param a
+     */
+    public void set(Long4 a) {
+        this.x = a.x;
+        this.y = a.y;
+        this.z = a.z;
+        this.w = a.w;
+    }
+
+    /** @hide
+     * set the vector field value by Long
+     *
+     * @param a
+     * @param b
+     * @param c
+     * @param d
+     */
+    public void setValues(long a, long b, long c, long d) {
+        this.x = a;
+        this.y = b;
+        this.z = c;
+        this.w = d;
+    }
+
+    /** @hide
+     * return the element sum of vector
+     *
+     * @return
+     */
+    public long elementSum() {
+        return (long)(x + y + z + w);
+    }
+
+    /** @hide
+     * get the vector field value by index
+     *
+     * @param i
+     * @return
+     */
+    public long get(int i) {
+        switch (i) {
+        case 0:
+            return (long)(x);
+        case 1:
+            return (long)(y);
+        case 2:
+            return (long)(z);
+        case 3:
+            return (long)(w);
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * set the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void setAt(int i, long value) {
+        switch (i) {
+        case 0:
+            x = value;
+            return;
+        case 1:
+            y = value;
+            return;
+        case 2:
+            z = value;
+            return;
+        case 3:
+            w = value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * add the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void addAt(int i, long value) {
+        switch (i) {
+        case 0:
+            x += value;
+            return;
+        case 1:
+            y += value;
+            return;
+        case 2:
+            z += value;
+            return;
+        case 3:
+            w += value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * copy the vector to long array
+     *
+     * @param data
+     * @param offset
+     */
+    public void copyTo(Long[] data, int offset) {
+        data[offset] = (long)(x);
+        data[offset + 1] = (long)(y);
+        data[offset + 2] = (long)(z);
+        data[offset + 3] = (long)(w);
+    }
 }
-
-
-
diff --git a/graphics/java/android/renderscript/Short2.java b/graphics/java/android/renderscript/Short2.java
index 7c6027f..070d608 100644
--- a/graphics/java/android/renderscript/Short2.java
+++ b/graphics/java/android/renderscript/Short2.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,27 +16,425 @@
 
 package android.renderscript;
 
-import java.lang.Math;
-import android.util.Log;
-
-
-/**
- * Class for exposing the native RenderScript Short2 type back to the Android system.
- *
- **/
+/** 
+ * Vector version of the basic short type.
+ * Provides two short fields packed.
+ */
 public class Short2 {
+    public short x;
+    public short y;
+
     public Short2() {
     }
 
-    public Short2(short initX, short initY) {
-        x = initX;
-        y = initY;
+    /** @hide */
+    public Short2(short i) {
+        this.x = this.y = i;
     }
 
-    public short x;
-    public short y;
+    public Short2(short x, short y) {
+        this.x = x;
+        this.y = y;
+    }
+
+    /** @hide */
+    public Short2(Short2 source) {
+        this.x = source.x;
+        this.y = source.y;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     */
+    public void add(Short2 a) {
+        this.x += a.x;
+        this.y += a.y;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short2 add(Short2 a, Short2 b) {
+        Short2 result = new Short2();
+        result.x = (short)(a.x + b.x);
+        result.y = (short)(a.y + b.y);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param value
+     */
+    public void add(short value) {
+        x += value;
+        y += value;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short2 add(Short2 a, short b) {
+        Short2 result = new Short2();
+        result.x = (short)(a.x + b);
+        result.y = (short)(a.y + b);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     */
+    public void sub(Short2 a) {
+        this.x -= a.x;
+        this.y -= a.y;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short2 sub(Short2 a, Short2 b) {
+        Short2 result = new Short2();
+        result.x = (short)(a.x - b.x);
+        result.y = (short)(a.y - b.y);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param value
+     */
+    public void sub(short value) {
+        x -= value;
+        y -= value;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short2 sub(Short2 a, short b) {
+        Short2 result = new Short2();
+        result.x = (short)(a.x - b);
+        result.y = (short)(a.y - b);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     */
+    public void mul(Short2 a) {
+        this.x *= a.x;
+        this.y *= a.y;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short2 mul(Short2 a, Short2 b) {
+        Short2 result = new Short2();
+        result.x = (short)(a.x * b.x);
+        result.y = (short)(a.y * b.y);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param value
+     */
+    public void mul(short value) {
+        x *= value;
+        y *= value;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short2 mul(Short2 a, short b) {
+        Short2 result = new Short2();
+        result.x = (short)(a.x * b);
+        result.y = (short)(a.y * b);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     */
+    public void div(Short2 a) {
+        this.x /= a.x;
+        this.y /= a.y;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short2 div(Short2 a, Short2 b) {
+        Short2 result = new Short2();
+        result.x = (short)(a.x / b.x);
+        result.y = (short)(a.y / b.y);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param value
+     */
+    public void div(short value) {
+        x /= value;
+        y /= value;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short2 div(Short2 a, short b) {
+        Short2 result = new Short2();
+        result.x = (short)(a.x / b);
+        result.y = (short)(a.y / b);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     */
+    public void mod(Short2 a) {
+        this.x %= a.x;
+        this.y %= a.y;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short2 mod(Short2 a, Short2 b) {
+        Short2 result = new Short2();
+        result.x = (short)(a.x % b.x);
+        result.y = (short)(a.y % b.y);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param value
+     */
+    public void mod(short value) {
+        x %= value;
+        y %= value;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short2 mod(Short2 a, short b) {
+        Short2 result = new Short2();
+        result.x = (short)(a.x % b);
+        result.y = (short)(a.y % b);
+
+        return result;
+    }
+
+    /** @hide
+     * get vector length
+     *
+     * @return
+     */
+    public short length() {
+        return 2;
+    }
+
+    /** @hide
+     * set vector negate
+     */
+    public void negate() {
+        this.x = (short)(-x);
+        this.y = (short)(-y);
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @return
+     */
+    public short dotProduct(Short2 a) {
+        return (short)((x * a.x) + (y * a.y));
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static short dotProduct(Short2 a, Short2 b) {
+        return (short)((b.x * a.x) + (b.y * a.y));
+    }
+
+    /** @hide
+     * Vector add Multiple
+     *
+     * @param a
+     * @param factor
+     */
+    public void addMultiple(Short2 a, short factor) {
+        x += a.x * factor;
+        y += a.y * factor;
+    }
+
+    /** @hide
+     * set vector value by Short2
+     *
+     * @param a
+     */
+    public void set(Short2 a) {
+        this.x = a.x;
+        this.y = a.y;
+    }
+
+    /** @hide
+     * set the vector field value by Short
+     *
+     * @param a
+     * @param b
+     */
+    public void setValues(short a, short b) {
+        this.x = a;
+        this.y = b;
+    }
+
+    /** @hide
+     * return the element sum of vector
+     *
+     * @return
+     */
+    public short elementSum() {
+        return (short)(x + y);
+    }
+
+    /** @hide
+     * get the vector field value by index
+     *
+     * @param i
+     * @return
+     */
+    public short get(int i) {
+        switch (i) {
+        case 0:
+            return (short)(x);
+        case 1:
+            return (short)(y);
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * set the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void setAt(int i, short value) {
+        switch (i) {
+        case 0:
+            x = value;
+            return;
+        case 1:
+            y = value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * add the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void addAt(int i, short value) {
+        switch (i) {
+        case 0:
+            x += value;
+            return;
+        case 1:
+            y += value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * copy the vector to short array
+     *
+     * @param data
+     * @param offset
+     */
+    public void copyTo(short[] data, int offset) {
+        data[offset] = (short)(x);
+        data[offset + 1] = (short)(y);
+    }
 }
-
-
-
-
diff --git a/graphics/java/android/renderscript/Short3.java b/graphics/java/android/renderscript/Short3.java
index 49de05e..661db0a 100644
--- a/graphics/java/android/renderscript/Short3.java
+++ b/graphics/java/android/renderscript/Short3.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,29 +16,462 @@
 
 package android.renderscript;
 
-import java.lang.Math;
-import android.util.Log;
-
-
 /**
- * Class for exposing the native RenderScript short3 type back to the Android system.
- *
- **/
+ * Vector version of the basic short type.
+ * Provides three short fields packed.
+ */
 public class Short3 {
-    public Short3() {
-    }
-
-    public Short3(short initX, short initY, short initZ) {
-        x = initX;
-        y = initY;
-        z = initZ;
-    }
-
     public short x;
     public short y;
     public short z;
+
+    public Short3() {
+    }
+
+    /** @hide */
+    public Short3(short i) {
+        this.x = this.y = this.z = i;
+    }
+
+    public Short3(short x, short y, short z) {
+        this.x = x;
+        this.y = y;
+        this.z = z;
+    }
+
+    /** @hide */
+    public Short3(Short3 source) {
+        this.x = source.x;
+        this.y = source.y;
+        this.z = source.z;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     */
+    public void add(Short3 a) {
+        this.x += a.x;
+        this.y += a.y;
+        this.z += a.z;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short3 add(Short3 a, Short3 b) {
+        Short3 result = new Short3();
+        result.x = (short)(a.x + b.x);
+        result.y = (short)(a.y + b.y);
+        result.z = (short)(a.z + b.z);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param value
+     */
+    public void add(short value) {
+        x += value;
+        y += value;
+        z += value;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short3 add(Short3 a, short b) {
+        Short3 result = new Short3();
+        result.x = (short)(a.x + b);
+        result.y = (short)(a.y + b);
+        result.z = (short)(a.z + b);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     */
+    public void sub(Short3 a) {
+        this.x -= a.x;
+        this.y -= a.y;
+        this.z -= a.z;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short3 sub(Short3 a, Short3 b) {
+        Short3 result = new Short3();
+        result.x = (short)(a.x - b.x);
+        result.y = (short)(a.y - b.y);
+        result.z = (short)(a.z - b.z);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param value
+     */
+    public void sub(short value) {
+        x -= value;
+        y -= value;
+        z -= value;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short3 sub(Short3 a, short b) {
+        Short3 result = new Short3();
+        result.x = (short)(a.x - b);
+        result.y = (short)(a.y - b);
+        result.z = (short)(a.z - b);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     */
+    public void mul(Short3 a) {
+        this.x *= a.x;
+        this.y *= a.y;
+        this.z *= a.z;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short3 mul(Short3 a, Short3 b) {
+        Short3 result = new Short3();
+        result.x = (short)(a.x * b.x);
+        result.y = (short)(a.y * b.y);
+        result.z = (short)(a.z * b.z);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param value
+     */
+    public void mul(short value) {
+        x *= value;
+        y *= value;
+        z *= value;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short3 mul(Short3 a, short b) {
+        Short3 result = new Short3();
+        result.x = (short)(a.x * b);
+        result.y = (short)(a.y * b);
+        result.z = (short)(a.z * b);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     */
+    public void div(Short3 a) {
+        this.x /= a.x;
+        this.y /= a.y;
+        this.z /= a.z;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short3 div(Short3 a, Short3 b) {
+        Short3 result = new Short3();
+        result.x = (short)(a.x / b.x);
+        result.y = (short)(a.y / b.y);
+        result.z = (short)(a.z / b.z);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param value
+     */
+    public void div(short value) {
+        x /= value;
+        y /= value;
+        z /= value;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short3 div(Short3 a, short b) {
+        Short3 result = new Short3();
+        result.x = (short)(a.x / b);
+        result.y = (short)(a.y / b);
+        result.z = (short)(a.z / b);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     */
+    public void mod(Short3 a) {
+        this.x %= a.x;
+        this.y %= a.y;
+        this.z %= a.z;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short3 mod(Short3 a, Short3 b) {
+        Short3 result = new Short3();
+        result.x = (short)(a.x % b.x);
+        result.y = (short)(a.y % b.y);
+        result.z = (short)(a.z % b.z);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param value
+     */
+    public void mod(short value) {
+        x %= value;
+        y %= value;
+        z %= value;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short3 mod(Short3 a, short b) {
+        Short3 result = new Short3();
+        result.x = (short)(a.x % b);
+        result.y = (short)(a.y % b);
+        result.z = (short)(a.z % b);
+
+        return result;
+    }
+
+    /** @hide
+     * get vector length
+     *
+     * @return
+     */
+    public short length() {
+        return 3;
+    }
+
+    /** @hide
+     * set vector negate
+     */
+    public void negate() {
+        this.x = (short)(-x);
+        this.y = (short)(-y);
+        this.z = (short)(-z);
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @return
+     */
+    public short dotProduct(Short3 a) {
+        return (short)((x * a.x) + (y * a.y) + (z * a.z));
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static short dotProduct(Short3 a, Short3 b) {
+        return (short)((b.x * a.x) + (b.y * a.y) + (b.z * a.z));
+    }
+
+    /** @hide
+     * Vector add Multiple
+     *
+     * @param a
+     * @param factor
+     */
+    public void addMultiple(Short3 a, short factor) {
+        x += a.x * factor;
+        y += a.y * factor;
+        z += a.z * factor;
+    }
+
+    /** @hide
+     * set vector value by Short3
+     *
+     * @param a
+     */
+    public void set(Short3 a) {
+        this.x = a.x;
+        this.y = a.y;
+        this.z = a.z;
+    }
+
+    /** @hide
+     * set the vector field value by Short
+     *
+     * @param a
+     * @param b
+     * @param c
+     */
+    public void setValues(short a, short b, short c) {
+        this.x = a;
+        this.y = b;
+        this.z = c;
+    }
+
+    /** @hide
+     * return the element sum of vector
+     *
+     * @return
+     */
+    public short elementSum() {
+        return (short)(x + y + z);
+    }
+
+    /** @hide
+     * get the vector field value by index
+     *
+     * @param i
+     * @return
+     */
+    public short get(int i) {
+        switch (i) {
+        case 0:
+            return (short)(x);
+        case 1:
+            return (short)(y);
+        case 2:
+            return (short)(z);
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * set the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void setAt(int i, short value) {
+        switch (i) {
+        case 0:
+            x = value;
+            return;
+        case 1:
+            y = value;
+            return;
+        case 2:
+            z = value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * add the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void addAt(int i, short value) {
+        switch (i) {
+        case 0:
+            x += value;
+            return;
+        case 1:
+            y += value;
+            return;
+        case 2:
+            z += value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * copy the vector to short array
+     *
+     * @param data
+     * @param offset
+     */
+    public void copyTo(short[] data, int offset) {
+        data[offset] = (short)(x);
+        data[offset + 1] = (short)(y);
+        data[offset + 2] = (short)(z);
+    }
 }
-
-
-
-
diff --git a/graphics/java/android/renderscript/Short4.java b/graphics/java/android/renderscript/Short4.java
index a7807a4..a2d74f2 100644
--- a/graphics/java/android/renderscript/Short4.java
+++ b/graphics/java/android/renderscript/Short4.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,30 +16,499 @@
 
 package android.renderscript;
 
-import java.lang.Math;
-import android.util.Log;
-
-
 /**
- * Class for exposing the native RenderScript short4 type back to the Android system.
- *
- **/
+ * Vector version of the basic short type.
+ * Provides four short fields packed.
+ */
 public class Short4 {
-    public Short4() {
-    }
-
-    public Short4(short initX, short initY, short initZ, short initW) {
-        x = initX;
-        y = initY;
-        z = initZ;
-        w = initW;
-    }
-
     public short x;
     public short y;
     public short z;
     public short w;
+
+    public Short4() {
+    }
+
+    /** @hide */
+    public Short4(short i) {
+        this.x = this.y = this.z = this.w = i;
+    }
+
+    public Short4(short x, short y, short z, short w) {
+        this.x = x;
+        this.y = y;
+        this.z = z;
+        this.w = w;
+    }
+
+    /** @hide */
+    public Short4(Short4 source) {
+        this.x = source.x;
+        this.y = source.y;
+        this.z = source.z;
+        this.w = source.w;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     */
+    public void add(Short4 a) {
+        this.x += a.x;
+        this.y += a.y;
+        this.z += a.z;
+        this.w += a.w;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short4 add(Short4 a, Short4 b) {
+        Short4 result = new Short4();
+        result.x = (short)(a.x + b.x);
+        result.y = (short)(a.y + b.y);
+        result.z = (short)(a.z + b.z);
+        result.w = (short)(a.w + b.w);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param value
+     */
+    public void add(short value) {
+        x += value;
+        y += value;
+        z += value;
+        w += value;
+    }
+
+    /** @hide
+     * Vector add
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short4 add(Short4 a, short b) {
+        Short4 result = new Short4();
+        result.x = (short)(a.x + b);
+        result.y = (short)(a.y + b);
+        result.z = (short)(a.z + b);
+        result.w = (short)(a.w + b);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     */
+    public void sub(Short4 a) {
+        this.x -= a.x;
+        this.y -= a.y;
+        this.z -= a.z;
+        this.w -= a.w;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short4 sub(Short4 a, Short4 b) {
+        Short4 result = new Short4();
+        result.x = (short)(a.x - b.x);
+        result.y = (short)(a.y - b.y);
+        result.z = (short)(a.z - b.z);
+        result.w = (short)(a.w - b.w);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param value
+     */
+    public void sub(short value) {
+        x -= value;
+        y -= value;
+        z -= value;
+        w -= value;
+    }
+
+    /** @hide
+     * Vector subtraction
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short4 sub(Short4 a, short b) {
+        Short4 result = new Short4();
+        result.x = (short)(a.x - b);
+        result.y = (short)(a.y - b);
+        result.z = (short)(a.z - b);
+        result.w = (short)(a.w - b);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     */
+    public void mul(Short4 a) {
+        this.x *= a.x;
+        this.y *= a.y;
+        this.z *= a.z;
+        this.w *= a.w;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short4 mul(Short4 a, Short4 b) {
+        Short4 result = new Short4();
+        result.x = (short)(a.x * b.x);
+        result.y = (short)(a.y * b.y);
+        result.z = (short)(a.z * b.z);
+        result.w = (short)(a.w * b.w);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param value
+     */
+    public void mul(short value) {
+        x *= value;
+        y *= value;
+        z *= value;
+        w *= value;
+    }
+
+    /** @hide
+     * Vector multiplication
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short4 mul(Short4 a, short b) {
+        Short4 result = new Short4();
+        result.x = (short)(a.x * b);
+        result.y = (short)(a.y * b);
+        result.z = (short)(a.z * b);
+        result.w = (short)(a.w * b);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     */
+    public void div(Short4 a) {
+        this.x /= a.x;
+        this.y /= a.y;
+        this.z /= a.z;
+        this.w /= a.w;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short4 div(Short4 a, Short4 b) {
+        Short4 result = new Short4();
+        result.x = (short)(a.x / b.x);
+        result.y = (short)(a.y / b.y);
+        result.z = (short)(a.z / b.z);
+        result.w = (short)(a.w / b.w);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param value
+     */
+    public void div(short value) {
+        x /= value;
+        y /= value;
+        z /= value;
+        w /= value;
+    }
+
+    /** @hide
+     * Vector division
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short4 div(Short4 a, short b) {
+        Short4 result = new Short4();
+        result.x = (short)(a.x / b);
+        result.y = (short)(a.y / b);
+        result.z = (short)(a.z / b);
+        result.w = (short)(a.w / b);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     */
+    public void mod(Short4 a) {
+        this.x %= a.x;
+        this.y %= a.y;
+        this.z %= a.z;
+        this.w %= a.w;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short4 mod(Short4 a, Short4 b) {
+        Short4 result = new Short4();
+        result.x = (short)(a.x % b.x);
+        result.y = (short)(a.y % b.y);
+        result.z = (short)(a.z % b.z);
+        result.w = (short)(a.w % b.w);
+
+        return result;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param value
+     */
+    public void mod(short value) {
+        x %= value;
+        y %= value;
+        z %= value;
+        w %= value;
+    }
+
+    /** @hide
+     * Vector Modulo
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static Short4 mod(Short4 a, short b) {
+        Short4 result = new Short4();
+        result.x = (short)(a.x % b);
+        result.y = (short)(a.y % b);
+        result.z = (short)(a.z % b);
+        result.w = (short)(a.w % b);
+
+        return result;
+    }
+
+    /** @hide
+     * get vector length
+     *
+     * @return
+     */
+    public short length() {
+        return 4;
+    }
+
+    /** @hide
+     * set vector negate
+     */
+    public void negate() {
+        this.x = (short)(-x);
+        this.y = (short)(-y);
+        this.z = (short)(-z);
+        this.w = (short)(-w);
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @return
+     */
+    public short dotProduct(Short4 a) {
+        return (short)((x * a.x) + (y * a.y) + (z * a.z) + (w * a.w));
+    }
+
+    /** @hide
+     * Vector dot Product
+     *
+     * @param a
+     * @param b
+     * @return
+     */
+    public static short dotProduct(Short4 a, Short4 b) {
+        return (short)((b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w));
+    }
+
+    /** @hide
+     * Vector add Multiple
+     *
+     * @param a
+     * @param factor
+     */
+    public void addMultiple(Short4 a, short factor) {
+        x += a.x * factor;
+        y += a.y * factor;
+        z += a.z * factor;
+        w += a.w * factor;
+    }
+
+    /** @hide
+     * set vector value by Short4
+     *
+     * @param a
+     */
+    public void set(Short4 a) {
+        this.x = a.x;
+        this.y = a.y;
+        this.z = a.z;
+        this.w = a.w;
+    }
+
+    /** @hide
+     * set the vector field value by Short
+     *
+     * @param a
+     * @param b
+     * @param c
+     * @param d
+     */
+    public void setValues(short a, short b, short c, short d) {
+        this.x = a;
+        this.y = b;
+        this.z = c;
+        this.w = d;
+    }
+
+    /** @hide
+     * return the element sum of vector
+     *
+     * @return
+     */
+    public short elementSum() {
+        return (short)(x + y + z + w);
+    }
+
+    /** @hide
+     * get the vector field value by index
+     *
+     * @param i
+     * @return
+     */
+    public short get(int i) {
+        switch (i) {
+        case 0:
+            return (short)(x);
+        case 1:
+            return (short)(y);
+        case 2:
+            return (short)(z);
+        case 3:
+            return (short)(w);
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * set the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void setAt(int i, short value) {
+        switch (i) {
+        case 0:
+            x = value;
+            return;
+        case 1:
+            y = value;
+            return;
+        case 2:
+            z = value;
+            return;
+        case 3:
+            w = value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * add the vector field value by index
+     *
+     * @param i
+     * @param value
+     */
+    public void addAt(int i, short value) {
+        switch (i) {
+        case 0:
+            x += value;
+            return;
+        case 1:
+            y += value;
+            return;
+        case 2:
+            z += value;
+            return;
+        case 3:
+            w += value;
+            return;
+        default:
+            throw new IndexOutOfBoundsException("Index: i");
+        }
+    }
+
+    /** @hide
+     * copy the vector to short array
+     *
+     * @param data
+     * @param offset
+     */
+    public void copyTo(short[] data, int offset) {
+        data[offset] = (short)(x);
+        data[offset + 1] = (short)(y);
+        data[offset + 2] = (short)(z);
+        data[offset + 3] = (short)(w);
+    }
 }
-
-
-
