Class GMatrixd

  • All Implemented Interfaces:
    java.io.Serializable

    public class GMatrixd
    extends java.lang.Object
    implements java.io.Serializable
    Matrix operations are applied on the left. For example, given a matrix M and a vector V, matrix-times-vector is M*V. That is, V is treated as a column vector. Some graphics APIs use V*M where V is treated as a row vector. In this context the "M" matrix is really a transpose of the M as represented in Wild Magic. Similarly, to apply two matrix operations M0 and M1, in that order, you compute M1*M0 so that the transform of a vector is (M1*M0)*V = M1*(M0*V). Some graphics APIs use M0*M1, but again these matrices are the transpose of those as represented in Wild Magic. You must therefore be careful about how you interface the transformation code with graphics APIS. Matrices are stored in row-major order, matrix[row][col].
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private double[] m_adData
      the matrix is stored in row-major form as a 1-dimensional array
      private int m_iCols
      rows, columns, and size:
      private int m_iQuantity
      rows, columns, and size:
      private int m_iRows
      rows, columns, and size:
      private static long serialVersionUID  
    • Constructor Summary

      Constructors 
      Constructor Description
      GMatrixd()
      Construct a general matrix of size 0,0.
      GMatrixd​(int iRows, int iCols)
      Construct a general matrix of size iRows,iCols.
      GMatrixd​(int iRows, int iCols, double[] adEntry)
      Construct a general matrix of size iRows,iCols.
      GMatrixd​(int iRows, int iCols, double[][] aadMatrix)
      Construct a general matrix of size iRows,iCols.
      GMatrixd​(int iRows, int iCols, float[][] aafMatrix)
      Construct a general matrix of size iRows,iCols.
      GMatrixd​(GMatrixd rkM)
      Construct a general matrix that is the copy of the input matrix.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void Allocate​(boolean bSetToZero)
      Support for allocation and deallocation.
      void Copy​(GMatrixd rkM)
      Set this to the copy of the input matrix.
      private void Deallocate()
      Delete the matrix data.
      void dispose()
      Deallocate the matrix.
      double Get​(int iRow, int iCol)
      Get the value of the matrix at the location iRow, iCol.
      GVectord GetColumn​(int iCol)
      Get the value of the matrix for the iCol th column.
      int GetColumns()
      Get the number of columns in the matrix.
      double[] GetData()
      Get the matrix values in double[] format.
      void GetData​(double[][] aadMatrix)  
      int GetQuantity()
      Get the size of the matrix rows*columns.
      GVectord GetRow​(int iRow)
      Get the value of the matrix for the iRow th row.
      int GetRows()
      Get the number of rows in the matrix.
      boolean Inverse()  
      GMatrixd Mult​(GMatrixd rkM)  
      void Set​(int iRow, int iCol, double dValue)
      Set the value of the matrix at the location iRow, iCol.
      void SetColumn​(int iCol, GVectord rkV)
      Set the value of the matrix for the iCol th column.
      void SetMatrix​(int iRows, int iCols, double[] adEntry)  
      void SetMatrix​(int iRows, int iCols, double[][] aadMatrix)
      Construct a general matrix of size iRows,iCols.
      void SetMatrix​(int iRows, int iCols, float[][] aafMatrix)
      Construct a general matrix of size iRows,iCols.
      void SetRow​(int iRow, GVectord rkV)
      Set the value of the matrix for the iRow th row.
      void SetSize​(int iRows, int iCols)
      Set the matrix size.
      void SwapRows​(int iRow0, int iRow1)
      Swap the iRow0 and iRow1 in the matrix.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • m_iRows

        private int m_iRows
        rows, columns, and size:
      • m_iCols

        private int m_iCols
        rows, columns, and size:
      • m_iQuantity

        private int m_iQuantity
        rows, columns, and size:
      • m_adData

        private double[] m_adData
        the matrix is stored in row-major form as a 1-dimensional array
    • Constructor Detail

      • GMatrixd

        public GMatrixd()
        Construct a general matrix of size 0,0.
      • GMatrixd

        public GMatrixd​(GMatrixd rkM)
        Construct a general matrix that is the copy of the input matrix.
        Parameters:
        rkM - input matrix.
      • GMatrixd

        public GMatrixd​(int iRows,
                        int iCols)
        Construct a general matrix of size iRows,iCols.
        Parameters:
        iRows - number of rows in the matrix.
        iCols - number of columns in the matrix.
      • GMatrixd

        public GMatrixd​(int iRows,
                        int iCols,
                        double[] adEntry)
        Construct a general matrix of size iRows,iCols. Copy the adEntry array into the new matrix.
        Parameters:
        iRows - number of rows in the matrix.
        iCols - number of columns in the matrix.
        adEntry - matrix values.
      • GMatrixd

        public GMatrixd​(int iRows,
                        int iCols,
                        float[][] aafMatrix)
        Construct a general matrix of size iRows,iCols. Copy the aafMatrix into the new matrix.
        Parameters:
        iRows - number of rows in the matrix.
        iCols - number of columns in the matrix.
        aafMatrix - matrix values.
      • GMatrixd

        public GMatrixd​(int iRows,
                        int iCols,
                        double[][] aadMatrix)
        Construct a general matrix of size iRows,iCols. Copy the aadMatrix into the new matrix.
        Parameters:
        iRows - number of rows in the matrix.
        iCols - number of columns in the matrix.
        aadMatrix - matrix values.
    • Method Detail

      • Copy

        public void Copy​(GMatrixd rkM)
        Set this to the copy of the input matrix.
        Parameters:
        rkM - input matrix.
      • dispose

        public void dispose()
        Deallocate the matrix.
      • Get

        public double Get​(int iRow,
                          int iCol)
        Get the value of the matrix at the location iRow, iCol.
        Parameters:
        iRow - row position.
        iCol - column position.
        Returns:
        the matrix value at the location iRow, iCol.
      • GetColumn

        public GVectord GetColumn​(int iCol)
        Get the value of the matrix for the iCol th column.
        Parameters:
        iCol - column to get.
        Returns:
        a general vector containing the column values.
      • GetColumns

        public int GetColumns()
        Get the number of columns in the matrix.
        Returns:
        the number of rows in the matrix.
      • GetData

        public double[] GetData()
        Get the matrix values in double[] format.
        Returns:
        the matrix values.
      • GetData

        public void GetData​(double[][] aadMatrix)
      • GetQuantity

        public int GetQuantity()
        Get the size of the matrix rows*columns.
        Returns:
        the size of the matrix rows*columns.
      • GetRow

        public GVectord GetRow​(int iRow)
        Get the value of the matrix for the iRow th row.
        Parameters:
        iRow - row to get.
        Returns:
        a general vector containing the row values.
      • GetRows

        public int GetRows()
        Get the number of rows in the matrix.
        Returns:
        the number of rows in the matrix.
      • Inverse

        public boolean Inverse()
      • Set

        public void Set​(int iRow,
                        int iCol,
                        double dValue)
        Set the value of the matrix at the location iRow, iCol.
        Parameters:
        iRow - row position.
        iCol - column position.
        dValue - new value.
      • SetColumn

        public void SetColumn​(int iCol,
                              GVectord rkV)
        Set the value of the matrix for the iCol th column.
        Parameters:
        iCol - column to set.
        rkV - general vector containing the new values.
      • SetMatrix

        public void SetMatrix​(int iRows,
                              int iCols,
                              double[] adEntry)
      • SetMatrix

        public void SetMatrix​(int iRows,
                              int iCols,
                              float[][] aafMatrix)
        Construct a general matrix of size iRows,iCols. Copy the aafMatrix into the new matrix.
        Parameters:
        iRows - number of rows in the matrix.
        iCols - number of columns in the matrix.
        aafMatrix - matrix values.
      • SetMatrix

        public void SetMatrix​(int iRows,
                              int iCols,
                              double[][] aadMatrix)
        Construct a general matrix of size iRows,iCols. Copy the aadMatrix into the new matrix.
        Parameters:
        iRows - number of rows in the matrix.
        iCols - number of columns in the matrix.
        aadMatrix - matrix values.
      • SetRow

        public void SetRow​(int iRow,
                           GVectord rkV)
        Set the value of the matrix for the iRow th row.
        Parameters:
        iRow - row to set.
        rkV - general vector containing the new values.
      • SetSize

        public void SetSize​(int iRows,
                            int iCols)
        Set the matrix size.
        Parameters:
        iRows - number of rows in the matrix.
        iCols - number of columns in the matrix.
      • SwapRows

        public void SwapRows​(int iRow0,
                             int iRow1)
        Swap the iRow0 and iRow1 in the matrix.
        Parameters:
        iRow0 - first row to swap.
        iRow1 - second row to swap.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • Allocate

        private void Allocate​(boolean bSetToZero)
        Support for allocation and deallocation. The allocation call requires m_iRows, m_iCols, and m_iQuantity to have already been correctly initialized.
        Parameters:
        bSetToZero - when true set the matrix to all 0-values.
      • Deallocate

        private void Deallocate()
        Delete the matrix data.