473,408 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

DFT routine

I developed a DFT routine using a language named "ATP Model Language".
It is based on FORTRAN and specific to electromagnetic transients
simulations, a study field in electrical engineering. Few months ago,
I cought up on C++ readings and, nowadays, fell very bad to retarn to
"FORTRAN". My Discret Fourier Trasmoration Routine (DFT) is used to
filtering data from electrical system by digital relays. Could you
help me with some tips to develop a routine like this one using C++
OOP? Or maybe help me to translate a "function-oriented" (Fortran) in
C++?

Thanks,

Roberto Dias
Jul 22 '05 #1
8 3678
Roberto Dias wrote:
I developed a DFT routine using a language named "ATP Model Language".
It is based on FORTRAN and specific to electromagnetic transients
simulations, a study field in electrical engineering. Few months ago,
I cought up on C++ readings and, nowadays, fell very bad to retarn to
"FORTRAN". My Discret Fourier Trasmoration Routine (DFT)
Ah, that's better. In my industry, DFT means "design for test."
is used to
filtering data from electrical system by digital relays. Could you
help me with some tips to develop a routine like this one using C++
OOP?
Like which one? The one you developed in Fortran? What specific
functionality do you want?
Or maybe help me to translate a "function-oriented" (Fortran) in
C++?


You can use a "function-oriented" approach in C++, too. You can use
classes if you feel it's appropriate, but you certainly don't have to do
so. In fact, you generally can call your Fortran routines directly from
C++ code. Here's an example of a math library including discrete
Fourier transforms that's callable from C, C++, and Fortran:

http://webdocs.caspur.it/ibm/web/pes...1.html#HDRXSOA

If you just want a DFT library written in C++, try Googling for a while.
Jul 22 '05 #2
Roberto Dias wrote:
I developed a DFT routine using a language named "ATP Model Language".
It is based on FORTRAN and specific to electromagnetic transients
simulations, a study field in electrical engineering. Few months ago,
I cought up on C++ readings and, nowadays, fell very bad to retarn to
"FORTRAN". My Discret Fourier Trasmoration Routine (DFT) is used to
filtering data from electrical system by digital relays. Could you
help me with some tips to develop a routine like this one using C++
OOP? Or maybe help me to translate a "function-oriented" (Fortran) in
C++?

Thanks,

Roberto Dias


There are several methods to go about your project:
1. Use somebody else's software.
2. Use existing libraries and just write "glue-ware".
3. Write your own from scratch.

The first two require the use of a web search engine,
which is off-topic to this newsgroup. For example,
one might use the keywords "Discrete Fourier Transformation
Filter C++ Library" (make sure the spelling is correct).
You could reorder the terms in order of importance:
"Fourier Transformation Descrete C++ Library".
Writing your own
----------------
From lurking in this newsgroup and after reading the
FAQ and Welcome.Txt, you know that the best method
is to start out small and work up.

We all know that a good starting point is with a simple
program:
#include <iostream>
#include <cstdlib>
using std::cout;
using std::endl;

int main(void)
{
cout << "It works!" << endl;
return EXIT_SUCCESS;
}
The Next Step: Input
---------------------
An FFT (Fast Fourier Transform) or a DFT requires data.
There are two routes here:
1. Place test data inside the program.
2. Input data from a file.
In the embedded systems arena, I would go with #1. Often
times, the platforms don't support files. However, in
this case we'll go with route 2.

So, add input capability to your main program. For simplicity,
just input the data and spit it back out.
#include <iostream>
#include <fstream>
#include <cstdlib>
using std::cerr;
using std::cout;
using std::endl;
using std::ifstream;

#define DATA_TYPE int // Change this to match your data type.

const char INPUT_FILENAME[] = "dft.data";

int main(void)
{
// Assume ASCII represented data i.e. "12" not 12.
ifstream inp(INPUT_FILENAME);

// Always check for errors after opening a file.
if (!inp)
{
cerr << "Error opening input file, "
<< INPUT_FILENAME
<< endl;
return EXIT_FAILURE;
}

DATA_TYPE value;

// Input one value and spit it out:
if (inp >> value)
{
cout << "Value read: " << value << endl;
}
else
{
cerr << "Error reading input data." << endl;
return EXIT_FAILURE;
}

// Read all the values and spit them out:
while (inp >> value)
{
cout << value << endl;
}

// A proper program closes the file before exiting.
inp.close();

return EXIT_SUCCESS;
}
Next: Adding Computation
-------------------------
After the above program works, we know that we can
input data properly, which is very important.

