From: <par...@us...> - 2010-08-19 07:41:09
|
Revision: 7556 http://octave.svn.sourceforge.net/octave/?rev=7556&view=rev Author: paramaniac Date: 2010-08-19 07:41:03 +0000 (Thu, 19 Aug 2010) Log Message: ----------- quaternion-oo: add abs.m Modified Paths: -------------- trunk/octave-forge/extra/quaternion_oo/INDEX Added Paths: ----------- trunk/octave-forge/extra/quaternion_oo/inst/@quaternion/abs.m Modified: trunk/octave-forge/extra/quaternion_oo/INDEX =================================================================== --- trunk/octave-forge/extra/quaternion_oo/INDEX 2010-08-18 21:35:28 UTC (rev 7555) +++ trunk/octave-forge/extra/quaternion_oo/INDEX 2010-08-19 07:41:03 UTC (rev 7556) @@ -1,6 +1,7 @@ quaternion >> Quaternion Quaternions quaternion + @quaternion/abs @quaternion/conj @quaternion/diag @quaternion/ispure Added: trunk/octave-forge/extra/quaternion_oo/inst/@quaternion/abs.m =================================================================== --- trunk/octave-forge/extra/quaternion_oo/inst/@quaternion/abs.m (rev 0) +++ trunk/octave-forge/extra/quaternion_oo/inst/@quaternion/abs.m 2010-08-19 07:41:03 UTC (rev 7556) @@ -0,0 +1,39 @@ +## Copyright (C) 2010 Lukas F. Reichlin +## +## This program 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. +## +## This program 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 this program. If not, see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {@var{qabs} =} abs (@var{q}) +## Modulus of a quaternion. +## +## @example +## q = w + x*i + y*j + z*k +## abs (q) = sqrt (w.^2 + x.^2 + y.^2 + z.^2) +## @end example +## @end deftypefn + +## Author: Lukas Reichlin <luk...@gm...> +## Created: August 2010 +## Version: 0.1 + + +function b = abs (a) + + if (nargin != 1) + print_usage (); + endif + + b = sqrt (a.w.^2 + a.x.^2 + a.y.^2 + a.z.^2); + +endfunction \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |