Golub-Kahan SVD algorithm for KMP tensors #499

Closed
grinisrit wants to merge 64 commits from dev into dev
Showing only changes of commit 40bab168a7 - Show all commits

View File

@ -65,8 +65,7 @@ internal fun MutableStructure2D<Double>.svdGolabKahan(v: MutableStructure2D<Doub
f = this[i, i] f = this[i, i]
if (f >= 0) { if (f >= 0) {
g = (-1) * abs(sqrt(s)) g = (-1) * abs(sqrt(s))
} } else {
else {
g = abs(sqrt(s)) g = abs(sqrt(s))
} }
val h = f * g - s val h = f * g - s
@ -106,8 +105,7 @@ internal fun MutableStructure2D<Double>.svdGolabKahan(v: MutableStructure2D<Doub
f = this[i, l] f = this[i, l]
if (f >= 0) { if (f >= 0) {
g = (-1) * abs(sqrt(s)) g = (-1) * abs(sqrt(s))
} } else {
else {
g = abs(sqrt(s)) g = abs(sqrt(s))
} }
val h = f * g - s val h = f * g - s
@ -183,8 +181,7 @@ internal fun MutableStructure2D<Double>.svdGolabKahan(v: MutableStructure2D<Doub
for (j in i until m) { for (j in i until m) {
this[j, i] *= g this[j, i] *= g
} }
} } else {
else {
for (j in i until m) { for (j in i until m) {
this[j, i] = 0.0 this[j, i] = 0.0
} }