~ubuntu-branches/ubuntu/wily/octave-miscellaneous/wily

« back to all changes in this revision

Viewing changes to inst/zagzig.m

  • Committer: Package Import Robot
  • Author(s): Sébastien Villemot, Rafael Laboissiere, Sébastien Villemot
  • Date: 2012-10-17 13:40:55 UTC
  • mfrom: (1.2.1) (12 sid)
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: package-import@ubuntu.com-20121017134055-vatltexghy77fnv7
Tags: 1.2.0-1
[ Rafael Laboissiere ]
* Imported Upstream version 1.2.0
* Bump Standards-Version to 3.9.4 (no changes needed)
* Refresh for new upstream release
* Use Sébastien Villemot's @debian.org email address
* Remove obsolete DM-Upload-Allowed flag
* Add patch autoload-yes.patch
* Add copyright info for file lauchli.m (included in a Debian patch)
* Add patch partcnt-test-succeeds.patch
* Build-depends on octave-pkg-dev >= 1.0.3

[ Sébastien Villemot ]
* debian/control: fix versioned dependency on debhelper
* Add lintian override for false positive on hardening (fortify)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
## Copyright (C) 2006 Fredrik Bulow <fredrik.bulow@gmail.com>
2
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 2 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
 
##
 
3
## This program is free software; you can redistribute it and/or modify it under
 
4
## the terms of the GNU General Public License as published by the Free Software
 
5
## Foundation; either version 3 of the License, or (at your option) any later
 
6
## version.
 
7
##
 
8
## This program is distributed in the hope that it will be useful, but WITHOUT
 
9
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
10
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 
11
## details.
 
12
##
 
13
## You should have received a copy of the GNU General Public License along with
 
14
## this program; if not, see <http://www.gnu.org/licenses/>.
16
15
 
17
16
## -*- texinfo -*-
18
17
## @deftypefn {Function File} {} zagzig (@var{mtrx})
43
42
## @end deftypefn
44
43
## @seealso{zigzag}
45
44
 
46
 
## Author:   Fredrik Bulow <fredrik.bulow@gmail.com>
47
 
 
48
45
function rval = zagzig(mtrx)
49
46
 
50
47
  if nargin != 1 #Checking arguments.
51
 
    error('usage: zagzig(matrix); see help zagzig');
 
48
    print_usage;
52
49
  endif
53
50
 
54
51
  if issquare(mtrx) #Square matrix (quick case)
79
76
    for i = n(2)-1:-1:1-n(1)
80
77
      new = diag(mtrx,i);
81
78
      if floor(i/2)==i/2 ##Even?
82
 
        rval=[rval new((1+length(new))-(1:length(new)))'];
 
79
        rval=[rval new((1+length(new))-(1:length(new)))'];
83
80
      else                ##Odd!
84
 
        rval=[rval new'];
 
81
        rval=[rval new'];
85
82
      endif
86
83
    endfor
87
84
  endif
88
85
endfunction
89
 
%!
 
86
 
90
87
%!assert(zagzig(reshape(1:9,3,3)),[1 4 2 3 5 7 8 6 9])
91
 
%!