[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Odd behavior of time-domain convolutions
From: |
David Bateman |
Subject: |
Re: Odd behavior of time-domain convolutions |
Date: |
Wed, 05 Sep 2007 17:34:33 +0200 |
User-agent: |
Thunderbird 1.5.0.7 (X11/20060921) |
Fredrik Lingvall wrote:
>
> The time-domain convolution algorithm look like this:
>
> for(i=0; i<nx; i++) {
> for(j=0; j<ny; j++) {
> zr[i+j] += xr[i] * yr[j];
> }
> }
>
Does the Octave version really look like the above or rather something like
const NDArray xr, yr;
NDArray zr;
for(i=0; i<nx; i++) {
for(j=0; j<ny; j++) {
zr(i+j) += xr(i) * yr(j);
}
}
If so then the operator () on Array<T> objects in octave does bounds
checking, etc. You should use the fortran_vec method to get "double *"
or "Complex *" pointers to the arrays something like
const NDArray xr, yr;
const double *pxr = xr.fortran_vec ();
const double *pyr = yr.fortran_vec ();
NDArray zr;
double *pzr = zr.fortran_vec ();
for(i=0; i<nx; i++) {
for(j=0; j<ny; j++) {
pzr[i+j] += pxr[i] * pyr[j];
}
}
Note that xr and yr are defined as "const" to avoid a copy being made
with the fortran_vec method.
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