Class MatrixType

    • Constructor Detail

      • MatrixType

        public MatrixType​(java.lang.Class c,
                          Type type,
                          java.lang.String name)
        Construct a new matrix type that represents matrix tokens of the given class with the given number of rows and columns.
        Parameters:
        c - The token class.
        type - The element type.
        name - The name.
    • Method Detail

      • clone

        public java.lang.Object clone()
        Return this, that is, return the reference to this object.
        Specified by:
        clone in interface Type
        Specified by:
        clone in class StructuredType
        Returns:
        A MatrixType.
      • convert

        public Token convert​(Token token)
                      throws IllegalActionException
        If the argument is an instance of this class or a subclass, then return the token. Otherwise, throw an exception.
        Specified by:
        convert in interface Type
        Parameters:
        token - A token.
        Returns:
        An instance of this class.
        Throws:
        IllegalActionException - If the argument is not an instance of this class.
      • equals

        public boolean equals​(java.lang.Object object)
        Determine if the argument represents the same MatrixType as this object.
        Specified by:
        equals in interface Type
        Overrides:
        equals in class java.lang.Object
        Parameters:
        object - A Type.
        Returns:
        True if the argument type is a matrix type representing the same class, with the same number of rows and columns.
      • getElementType

        public Type getElementType()
        Return the type of the elements contained in an instance of this matrix type. Tokens of the type returned by this method will be returned by the getElementAsToken of matrices that have this type. If this is an instance of this base class rather than the specific matrix types, then return null.
        Returns:
        The type of the elements.
      • getMatrixTypeForElementType

        public static MatrixType getMatrixTypeForElementType​(Type elementType)
                                                      throws IllegalActionException
        Return a matrix type whose element type is the given element type.
        Parameters:
        elementType - The type of the element.
        Returns:
        The matrix type.
        Throws:
        IllegalActionException - If the elementType is not a type that has a corresponding matrix type.
      • getTokenClass

        public java.lang.Class getTokenClass()
        Return the class for tokens that this type represents.
        Specified by:
        getTokenClass in interface Type
        Returns:
        A class that represents a matrix token.
      • hashCode

        public int hashCode()
        Return a hash code value for this object.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        The hash code for the token class of this type.
      • initialize

        public void initialize​(Type type)
        Set the elements that have declared type BaseType.UNKNOWN to the specified type.
        Specified by:
        initialize in class StructuredType
        Parameters:
        type - A Type.
      • isAbstract

        public boolean isAbstract()
        Return true if the element type is abstract.
        Specified by:
        isAbstract in interface Type
        Overrides:
        isAbstract in class StructuredType
        Returns:
        True.
      • isCompatible

        public boolean isCompatible​(Type type)
        Test if the argument type is compatible with this type. The method returns true if this type is UNKNOWN, since any type is a substitution instance of it. If this type is not UNKNOWN, this method returns true if the argument type is less than or equal to this type in the type lattice, and false otherwise.
        Specified by:
        isCompatible in interface Type
        Parameters:
        type - An instance of Type.
        Returns:
        True if the argument is compatible with this type.
      • isConstant

        public boolean isConstant()
        Test if this Type is a constant. A Type is a constant if it does not contain BaseType.UNKNOWN in any level within it.
        Specified by:
        isConstant in interface Type
        Returns:
        False.
      • isInstantiable

        public boolean isInstantiable()
        Return true, indicating that instances of this type can exist.
        Specified by:
        isInstantiable in interface Type
        Returns:
        True.
      • isSubstitutionInstance

        public boolean isSubstitutionInstance​(Type type)
        Test if the argument is a substitution instance of this type.
        Specified by:
        isSubstitutionInstance in interface Type
        Parameters:
        type - A Type.
        Returns:
        False.
      • toString

        public java.lang.String toString()
        Return the string representation of this type.
        Specified by:
        toString in interface Type
        Overrides:
        toString in class java.lang.Object
        Returns:
        A String.
      • updateType

        public void updateType​(StructuredType newType)
                        throws IllegalActionException
        Update this StructuredType to the specified Structured Type. The specified type must have the same structure as this type. This method will only update the component type that is BaseType.UNKNOWN, and leave the constant part of this type intact.
        Overrides:
        updateType in class StructuredType
        Parameters:
        newType - A StructuredType.
        Throws:
        IllegalActionException - If the specified type has a different structure.
      • _compare

        protected int _compare​(StructuredType type)
        Compare this type with the specified type. The specified type must be of the same structured type, otherwise an exception will be thrown. This method returns one of ptolemy.graph.CPO.LOWER, ptolemy.graph.CPO.SAME, ptolemy.graph.CPO.HIGHER, ptolemy.graph.CPO.INCOMPARABLE, indicating this type is lower than, equal to, higher than, or incomparable with the specified type in the type hierarchy, respectively.
        Specified by:
        _compare in class StructuredType
        Parameters:
        type - a StructuredType.
        Returns:
        An integer.
        Throws:
        java.lang.IllegalArgumentException - If the specified type is not the same structured type as this one.
      • _getRepresentative

        protected StructuredType _getRepresentative()
        Return a static instance of this structured type. The return value is used by TypeLattice to represent this type.
        Specified by:
        _getRepresentative in class StructuredType
        Returns:
        a StructuredType.
      • _greatestLowerBound

        protected StructuredType _greatestLowerBound​(StructuredType type)
        Return the greatest lower bound of this type with the specified type. The specified type must be of the same structured type, otherwise an exception will be thrown.
        Specified by:
        _greatestLowerBound in class StructuredType
        Parameters:
        type - a StructuredType.
        Returns:
        a StructuredType.
        Throws:
        java.lang.IllegalArgumentException - If the specified type is not the same structured type as this one.
      • _leastUpperBound

        protected StructuredType _leastUpperBound​(StructuredType type)
        Return the least upper bound of this type with the specified type. The specified type must be of the same structured type, otherwise an exception will be thrown.
        Specified by:
        _leastUpperBound in class StructuredType
        Parameters:
        type - a StructuredType.
        Returns:
        a StructuredType.
        Throws:
        java.lang.IllegalArgumentException - If the specified type is not the same structured type as this one.