QR decomposition: Difference between revisions
Content added Content deleted
(Added Java example using JAMA matrix library) |
(Scala contribution added.) |
||
Line 2,188: | Line 2,188: | ||
0 -175 70 |
0 -175 70 |
||
0 0 35 |
0 0 35 |
||
*/</lang> |
*/</lang> |
||
=={{header|Scala}}== |
|||
{{Out}}Best seen running in your browser [https://scastie.scala-lang.org/NMueO16uQl6oivliBKZHew Scastie (remote JVM)]. |
|||
<lang Scala>import java.io.{PrintWriter, StringWriter} |
|||
import Jama.{Matrix, QRDecomposition} |
|||
object QRDecomposition extends App { |
|||
val matrix = |
|||
new Matrix( |
|||
Array[Array[Double]](Array(12, -51, 4), |
|||
Array(6, 167, -68), |
|||
Array(-4, 24, -41))) |
|||
val d = new QRDecomposition(matrix) |
|||
def toString(m: Matrix): String = { |
|||
val sw = new StringWriter |
|||
m.print(new PrintWriter(sw, true), 8, 6) |
|||
sw.toString |
|||
} |
|||
print(toString(d.getQ)) |
|||
print(toString(d.getR)) |
|||
}</lang> |
|||
=={{header|SequenceL}}== |
=={{header|SequenceL}}== |