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 Q-less tutorial #105

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

MaxenceGollier
Copy link
Contributor

Added two examples for solving
$AA^T y = b$ and $A^T A x = A^Tb$ without $Q$.

What do you think @amontoison ?

@dpo
Copy link
Member

dpo commented Jul 21, 2024

Please add text to describe that the examples are showing. It would also be useful to show how to use iterative refinement and compare the residuals and errors with and without it.

docs/src/tutorials/qless.md Show resolved Hide resolved
docs/src/tutorials/qless.md Show resolved Hide resolved
@amontoison
Copy link
Member

Thanks @MaxenceGollier for adding a tutorial!

I have the following suggestions:

  • Use m and n instead of 7 and 5;
  • Use zeros instead of similar so that the user knows the shape of the vectors that should be allocated to solve the problems. We might want to do this before that we compute the right-hand side;
  • Specify the option of not storing Q before the analysis so that QRMumps doesn't allocate memory to store the Q factor. You probably just don't update the Q factor if you do it after the analysis and before the factorization, but by then it's too late.

For the iterative refinement, we need to use get_factors to dump the sparse factor in Julia and perform the sparse triangular solves directly in Julia.
We should do that in another tutorial, but it will be easier if Alfredo (@abuttari) supports it directly in qr_mumps and its C interface.

@abuttari
Copy link
Contributor

Thanks @MaxenceGollier !
I believe there is a mistake in the first example: y_star and y\_2 have to be of size n(=7) instead of m(=5). In fact you cannot compute norm(A*y\_2-b) because of incompatible dimensions. The actual least-norm solution is y\_3=A'*y\_2.
Have I missed something?

@abuttari
Copy link
Contributor

For the iterative refinement, we need to use get_factors to dump the sparse factor in Julia and perform the sparse triangular solves directly in Julia. We should do that in another tutorial, but it will be easier if Alfredo (@abuttari) supports it directly in qr_mumps and its C interface.

@amontoison why can't you do the solves using qrm_solve?

@MaxenceGollier
Copy link
Contributor Author

Thanks @MaxenceGollier ! I believe there is a mistake in the first example: y_star and y\_2 have to be of size n(=7) instead of m(=5). In fact you cannot compute norm(A*y\_2-b) because of incompatible dimensions. The actual least-norm solution is y\_3=A'*y\_2. Have I missed something?

In the first example, $A \in \mathbb{R}^{5 \times 7}$ and then, $AA^T \in \mathbb{R}^{5 \times 5}$. Hence, $b, y^*, y_2$ all lie in $\mathbb{R}^5$

@abuttari
Copy link
Contributor

Thanks @MaxenceGollier ! I believe there is a mistake in the first example: y_star and y\_2 have to be of size n(=7) instead of m(=5). In fact you cannot compute norm(A*y\_2-b) because of incompatible dimensions. The actual least-norm solution is y\_3=A'*y\_2. Have I missed something?

In the first example, A∈R5×7 and then, AAT∈R5×5. Hence, b,y∗,y2 all lie in R5

@MaxenceGollier I get that. What I'm saying is that $y_2$ cannot be the solution of the problem because the solution has to be in $\mathbb{R}^7$

@amontoison
Copy link
Member

For the iterative refinement, we need to use get_factors to dump the sparse factor in Julia and perform the sparse triangular solves directly in Julia. We should do that in another tutorial, but it will be easier if Alfredo (@abuttari) supports it directly in qr_mumps and its C interface.

@amontoison why can't you do the solves using qrm_solve?

You're right, we can. I was thinking of something else when I answered. We also don't need to call get_factors.

@MaxenceGollier
Copy link
Contributor Author

What do you think now @dpo @amontoison @abuttari ?
$$y^*$$ is now in $$\mathbb{R}^7$$ as suggested.

@dpo
Copy link
Member

dpo commented Oct 8, 2024

Let's illustrate iterative refinement here, or else this tutorial is misleading. Also add a reference to Björck's paper where it is justified.

@dpo
Copy link
Member

dpo commented Oct 28, 2024

@MaxenceGollier

@MaxenceGollier
Copy link
Contributor Author

@dpo I have added iterative refinement now.

Copy link
Member

@dpo dpo left a comment

Choose a reason for hiding this comment

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

I added suggestions to make the examples look more like a tutorial and be more didactic. Also, there seem to be extra steps.

Please modify example 2 accordingly.

docs/src/tutorials/qless.md Outdated Show resolved Hide resolved
docs/src/tutorials/qless.md Outdated Show resolved Hide resolved
docs/src/tutorials/qless.md Show resolved Hide resolved
docs/src/tutorials/qless.md Outdated Show resolved Hide resolved
docs/src/tutorials/qless.md Outdated Show resolved Hide resolved
docs/src/tutorials/qless.md Outdated Show resolved Hide resolved
docs/src/tutorials/qless.md Outdated Show resolved Hide resolved

# Overall, RᵀRy₂ = b. Equivalently, RᵀQᵀQRy₂ = b or AAᵀy₂ = b

# Compute least norm solution of min ‖b - Ay‖
Copy link
Member

Choose a reason for hiding this comment

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

I’m confused. This step doesn’t belong in the solution of the least-norm problem.

Copy link
Contributor Author

@MaxenceGollier MaxenceGollier Nov 8, 2024

Choose a reason for hiding this comment

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

See this comment. I am not sure if this answers your question @dpo ?

Thanks @MaxenceGollier ! I believe there is a mistake in the first example: y_star and y\_2 have to be of size n(=7) instead of m(=5). In fact you cannot compute norm(A*y\_2-b) because of incompatible dimensions. The actual least-norm solution is y\_3=A'*y\_2. Have I missed something?

Comment on lines 11 to 14
# This procedure is backward stable if we perform one step of iterative refinement---see
#
# Å. Björck, Stability analysis of the method of seminormal equations for linear least squares problems,
# Linear Algebra and its Applications, 88–89, pp. 31-48, 1987, DOI 10.1016/0024-3795(87)90101-7.
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, this needs to be adjusted. The method of seminormal equations for the least-norm problem is analyzed in by Paige in https://www.ams.org/journals/mcom/1973-27-122/S0025-5718-1973-0331745-1.

For normal equations, the stability with and without Q is similar.

But it's not the same for least squares. It's only for least squares that we need iterative refinement. I think it would be useful to write functions that solve those problems and hide the details.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will add iterative refinement in a separate PR.

Copy link
Member

Choose a reason for hiding this comment

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

I'm saying the text needs to be adjusted too.

@MaxenceGollier
Copy link
Contributor Author

I think this is ready for a merge now, what do you think @dpo ?

docs/src/tutorials/qless.md Outdated Show resolved Hide resolved
docs/src/tutorials/qless.md Show resolved Hide resolved
docs/src/tutorials/qless.md Outdated Show resolved Hide resolved
docs/src/tutorials/qless.md Outdated Show resolved Hide resolved
docs/src/tutorials/qless.md Outdated Show resolved Hide resolved
docs/src/tutorials/qless.md Outdated Show resolved Hide resolved
docs/src/tutorials/qless.md Outdated Show resolved Hide resolved
docs/src/tutorials/qless.md Outdated Show resolved Hide resolved
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.

4 participants