473,657 Members | 2,535 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

expression template and FFT

Hi,

Expression template can be used for the implementation of simple
operators without using temporaries (e.g. the ones in the book C++
Template).

I'm wondering whether expression template is useful for the
convolution operation.

For example, I have two arrays a1 and a2. To compute the convolution
between them I need to compute the FFT of both of them, which shall be
stored in two temporary arrays. These arrays then shall be multiplied
and FFT back, which also need a temporary arrays. There are totally
three temporary arrays.

It seems that expression template would not reduce the number of
temporary arrays. Are there any better way to reduce the temporaries?

Thanks,
Peng
Oct 20 '08 #1
12 2515
On Oct 19, 7:49*pm, Peng Yu <PengYu...@gmai l.comwrote:
Hi,

Expression template can be used for the implementation of simple
operators without using temporaries (e.g. the ones in the book C++
Template).

I'm wondering whether expression template is useful for the
convolution operation.

For example, I have two arrays a1 and a2. To compute the convolution
between them I need to compute the FFT of both of them, which shall be
stored in two temporary arrays. These arrays then shall be multiplied
and FFT back, which also need a temporary arrays. There are totally
three temporary arrays.

It seems that expression template would not reduce the number of
temporary arrays. Are there any better way to reduce the temporaries?

Thanks,
Peng
If you want to reduce temporaries, try to read Alexandrescu's mojo
code. Expression templates are too advanced for what you need to do,
so it may not pay the time in coding it. Hope it helps,

aa
Oct 20 '08 #2
On 20 Okt., 05:53, aaragon <alejandro.ara. ..@gmail.comwro te:
>
If you want to reduce temporaries, try to read Alexandrescu's mojo
code. Expression templates are too advanced for what you need to do,
so it may not pay the time in coding it. Hope it helps,

aa
Hm, I didn't know the term "mojo". Just search-machined for it and
found:
- http://www.ddj.com/database/184403855
I'll have a look into this. Thanks for hint.

-- Maik
Oct 20 '08 #3
On Oct 20, 5:01*am, Maik <Beckmann.M...@ googlemail.comw rote:
On 20 Okt., 05:53, aaragon <alejandro.ara. ..@gmail.comwro te:
If you want to reduce temporaries, try to read Alexandrescu's mojo
code. Expression templates are too advanced for what you need to do,
so it may not pay the time in coding it. Hope it helps,
aa

Hm, I didn't know the term "mojo". *Just search-machined for it and
found:
*-http://www.ddj.com/database/184403855
I'll have a look into this. Thanks for hint.

-- Maik
That is very easy to implement after you understand how it works. Good
luck,

aa
Oct 20 '08 #4
SG
On 20 Okt., 02:49, Peng Yu <PengYu...@gmai l.comwrote:
I'm wondering whether expression template is useful for the
convolution operation.
Calculating the FFT and inverse FFT can be done in-place. No
temporaries needed. If you want to keep the original signals 'a1' and
'a2' you can do it with TWO temporaries:

<pseudo code>
t1 = a1; fft(t1); // copy 'a1' to 't1' and do an FFT on it
t2 = a2; fft(t2); // copy 'a2' to 't2' and do an FFT on it
t1 *= t2; // element-wise complex product
ifft(t1); // t1 will contains the (circular-)convolution result
</pseudo code>

I don't think that expression templates can help here.

Cheers,
SG
Oct 20 '08 #5
On Oct 20, 2:11 pm, aaragon <alejandro.ara. ..@gmail.comwro te:
On Oct 20, 5:01 am, Maik <Beckmann.M...@ googlemail.comw rote:
On 20 Okt., 05:53, aaragon <alejandro.ara. ..@gmail.comwro te:
If you want to reduce temporaries, try to read Alexandrescu's mojo
code. Expression templates are too advanced for what you need to do,
so it may not pay the time in coding it. Hope it helps,
aa
Hm, I didn't know the term "mojo". Just search-machined for it and
found:
-http://www.ddj.com/database/184403855
I'll have a look into this. Thanks for hint.
-- Maik

That is very easy to implement after you understand how it works. Good
luck,
Hi,

It is too long to read the webpage. Can somebody explain in a brief
way what the main point is and what the major steps to use mojo?

Thanks,
Peng
Oct 21 '08 #6
Peng Yu wrote:
On Oct 20, 2:11 pm, aaragon <alejandro.ara. ..@gmail.comwro te:
>On Oct 20, 5:01 am, Maik <Beckmann.M...@ googlemail.comw rote:
[...]
>> -http://www.ddj.com/database/184403855
I'll have a look into this. Thanks for hint.
-- Maik
That is very easy to implement after you understand how it works. Good
luck,

Hi,

It is too long to read the webpage. Can somebody explain in a brief
way what the main point is and what the major steps to use mojo?
It's main point is to avoid unnecessary copying. It does so by
"stealing" the data from temporary objects instead. This is what
rvalue references will be in C++0x.
If you want to use it to write fast code, you won't get around
reading and understanding it.
Thanks,
Peng
Schobi
Oct 21 '08 #7
On Oct 21, 3:33 am, Hendrik Schober <spamt...@gmx.d ewrote:
Peng Yu wrote:
On Oct 20, 2:11 pm, aaragon <alejandro.ara. ..@gmail.comwro te:
On Oct 20, 5:01 am, Maik <Beckmann.M...@ googlemail.comw rote:
[...]
> -http://www.ddj.com/database/184403855
I'll have a look into this. Thanks for hint.
-- Maik
That is very easy to implement after you understand how it works. Good
luck,
Hi,
It is too long to read the webpage. Can somebody explain in a brief
way what the main point is and what the major steps to usemojo?

