public static Info eye ( final Variable A , ManagerTempVariables manager ) { Info ret = new Info ( ) ; final VariableMatrix output = manager . createMatrix ( ) ; ret . output = output ; if ( A instanceof VariableMatrix ) { ret . op = new Operation ( "eye-m" ) { @ Override public void process ( ) { DMatrixRMaj mA = ( ( VariableMatrix ) A ) . matrix ; output . matrix . reshape ( mA . numRows , mA . numCols ) ; CommonOps_DDRM . setIdentity ( output . matrix ) ; } } ; } else if ( A instanceof VariableInteger ) { ret . op = new Operation ( "eye-i" ) { @ Override public void process ( ) { int N = ( ( VariableInteger ) A ) . value ; output . matrix . reshape ( N , N ) ; CommonOps_DDRM . setIdentity ( output . matrix ) ; } } ; } else { throw new RuntimeException ( "Unsupported variable type " + A ) ; } return ret ; }
Returns an identity matrix