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

資源簡介

Cholesky算法的MPI并行C語言實現 包含以下內容: (1)Cholesky的所用的正定矩陣的生成算法 (2)Cholesky的串行算法實現 (3)Cholesky的MPI并行算法實現 (4)完整的設計報告

資源截圖

代碼片段和文件信息

/*
?*?INFO
?*?File:?cholesky.c
?*?Date:?2015-10-21
?*?Author:?Team?of?Zhangguoqing
?*
?*?EXEC:
?*?Build:?mpicc?-o?cholesky?-lm?cholesky.c?
?*?Run:?mpiexec?-np?numprocess?./cholesky?matrix-order
?*?Note:?matrix-order?=?m?*?numprocess
?*?Verify:?http://www.yunsuanzi.com/matrixcomputations/solvecholeskyfactorization.html
?*
?*?*/

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


//Macro?Definition
#define?RANDMAX?10


void?initMatrix(double?*matrix?int?row?int?col)
{
int?i?j;
????for(i=0;?i for(j=0;?j???????? matrix[i*col+j]=0;
???? }
}
}


void?printMatrix(double?*matrix?int?row?int?col)
{
int?i?j;
????for(i=0;?i for(j=0;?j???????? printf(“%10.4f“?matrix[i*col+j]);
???? }
????????printf(“\n“);
}
}


void?printTriangleMatrix(double?*matrix?int?order)
{
int?i?j;
????for(i=0;?i for(j=0;?j<=i;?j++){
???????? printf(“%10.4f“?matrix[i*order+j]);
???? }
????????printf(“\n“);
????}
}


/*
?*?Function?Purpose:
?*?Generate?a?positive?random?(semi-)definite?matrices
?*?
?*?Method:
?*?Given?an?arbitrary?matrix?A?compute?M?=?AT?*?A
?*?AT?means?A‘s?transposition?(constructing?a?Cholesky?decomposition)
?*
?*?Reference:
?*?http://stackoverflow.com/questions/619335/a-simple-algorithm-for-generating-positive-semidefinite-matrices
?*
?*?*/
void?generate(double?*matrix?int?order)
{
int?i?j?k;
????double?*ori_matrix?=?(double*)malloc(sizeof(double)*order*order);
????double?*tra_matrix?=?(double*)malloc(sizeof(double)*order*order);

????//Generate?origin?matrix
????printf(“#####?Generate?%d*%d?semi-definite?matrix?#####\n“?order?order);
????srand(time(0));
????for(i=0;?i for(j=0;?j????????????ori_matrix[i*order+j]=(double)(rand()%RANDMAX)?+?1;
}
}
????printf(“\nRand?Arbitrary?Matrix:\n“);
????printMatrix(ori_matrix?order?order);

????//Transpose?ori_matrix?tra_matrix
????for(i=0;?i for(j=0;?j????????????tra_matrix[j*order+i]?=?ori_matrix[i*order+j];
}
}
????printf(“\nTranspose?matrix:\n“);
????printMatrix(tra_matrix?orderorder);

????//matrix?=?ori_matrix?*?tra_matrix
????for(i=0;?i for(j=0;?j ????for(k=0;?k????????????????matrix[i*order+j]?=?matrix[i*order+j]?+?tra_matrix[i*order+k]?*?ori_matrix[k*order+j];
????????????}
}
}
????printf(“\nSemi-definite?Matrix?one-dimension:\n“);
????printMatrix(matrix?orderorder);

????free(ori_matrix);
????free(tra_matrix);
}


void?serial_cholesky(double?*A_matrix?int?order)
{
????int?i?j?k;
????double?sum;
????double?*matrix?=?(double*)malloc(sizeof(double)*order*order);
????for(i=0;i????????for(j=0;j????????????matrix[i*order+j]?=?A_matrix[i*order+j];
????????}
????}

for(j=0;?j sum?=?0.0;
for(k=0;?k sum?+=?matrix[j*order+k]?*?matrix[j*order+k];
}
matrix[j*order+j]?=?matrix[j*order+j]?-?sum;
matrix[j*order+j]?=?sqrt(matrix[

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-11-10?14:32??Cholesky?MPI并行C語言實現\
?????文件????????7936??2015-11-10?14:20??Cholesky?MPI并行C語言實現\cholesky.c
?????文件?????1854464??2015-11-10?14:28??Cholesky?MPI并行C語言實現\Cholesky并行分解-實驗報告.doc

評論

共有 條評論