Identity Matrix Primitive

This section develops a primitive in the DE domain that will create an identity matrix.

Instead of creating a source primitive which must schedule itself, it is being done with a primitive that fires whenever it receives a new input value. For example, a clock or some other source can be attached to the primitive to set its firing pattern.

  name        { Identity_M }
  domain      { DE }
    Output a floating-point identity matrix

    name { Input }
    type { anytype }

    name { Output }
    type { float_matrix_env }

    name        { RowsCols }
    type        { int }
    default     { "2" }
    desc        { "Number of rows and columns of the output matrix." }

  ccinclude { "kernel/Matrix.h" }

    // Functional Primitive: pass timestamp without change
    completionTime = arrivalTime;

    // For messages, you must pass dynamically allocated data
    FloatMatrix& tResult = *(new FloatMatrix(int(RowsCols),

    // Set the contents of the matrix to an identity matrix

    // Send the matrix result to the output port
    Output.put(completionTime) << tResult;

This is a functional primitive because the time-stamp on the input particle is not altered. The output is a matrix message. The matrix is a square matrix. In order for the matrix to remain defined after the go method finishes, the matrix result cannot be allocated from local memory. Instead, it must be allocated from global dynamic memory via the new operator. In the syntax for the new operator, the int cast in int(RowsCols) extracts the value from RowsCols which is an instance of the State class. The dynamic memory allocated for the matrix will be automatically deleted by the Message class. Then, the matrix is reset to be an identity matrix. Finally, the matrix is sent to the output port with the same-time stamp as that of the input data.

Note that the syntax to output data in the DE domain differs from the syntax of the SDF due to the time-stamp. In the SDF domain, the output code would be

Output%0 << tResult