]> Creatis software - CreaPhase.git/blob - octave_packages/nurbs-1.3.6/vecmag2.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / nurbs-1.3.6 / vecmag2.m
1 function mag = vecmag2(vec)
2
3 % VECMAG2: Squared magnitude of a set of vectors.
4
5 % Calling Sequence:
6
7 %   mvec = vecmag2(vec)
8
9 % INPUT:
10
11 %   vec         : An array of column vectors represented by a matrix of
12 %               size (dim,nv), where dim is the dimension of the vector and
13 %               nv the number of vectors.
14 %
15 % OUTPUT:
16
17 %   mvec        : Squared magnitude of the vectors, vector of size (1,nv).
18
19 % Description:
20
21 %   Determines the squared magnitude of the vectors.
22
23 % Examples:
24
25 %   Find the squared magnitude of the two vectors (0.0,2.0,1.3)
26 %   and (1.5,3.4,2.3)
27
28 %   mvec = vecmag2([0.0 1.5; 2.0 3.4; 1.3 2.3]);
29 %
30 %    Copyright (C) 2000 Mark Spink
31 %
32 %    This program is free software: you can redistribute it and/or modify
33 %    it under the terms of the GNU General Public License as published by
34 %    the Free Software Foundation, either version 2 of the License, or
35 %    (at your option) any later version.
36
37 %    This program is distributed in the hope that it will be useful,
38 %    but WITHOUT ANY WARRANTY; without even the implied warranty of
39 %    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
40 %    GNU General Public License for more details.
41 %
42 %    You should have received a copy of the GNU General Public License
43 %    along with this program.  If not, see <http://www.gnu.org/licenses/>.
44
45 mag = sum(vec.^2);
46
47 end