-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added realignment to dlgp and pdm #428
Open
JonathanAellen
wants to merge
14
commits into
unibas-gravis:release-1.0
Choose a base branch
from
JonathanAellen:realign
base: release-1.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b2a67a0
Merge pull request #423 from unibas-gravis/ci-with-jdk11
marcelluethi 92b7ab0
initial draft.
JonathanAellen 8ed6298
corrected the algorithm and tests
JonathanAellen 1515d9d
merged realign implementation
JonathanAellen 1cb3ec3
Merge pull request #3 from JonathanAellen/release-1.0
JonathanAellen d3d064c
formatting of tests
JonathanAellen ba6c5f1
improved implementation. added the type classing setup to scalismo.co…
JonathanAellen 1aa1c45
fixed formatting of missed extension
JonathanAellen d20085e
improved dimensionality inference
JonathanAellen a0272cb
moved extension type class
JonathanAellen 1f964de
removed unapply and omitted inferrable bound
JonathanAellen 51c1203
updates to doc
JonathanAellen db9eced
further updates to doc. additional test for the non diagonal model ba…
JonathanAellen c927e7f
fixed typo in doc
JonathanAellen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package scalismo.numerics | ||
|
||
import breeze.linalg.{*, given} | ||
|
||
object GramDiagonalize { | ||
|
||
/** | ||
* Given a non orthogonal basis nxr and the variance (squared [eigen]scalars) of that basis, returns an orthonormal | ||
* basis with the adjusted variance. sets small eigenvalues to zero. | ||
*/ | ||
def rediagonalizeGram(basis: DenseMatrix[Double], | ||
s: DenseVector[Double] | ||
): (DenseMatrix[Double], DenseVector[Double]) = { | ||
// val l: DenseMatrix[Double] = basis(*, ::) * breeze.numerics.sqrt(s) | ||
val l: DenseMatrix[Double] = DenseMatrix.zeros[Double](basis.rows, basis.cols) | ||
val sqs: DenseVector[Double] = breeze.numerics.sqrt(s) | ||
for i <- 0 until basis.cols do l(::, i) := sqs(i) * basis(::, i) | ||
|
||
val gram = l.t * l | ||
val svd = breeze.linalg.svd(gram) | ||
val newS: DenseVector[Double] = breeze.numerics.sqrt(svd.S).map(d => if (d > 1e-10) 1.0 / d else 0.0) | ||
|
||
// val newbasis: DenseMatrix[Double] = l * (svd.U(*, ::) * newS) | ||
val inner: DenseMatrix[Double] = DenseMatrix.zeros[Double](gram.rows, gram.cols) | ||
for i <- 0 until basis.cols do inner(::, i) := newS(i) * svd.U(::, i) | ||
val newbasis = l * inner | ||
|
||
(newbasis, svd.S) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we add an unapply method, we should also remove the private modifier from the corresponding fields, and maybe add an apply method. Like this it is a bit contradictory.
It was private so far to prevent access to it, but I don't have a strong opinion to keep it like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i forgot to remove the unapply method. will be removed in the next version