Android examples for java.lang:Math Matrix
Vector Matrix multiplication
//package com.java2s; public class Main { /**/*from w ww . ja v a 2 s. c o m*/ * Cache matrix */ private final static float[] sTemp = new float[32]; /** * Vector Matrix multiplication * * @param result The float array that holds the result. * @param resultOffset The offset into result array * @param lhs The float array that holds the left-hand-side matrix. * @param lhsOffset The offset into the lhs array where the lhs is stored * @param rhs The float array that holds the right-hand-side matrix * @param rhsOffset The offset into the rhs array where the rhs is stored. */ public static void multiplyMV(final float[] result, final int resultOffset, final float[] lhs, final int lhsOffset, final float[] rhs, final int rhsOffset) { //android.util.Log.d(TAG,"multiplyMV()"); synchronized (sTemp) { sTemp[0] = rhs[rhsOffset]; sTemp[1] = rhs[rhsOffset + 1]; sTemp[2] = rhs[rhsOffset + 2]; sTemp[3] = rhs[rhsOffset + 3]; System.arraycopy(lhs, lhsOffset, sTemp, 4, 16); result[3 + resultOffset] = (sTemp[7] * sTemp[0]) + (sTemp[11] * sTemp[1]) + (sTemp[15] * sTemp[2]) + (sTemp[19] * sTemp[3]); result[2 + resultOffset] = (sTemp[6] * sTemp[0]) + (sTemp[10] * sTemp[1]) + (sTemp[14] * sTemp[2]) + (sTemp[18] * sTemp[3]); result[1 + resultOffset] = (sTemp[5] * sTemp[0]) + (sTemp[9] * sTemp[1]) + (sTemp[13] * sTemp[2]) + (sTemp[17] * sTemp[3]); result[0 + resultOffset] = (sTemp[4] * sTemp[0]) + (sTemp[8] * sTemp[1]) + (sTemp[12] * sTemp[2]) + (sTemp[16] * sTemp[3]); } } }