Projection using Modified Gram-Schmidt orthogonality
Afficher commentaires plus anciens
Hello,
I need the Modified Gram-Schmidt orthogonalization method in my Research.
I wrote the following code for the projection using the Classic Gram-Schmidt:
function[Xp] = Project(A,B)
Xp = [] ;
u1 = B;
for i = 1:1:6
u2 = A(i,:)- (A(i,:)*u1)/(u1'*u1) * u1';
Xp = [Xp;u2] ;
end
end
I faced problems to convert the Modified Gram-Schmidt orthogonalization method into MATLAB code, which is illustrated in the following link https://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process
under section Numerical stability.
Can anyone help me in this problem please?
22 commentaires
Torsten
le 25 Jan 2023
The question is what you want.
The two codes do very different things:
The first code orthonormalizes A, the second projects A on the subspace spanned by B.
M
le 25 Jan 2023
As said, projection is not normalization. To project a set of vectors A on a given vector B, you don't need Gram-Schmidt - neither classical nor modified.
You only need the projection formula
A_projected(i,:) = A(i,:)*B/(B.'*B) * B.';
M
le 25 Jan 2023
M
le 25 Jan 2023
M
le 25 Jan 2023
As said, projecting a set of vectors (rows of A) on one other vector (B) doesn't produce any problems.
Maybe the real problem you are trying to solve is different from what you do, but my abilities as clairvoyant are limited. So you should describe what you are trying to do. If it is really projecting a set of vectors on one given vector, you don't need Gram-Schmid - you only need the projection formula supplied. If you want to project a vector on the span of a set of vectors, the problem will be different.
The statement "there is a matrix that should be orthogonalized with a certain vector" makes no sense to me. Could you elaborate ?
If it means that you want to extract the portion of each row of A that is orthogonal to this certain vector, then your function "Project" does the job. But since one vector is compared with only one other vector, there is no such thing as "modified Gram Schmid" for this application.
I already wrote that I don't understand what you mean by
In my problem there is a matrix A is always orthogonalized with vector B.
As a consequence, I also don't understand what you mean by
I want to take advantage from this info and apply orthognalization methods as a cost function
Maybe someone else in the forum gets it. Or you make an attempt to explain better.
M
le 25 Jan 2023
Torsten
le 25 Jan 2023
You don't have a Gram-Schmid orthogonalization if you project several vectors separately on only one other vector. And this is what your "Project" function does. So there is no such thing as "Numerical Stability" you have to care about or that would change the projection formula.
If you want to project B on the row space of A, this would be a different thing.
But I repeat myself ...
Torsten
le 25 Jan 2023
in this case is there a need to use the Gram-Schmid method?
Yes. The easiest way is to orthonormalize the row space first (maybe using modified Gram-Schmid) and then use the formula under
Torsten
le 26 Jan 2023
The easiest way is to orthonormalize the row space first (maybe using modified Gram-Schmid) and then use the formula under
Anything you didn't understand in my answer ? Or wasn't it what you were asking for ?
M
le 26 Jan 2023
Torsten
le 26 Jan 2023
Then I can assure you that from what you wrote, nobody will be able to understand what you are looking for.
Try to understand the problem first before looking for a solution.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Linear Algebra dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!