Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| documentation:language_reference:objects:matrix:start [2018/09/25 14:53] – Added Code Example Simon Heinze | documentation:language_reference:objects:matrix:start [2025/11/20 04:15] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| ### | ### | ||
| - | The object Matrix defines matrices, i.e. tables of tables, and defines the standard lua math operations | + | The object Matrix defines matrices. |
| + | ### | ||
| + | ### | ||
| + | Matrices can be created from tables of tables by setting the meta table of the table to MatrixMeta | ||
| <code Quanty Example.Quanty> | <code Quanty Example.Quanty> | ||
| - | --This creates a table of tables | + | M = {{1,2},{3,4}} |
| - | A = {{1, | + | setmetatable(M, MatrixMeta) |
| - | {33, 4.7}} | + | </ |
| - | B = {{3, 1.6 }, | + | Matrices can be created as a user data with the function |
| - | | + | <code Quanty Example.Quanty> |
| - | --This defines functionalities like addition or multiplication on M | + | M = Matrix.New( {{1,2}, |
| - | setmetatable(A, MatrixMeta) | + | |
| - | setmetatable(B, | + | |
| - | + | ||
| - | print("" | + | |
| - | print(" | + | |
| - | print(A + B) | + | |
| - | + | ||
| - | print("" | + | |
| - | print(" | + | |
| - | print(A - B) | + | |
| - | + | ||
| - | print("" | + | |
| - | print(" | + | |
| - | print(A * B) | + | |
| - | + | ||
| - | --This is equivalent to A * Matrix.Inverse(B) | + | |
| - | print("" | + | |
| - | print(" | + | |
| - | print(A / B) | + | |
| - | + | ||
| - | --This is equivalent to Matrix.Inverse(A) | + | |
| - | print("" | + | |
| - | print(" | + | |
| - | print(1 / A) | + | |
| - | + | ||
| - | print("" | + | |
| - | print(" | + | |
| - | print(A^2) | + | |
| </ | </ | ||
| ### | ### | ||
| - | <file Quanty_Output> | + | ### |
| - | A + B | + | Below you can find a list of possible functions and operations one can perform on matrices |
| - | { { 4 , 15.6 } , | + | ### |
| - | { 38 , 11.7 } } | + | |
| - | + | ||
| - | A - B | + | |
| - | { { -2 , 12.4 } , | + | |
| - | { 28 , -2.3 } } | + | |
| - | + | ||
| - | A * B | + | |
| - | { { 73 , 99.6 } , | + | |
| - | { 122.5 , 85.7 } } | + | |
| - | + | ||
| - | A / B | + | |
| - | { { -4.8461538461538 , 3.1076923076923 } , | + | |
| - | { 15.961538461538 , -2.9769230769231 } } | + | |
| - | + | ||
| - | 1 / A | + | |
| - | { { -0.010277717034769 , 0.030614476273781 } , | + | |
| - | { 0.072162694073912 , -0.0021867483052701 } } | + | |
| - | + | ||
| - | A^2 | + | |
| - | { { 463 , 79.8 } , | + | |
| - | { 188.1 , 484.09 } } | + | |
| - | + | ||
| - | </ | + | |
| ===== Table of contents ===== | ===== Table of contents ===== | ||
| - | {{indexmenu> | + | {{indexmenu> |