# HG changeset patch # User David Bateman # Date 1206638338 14400 # Node ID d9eb2aec6d8457b255b323fa6f8619233cf0e294 # Parent b5731e43283a091e6b803af39307be78ef2c0fe1 Add the planerot function diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2008-03-27 David Bateman + + * linear-algebra/planerot.m: Givens rotation function. + 2008-03-26 John W. Eaton * set/ismember.m: Set size of idx output correctly for empty args. diff --git a/scripts/linear-algebra/Makefile.in b/scripts/linear-algebra/Makefile.in --- a/scripts/linear-algebra/Makefile.in +++ b/scripts/linear-algebra/Makefile.in @@ -35,8 +35,8 @@ SOURCES = __norm__.m commutation_matrix.m cond.m condest.m cross.m \ dmult.m dot.m duplication_matrix.m housh.m krylov.m krylovb.m logm.m \ - null.m onenormest.m orth.m qzhess.m rank.m rref.m subspace.m trace.m \ - vec.m vech.m + null.m onenormest.m orth.m planerot.m qzhess.m rank.m rref.m subspace.m \ + trace.m vec.m vech.m DISTFILES = $(addprefix $(srcdir)/, Makefile.in $(SOURCES)) diff --git a/scripts/linear-algebra/planerot.m b/scripts/linear-algebra/planerot.m new file mode 100644 --- /dev/null +++ b/scripts/linear-algebra/planerot.m @@ -0,0 +1,38 @@ +## Copyright (C) 2008 David Bateman +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## . + +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{g}, @var{y}] =} planerot (@var{x}) +## Given a two-element column vector, returns the +## @iftex +## @tex +## $2\\times 2$ orthogonal matrix +## @end tex +## @end iftex +## @ifnottex +## 2 by 2 orthogonal matrix +## @end ifnottex +## @var{G} such that +## @code{@var{y} = @var{g} * @var{x}} and @code{@var{y}(2) = 0}. +## @seealso{givens} +## @end deftypefn + +function [G, y] = planerot (x) + G = givens (x(1), x(2)); + y = G * x(:); +endfunction