eqObj

Syntax

eqObj(obj1, obj2, [precision])

Arguments

obj1 / obj2 is a scalar/pair/vector/matrix.

precision is a nonnegative integer. FLOAT and DOUBLE types are compared up to precision digits after the decimal point.

Details

Check if the data types and values of two objects are identical. Return true only if both data types and values are identical. Please note that eqObj returns false if values are identical but object types are different. This is different from fuction eq.

Note: When comparing floating point numbers, function eqObj determines whether the values of obj1 and obj2 are equal based on the result of abs(obj1-obj2)<=pow(10,-precision).

Examples

$ eqObj(2, 2.0);
false

$ eq(2, 2.0);
true

$ eqObj(1.1, 1.2, 0);
true

$ eqObj(1.1, 1.2, 1);
false

$ eqObj(1 2 3, 1 2 3);
true
$ eq(1 2 3, 1 2 3);
[true,true,true]

eqObj cannot be used to compare 2 tables directly. However, we can use the template function each (:E) to compare the values of each column for 2 tables:

$ t1=table(1 2 3 as x, 4 5 6 as y);
$ t2=table(1 2 3 as x, 4 5 6 as y);

$ t1.values();
([1,2,3],[4,5,6])

$ each(eqObj, t1.values(), t2.values());
[true,true]