identity

Prev Next

Function Names

identity

Description

This function creates an identity matrix with 1's diagonally from to left to bottom right, with other fields at zero

Call as: function

Restrictions

Indirect parameter passing is disabled

Parameter count

1

Parameters

No.TypeDescription
1
input
numeral size

Defines the nxn size of the identity matrix to be created

Return value

TypeDescription
matrix Identity matrix

Contains 1's across the diagonal

Examples

       print matrix( "0", 2, " |", "Identity Matrix = ", identity(5) );

Output

                   | 1   0   0   0   0 |
                   | 0   1   0   0   0 |
Identity Matrix =  | 0   0   1   0   0 |
                   | 0   0   0   1   0 |
                   | 0   0   0   0   1 |
Try it yourself: Open LIB_Function_identity.b4p in B4P_Examples.zip. Decompress before use.

See also

diagonal