91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 10KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2024-01-05
  • 語言: 其他
  • 標簽: FFT??MPI??

資源簡介

FFT算法的MPI實現源代碼,編程風格還行,易于理解

資源截圖

代碼片段和文件信息

#include?
#include?
#include?
#include?“mpi.h“

#define?MAX_N?50
#define?PI????3.1415926535897932
#define?EPS???10E-8
#define?V_TAG?99
#define?P_TAG?100
#define?Q_TAG?101
#define?R_TAG?102
#define?S_TAG?103
#define?S_TAG2?104

typedef?enum?{FALSE?TRUE}
BOOL;

typedef?struct
{
????double?r;
????double?i;
}?complex_t;

complex_t?p[MAX_N]?q[MAX_N]?s[2*MAX_N]?r[2*MAX_N];
complex_t?w[2*MAX_N];
int?variableNum;
double?transTime?=?0?totalTime?=?0?beginTime;
MPI_Status?status;

void?comp_add(complex_t*?result?const?complex_t*?c1?const?complex_t*?c2)
{
????result->r?=?c1->r?+?c2->r;
????result->i?=?c1->i?+?c2->i;
}


void?comp_multiply(complex_t*?result?const?complex_t*?c1?const?complex_t*?c2)
{
????result->r?=?c1->r?*?c2->r?-?c1->i?*?c2->i;
????result->i?=?c1->r?*?c2->i?+?c2->r?*?c1->i;
}


/*
?*?Function:????shuffle
?*?Description:?移動f中從beginPos到endPos位置的元素,使之按位置奇偶
?*??????????????重新排列。舉例說明:假設數組f,beginPos=2?endPos=5
?*??????????????則shuffle函數的運行結果為f[2..5]重新排列,排列后各個
?*??????????????位置對應的原f的元素為:?f[2]f[4]f[3]f[5]
?*?Parameters:??f為被操作數組首地址
?*??????????????beginPos?endPos為操作的下標范圍
?*/
void?shuffle(complex_t*?f?int?beginPos?int?endPos)
{
????int?i;
????complex_t?temp[2*MAX_N];

????for(i?=?beginPos;?i?<=?endPos;?i?++)
????{
????????temp[i]?=?f[i];
????}

????int?j?=?beginPos;
????for(i?=?beginPos;?i?<=?endPos;?i?+=2)
????{
????????f[j]?=?temp[i];
????????j++;
????}
????for(i?=?beginPos?+1;?i?<=?endPos;?i?+=?2)
????{
????????f[j]?=?temp[i];
????????j++;
????}
}


/*
?*?Function: evaluate
?*?Description: 對復數序列f進行FFT或者IFFT(由x決定),結果序列為y,
?*? 產生leftPos?到?rightPos之間的結果元素
?*?Parameters: f?:?原始序列數組首地址
?*? beginPos?:?原始序列在數組f中的第一個下標
?*? endPos?:?原始序列在數組f中的最后一個下標
?*? x?:?存放單位根的數組,其元素為ww^2w^3...
?*? y?:?輸出序列
?*? leftPos?:?所負責計算輸出的y的片斷的起始下標
?*? rightPos?:?所負責計算輸出的y的片斷的終止下標
?*? totalLength?:?y的長度
?*/
void?evaluate(complex_t*?f?int?beginPos?int?endPos
const?complex_t*?x?complex_t*?y
int?leftPos?int?rightPos?int?totalLength)
{
????int?i;
????if?((beginPos?>?endPos)||(leftPos?>?rightPos))
????{
????????printf(“Error?in?use?Polynomial!\n“);
????????exit(-1);
????}
????else?if(beginPos?==?endPos)
????{
????????for(i?=?leftPos;?i?<=?rightPos;?i?++)
????????{
????????????y[i]?=?f[beginPos];
????????}
????}
????else?if(beginPos?+?1?==?endPos)
????{
????????for(i?=?leftPos;?i?<=?rightPos;?i?++)
????????{
????????????complex_t?temp;
????????????comp_multiply(&temp?&f[endPos]?&x[i]);
????????????comp_add(&y[i]?&f[beginPos]?&temp);
????????}
????}
????else
????{
????????complex_t?tempX[2*MAX_N]tempY1[2*MAX_N]?tempY2[2*MAX_N];
????????int?midPos?=?(beginPos?+?endPos)/2;

????????shuffle(f?beginPos?endPos);

????????for(i?=?leftPos;?i?<=?rightPos;?i?++)
????????{
????????????comp_multiply(&tempX[i]?&x[i]?&x[i]);
????????}

????????evaluate(f?beginPos?midPos?tempX?tempY1
????????????leftPos?rightPos?totalLength);
????????evaluate(f?midPos+1?endPos?tempX?tempY2
????????????leftPos?rightPos?total

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件??????57350??2010-01-27?10:19??新建文件夾\data.txt

?????文件?????????24??2003-07-14?02:22??新建文件夾\dataIn.txt

?????文件??????21553??2010-01-27?10:22??新建文件夾\dataout.txt

?????文件??????10722??2003-07-14?03:19??新建文件夾\fft.c

?????文件????????471??2003-07-14?02:22??新建文件夾\readme.txt

?????目錄??????????0??2010-04-14?16:51??新建文件夾

-----------?---------??----------?-----??----

????????????????90120????????????????????6


評論

共有 條評論