fixed a bug in triangularMatrix that was skipping missing values