The ALL function returns a value of 1 if all elements in matrix are nonzero. If any element of matrix is zero or missing, the ALL function returns a value of 0.
You can use the ALL function to express the results of a comparison operator as a single 1 or 0. For example, the following statement compares elements in two matrices:
a = { 1 2, 3 4}; b = {-1 0, 0 1}; if all(a>b) then msg = "a[i,j] > b[i,j] for all i,j"; else msg = "for some element, a[i,j] is not greater than b[i,j]"; print msg;
In the preceding statements, the comparison operation a>b
creates a matrix of zeros and ones. The ALL function returns a value of 1 because every element of a
is greater than the corresponding element of b
.
The ALL function is implicitly applied to the evaluation of all conditional expressions, so in fact the previous IF-THEN statement is equivalent to the following:
if a>b then /* implicit ALL */ msg = "a[i,j] > b[i,j] for all i,j";