Module org.dyn4j

Class Matrix22

  • All Implemented Interfaces:
    Copyable<Matrix22>

    public class Matrix22
    extends Object
    implements Copyable<Matrix22>
    Represents a 2x2 Matrix.

    Used to solve 2x2 systems of equations.

    Since:
    1.0.0
    Version:
    4.0.0
    Author:
    William Bittle
    • Field Detail

      • m00

        public double m00
        The element at 0,0
      • m01

        public double m01
        The element at 0,1
      • m10

        public double m10
        The element at 1,0
      • m11

        public double m11
        The element at 1,1
    • Constructor Detail

      • Matrix22

        public Matrix22()
        Default constructor.
      • Matrix22

        public Matrix22​(double m00,
                        double m01,
                        double m10,
                        double m11)
        Full constructor.
        Parameters:
        m00 - the element at 0,0
        m01 - the element at 0,1
        m10 - the element at 1,0
        m11 - the element at 1,1
      • Matrix22

        public Matrix22​(Matrix22 matrix)
        Copy constructor.
        Parameters:
        matrix - the Matrix22 to copy
    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • multiply

        public Matrix22 multiply​(double scalar)
        Multiplies this Matrix22 by the given scalar and places the result in this Matrix22.
         this = this * scalar
         
        Parameters:
        scalar - the scalar to multiply by
        Returns:
        Matrix22 this matrix
      • product

        public Matrix22 product​(double scalar)
        Multiplies this Matrix22 by the given scalar returning a new Matrix22 containing the result.
         r = this * scalar
         
        Parameters:
        scalar - the scalar to multiply by
        Returns:
        Matrix22 a new matrix containing the result
      • getTranspose

        public Matrix22 getTranspose()
        Returns the the transpose of this Matrix22 in a new Matrix22.
        Returns:
        Matrix22 a new matrix contianing the transpose
      • determinant

        public double determinant()
        Returns the determinant of this Matrix22.
        Returns:
        double
      • invert

        public void invert​(Matrix22 dest)
        Performs the inverse of this Matrix22 and places the result in the given Matrix22.
        Parameters:
        dest - the destination for the inverse
        Since:
        4.0.0
      • getInverse

        public Matrix22 getInverse()
        Returns a new Matrix22 containing the inverse of this Matrix22.
        Returns:
        Matrix22 a new matrix containing the result
      • solve

        public Vector2 solve​(Vector2 b)
        Solves the system of linear equations:

        Ax = b Multiply by A-1 on both sides x = A-1b

        Parameters:
        b - the b Vector2
        Returns:
        Vector2 the x vector
      • normMax

        public double normMax()
        Returns the max-norm of this matrix.
        Returns:
        double
      • normInfinity

        public double normInfinity()
        Returns the infinity-norm of this matrix.
        Returns:
        double
      • norm1

        public double norm1()
        Returns the 1-norm of this matrix.
        Returns:
        double
      • normFrobenius

        public double normFrobenius()
        Returns the frobenius-norm of this matrix.
        Returns:
        double