next up previous
Next: 3.2.1.2 Union TypeSpec Up: 3.2.1 Prototype Operator TypeSpec Previous: 3.2.1 Prototype Operator TypeSpec

3.2.1.1 Struct TypeSpec


<Struct TypeSpec> ::= 		 Cop:Proto::Struct:n <MP  TypeSpec>n 
		 		 | Cop:Proto::RecStruct:n <MP TypeSpec>n 

A collection of (possibly heterogeneous) objects that are to be treated as logically related is described using a Cop:Proto::Struct:n or a Cop:Proto::RecStruct:n operator node packet. The only difference between these operators is that a Cop:Proto::RecStruct:n operator is used for designating a structure as a target for a recursive type specification (see section 3.2.3). The number-of-arguments field specifies both the number of actual arguments the operator has in the prototype tree and the number of corresponding data items to be transmitted at data communication time. The arguments to the Cop:Proto::Struct:n operator specify the types of the struct's fields individually using MP TypeSpecs, where the ith argument TypeSpec specifies the type of the ith field.

Figure 3 shows how an array of, say, three sparse matrix elements, is represented using a Struct TypeSpec.

struct {    
   MP_Uint32    row_num;
   MP_Uint32    col_num;
   MP_Real64    val;     
} array[3] = {{2,2,1.0},{2,3,1.0},{2,4,1.0}};


  
Figure 3: A sparse matrix
\begin{figure}% latex2html id marker 505
\setlength{\tabcolsep}{1.0mm} \centerin...
...eal64& & 1.0 & &~~~~~~~~[2,4] = 1.0\\ \hline\end{tabular}\end{small}\end{figure}

The top-level operator on line 1 indicates that this is a three element array. The prototype (lines 2 - 6) specifies the type of each element. Line 3 says that each element is a 3-field structure and the arguments to this Struct operator (lines 4 - 6) specify the individual types of the arguments using common meta type (Cmt) packets. The prototyped data trees begin on line 7 with the first field of the first structure. The data for the second structure begins on line 8 and the third on line 9.


next up previous
Next: 3.2.1.2 Union TypeSpec Up: 3.2.1 Prototype Operator TypeSpec Previous: 3.2.1 Prototype Operator TypeSpec
| ZCA Home | Reports |