LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
ApplyGivens.m
1function [v1,v2]=ApplyGivens(c,s,v1,v2,option)
2%[v1,v2]=ApplyGivens(c,s,v1,v2)
3% Apply a Givens rotation Q=[c,-s;s,c] to vectors v1 and v2
4% when option = 'L' ApplyGivens computes [v1;v2]=Q*[v1;v2]
5% In this case v1 and v2 must be row vectors
6% when option = 'R' ApplyGivens computes [v1,v2)=[v1,v2]*Q
7% In this case v1 and v2 must be column vectors
8%
9% option = 'RT' or option = 'LT' do the same with Q=[c,s;-s,c] (opposite rotation)
10% default value option='L'
11%
12% Author : Alain Barraud, copyright abc.consultant@wanadoo.fr 2003-2015
13%
14%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
15if nargin<5, option='L';else, option=upper(option);end
16if length(option)==2, s=-s;end
17Q=[c,-s;s,c];
18switch option(1)
19 case 'L'%compute Q*[v1;v2],
20 tmp=Q*[v1;v2];v1=tmp(1,:);v2=tmp(2,:);
21 case 'R'%compute [v1,v2]*Q,
22 tmp=[v1,v2]*Q;v1=tmp(:,1);v2=tmp(:,2);
23end
24%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%