{{indexmenu_n>999}}
====== Eq ======
###
We can compare two matrices with the == operator. One needs to be careful though as matrices stored as tables + meta methods are always different from matrices stored as user date. Comparison is done element by element.
###
===== Example =====
==== Input ====
A = Matrix.New({{1,2},{3,4}})
B = Matrix.New({{1,2},{3,4}})
C = Matrix.New({{5,6},{7,8}})
D = {{1,2},{3,4}}
setmetatable(D, MatrixMeta)
E = {{1,2},{3,4}}
setmetatable(E, MatrixMeta)
F = {{5,6},{7,8}}
setmetatable(F, MatrixMeta)
print("Matrix as Userdata comparison")
print("A==B ",A==B)
print("A==C", A==C)
print("Matrix as table with metadata comparison")
print("D==E ",D==E)
print("D==F", D==F)
print("but WARNING WARNING, userdata are never equal to tables with metadata")
print("A==D", A==D)
==== Result ====
Matrix as Userdata comparison
A==B true
A==C false
Matrix as table with metadata comparison
D==E true
D==F false
but WARNING WARNING, userdata are never equal to tables with metadata
A==D false
===== Table of contents =====
{{indexmenu>..:#2|tsort}}