Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
documentation:language_reference:objects:matrix:operations:eq [2024/12/12 14:27] – created Maurits W. Haverkortdocumentation:language_reference:objects:matrix:operations:eq [2024/12/12 15:36] (current) Maurits W. Haverkort
Line 3: Line 3:
  
 ### ###
-alligned paragraph text+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 ===== ===== Example =====
- 
-### 
-description text 
-### 
  
 ==== Input ==== ==== Input ====
 <code Quanty Example.Quanty> <code Quanty Example.Quanty>
--- some example code+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)
 </code> </code>
  
 ==== Result ==== ==== Result ====
 <file Quanty_Output> <file Quanty_Output>
-text produced as output+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
 </file> </file>
  
 ===== Table of contents ===== ===== Table of contents =====
-{{indexmenu>.#1|msort}}+{{indexmenu>..:#2|tsort}}
  
Print/export