diff --git a/java/src/com/android/inputmethod/keyboard/internal/MatrixUtils.java b/java/src/com/android/inputmethod/keyboard/internal/MatrixUtils.java
new file mode 100644
index 0000000..4916a15
--- /dev/null
+++ b/java/src/com/android/inputmethod/keyboard/internal/MatrixUtils.java
@@ -0,0 +1,166 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.keyboard.internal;
+
+import com.android.inputmethod.annotations.UsedForTesting;
+
+import android.util.Log;
+
+import java.util.Arrays;
+
+/**
+ * Utilities for matrix operations. Don't instantiate objects inside this class to prevent
+ * unexpected performance regressions.
+ */
+@UsedForTesting
+public class MatrixUtils {
+    private static final String TAG = MatrixUtils.class.getSimpleName();
+    public static class MatrixOperationFailedException extends Exception {
+        private static final String TAG = MatrixOperationFailedException.class.getSimpleName();
+        private static final long serialVersionUID = 4384485606788583829L;
+
+        public MatrixOperationFailedException(String msg) {
+            super(msg);
+            Log.d(TAG, msg);
+        }
+    }
+
+    /**
+     * A utility function to inverse matrix.
+     * Find a pivot and swap the row of squareMatrix0 and squareMatrix1
+     */
+    private static void findPivotAndSwapRow(final int row, final float[][] squareMatrix0,
+            final float[][] squareMatrix1, final int size) {
+        int ip = row;
+        float pivot = Math.abs(squareMatrix0[row][row]);
+        for (int i = row + 1; i < size; ++i) {
+            if (pivot < Math.abs(squareMatrix0[i][row])) {
+                ip = i;
+                pivot = Math.abs(squareMatrix0[i][row]);
+            }
+        }
+        if (ip != row) {
+            for (int j = 0; j < size; ++j) {
+                final float temp0 = squareMatrix0[ip][j];
+                squareMatrix0[ip][j] = squareMatrix0[row][j];
+                squareMatrix0[row][j] = temp0;
+                final float temp1 = squareMatrix1[ip][j];
+                squareMatrix1[ip][j] = squareMatrix1[row][j];
+                squareMatrix1[row][j] = temp1;
+            }
+        }
+    }
+
+    /**
+     * A utility function to inverse matrix. This function calculates answer for each row by
+     * sweeping method of Gauss Jordan elimination
+     */
+    private static void sweep(final int row, final float[][] squareMatrix0,
+            final float[][] squareMatrix1, final int size) throws MatrixOperationFailedException {
+        final float pivot = squareMatrix0[row][row];
+        if (pivot == 0) {
+            throw new MatrixOperationFailedException("Inverse failed. Invalid pivot");
+        }
+        for (int j = 0; j < size; ++j) {
+            squareMatrix0[row][j] /= pivot;
+            squareMatrix1[row][j] /= pivot;
+        }
+        for (int i = 0; i < size; i++) {
+            final float sweepTargetValue = squareMatrix0[i][row];
+            if (i != row) {
+                for (int j = row; j < size; ++j) {
+                    squareMatrix0[i][j] -= sweepTargetValue * squareMatrix0[row][j];
+                }
+                for (int j = 0; j < size; ++j) {
+                    squareMatrix1[i][j] -= sweepTargetValue * squareMatrix1[row][j];
+                }
+            }
+        }
+    }
+
+    /**
+     * A function to inverse matrix.
+     * The inverse matrix of squareMatrix will be output to inverseMatrix. Please notice that
+     * the value of squareMatrix is modified in this function and can't be resuable.
+     */
+    @UsedForTesting
+    public static void inverse(final float[][] squareMatrix,
+            final float[][] inverseMatrix) throws MatrixOperationFailedException {
+        final int size = squareMatrix.length;
+        if (squareMatrix[0].length != size || inverseMatrix.length != size
+                || inverseMatrix[0].length != size) {
+            throw new MatrixOperationFailedException(
+                    "--- invalid length. column should be 2 times larger than row.");
+        }
+        for (int i = 0; i < size; ++i) {
+            Arrays.fill(inverseMatrix[i], 0.0f);
+            inverseMatrix[i][i] = 1.0f;
+        }
+        for (int i = 0; i < size; ++i) {
+            findPivotAndSwapRow(i, squareMatrix, inverseMatrix, size);
+            sweep(i, squareMatrix, inverseMatrix, size);
+        }
+    }
+
+    /**
+     * A matrix operation to multiply m0 and m1.
+     */
+    @UsedForTesting
+    public static void multiply(final float[][] m0, final float[][] m1,
+            final float[][] retval) throws MatrixOperationFailedException {
+        if (m0[0].length != m1.length) {
+            throw new MatrixOperationFailedException(
+                    "--- invalid length for multiply " + m0[0].length + ", " + m1.length);
+        }
+        final int m0h = m0.length;
+        final int m0w = m0[0].length;
+        final int m1w = m1[0].length;
+        if (retval.length != m0h || retval[0].length != m1w) {
+            throw new MatrixOperationFailedException(
+                    "--- invalid length of retval " + retval.length + ", " + retval[0].length);
+        }
+
+        for (int i = 0; i < m0h; i++) {
+            Arrays.fill(retval[i], 0);
+            for (int j = 0; j < m1w; j++) {
+                for (int k = 0; k < m0w; k++) {
+                    retval[i][j] += m0[i][k] * m1[k][j];
+                }
+            }
+        }
+    }
+
+    /**
+     * A utility function to dump the specified matrix in a readable way
+     */
+    @UsedForTesting
+    public static void dump(final String title, final float[][] a) {
+        final int column = a[0].length;
+        final int row = a.length;
+        Log.d(TAG, "Dump matrix: " + title);
+        Log.d(TAG, "/*---------------------");
+        final StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < row; ++i) {
+            sb.setLength(0);
+            for (int j = 0; j < column; ++j) {
+                sb.append(String.format("%4f", a[i][j])).append(' ');
+            }
+            Log.d(TAG, sb.toString());
+        }
+        Log.d(TAG, "---------------------*/");
+    }
+}
diff --git a/java/src/com/android/inputmethod/keyboard/internal/SmoothingUtils.java b/java/src/com/android/inputmethod/keyboard/internal/SmoothingUtils.java
new file mode 100644
index 0000000..e5665bc
--- /dev/null
+++ b/java/src/com/android/inputmethod/keyboard/internal/SmoothingUtils.java
@@ -0,0 +1,102 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.keyboard.internal;
+
+import com.android.inputmethod.annotations.UsedForTesting;
+import com.android.inputmethod.keyboard.internal.MatrixUtils.MatrixOperationFailedException;
+
+import android.util.Log;
+
+import java.util.Arrays;
+
+/**
+ * Utilities to smooth coordinates. Currently, we calculate 3d least squares formula by using
+ * Lagrangian smoothing
+ */
+@UsedForTesting
+public class SmoothingUtils {
+    private static final String TAG = SmoothingUtils.class.getSimpleName();
+    private static final boolean DEBUG = false;
+
+    private SmoothingUtils() {
+        // not allowed to instantiate publicly
+    }
+
+    /**
+     * Find a most likely 3d least squares formula for specified coordinates.
+     * "retval" should be a 1x4 size matrix.
+     */
+    @UsedForTesting
+    public static void get3DParameters(final float[] xs, final float[] ys,
+            final float[][] retval) throws MatrixOperationFailedException {
+        final int COEFF_COUNT = 4; // Coefficient count for 3d smoothing
+        if (retval.length != COEFF_COUNT || retval[0].length != 1) {
+            Log.d(TAG, "--- invalid length of 3d retval " + retval.length + ", "
+                    + retval[0].length);
+            return;
+        }
+        final int N = xs.length;
+        // TODO: Never isntantiate the matrix
+        final float[][] m0 = new float[COEFF_COUNT][COEFF_COUNT];
+        final float[][] m0Inv = new float[COEFF_COUNT][COEFF_COUNT];
+        final float[][] m1 = new float[COEFF_COUNT][N];
+        final float[][] m2 = new float[N][1];
+
+        // m0
+        for (int i = 0; i < COEFF_COUNT; ++i) {
+            Arrays.fill(m0[i], 0);
+            for (int j = 0; j < COEFF_COUNT; ++j) {
+                final int pow = i + j;
+                for (int k = 0; k < N; ++k) {
+                    m0[i][j] += (float) Math.pow((double) xs[k], pow);
+                }
+            }
+        }
+        // m0Inv
+        MatrixUtils.inverse(m0, m0Inv);
+        if (DEBUG) {
+            MatrixUtils.dump("m0-1", m0Inv);
+        }
+
+        // m1
+        for (int i = 0; i < COEFF_COUNT; ++i) {
+            for (int j = 0; j < N; ++j) {
+                m1[i][j] = (i == 0) ? 1.0f : m1[i - 1][j] * xs[j];
+            }
+        }
+
+        // m2
+        for (int i = 0; i < N; ++i) {
+            m2[i][0] = ys[i];
+        }
+
+        final float[][] m0Invxm1 = new float[COEFF_COUNT][N];
+        if (DEBUG) {
+            MatrixUtils.dump("a0", m0Inv);
+            MatrixUtils.dump("a1", m1);
+        }
+        MatrixUtils.multiply(m0Inv, m1, m0Invxm1);
+        if (DEBUG) {
+            MatrixUtils.dump("a2", m0Invxm1);
+            MatrixUtils.dump("a3", m2);
+        }
+        MatrixUtils.multiply(m0Invxm1, m2, retval);
+        if (DEBUG) {
+            MatrixUtils.dump("result", retval);
+        }
+    }
+}
diff --git a/tests/src/com/android/inputmethod/keyboard/internal/MatrixUtilsTests.java b/tests/src/com/android/inputmethod/keyboard/internal/MatrixUtilsTests.java
new file mode 100644
index 0000000..e2a11ab
--- /dev/null
+++ b/tests/src/com/android/inputmethod/keyboard/internal/MatrixUtilsTests.java
@@ -0,0 +1,84 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.keyboard.internal;
+
+import com.android.inputmethod.keyboard.internal.MatrixUtils.MatrixOperationFailedException;
+
+import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+
+@SmallTest
+public class MatrixUtilsTests extends AndroidTestCase {
+    // "run tests" -c com.android.inputmethod.keyboard.internal.MatrixUtilsTests
+    private static final boolean DEBUG = false;
+    private static final float EPSILON = 0.00001f;
+
+    private static void assertEqualsFloat(float f0, float f1) {
+        assertEqualsFloat(f0, f1, EPSILON);
+    }
+
+    /* package */ static void assertEqualsFloat(float f0, float f1, float error) {
+        assertTrue(Math.abs(f0 - f1) < error);
+    }
+
+    public void testMulti() {
+        final float[][] matrixA = {{1, 2}, {3, 4}};
+        final float[][] matrixB = {{5, 6}, {7, 8}};
+        final float[][] retval = new float[2][2];
+        try {
+            MatrixUtils.multiply(matrixA, matrixB, retval);
+        } catch (MatrixOperationFailedException e) {
+            assertTrue(false);
+        }
+        if (DEBUG) {
+            MatrixUtils.dump("multi", retval);
+        }
+        assertEqualsFloat(retval[0][0], 19);
+        assertEqualsFloat(retval[0][1], 22);
+        assertEqualsFloat(retval[1][0], 43);
+        assertEqualsFloat(retval[1][1], 50);
+    }
+
+    public void testInverse() {
+        final int N = 4;
+        final float[][] matrix =
+                {{1, 2, 3, 4}, {4, 0, 5, 6}, {6, 4, 2, 0}, {6, 4, 2, 1}};
+        final float[][] inverse = new float[N][N];
+        final float[][] tempMatrix = new float[N][N];
+        for (int i = 0; i < N; ++i) {
+            for (int j = 0; j < N; ++j) {
+                tempMatrix[i][j] = matrix[i][j];
+            }
+        }
+        final float[][] retval = new float[N][N];
+        try {
+            MatrixUtils.inverse(tempMatrix, inverse);
+        } catch (MatrixOperationFailedException e) {
+            assertTrue(false);
+        }
+        try {
+            MatrixUtils.multiply(matrix, inverse, retval);
+        } catch (MatrixOperationFailedException e) {
+            assertTrue(false);
+        }
+        for (int i = 0; i < N; ++i) {
+            for (int j = 0; j < N; ++j) {
+                assertEqualsFloat(((i == j) ? 1.0f : 0.0f), retval[i][j]);
+            }
+        }
+    }
+}
diff --git a/tests/src/com/android/inputmethod/keyboard/internal/SmoothingUtilsTests.java b/tests/src/com/android/inputmethod/keyboard/internal/SmoothingUtilsTests.java
new file mode 100644
index 0000000..293741a
--- /dev/null
+++ b/tests/src/com/android/inputmethod/keyboard/internal/SmoothingUtilsTests.java
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.keyboard.internal;
+
+import com.android.inputmethod.keyboard.internal.MatrixUtils.MatrixOperationFailedException;
+
+import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+
+@SmallTest
+public class SmoothingUtilsTests extends AndroidTestCase {
+    // "run tests" -c com.android.inputmethod.keyboard.internal.SmoothingUtilsTests
+    private static final boolean DEBUG = false;
+
+    public void testGet3DParamaters() {
+        final float[] xs = new float[] {0, 1, 2, 3, 4};
+        final float[] ys = new float[] {1, 4, 15, 40, 85}; // y = x^3 + x^2 + x + 1
+        final float[][] retval = new float[4][1];
+        try {
+            SmoothingUtils.get3DParameters(xs, ys, retval);
+            if (DEBUG) {
+                MatrixUtils.dump("3d", retval);
+            }
+            for (int i = 0; i < 4; ++i) {
+                MatrixUtilsTests.assertEqualsFloat(retval[i][0], 1.0f, 0.001f);
+            }
+        } catch (MatrixOperationFailedException e) {
+            assertTrue(false);
+        }
+    }
+}