The next step is to perform the computation. But
this requires some planning or design. Here are
some routes:
1. DFT wants all data at once.
2. DFT can handle one value at a time.
For route #2, we just add a function call inside
the input loop. For route #1, we append each value
to a vector, then after all values are read in, we
pass the vector to the DFT:
#include <vector>
//...
using std::vector;

#define DFT_RESULT_TYPE int // or whatever your's is.

// Create a function declaration.
DFT_RESULT_TYPE My_Dft(vector<DATA_TYPE>& dft_values);

//...
int main(void)
{
vector<DATA_TYPE> dft_values;
DFT_RESULT_TYPE result;

//...
while (inp >> value)
{
dft_values.push_back(value);
}

// Process the data.
result = My_Dft(dft_values);

// Output the result
cout << "DFT result: " << result << endl;

// ...
return EXIT_SUCCESS;
}
DFT_RESULT_TYPE My_Dft(vector<DATA_TYPE>& dft_values)
{
cout << "Processing " << dft_values.size()
<< " values" << endl;
return 12; // Some test value.
}
After the above modifications have been made and tested,
you now can go on and add details to the DFT routine.
Follow this method of writing simple test programs,
getting them to work, then building up.

Search the Web for "Test Driven Development".

Hope that helps.


--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Jul 22 '05 #3
why dont u use MATLAB.....U can use MATLAB's c++ interface to convert code
in MATLAB and get it in C++

"Roberto Dias" <di*****@br.inter.net> wrote in message
news:51**************************@posting.google.c om...
I developed a DFT routine using a language named "ATP Model Language".
It is based on FORTRAN and specific to electromagnetic transients
simulations, a study field in electrical engineering. Few months ago,
I cought up on C++ readings and, nowadays, fell very bad to retarn to
"FORTRAN". My Discret Fourier Trasmoration Routine (DFT) is used to
filtering data from electrical system by digital relays. Could you
help me with some tips to develop a routine like this one using C++
OOP? Or maybe help me to translate a "function-oriented" (Fortran) in
C++?

Thanks,

Roberto Dias

Jul 22 '05 #4
Jeff Schwab <je******@comcast.net> wrote in message news:<gc********************@comcast.com>...
Roberto Dias wrote:
I developed a DFT routine using a language named "ATP Model Language".
It is based on FORTRAN and specific to electromagnetic transients
simulations, a study field in electrical engineering. Few months ago,
I cought up on C++ readings and, nowadays, fell very bad to retarn to
"FORTRAN". My Discret Fourier Trasmoration Routine (DFT)
Ah, that's better. In my industry, DFT means "design for test."
is used to
filtering data from electrical system by digital relays. Could you
help me with some tips to develop a routine like this one using C++
OOP?


Like which one? The one you developed in Fortran? What specific
functionality do you want?

When you use DFT filtering, you are interested in convert cosinoidal
measured values into phasor (Module, Angle) that belongs to the
frequency domain, I mean, handle complex values is essencial. Yes I
partialy-developed using FORTRAN, but I indentified that if a OOP
approach will be used, re-using advantage could compress my source
file.
Or maybe help me to translate a "function-oriented" (Fortran) in
C++?


You can use a "function-oriented" approach in C++, too. You can use
classes if you feel it's appropriate, but you certainly don't have to do
so. In fact, you generally can call your Fortran routines directly from
C++ code. Here's an example of a math library including discrete
Fourier transforms that's callable from C, C++, and Fortran:

http://webdocs.caspur.it/ibm/web/pes...1.html#HDRXSOA

If you just want a DFT library written in C++, try Googling for a while.

Thank you very much. I didn't realized this. Call FORTRAN like
subroutines... What good ideia.
Jul 22 '05 #5
Roberto Dias wrote:
Jeff Schwab <je******@comcast.net> wrote in message news:<gc********************@comcast.com>...
Roberto Dias wrote:
I developed a DFT routine using a language named "ATP Model Language".
It is based on FORTRAN and specific to electromagnetic transients
simulations, a study field in electrical engineering. Few months ago,
I cought up on C++ readings and, nowadays, fell very bad to retarn to
"FORTRAN". My Discret Fourier Trasmoration Routine (DFT)
Ah, that's better. In my industry, DFT means "design for test."

