From octave-sources-request at bevo dot che dot wisc dot edu Mon Oct 2 11:47:53 2000 Subject: function : outer product From: Antoine Mathys To: octave-sources at bevo dot che dot wisc dot edu Date: Mon, 02 Oct 2000 18:47:15 +0200 This is a multi-part message in MIME format. --Boundary_(ID_bCbBiAgdG6b1/EpwaUkQlg) Content-type: MULTIPART/ALTERNATIVE; BOUNDARY="Boundary_(ID_7ntOIv9d5WncZqQy8uvg9w)" --Boundary_(ID_7ntOIv9d5WncZqQy8uvg9w) Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit Hello, Here is an outer function, as described in octave's project file. outer(x,y,f) returns a matrix with f(x(i),y(j)) as elements. -- -------------------------------------------------- Antoine Mathys / e-mail : mathyant at student dot ethz dot ch URL : http://n.ethz.ch/student/mathyant/ -------------------------------------------------- --Boundary_(ID_7ntOIv9d5WncZqQy8uvg9w) Content-type: text/html; charset=us-ascii Content-transfer-encoding: 7bit Hello,

Here is an outer function, as described in octave's project file.
outer(x,y,f) returns a matrix with f(x(i),y(j)) as elements.
 
 

-- 
--------------------------------------------------
Antoine Mathys / e-mail : mathyant at student dot ethz dot ch
URL : http://n.ethz.ch/student/mathyant/
--------------------------------------------------
  --Boundary_(ID_7ntOIv9d5WncZqQy8uvg9w)-- --Boundary_(ID_bCbBiAgdG6b1/EpwaUkQlg) Content-type: text/plain; name=outer.m; charset=us-ascii Content-disposition: inline; filename=outer.m Content-transfer-encoding: 7bit ## Copyright (C) 2000 Antoine Mathys ## ## 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, 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. ## -*- texinfo -*- ## at deftypefn {Function File} {@var{a} =} outer (@var{x}, @var{y}, [@var{f}]) ## Given two vectors of length at var{m} and @var{n}, return a ## at var{m}-by-@var{n} matrix with entries @var{f (x(i), y(j))}. ## ## If at var{f} is omitted, multiplication is the default. ## at end deftypefn ## Author: Antoine Mathys ## Created: 2 October 2000 ## Adapted-By: Antoine Mathys function retval = outer (x, y, f) if (nargin < 2 || nargin > 3) usage ("outer (x, y, [f])"); endif if (!is_vector(x) || !is_vector(y)) error ("outer: both x and y must be vectors"); endif m = length (x); n = length (y); retval = zeros (m, n); for i=1:m for j=1:n if (nargin == 2) retval(i,j) = x(i) * y(j); else retval(i,j) = eval(sprintf("%s (x(i), y(j));",f)); endif endfor endfor endfunction --Boundary_(ID_bCbBiAgdG6b1/EpwaUkQlg)-- ----------------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.che.wisc.edu/octave/octave.html How to fund new projects: http://www.che.wisc.edu/octave/funding.html Subscription information: http://www.che.wisc.edu/octave/archive.html -----------------------------------------------------------------------