Skip to content
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

Add LDLT Cholesky decomposition #4130

Merged
merged 4 commits into from Feb 6, 2018

Conversation

vinx13
Copy link
Member

@vinx13 vinx13 commented Jan 28, 2018

Add LDLT cholesky decomposition and solver for positive semidefinite or negative semidefinite Hermitan matrixes.
See discussion in #4085

*
* @param A The matrix whose LDLT cholesky decomposition is to be
* computed
* @param L The matrix that saves tht upper or lower triangular LDLT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: "tht"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also remove "upper or lower", just say "triangular LDLT (default: lower)"

const SGMatrix<T>& A, SGMatrix<T>& L, SGVector<T>& d,
SGVector<index_t>& p, const bool lower = true)
{
REQUIRE(A.num_rows == A.num_cols, "Matrix A is not square\n");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should technically write: "Matrix dimensions (%dx%d) are not square.\n"

Copy link
Member

@karlnapf karlnapf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks pretty good to me :)
Some comments need polish but otherwise good.

Thanks! :)

* @return @see LinalgBackendBase pointer
*/
template <typename T, template <typename> class Container>
LinalgBackendBase* infer_backend(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we make this a bit nicer here, so that any number of things that have the .on_gpu(), .on_cpu() method implemented is checked?

@lisitsyn can you do some magic ?

* Solve the linear equations \f$Ax=b\f$, given the LDLT Cholesky
* factorization of A,
* where \f$A\f$ is a positive semidefinite or negative semidefinite
* Hermitan matrix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add a @see factor (or however it is called) here

@@ -406,6 +406,44 @@ TEST(LinalgBackendEigen, SGMatrix_cholesky_solver)
EXPECT_EQ(x_ref.size(), x_cal.size());
}

TEST(LinalgBackendEigen, SGMatrix_ldlt_solver)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i wonder why there is "SGMatrix" in the test name?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just followed other test cases like SGMatrix_cholesky_solver

const SGMatrix<T>& A, SGMatrix<T>& L, SGVector<T>& d,
SGVector<index_t>& p, const bool lower = true)
{
REQUIRE(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lisitsyn we need some systematic and compact way to do these checks. The amount of lines of code for such error messages is crazy

b[2] = 11.0;

SGVector<float64_t> x_ref(size), x(size);
x_ref[0] = 0.0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer a test that is more self explaining.

Like you do
x = A*b

then you solve b2= A^-1 * x
and then you check that b==b2

But this one is OK as well

@karlnapf
Copy link
Member

karlnapf commented Feb 4, 2018

I restarted the CI, after which we can merge this, thanks!

@OXPHOS all ok with this?

@OXPHOS OXPHOS merged commit be16f3e into shogun-toolbox:develop Feb 6, 2018
@OXPHOS
Copy link
Member

OXPHOS commented Feb 6, 2018

LGTM! I'll merge it.

ktiefe pushed a commit to ktiefe/shogun that referenced this pull request Jul 30, 2019
* Add LDLT decomposition

* Add LDLT Cholesky solver

* Polish error message

* Add ref to ldlt_factor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants