- HasNan
- Transpose
- TransposeConjugate
- TriL
- TriU
- Diag
- Row
- Col
- Copy
- Concat
- Compare
- CompareByDigits
- CompareEqual
- Flat
- Clip
- Reshape
- Resize
- Set
- SwapRows
- SwapCols
- Split
- Hsplit
- Vsplit
- ArgSort
- Sort
Compare
Compare the elements of two matrices/vectors with the specified precision.
ulong vector::Compare(
|
Parameters
vec
[in] Vector to compare.
mat
[in] Matrix to compare.
epsilon
[in] Precision.
Return Value
The number of mismatched elements of the matrices or vectors being compared: 0 if the matrices are equal, greater than 0 otherwise.
Note
The comparison operators == or != execute an exact element-wise comparison. It is known that the exact comparison of real numbers is of limited use, so the epsilon comparison method was added. It may happen that one matrix can contain elements in a range, for example from 1e-20 to 1e+20. Such matrices can be processed using element-wise comparison up to significant figures.
For complex matrices/vectors, the comparison involves estimating the distance between complex numbers. The distance is calculated as sqrt(pow(r1-r2, 2) + pow(i1-i2, 2) and is a real number that can already be compared with epsilon.
Example
matrix matrix_a={{10,3,2},{1,8,12},{6,5,4}};
|