Solving a linear system Ax = b where A, b are complex #1577
-
Hi There, I am trying to solve a linear systems Ax = b where A,b are complex. I have saved A, b and x [the starting guess] as .mtx file. Here is my code **using IndexType = int; using cg = gko::solver::Cg<std::complex>; auto A = gko::share(gko::read(std::ifstream("../data/A.mtx"), exec)); auto solver_gen = auto solver = solver_gen->generate(A); I get the following error: terminate called after throwing an instance of 'gko::DimensionMismatch' I am not sure where is the dimension mismatch coming from? How do I fix the code? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
Your vector x0.mtx is stored as a row vector, it should be a column vector. You can either fix your output, or transpose it after reading: x = gko::as<vec>(x->transpose()); |
Beta Was this translation helpful? Give feedback.
-
Is there an example that I could use. I think I am struggling to deal with Complex vectors. Essentially, I pass a vector of size 62476 X 1 as a .mtx file to Ginkgo. This vector was created in python and converted to a .mtx file using mmwrite function. The problem is that when Ginkgo reads this .mtx file, it somehow converts itself into 1 X 62476 vector. I tried the instruction
but it still doesn't correct it. That is, it still prints the error /usr/local/include/ginkgo/core/base/lin_op.hpp:303: validate_application_parameters: attempting to combine operators this [62476 x 62476] and b [1 x 62476]: expected matching inner dimensions |
Beta Was this translation helpful? Give feedback.
Thank you. I was able to run your code without any issues after commenting out the transposing of both
x
andb
.