[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C++ using Octave headers, mkoctfile
From: |
Francesco Potorti` |
Subject: |
Re: C++ using Octave headers, mkoctfile |
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: address@hidden
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
-------------------------------------------------------------