QR decomposition: Difference between revisions
Content added Content deleted
(→{{header|Tcl}}: added zkl) |
(C# solution) |
||
Line 621: | Line 621: | ||
2.000 -0.000 3.000 |
2.000 -0.000 3.000 |
||
</pre> |
</pre> |
||
=={{header|C sharp|C#}}== |
|||
{{libheader|Math.Net}} |
|||
<lang csharp>using System; |
|||
using MathNet.Numerics.LinearAlgebra; |
|||
using MathNet.Numerics.LinearAlgebra.Double; |
|||
class Program |
|||
{ |
|||
static void Main(string[] args) |
|||
{ |
|||
Matrix<double> A = DenseMatrix.OfArray(new double[,] |
|||
{ |
|||
{ 12, -51, 4 }, |
|||
{ 6, 167, -68 }, |
|||
{ -4, 24, -41 } |
|||
}); |
|||
Console.WriteLine("A:"); |
|||
Console.WriteLine(A); |
|||
var qr = A.QR(); |
|||
Console.WriteLine(); |
|||
Console.WriteLine("Q:"); |
|||
Console.WriteLine(qr.Q); |
|||
Console.WriteLine(); |
|||
Console.WriteLine("R:"); |
|||
Console.WriteLine(qr.R); |
|||
} |
|||
}</lang> |
|||
{{out}} |
|||
<pre>A: |
|||
DenseMatrix 3x3-Double |
|||
12 -51 4 |
|||
6 167 -68 |
|||
-4 24 -41 |
|||
Q: |
|||
DenseMatrix 3x3-Double |
|||
-0.857143 0.394286 -0.331429 |
|||
-0.428571 -0.902857 0.0342857 |
|||
0.285714 -0.171429 -0.942857 |
|||
R: |
|||
DenseMatrix 3x3-Double |
|||
-14 -21 14 |
|||
0 -175 70 |
|||
0 0 35</pre> |
|||
=={{header|Common Lisp}}== |
=={{header|Common Lisp}}== |