numpi / hm-toolbox

Toolbox for HODLR and HSS matrices in MATLAB
GNU General Public License v3.0
43 stars 8 forks source link

Complex solution vector from real nonsymmetric Toeplitz systems with real RHS vector #1

Closed Hsien-Ming-Ku closed 5 years ago

Hsien-Ming-Ku commented 5 years ago

Dear authors, Recently, I needs to solve a sequence of real nonsymmetric Toeplitz linear systems, i.e., Ax = b, b is also a real vector. Then I call the function "toeplitz_solve.m" to solve them, however, it produces the complex solution vectors x, then the solvers will become slow and inexact. Maybe, you can improve this case.

robol commented 5 years ago

Dear Hsien-Ming-Ku, thanks for the comment. There was indeed a bug in the complex version of toeplitz_solve, which should have now been fixed. Thanks for noticing it!

Best, -- Leonardo.

Hsien-Ming-Ku commented 5 years ago

Many thanks for your kind reply. But it seems that the bug is still here.

Please try the following example:

ac = [1 rand(1,255)]; ar = [1 randn(1,255)]; ac = ac.'; A = toeplitz(ac,ar) + 0.1eye(256); b = Aones(256,1); c = A(:,1); r = A(1,:); x = toeplitz_solve(c, r, b); norm(x - ones(256,1)); isreal(x);

So we maybe make it real, not complex.

All the best, Xianming


发件人: Leonardo Robol notifications@github.com 发送时间: 2019年9月13日 16:30 收件人: numpi/hm-toolbox hm-toolbox@noreply.github.com 抄送: Xian-Ming Gu guxianming@live.cn; Author author@noreply.github.com 主题: Re: [numpi/hm-toolbox] Complex solution vector from real nonsymmetric Toeplitz systems with real RHS vector (#1)

Dear Hsien-Ming-Ku, thanks for the comment. There was indeed a bug in the complex version of toeplitz_solve, which should have now been fixed. Thanks for noticing it!

Best, -- Leonardo.

― You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/numpi/hm-toolbox/issues/1?email_source=notifications&email_token=ACJ4KLH62PNJ477F6Z3PKX3QJNFSJA5CNFSM4IVDVZYKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6ULHPI#issuecomment-531149757, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACJ4KLG3Y2W6FU5EOIDMXL3QJNFSJANCNFSM4IVDVZYA.

robol commented 5 years ago

Thanks for the feedback; I tried your example, and the accuracy is about 10^(-12), which is of the order of the truncation done in the toolbox, that can be set with hssoption('threshold', ...); So on that regards, I think the solver is accurate.

I added a check at the end to enforce the solution to be real if all the inputs are. It's currently in the fix-toeplitz branch, hopefully it will be merged soon.