Java Utililty Methods Matrix Convert To

List of utility methods to do Matrix Convert To

Description

The list of methods to do Matrix Convert To are organized into topic(s).

Method

double[][]matrixCastToDouble(String[][] m)
matrix Cast To Double
double[][] matrixDouble = new double[m.length][];
for (int i = 0; i < m.length; i++)
    matrixDouble[i] = arrayCastToDouble(m[i]);
return matrixDouble;
double[]matrixToArray(double[][] m)
matrix To Array
int p = m.length * m[0].length;
double[] result = new double[p];
for (int i = 0; i < m.length; i++) {
    for (int j = 0; j < m[i].length; j++) {
        int q = j * m.length + i;
        result[q] = m[i][j];
return result;
int[]matrixToArray(int[][] input, int fromRow, int rows, int fromColumn, int columns)
Converts a 2 dimensional array into a single dimension.
int[] output = new int[rows * columns];
for (int c = 0; c < columns; c++) {
    for (int r = 0; r < rows; r++) {
        output[c * rows + r] = input[r + fromRow][c + fromColumn];
return output;
double[]matrixToQuaternion(float[] m)
matrix To Quaternion
double[] res = new double[4];
res[0] = Math.sqrt(1.0 + m[0] + m[5] + m[10]) / 2.0;
double w4 = (4.0 * res[0]);
res[1] = (m[9] - m[6]) / w4; 
res[2] = (m[2] - m[8]) / w4; 
res[3] = (m[4] - m[1]) / w4; 
return res;
shortmatrixToShort(final byte[][] b)
Converts a 2x2 matrix of nibbles to a 16-bit short.
short result = 0;
result = (short) (result | b[0][0]);
result = (short) ((result << 4) | b[1][0]);
result = (short) ((result << 4) | b[0][1]);
result = (short) ((result << 4) | b[1][1]);
return result;
double[][]toDiagonalMatrix(double[] x)
to Diagonal Matrix
double[][] m = null;
if (x != null && x.length > 0) {
    m = new double[x.length][x.length];
    int i;
    for (i = 0; i < x.length; i++)
        Arrays.fill(m[i], 0.0);
    for (i = 0; i < x.length; i++)
        m[i][i] = x[i];
...