]> Creatis software - CreaPhase.git/blob - octave_packages/quaternion-2.0.0/@quaternion/size.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / quaternion-2.0.0 / @quaternion / size.m
1 ## Copyright (C) 2010   Lukas F. Reichlin
2 ##
3 ## This program is free software: you can redistribute it and/or modify
4 ## it under the terms of the GNU General Public License as published by
5 ## the Free Software Foundation, either version 3 of the License, or
6 ## (at your option) any later version.
7 ##
8 ## This program is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 ## GNU General Public License for more details.
12 ##
13 ## You should have received a copy of the GNU General Public License
14 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16 ## -*- texinfo -*-
17 ## @deftypefn {Function File} {@var{nvec} =} size (@var{q})
18 ## @deftypefnx {Function File} {@var{n} =} size (@var{q}, @var{dim})
19 ## @deftypefnx {Function File} {[@var{nx}, @var{ny}, @dots{}] =} size (@var{q})
20 ## Return size of quaternion arrays.
21 ##
22 ## @strong{Inputs}
23 ## @table @var
24 ## @item q
25 ## Quaternion object.
26 ## @item dim
27 ## If given a second argument, @command{size} will return the size of the
28 ## corresponding dimension.
29 ## @end table
30 ##
31 ## @strong{Outputs}
32 ## @table @var
33 ## @item nvec
34 ## Row vector.  The first element is the number of rows and the second
35 ## element the number of columns.  If @var{q} is an n-dimensional array
36 ## of quaternions, the n-th element of @var{nvec} corresponds to the
37 ## size of the n-th dimension of @var{q}.
38 ## @item n
39 ## Scalar value.  The size of the dimension @var{dim}.
40 ## @item nx
41 ## Number of rows.
42 ## @item ny
43 ## Number of columns.
44 ## @item @dots{}
45 ## Sizes of the 3rd to n-th dimensions.
46 ## @end table
47 ## @end deftypefn
48
49 ## Author: Lukas Reichlin <lukas.reichlin@gmail.com>
50 ## Created: May 2010
51 ## Version: 0.2
52
53 function varargout = size (a, b)
54
55   switch (nargout)
56     case {0, 1}
57       switch (nargin)
58         case 1                          # nvec = size (q)
59           varargout{1} = size (a.w);
60         case 2                          # n = size (q, dim)
61           varargout{1} = size (a.w, b);
62         otherwise
63           print_usage ();
64       endswitch
65
66     otherwise
67       if (nargin == 1)                  # [nx, ny, ...] = size (q)
68         varargout = num2cell (size (a.w));
69       else
70         print_usage ();
71       endif
72   endswitch
73
74 endfunction