Java Matrix Invert invertSymmetric3x3(final double[][] m, final double[][] inverse)

Here you can find the source of invertSymmetric3x3(final double[][] m, final double[][] inverse)

Description

Inverts a (invertible) symmetric 3x3 matrix.

License

Open Source License

Parameter

Parameter Description
m symmetric matrix to invert.
inverse inverse of m is stored here.

Declaration

public static void invertSymmetric3x3(final double[][] m, final double[][] inverse) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*  w  w  w.j a  v  a  2  s  .  c o m*/
     * Inverts a (invertible) symmetric 3x3 matrix.
     *
     * @param m
     *            symmetric matrix to invert.
     * @param inverse
     *            inverse of {@code m} is stored here.
     */
    public static void invertSymmetric3x3(final double[][] m, final double[][] inverse) {
        final double a00 = m[2][2] * m[1][1] - m[1][2] * m[1][2];
        final double a01 = m[0][2] * m[1][2] - m[2][2] * m[0][1];
        final double a02 = m[0][1] * m[1][2] - m[0][2] * m[1][1];

        final double a11 = m[2][2] * m[0][0] - m[0][2] * m[0][2];
        final double a12 = m[0][1] * m[0][2] - m[0][0] * m[1][2];

        final double a22 = m[0][0] * m[1][1] - m[0][1] * m[0][1];

        final double Dinv = 1.0 / ((m[0][0] * a00) + (m[1][0] * a01) + (m[0][2] * a02));

        inverse[0][0] = a00 * Dinv;
        inverse[1][0] = inverse[0][1] = a01 * Dinv;
        inverse[2][0] = inverse[0][2] = a02 * Dinv;
        inverse[1][1] = a11 * Dinv;
        inverse[2][1] = inverse[1][2] = a12 * Dinv;
        inverse[2][2] = a22 * Dinv;
    }
}

Related

  1. invertMatrix(int[][] matrix)
  2. invertMatrix3x3(float[] result, float[] m)
  3. invertMatrix4x4(double[][] A)
  4. invertRegions(int[][] image)
  5. invertSymmetric2x2(final double[][] m, final double[][] inverse)
  6. invertUpperTriangular(double[][] r)