is used to
filtering data from electrical system by digital relays. Could you
help me with some tips to develop a routine like this one using C++
OOP?


Like which one? The one you developed in Fortran? What specific
functionality do you want?


When you use DFT filtering, you are interested in convert cosinoidal


Sinusoidal?
measured values into phasor (Module, Angle) that belongs to the
frequency domain, I mean, handle complex values is essencial.
Essential?

I know what Fourier transforms are. Thank you.
Yes I
partialy-developed using FORTRAN, but I indentified that if a OOP
approach will be used, re-using advantage could compress my source
file.
Or maybe help me to translate a "function-oriented" (Fortran) in
C++?


You can use a "function-oriented" approach in C++, too. You can use
classes if you feel it's appropriate, but you certainly don't have to do
so. In fact, you generally can call your Fortran routines directly from
C++ code. Here's an example of a math library including discrete
Fourier transforms that's callable from C, C++, and Fortran:

http://webdocs.caspur.it/ibm/web/pes...1.html#HDRXSOA

If you just want a DFT library written in C++, try Googling for a while.


Thank you very much. I didn't realized this. Call FORTRAN like
subroutines... What good ideia.


Idea?

Good luck.
Jul 22 '05 #6
Roberto Dias wrote:

[snip]

Take a look at
The C++ Scalar, Vector, Matrix and Tensor class Library

http://www.netwood.net/~edwin/svmtl/

and
The Object Oriented Numerics Page

http://www.oonumerics.org/oon/
Jul 22 '05 #7
Jeff Schwab <je******@comcast.net> wrote in message news:<3Y********************@comcast.com>...
Roberto Dias wrote:
Jeff Schwab <je******@comcast.net> wrote in message news:<gc********************@comcast.com>...
Roberto Dias wrote:

I developed a DFT routine using a language named "ATP Model Language".
It is based on FORTRAN and specific to electromagnetic transients
simulations, a study field in electrical engineering. Few months ago,
I cought up on C++ readings and, nowadays, fell very bad to retarn to
"FORTRAN". My Discret Fourier Trasmoration Routine (DFT)

Ah, that's better. In my industry, DFT means "design for test."
is used to
filtering data from electrical system by digital relays. Could you
help me with some tips to develop a routine like this one using C++
OOP?

Like which one? The one you developed in Fortran? What specific
functionality do you want?
When you use DFT filtering, you are interested in convert cosinoidal


Sinusoidal?

No, cosinoidal, Jeff. Because to be cosinoidal or sinusoidal depends
on the reference adopted. I choose this one. There is no incorrect
term used here.
measured values into phasor (Module, Angle) that belongs to the
frequency domain, I mean, handle complex values is essencial.
Essential?

Thanks. This one was a "essential" comment ! He, he. I'm joking.
I know what Fourier transforms are. Thank you. I'm sure about this. I did a non-essential comment. Sorry.
Yes I
partialy-developed using FORTRAN, but I indentified that if a OOP
approach will be used, re-using advantage could compress my source
file.
Or maybe help me to translate a "function-oriented" (Fortran) in
C++?

You can use a "function-oriented" approach in C++, too. You can use
classes if you feel it's appropriate, but you certainly don't have to do
so. In fact, you generally can call your Fortran routines directly from
C++ code. Here's an example of a math library including discrete
Fourier transforms that's callable from C, C++, and Fortran:

http://webdocs.caspur.it/ibm/web/pes...1.html#HDRXSOA

If you just want a DFT library written in C++, try Googling for a while.
Thank you very much. I didn't realized this. Call FORTRAN like
subroutines... What good ideia.


Idea?

Another essential comment.
Good luck.

Jeff, I'm sorry, but there was I misunderstand. When I answer you I
was not trying to put you in prove. But the way you used to respond
me, sounded so rude and impolite, like a Bush one.
Jul 22 '05 #8
Roberto Dias wrote:
Jeff Schwab <je******@comcast.net> wrote in message news:<3Y********************@comcast.com>...
Roberto Dias wrote:
Jeff Schwab <je******@comcast.net> wrote in message news:<gc********************@comcast.com>...
Roberto Dias wrote:
>I developed a DFT routine using a language named "ATP Model Language".
>It is based on FORTRAN and specific to electromagnetic transients
>simulations, a study field in electrical engineering. Few months ago,
>I cought up on C++ readings and, nowadays, fell very bad to retarn to
>"FORTRAN". My Discret Fourier Trasmoration Routine (DFT)

