Array Types and Type Checking

1 ColorPixel

It is possible to declare user-defined array types analogously to other user-defined types. For example, a ColorPixel can be defined as a three-element vector representing the three base colors, and a variable image declared as a matrix of such pixels.

The expanded type of an array is the multidimensional array which is constructed by taking the first dimensions from the variable declaration and subsequent dimensions from the maximally expanded array element type of the declaration. Note that we are not using ColorPixel[512, 512] as in the book, because of the incredible amount of variables it would imply.




1.1 Simulation of ColorPixelInst


Take a look at the value at time=0:



2 Voltage and Current

Consider the definition of the notion of the expanded type in the example below. The user-defined types Voltage and Current are defined using type definitions.




3 Pin

Pin is defined through the declaration of a connector. The type of v and i is Voltage and the expanded type of v and i is Real.



This is not allowed in the current version of Modelica, so the simulation of this example won't work.



The type of p is MultiPin[4], expanded type is Pin[4, 5].



4 Point

The array variables p1 and p2 have identical expanded types of Real[10,3] which makes the two equations in PointSum correct.





4.1 Simulation of PointSum