logo资料库

C语言实现最小二乘法解线性方程组.doc

第1页 / 共6页
第2页 / 共6页
第3页 / 共6页
第4页 / 共6页
第5页 / 共6页
第6页 / 共6页
资料共6页,全文预览结束
#include "stdafx.h" #include #include #include using namespace std; #ifndef _COORDINATION_LS_2_H_ #define _COORDINATION_LS_2_H_ #define N #define M struct REF{ float x; float y; float z; float r; 3 3 }; int MatrixProduct(float *a,float *b,float *c,int lin1,int col1,int lin2,int col2); int MatrixAddition(float *a,float *b,float *c,int lin1,int col1,int lin2,int col2); void MatrixReverse(float *a,float *b,int lin,int col); int MaxOfArray(float *a,int n); void ExchangeRow(float *array,int row1,int row2,int m); void SelectMaxElement(float *array,int n,int m,int row); void GAUSSProcess(float *array,int n,int m,int row); void GAUSSCaculate(float *array,float *x,int n,int m); void MatrixMerge(float *A,float *B,float *C,int colomn1,int colomn2); void SolveEquations(float *a,float *b,float *x,int colomn1); void LS_2(); #endif /***************************************************** *MatrixProduct: 求两个矩阵相乘 * *******************************************************/ int MatrixProduct(float *a,float *b,float *c,int lin1,int col1,int lin2,int col2) { /* lin1 = LIN1; col1 = COL1; lin2 = LIN2; col2 = COL2; */ int i,j,k;
if (col1!=lin2) { return 0; } for (i=0;i
{ for (j=0;j
*ExchangeRow:交换矩阵的两行 *row1,row2 为所要交换的两行的行序数,m 为矩阵的列数 *****************************************************/ void ExchangeRow(float *array,int row1,int row2,int m) { float t[MAX_COLOMN]; for (int j=0;j
float rate_row ; for (i=row+1;i=0;i--) { sum = 0; for (int j=i+1;j
for (k =0;k
分享到:
收藏