Re: [BLACKBOX] LibVector question

From: [at]} <Robert>
Date: Wed, 25 Mar 2009 23:44:36 +0000

----boundary-LibPST-iamunique-125273909_-_-
Content-type: text/plain

Wojtek

I quick, partial reply, as it is late at night.

1. The published version of Lib is several years old, but use that if it is
later than what you have.

2. Why are there two functions Correlation & Convolution? Why indeed! Why is
grass green? It just is. Look, for example, at

http://en.wikipedia.org/wiki/Convolution
&
http://en.wikipedia.org/wiki/Cross-correlation

for their accepted definitions (I hope mine are the same!).
My definition of Correlation appears to be different (I use g(t-tau) rather than
g(t+tau)). However this difference is illusary; see for example:
http://en.wikipedia.org/wiki/Auto-correlation.

I do agree that it is easy to get one confused with the other, but that is not a
good idea!

3. By 'Filter' I assume you mean a 'digital' filter, or more precisely a
discrete time filter analysed in terms of its 'z' transform. I mention this
because the Filter SubSystem also provides some facilities for analysis of
continuous time filters, ie things analysed in terms of their Laplace or 's'
transform.

I also assume that you want to implement a 'Finite Impulse Response' digital
filter (one whose z transform is a polynomial) not an 'Infinite Impulse
Response' filter (one whose z transform is a rational function).

In this case (ie a FIR) the answer is simple.

In 'x' is a vector describing the input sequence and 'h' is the filters time
domain 'Impulse Response', ie its 'coefficients, then we get the output sequence
'y' by

y := LibVectors.Conv (x, h);

Or use LibCVectors.Conv if you are using Complex data.


The Function FilterDFTs.Conv does the same thing as LibCVectors.Conv, but it is
much 'faster' as it uses FFTs behind the scenes. But take 'faster' with a pinch
of salt. It is certainly true if x and h are both long, and both of comparable
size, but for your modest and disparate sizes there may not be much advantage
unless you start adopting more complex 'overlap-and-add' or 'overlap-and-save'
processing schemes. You possibly are not in enough of a hurry to justify the
complexity.


Regards

Robert




Wojtek Skulski wrote:
> Robert:
>
> after a break I am back to using Lib for a small but important
> project. I need to apply custom digital filters to waveform digitizer
> data. I prefer not to use Filters because Filters look like overkill. I
> thought of coding from scratch, but before I started
> I fortunately looked at LibVectors. Both the convolution and the
> correlation are there, so I can use LibVectors and on that occasion
> brush up my knowledge concerning LibPlotters etc.
>
> Before I start, I have a couple silly questions.
>
> 1. Is it advisable to upgrade Lib now to the new revision?
> The one I have on disk is a few years old.
>
> 2. Which function would you advise to digitally filter a waveform
> with a filter? (Waveform has 1k samples, the filter has about
> 40 coefficients.)
>
> res := Corr (waveform, filter);
> res := Conv (waveform, filter);
>
> Why are there two functions anyway? The math seems almost the same
> except for indexing. What is the reason for the two indexing schemes?
>
> Thank you,
>
> Wojtek
>
>
> ------------------------------------------------------------------------
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 8.5.278 / Virus Database: 270.11.28/2022 - Release Date: 03/25/09 07:16:00
>


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-125273909_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZjaGFyc2V0MCBDb3VyaWVyIE5ldzt9fQ0Ke1xj
b2xvcnRibFxyZWQwXGdyZWVuMFxibHVlMDtccmVkMFxncmVlbjBcYmx1ZTI1NTt9DQpcdWMxXHBh
cmRccGxhaW5cZGVmdGFiMzYwIFxmMFxmczIwIFdvanRla1xwYXINClxwYXINCkkgcXVpY2ssIHBh
cnRpYWwgcmVwbHksIGFzIGl0IGlzIGxhdGUgYXQgbmlnaHQuXHBhcg0KXHBhcg0KMS4gVGhlIHB1
Ymxpc2hlZCB2ZXJzaW9uIG9mIExpYiBpcyBzZXZlcmFsIHllYXJzIG9sZCwgYnV0IHVzZSB0aGF0
IGlmIGl0IGlzIFxwYXINCmxhdGVyIHRoYW4gd2hhdCB5b3UgaGF2ZS5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Bhcg0KPiAg
ICByZXMgOj0gQ29udiAod2F2ZWZvcm0sIGZpbHRlcik7XHBhcg0KPiBccGFyDQo+IFdoeSBhcmUg
dGhlcmUgdHdvIGZ1bmN0aW9ucyBhbnl3YXk/IFRoZSBtYXRoIHNlZW1zIGFsbW9zdCB0aGUgc2Ft
ZVxwYXINCj4gZXhjZXB0IGZvciBpbmRleGluZy4gV2hhdCBpcyB0aGUgcmVhc29uIGZvciB0aGUg
dHdvIGluZGV4aW5nIHNjaGVtZXM/XHBhcg0KPiBccGFyDQo+IFRoYW5rIHlvdSxccGFyDQo+IFxw
YXINCj4gV29qdGVrXHBhcg0KPiBccGFyDQo+IFxwYXINCj4gLS0tLS0tLS0tLS0tLS0tLS0tLS0t
LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tXHBhcg0K
PiBccGFyDQo+IFxwYXINCj4gTm8gdmlydXMgZm91bmQgaW4gdGhpcyBpbmNvbWluZyBtZXNzYWdl
LlxwYXINCj4gQ2hlY2tlZCBieSBBVkcgLSB3d3cuYXZnLmNvbSBccGFyDQo+IFZlcnNpb246IDgu
NS4yNzggLyBWaXJ1cyBEYXRhYmFzZTogMjcwLjExLjI4LzIwMjIgLSBSZWxlYXNlIERhdGU6IDAz
LzI1LzA5IDA3OjE2OjAwXHBhcg0KPiBccGFyDQpccGFyDQpccGFyDQotLS0tXHBhcg0KVG8gdW5z
dWJzY3JpYmUsIHNlbmQgYSBtZXNzYWdlIHdpdGggYm9keSAiU0lHTk9GRiBCTEFDS0JPWCIgdG8g
TElTVFNFUlZATElTVFMuT0JFUk9OLkNIXHBhcg0KfQ==
----boundary-LibPST-iamunique-125273909_-_---
Received on Thu Mar 26 2009 - 00:44:36 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:30:48 UTC