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

[Error] inverse-iteration #606

Closed
nghiakvnvsd opened this issue Jul 30, 2020 · 6 comments · Fixed by #612
Closed

[Error] inverse-iteration #606

nghiakvnvsd opened this issue Jul 30, 2020 · 6 comments · Fixed by #612
Assignees
Labels
is:bug Something looks wrong. is:confirmed Someone confirmed this issue. reg:example This is related to the examples.

Comments

@nghiakvnvsd
Copy link

nghiakvnvsd commented Jul 30, 2020

Hello everyone!

When I ran the inverse-iteration example, it reports: Operation gko::as<gko::matrix::Dense> does not support parameters of type gko::matrix::Dense<std::complex >. I have no idea about it. May you help me?

Thank you!

@thoasm thoasm self-assigned this Jul 30, 2020
@tcojean
Copy link
Member

tcojean commented Jul 30, 2020

Hi, thanks for the issue indeed we can easily reproduce this. We will fix this ASAP.

@tcojean tcojean added is:bug Something looks wrong. is:confirmed Someone confirmed this issue. reg:example This is related to the examples. labels Jul 30, 2020
@nghiakvnvsd
Copy link
Author

And I don't know if This example can run on CudaExecutor?

@thoasm
Copy link
Member

thoasm commented Jul 30, 2020

Hello @nghiakvnvsd,
thank you very much for your feedback, this is indeed a bug.
The issue here is that the norm expects a non-complex type, which we changed not so long ago. The problem was that I forgot to check the examples for potential problems, which I will now do.
In the meantime, if you want to resolve it yourself, you can use the branch fix_example_norms where I am currently working on resolving that for all examples, or apply the following changes:

diff --git a/examples/inverse-iteration/inverse-iteration.cpp b/examples/inverse-iteration/inverse-iteration.cpp
index 856483bfb..5be92f905 100644
--- a/examples/inverse-iteration/inverse-iteration.cpp
+++ b/examples/inverse-iteration/inverse-iteration.cpp
@@ -45,8 +45,9 @@ int main(int argc, char *argv[])
 {
     // Some shortcuts
     using precision = std::complex<double>;
-    using real_precision = double;
+    using real_precision = gko::remove_complex<precision>;
     using vec = gko::matrix::Dense<precision>;
+    using real_vec = gko::matrix::Dense<real_precision>;
     using mtx = gko::matrix::Csr<precision>;
     using solver_type = gko::solver::Bicgstab<precision>;
 
@@ -126,7 +127,7 @@ int main(int argc, char *argv[])
     }();
     auto y = clone(x);
     auto tmp = clone(x);
-    auto norm = clone(one);
+    auto norm = gko::share(gko::initialize<real_vec>({1.0}, exec));
     auto inv_norm = clone(this_exec, one);
     auto g = clone(one);
 
@@ -142,7 +143,7 @@ int main(int argc, char *argv[])
         // x = y / || y ||
         x->compute_norm2(lend(norm));
         inv_norm->get_values()[0] =
-            precision{1.0} / clone(this_exec, norm)->get_values()[0];
+            real_precision{1.0} / clone(this_exec, norm)->get_values()[0];
         x->scale(lend(clone(exec, inv_norm)));
         // g = x^* A x
         A->apply(lend(x), lend(tmp));

And yes, this should also run with the CudaExecutor (to be sure, I am currently running tests for that).

@thoasm
Copy link
Member

thoasm commented Jul 30, 2020

@nghiakvnvsd Can confirm that the fix also works on the CudaExecutor (should also work on HIP, but currently not when compiling for both HIP and CUDA at the same time, see PR #602 for a solution there).

@nghiakvnvsd
Copy link
Author

Thank you so much!!!

@nghiakvnvsd
Copy link
Author

nghiakvnvsd commented Aug 1, 2020

I have a question about eigenvalues and eigenvectors. While searching ideas, I saw the topic: #135 . I know you guys developing it but I don't know if it is finished. I'm looking forward it because it is very useful for scientists. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
is:bug Something looks wrong. is:confirmed Someone confirmed this issue. reg:example This is related to the examples.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants