RosettaCodeData/Task/QR-decomposition/Pluto/qr-decomposition.pluto
2026-04-30 12:34:36 -04:00

20 lines
312 B
Text

require "matrix"
local inp = {
{12, -51, 4},
{ 6, 167, -68},
{-4, 24, -41},
{-1, 1, 0},
{ 2, 0, 3}
}
local x = matrix.from(inp)
local [Q, R] = x:qr()
local m = Q:matmul(R)
local f = "%8.3f"
print("Q:")
print(Q:format(f))
print("\nR:")
print(R:format(f))
print("\nQ x R:")
print(m:format(f))