QR decomposition: Difference between revisions

Content added Content deleted
(→‎{{header|Java}}: +Commons Math)
Line 1,930:
=={{header|Java}}==
=== Jama ===
Using the [https://math.nist.gov/javanumerics/jama/ Jama] library. Compile with: '''javac -cp Jama-1.0.3.jar Decompose.java'''.
 
Compile with: '''javac -cp Jama-1.0.3.jar Decompose.java'''.
 
<lang java>import Jama.Matrix;
Line 1,963 ⟶ 1,961:
=== Colt ===
 
Using the [https://dst.lbl.gov/ACSSoftware/colt/ Colt] library. Compile with: '''javac -cp colt.jar Decompose.java'''.
 
Compile with: '''javac -cp colt.jar Decompose.java'''.
 
<lang java>import cern.colt.matrix.impl.DenseDoubleMatrix2D;
Line 1,972 ⟶ 1,968:
public class Decompose {
public static void main(String[] args) {
var a = new DenseDoubleMatrix2D(new double[][] {{12, -51, 4},
{ 612, 167-51, -68 4},
{ {-46, 24167, -4168}});,
{-4, 24, -41}
});
var qr = new QRDecomposition(a);
System.out.println(qr.getQ());
Line 2,008 ⟶ 2,006:
public class Decompose {
public static void main(String[] args) {
var a = new Array2DRowRealMatrix(new double[][] {{12, -51, 4},
{ 612, 167-51, -68 4},
{ {-46, 24167, -4168}});,
{-4, 24, -41}
});
var qr = new QRDecomposition(a);
Line 2,038:
[ 0.0000 -175.0000 70.0000 ]
[ 0.0000 0.0000 35.0000 ]</pre>
 
=== la4j ===
 
Using the [http://la4j.org/ la4j] library. Compile with: '''javac -cp Jamala4j-1.0.36.0.jar Decompose.java'''.
 
<lang java>import org.la4j.Matrix;
import org.la4j.decomposition.QRDecompositor;
 
public class Decompose {
public static void main(String[] args) {
var a = Matrix.from2DArray(new double[][] {
{12, -51, 4},
{ 6, 167, -68},
{-4, 24, -41},
});
Matrix[] qr = new QRDecompositor(a).decompose();
System.out.println(qr[0]);
System.out.println(qr[1]);
}
}</lang>
 
{{out}}
 
<pre>-0,857 0,394 -0,331
-0,429 -0,903 0,034
0,286 -0,171 -0,943
 
-14,000 -21,000 14,000
0,000 -175,000 70,000
0,000 0,000 35,000</pre>
 
=={{header|Julia}}==