Ah, that's better. In my industry, DFT means "design for test."

>is used to
>filtering data from electrical system by digital relays. Could you
>help me with some tips to develop a routine like this one using C++
>OOP?

Like which one? The one you developed in Fortran? What specific
functionality do you want?

When you use DFT filtering, you are interested in convert cosinoidal


Sinusoidal?


No, cosinoidal, Jeff. Because to be cosinoidal or sinusoidal depends
on the reference adopted. I choose this one. There is no incorrect
term used here.

http://dictionary.reference.com/search?q=cosinoidal

The term "sinusoidal" doesn't imply "zero phase."
measured values into phasor (Module, Angle) that belongs to the
frequency domain, I mean, handle complex values is essencial.


Essential?


Thanks. This one was a "essential" comment ! He, he. I'm joking.


:)
I know what Fourier transforms are. Thank you.


I'm sure about this. I did a non-essential comment. Sorry.


No problem. I just prefer to keep the discussion here centered on C++,
rather than the context of particular problems; particularly when the
technical terms in use can be looked up elsewhere.
Yes I
partialy-developed using FORTRAN, but I indentified that if a OOP
approach will be used, re-using advantage could compress my source
file.
>Or maybe help me to translate a "function-oriented" (Fortran) in
>C++?

You can use a "function-oriented" approach in C++, too. You can use
classes if you feel it's appropriate, but you certainly don't have to do
so. In fact, you generally can call your Fortran routines directly from
C++ code. Here's an example of a math library including discrete
Fourier transforms that's callable from C, C++, and Fortran:

http://webdocs.caspur.it/ibm/web/pes...1.html#HDRXSOA

If you just want a DFT library written in C++, try Googling for a while.

Thank you very much. I didn't realized this. Call FORTRAN like
subroutines... What good ideia.


Idea?


Another essential comment.
Good luck.


Jeff, I'm sorry, but there was I misunderstand. When I answer you I
was not trying to put you in prove. But the way you used to respond
me, sounded so rude and impolite, like a Bush one.


:( Sorry. I know what you mean; I certainly didn't mean to come across
that way.
Jul 22 '05 #9

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

Similar topics

1
by: peteh | last post by:
Hi All; I'm having a problem running an external routine (C language) under DB2 8.2 (FP 9) on AIX 5.3. Since the code was mostly copied from the DB2 sample library, I'm pretty sure it's sound....
7
by: Morgan | last post by:
I have read much posts on the argument but no one clearly says if this operation is possible or not. Simply I have a routine which reads from a text file some integer arrays (1 or 2D). The...
7
by: active | last post by:
I have a VB6 app that is being converted to VB.NET. It contains a routine (large) that is sometimes called with a PictureBox and sometimes with a Printer. I think it was common in VB6 to use the...
1
by: everymn | last post by:
Hi, Supposedly the Alter Routine privilege can be granted at the level of a single routine but I haven't been able to get that to work. I've tried it a number of different ways like: GRANT...
7
by: Bob Darlington | last post by:
I'm using the following routine to call UpdateDiary() - below: Private Sub Form_BeforeUpdate(Cancel As Integer) On Error GoTo Form_BeforeUpdate_Error Call UpdateDiary(Me!TenantCounter,...
5
by: Railgunner | last post by:
I am looking for a routine that can evaluate boolean expressions like: IF/ELSE-IF (X1=X2 AND (Y=1 OR Z1=Z2)) IF/ELSE-IF (A$='Y' AND B=1) OR (C=1 AND D>E) etc. I can handle...
0
by: Independent | last post by:
Python programmers may find the application to decoding an encrypted map image format known as Memory Map to produce a standard PNG image file interesting. Someone obviously very well versed in...
0
by: james.duckworthy | last post by:
Python programmers may find the application to decoding an encrypted map image format known as Memory Map to produce a standard PNG image file interesting. Someone obviously very well versed in...
2
by: pvong | last post by:
I'm a newbie. I'm using VS2008 & VB.net I have a simple site and each page uses the same sub-routine. I copy and paste to each page and that's no big deal but that can get tiresome. I was...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.