共轭梯度法C语言实现
共轭梯度法的C实现西安交通大学实验报告 课程名称:数值分析上机实验 实验名称:共轭梯度法 学院:___数学学院___ 班级 姓名: 学号: 实验日期 2015 年 05 月 26 日 自评成绩:97 一、实验目的 (1)熟练掌握改进平方根法和共轭梯度法的迭代过程 (2)尝试使用自己熟悉的计算机语言解决数学中的问题 (3)通过上机实验...
共轭梯度法的C程序代码
# include <stdio.h> # include <math.h> # define N 5 /*目标函数*/ double F(double x[],double p[],double t) { double f=0; int i; for(i=0;i<N;i++) { f+=(x[i]+t*p[i])*(x[i]+t*p[i]); } return f; } /*欧氏范数平方*/ double D(double g[]) { double d=0...
共轭梯度法的C+=语言实现 ---基于成都理工大学最优化教材 #include <iostream.h> #include "Matrix.h" #include<LIMITS.H> #define MAX_M 2048 #include<math.h> #define beta (sqrt(5)-1)/2 #define eclipse 0.01 CMatrix hesse() { CMatrix temp(2,2); temp.A[0][0] = 2; temp.A[0][1]...
共轭梯度法C语言(西安交大)#include<stdio.h> #include<math.h> #define N 10 /*定义矩阵阶数*/ void main() { int i,j,m,A[N][N],B[N]; double X[N],akv[N],dka[N],rk[N],dk[N],pk,pkk,ak,bk; for(i=0;i<N;i++) /*输入系数矩阵A*/ { for(j=0;j<N;j++) { if(i=...
用C语言实现雅可比迭代法 热度: 共轭梯度法.txt #include #include intGong(double**A,double*b,double*x,int n,intCND=100000); voidprint(double*b,intn); voidprint(double**A,intn); intmain() { constintn=5;inti,j; double**A=newdouble*[n],*b=new ...
共轭梯度法程序源代码#include<stdio.h>#include<math.h>#defineN10#defineepspow10-6doublefdoublex[]doublep[]doubletdoubles;s=powx[0]+t*p[0]+5*powx[1]+t*p[1];returns;/*以下是进退法搜索区间源程序*/voidsbdouble*adouble*bdoublex[]doublep[]doublet0t1thalphaf0f1;
共轭梯度法程序源代码#include<stdio.h>#include<math.h>#defineN10#defineepspow(10,-6)doublef(doublex[],doublep[],doublet){doubles;s=pow(x[0]+t*p[0],..
共轭梯度法C语言源程序 //*** //function:minf=x1*x1+25*x2*x2 //method:gradient //*** #include<stdlib.h> #include<stdio.h> #include<math.h> constfloateps=0.000001; voidmain() { doubled[2],x[2],g[2],temp[2],lamda,alpha,g_org,g_now,t; intn=0; x[0]=2; x[1]=2...