It's main point is to avoid unnecessary copying. It does so by
"stealing" the data from temporary objects instead. This is what
rvalue references will be in C++0x.
If you want to use it to write fast code, you won't get around
reading and understanding it.
So it is still quite useful even after 5 years since it was written,
and no other technique beats it right now? Is it a widely used and
necessary technique today?

Thanks,
Peng
Oct 21 '08 #8
Peng Yu wrote:
On Oct 21, 3:33 am, Hendrik Schober <spamt...@gmx.d ewrote:
>Peng Yu wrote:
>>On Oct 20, 2:11 pm, aaragon <alejandro.ara. ..@gmail.comwro te:
On Oct 20, 5:01 am, Maik <Beckmann.M...@ googlemail.comw rote:
[...]
-http://www.ddj.com/database/184403855
I'll have a look into this. Thanks for hint.
-- Maik
That is very easy to implement after you understand how it works. Good
luck,
Hi,
It is too long to read the webpage. Can somebody explain in a brief
way what the main point is and what the major steps to usemojo?
It's main point is to avoid unnecessary copying. It does so by
"stealing" the data from temporary objects instead. This is what
rvalue references will be in C++0x.
If you want to use it to write fast code, you won't get around
reading and understanding it.

So it is still quite useful even after 5 years since it was written,
and no other technique beats it right now? Is it a widely used and
necessary technique today?
From what I read, rvalue references seem to be better, but
until you get your hands on a compiler that has them, Andrei's
code and ideas are most likely the best you can get.
Peng
Schobi
Oct 21 '08 #9
On Oct 21, 11:28 am, Hendrik Schober <spamt...@gmx.d ewrote:
Peng Yu wrote:
On Oct 21, 3:33 am, Hendrik Schober <spamt...@gmx.d ewrote:
Peng Yu wrote:
On Oct 20, 2:11 pm, aaragon <alejandro.ara. ..@gmail.comwro te:
On Oct 20, 5:01 am, Maik <Beckmann.M...@ googlemail.comw rote:
[...]
-http://www.ddj.com/database/184403855
I'll have a look into this. Thanks for hint.
-- Maik
That is very easy to implement after you understand how it works. Good
luck,
Hi,
It is too long to read the webpage. Can somebody explain in a brief
way what the main point is and what the major steps to usemojo?
It's main point is to avoid unnecessary copying. It does so by
"stealing" the data from temporary objects instead. This is what
rvalue references will be in C++0x.
If you want to use it to write fast code, you won't get around
reading and understanding it.
So it is still quite useful even after 5 years since it was written,
and no other technique beats it right now? Is it a widely used and
necessary technique today?

From what I read, rvalue references seem to be better, but
until you get your hands on a compiler that has them, Andrei's
code and ideas are most likely the best you can get.
I see a proposal to add rvalue reference in the standard. Is it in the
standard now? Is there any compiler that supports it?

Thanks,
Peng
Oct 21 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2022
by: Rex_chaos | last post by:
Hi all, As some book tells, I try the following example of expression template. template < typename LeftOpd, typename Op, typename RightOpd > struct LOP { LeftOpd lod; RightOpd rod;
3
11300
by: Peter Rohleder | last post by:
Hi, I'm using a style-sheet where I make use of the XPATH-"following-sibling"-expression. The part which makes problems looks similar to the following code: --------------------------- <xsl:for-each select="headdata/extension/person">
8
1441
by: bartek | last post by:
Hello, I've been toying around with expression templates recently while writing a simple static lexical analyser, hence I have some questions which keep bothering me... The expression objects are wrapped around following the 'curious base' pattern. E.g.
1
2361
by: PengYu.UT | last post by:
Hi, I read Klaus Kreft & Angelika Langer's C++ Expression Templates: An Introduction to the Principles of Expression Templates at http://www.angelikalanger.com/Articles/Cuj/ExpressionTemplates/ExpressionTemplates.htm It provide an express template for only one argument (see Listing 19 and so on), which can be used to do numerical integral. I'm wondering how to generalize it to handle multiple arguments.
11
3098
by: Steve | last post by:
Hi All, I'm having a tough time converting the following regex.compile patterns into the new re.compile format. There is also a differences in the regsub.sub() vs. re.sub() Could anyone lend a hand? import regsub
28
16384
by: Marc Gravell | last post by:
In Linq, you can apparently get a meaningful body from and expression's .ToString(); random question - does anybody know if linq also includes a parser? It just seemed it might be a handy way to write a safe but easy implementation (i.e. no codedom) for an IBindingListView.Filter (by compiling to a Predicate<T>). Anybody know if this is possible at all? Marc
6
5316
by: Lawrence Spector | last post by:
I ran into a problem using g++. Visual Studio 2005 never complained about this, but with g++ I ran into this error. I can't figure out if I've done something wrong or if this is a compiler bug. Here's a very simple example which should illustrate what I'm doing. #include <iostream> template <class T> class TestBase {
3
4759
by: Dan Smithers | last post by:
What constitutes a constant-expression? I know that it is something that can be determined at compile time. I am trying to use template code and keep getting compiler errors "error: cannot appear in a constant-expression" template <int s> class CFoo { private:
2
2441
by: madhu.srikkanth | last post by:
Hi, I came across a paper by Angelika Langer in C++ Users Journal on Expression Templates. In the article she had mentioned that the code snippet below used to calculate a dot product is an expression template. template <size_t N, class T> class DotProduct {
0
8413
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8513
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7352
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2742
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.