Matrix Elements VB-800 Instrukcja Użytkownika Strona 155

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 172
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 154
A6.8 Expressions 147
extra column (~ )orrow(|) is pre/appended. If both operands are a matrix, the matrices
are joined. Note that the dimensions need not match: missing elements are set to zero
(however, a warning is printed of non-matching matrices are concatenated). Horizontal
concatenation has higher precedence than vertical concatenation.
Two strings or an integer and a string can be concatenated, resulting in a longer
string. Both horizontal and vertical concatenation yield the same result.
The result is most easily demonstrated by examples:
print(1 ~ 2 ~ 3 | 4 ~ 5 ~ 6); // <1,2,3; 4,5,6>
print("tinker" ~ ’&’ ~ "tailor" ); // "tinker&tailor"
print(<1,0; 0,1> ~ 2); // <1,0,2; 0,1,2>
print(2 | <1,0; 0,1>); // <2,2; 1,0; 0,1>
print(<2> ~ <1,0; 0,1>); // <2,1,0; 0,0,1>
When the operands are an address of a function, the result is an array of functions,
see §A6.6.3.
A6.8.9 Dot-relational expressions
The dot relational operators are .<, .<=, .>, .>=, .==, ./=, standing for ‘dot less’, ‘dot
less or equal’, ‘dot greater’, ‘dot greater or equal’, ‘is dot equal to’, ‘is dot not equal to’.
They conform to Table A6.3, except when both arguments are a string, in which
case the result is as for the non-dotted versions.
If both arguments are scalar, the result type inherits the higher type, so 1>=1.5
yields a double with value 0.0. If both operands are a matrix the return value is a matrix
with a 1 in each position where the relation is true and zero where it is false. If one of
the operands is of scalar-type, and the other of matrix-type, each element in the matrix
is compared to the scalar returning a matrix with 1 at each position where the relation
holds.
String-type operands can be compared in a similar way. If both operands are a
string, the results is int with value 1 or 0, depending on the case sensitive string com-
parison.
In if statements, it is possible to use matrix values. Remember that a matrix is true if
all elements are true (i.e. no element is zero).
A6.8.9.1 Logical dot-NOT expressions
The operand of the logical .not operator must have arithmetic type, and the result is 1
if the operand is equal to 0 and 0 otherwise. For a matrix, logical negation is applied to
each element.
A6.8.10 Logical dot-AND expressions
The dot-or operator is written as .\&\& or .and. It returns 1 if both of its operands
compare unequal to 0, 0 otherwise. Both operands must have arithmetic type. Handling
of matrix-type is as for dot-relational operators: if one or both operands is a matrix,
the result is a matrix of zeros and ones. Unlike the non-dotted version, both operands
Przeglądanie stron 154
1 2 ... 150 151 152 153 154 155 156 157 158 159 160 ... 171 172

Komentarze do niniejszej Instrukcji

Brak uwag