help-octave
[Top][All Lists]
Advanced

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

Re: algorithm efficiency (memory allocation issue?) APL like.


From: Jonathan C. Webster
Subject: Re: algorithm efficiency (memory allocation issue?) APL like.
Date: Wed, 27 Jun 2001 11:53:45 -0400

Aaron Brick wrote:

> hello all,
>
> i wrote a simple routine to reproduce a vector many times (i couldn't find
> any built-in method of copying and aggregating whole vectors - let me know,
> please, if i missed it).

Hi,
Like the APL  operator that insired it, this routine DOES NOT  that the
dimensions of the
input and output arrays be related.

Feel free,
Jonathan

_______________________
function [arout,ver] =  rho( arin,ny,nx)
%  function arout =  rho( arin,ny,nx)
%  inslpired in name and function by the APL operator of the same name
%  does NOT use Fortran indexing: fills rows first

%author: JCWebster
%cdate: 4/27/2000
%purpose: utility routine like the APL operator 'rho'
%modified: 6/15/2000 to add revision number
ver = ["RHO","1.2"];

[nyi,nxi]= size(arin);
if (nyi >= 1)
 arin = reshape (arin,1,(nyi*nxi));
endif

nnTot = ny * nx ; % total number of elemenents in output
arout = zeros(1,nnTot);
lengIn = length( arin); % length of input
ii = 0; % counter in input arg
for iii = 1:nnTot
ii++;
arout(1,iii) = arin(1,ii);
if(ii>=lengIn)
ii=0;
end
end

arout = reshape(arout, nx,ny)';



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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