QR decomposition: Difference between revisions

Content deleted Content added
Bastet (talk | contribs)
m →‎{{header|Java}}: a bit simpler
Bastet (talk | contribs)
Line 1,929:
 
=={{header|Java}}==
=== Using Jama ===
Note: uses the [https://math.nist.gov/javanumerics/jama/ JAMA Java Matrix Package].
 
Line 1,959 ⟶ 1,960:
0.0000 -175.0000 70.0000
0.0000 0.0000 35.0000</pre>
 
=== Using Colt ===
 
Note: uses the [https://dst.lbl.gov/ACSSoftware/colt/ Colt] library.
 
Compile with: '''javac -cp colt.jar ColtQR.java'''.
 
<lang java>import cern.colt.matrix.impl.DenseDoubleMatrix2D;
import cern.colt.matrix.linalg.QRDecomposition;
 
public class ColtQRExample {
public static void main(String[] args) {
var a = new DenseDoubleMatrix2D(new double[][] {{12, -51, 4},
{ 6, 167, -68},
{-4, 24, -41}});
var qr = new QRDecomposition(a);
System.out.println(qr.getQ());
System.out.println();
System.out.println(qr.getR());
}
}</lang>
 
{{out}}
 
<pre>3 x 3 matrix
-0.857143 0.394286 -0.331429
-0.428571 -0.902857 0.034286
0.285714 -0.171429 -0.942857
 
3 x 3 matrix
-14 -21 14
0 -175 70
0 0 35</pre>
 
=={{header|Julia}}==