Skip to content Skip to navigation

Connexions

You are here: Home » Content » Complex Fourier Series Data Analysis Using C++ and x86 Inline Assembler

Navigation

Recently Viewed

This feature requires Javascript to be enabled.
 

Complex Fourier Series Data Analysis Using C++ and x86 Inline Assembler

Module by: Marc Balke. E-mail the author

Summary: Complex Fourier Series Written in 80x86 Asembler Using x86 FPU commands, no error checking, utilized in a Visual C++ 2005 function wrapper.

This Function is a small part of a larger data analysis program utilizing Visual C# and Visual C++ to analyze Stock Markets, Stocks, Funds, Options and US Federal Reserve Data. Stock Market, Individual Stocks, Options, Mutual Fund Data or Federal Reserve Economic Data can be analyzed. Input to the function is a double precision (IEEE 754 stanard) vector, containing of one of the data streams from a given series ( Market, Stock, Option, Mutual Fund, FRED ). The start and end pointers into the input vector are required, along with the sample frequency ( Minimum 2x the number of data points supplied ). Output consists of 3 vectors -- Frequency, Amplitude and Phase Shift. By using the Complex Fourier Function, we are able to break down the input data into a Constant ( DC ) component, and variable Frequency, Amplitude and Phase Shift components. Amplitude results of 0 are of no significance. When reconstructed, the data stream should contain future values for the given input data. The idea is to build a more accurate time series forcasting model.

FOURIERDEV_API void DFT64(double* , double* , double* , double* , int ); FOURIERDEV_API void DFT32(float* , float* , float* , float* , int ); FOURIERDEV_API void DFT64(double* dxx, double* cxx, double* th, double* fr, int cnt) { double dxe, cxe, theta, freq, rad, pi2, dne, dnx, cv, cvc; int i, j, n; n = cnt; rad = 360.0; __asm { ; finit; ; fldpi; fldpi; fadd; fstp pi2; ; fld rad; fdiv pi2; fstp rad; ; fld pi2; fchs; fidiv n; fstp pi2; ; mov i,0; ; Loop1: ; ; fild i; fmul pi2; fstp dnx; ; } dxe = *(dxx + i); __asm { ; fldz; fstp cv; ; mov j,0; ; Loop2: ; ; fild j; fmul dnx; fstp dne; ; } cxe = exp(dne); __asm { ; fld cxe; fmul dxe; fadd cv; fstp cv; ; inc j; mov eax,j; cmp eax,n; jl Loop2; ; fld cv; fcos; fmul cv; fdiv cv; fstp cvc; ; } theta = acos(cvc); __asm { ; fld theta; fmul rad; fstp theta; ; fild i; fstp freq; ; } *(cxx + i) = cv; *(th + i) = theta; *(fr + i) = freq; __asm { ; inc i; mov eax,i; cmp eax,n; jl Loop1; ; } } FOURIERDEV_API void DFT32(float* dxx, float* cxx, float* th, float* fr, int cnt) { float dxe, cxe, theta, freq, rad, pi2, dne, dnx, cv, cvc; int i, j, n; n = cnt; rad = 360.0; __asm { ; finit; ; fldpi; fldpi; fadd; fstp pi2; ; fld rad; fdiv pi2; fstp rad; ; fld pi2; fchs; fidiv n; fstp pi2; ; mov i,0; ; Loop1: ; ; fild i; fmul pi2; fstp dnx; ; } dxe = *(dxx + i); __asm { ; fldz; fstp cv; ; mov j,0; ; Loop2: ; ; fild j; fmul dnx; fstp dne; ; } cxe = exp(dne); __asm { ; fld cxe; fmul dxe; fadd cv; fstp cv; ; inc j; mov eax,j; cmp eax,n; jl Loop2; ; fld cv; fcos; fmul cv; fdiv cv; fstp cvc; ; } theta = acos(cvc); __asm { ; fld theta; fmul rad; fstp theta; ; fild i; fstp freq; ; } *(cxx + i) = cv; *(th + i) = theta; *(fr + i) = freq; __asm { ; inc i; mov eax,i; cmp eax,n; jl Loop1; ; } }

Content actions

Download module as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Add module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks