diff options
| author | Abdellah El Morabit <nsrddyn@gmail.com> | 2025-11-25 20:28:57 +0100 |
|---|---|---|
| committer | Abdellah El Morabit <nsrddyn@gmail.com> | 2025-11-25 20:28:57 +0100 |
| commit | e70ce01ce40d4e3fc86f887913ee1c7fa6ffb50e (patch) | |
| tree | 0db433d1c3cf6d2b3b7229819b40a107824016de /src/main/scala/com/nsrddyn/FPU | |
| parent | 409b76a88e589cbd7a8dfd9d0aad8152bb00d0bb (diff) | |
feature: checkpoint
Diffstat (limited to 'src/main/scala/com/nsrddyn/FPU')
| -rw-r--r-- | src/main/scala/com/nsrddyn/FPU/CholeskyDecomposition.scala | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/main/scala/com/nsrddyn/FPU/CholeskyDecomposition.scala b/src/main/scala/com/nsrddyn/FPU/CholeskyDecomposition.scala index b42ade9..80a1778 100644 --- a/src/main/scala/com/nsrddyn/FPU/CholeskyDecomposition.scala +++ b/src/main/scala/com/nsrddyn/FPU/CholeskyDecomposition.scala @@ -1,5 +1,8 @@ package com.nsrddyn.fpu +import scala.math._ +import scala.collection.immutable.ListSet +import scala.collection.mutable.ArrayBuffer class CholeskyDecomposition { @@ -13,14 +16,38 @@ class CholeskyDecomposition { * Linpack uses the cholesky decomposition * https://www.netlib.org/linpack/ * + * https://www.geeksforgeeks.org/dsa/cholesky-decomposition-matrix-decomposition/ * + * The Cholesky decomposition maps matrix A into the product of A = L ยท LH where L is the lower triangular matrix and LH is the transposed, + * complex conjugate or Hermitian, and therefore of upper triangular form (Fig. 13.6). + * This is true because of the special case of A being a square, conjugate symmetric matrix. */ - def choleskyDecomposition(n: Int): Unit = { + def run(matrix: List[List[Int]]): Unit = { - for (w <- 0 to n) { + val n: Int = matrix.size + // store the lower triangular matrix + val lower = Vector[Vector[Int]]() + + for (i <- 0 until n) + { + for (j <- 0 until i) + var sum: Double = 0 + + if j == i then + sum += math.pow(lowerBuffer(i)(j), 2) + + end if + lower(i)(j) = (sqrt(matrix(i)(j))()) + + j += 1 } + i += 1 } + + def (matrix: Vector[Vector[Int]], index: int, jindex: int ): Int = if j == 1 then return math.pow(matrix(index)(jindex)) else + + } |
