octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: merging functions from octave-forge


From: David Bateman
Subject: Re: merging functions from octave-forge
Date: Fri, 19 May 2006 10:19:03 +0200
User-agent: Mozilla Thunderbird 1.0.6-7.6.20060mdk (X11/20050322)

John W. Eaton wrote:

>On 18-May-2006, David Bateman wrote:
>
>| Sorry, please find attached a fix for this and ported versions of mkpp, 
>| unmkpp, ppval, spline. Other files currently on my hit list are
>
>I checked in the new polynomial funtions.  The patch you sent still
>just had a few changes for setxor.m, but there is no
>scripts/set/setxor.m file in Octave yet, so I need the complete file.
>I'm not sure why you are able to generate a diff for it since there
>doesn't seem to be a file in the Octave CVS.  Or am I missing
>something?
>
>jwe
>
>  
>
Weird, I see now that the the file setxor.m.orig is not empty when it
should be.. Here is the complete file..

D.


-- 
David Bateman                                address@hidden
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary

## Copyright (C) 2000 Paul Kienzle
##
## 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 2, 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, write to the Free
## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
## 02110-1301, USA.

## -*- texinfo -*-
## @deftypefn {Function File} {} setxor(@var{a}, @var{b})
##
## Return the elements exclusive to @var{a} or @var{b}, sorted in ascending
## order. If @var{a} and @var{b} are both column vectors return a column
## vector, otherwise return a row vector.
##
## @seealso{unique, union, intersect, setdiff, ismember}
## @end deftypefn

function c = setxor(a,b)
  if nargin != 2
    usage("setxor(a,b)");
  endif

  ## form a and b into sets
  a = unique(a);
  b = unique(b);

  if isempty(a)
    c = b;
  elseif isempty(b)
    c = a;
  else
    ## reject duplicates
    c = sort([a(:) ; b(:)]);
    n = length(c);
    idx = find(c(1:n-1) == c(2:n));
    if !isempty(idx)
      c([idx, idx+1]) = [];
    endif
    if size(a,1) == 1 ||  size(b,1) == 1
      c = c.';
    endif
  endif
endfunction

%!assert(setxor([1,2,3],[2,3,4]),[1,4])

reply via email to

[Prev in Thread] Current Thread [Next in Thread]