From help-request at octave dot org Fri Feb 18 11:37:46 2005 Subject: Re: C++ using Octave headers, mkoctfile From: Francesco Potorti` To: sct at ucsd dot edu CC: help at octave dot org Date: Fri, 18 Feb 2005 18:40:44 +0100 >I have learned how to generate random variables -- a big step. But I'm >currently stuck on building a complex matrix (or returning a complex >number). For example, what would the C++ code be to generate: > >n=[0:29]'; >W=zeros(30,30); >for k=1:30 > W(:,k)=exp(j*2*pi*k*n/30); >end Perhaps, before trying to produce C++ code, you should try to learn how to use Octave's vector abilities at their best. For example, the code you wrote can be vectorialised as: N=30; W=exp(j*2*pi*[0:N-1]'*[1:N]/N); and it runs faster. -- Francesco Potort́ (ricercatore) Voice: +39 050 315 3058 (op.2111) ISTI - Area della ricerca CNR Fax: +39 050 313 8091 via G. Moruzzi 1, I-56124 Pisa Email: Potorti at isti dot cnr dot it Web: http://fly.isti.cnr.it/ Key: fly.isti.cnr.it/public.key ------------------------------------------------------------- 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 -------------------------------------------------------------