高斯模糊源码消元法的c++实现 要求用c++完成 要源码,最好带注释

用C++编程简单迭代法和史蒂芬孙迭代法和GAUSS列主消元法_百度知道
用C++编程简单迭代法和史蒂芬孙迭代法和GAUSS列主消元法
用简单迭代法和史蒂芬孙迭代法求出f(x)=2x^3-5x-1=0 要求自定义初值,精度,迭代次数用GAUSS列主消元法求
0.001 2.000 3.000
1.000(-1.000 3.712 4.623)(X2) =( 2.000)
-2.000 1.072 5.643
我有更好的答案
史蒂芬孙 是啥迭代法呢?应该是史蒂芬森吧?其实你直接写割线法或者弦位法比较好。&&迭代法。选取初值x0,并确定方程f(x)=0的等价形式x=ψ(x).计算x1=ψ(x0).判别:如果|x1-x0|&з,则停止计算,否则用x1代替x0。重复步骤。割线法。选取初始值X0,X1,并计算f(X0)和f(X1);按迭代公式Xn+1=Xn- f(Xn)*(Xn-Xn-1)/(f(Xn)-f(Xn-1))。计算出X2,再求f(X2)。判别:如果f(X2)=0则迭代停止;否则,用(X2,f(X2))和(X1,f(X1))分别代替(X1,f(X1))和(X0,f(X0)).重复步骤,直到相邻两次迭代值之差在容许范围。&列主元消元法解n元线形方程组:&1、先把线形法程组写成增广矩阵的形式。& 2、应用列主元的方法,把增广矩阵转换成行阶梯矩阵。&&&&&&&&&&&&& 枚举k从0到equ – 1,当前处理的列为col(初始为0) ,每次找第k行以下(包括第k行),col列中元素绝对值最大的列与第k行交换。如果col列中的元素全为0,那么则处理col + 1列,k不变。再对这一列进行高斯消元,将这一列的元素变为0;重复这一步骤,直到矩阵变为上三角矩阵。&&&3、对上三角形的矩阵回代,即求出方程解。
第一题你说的都知道 但是编出来程序漏洞太多 都不知道怎么改 一个是精度的设置问题 要求四位小数 第二题能给出程序么?
迭代法和解线性方程组都是计算方法或者叫数值分析这门课程很基础的程序,鉴于你知道五级,我觉得应该不是问题吧。还是把这俩个程序好好写写,因为后续还有涉及到画函数图象的编程题目,为以后打个基础。
其他类似问题
为您推荐:
消元法的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁linequ 高斯列主元消去法的c++源码
用以计算线性方程的解 Special Effects 图形图像处理 238万源代码下载-
&文件名称: linequ
& & & & &&]
&&所属分类:
&&开发工具: C-C++
&&文件大小: 2 KB
&&上传时间:
&&下载次数: 1
&&提 供 者:
&详细说明:高斯列主元消去法的c++源码
用以计算线性方程的解-Gaussian elimination of the PCA column c++ source code used to calculate the linear equation
文件列表(点击判断是否您需要的文件,如果是垃圾请在下面评价投诉):
&&linequ.h&&matrix.cpp&&matrix.h&&linequ.cpp
&输入关键字,在本站238万海量源码库中尽情搜索:hdu 3359 高斯消元法
Kind of a Blur
Time Limit:
MS (Java/Others)
Memory Limit:
K (Java/Others)
Total Submission(s): 1226
Accepted Submission(s): 356
Problem Description
Image blurring occurs when the object being captured is out of the camera's focus. The top two figures on the right are an example of an image and its blurred version. Restoring the original image given only the blurred version is
one of the most interesting topics in image processing. This process is called deblurring, which will be your task for this problem.
In this problem, all images are in grey-scale (no colours). Images are represented as a 2 dimensional matrix of real numbers, where each cell corresponds to the brightness of the corresponding pixel. Although not mathematically accurate, one way to describe
a blurred image is through averaging all the pixels that are within (less than or equal to) a certain Manhattan distance?from each pixel (including the pixel itself ). Here's an example of how to calculate the blurring of a 3x3 image with a blurring distance
Given the blurred version of an image, we are interested in reconstructing the Z"/kf/ware/vc/" target="_blank" class="keylink">vcmlnaW5hbCB2ZXJzaW9uIGFzc3VtaW5nIHRoYXQgdGhlIGltYWdlIHdhcyBibHVycmVkIGFzIGV4cGxhaW5lZCBhYm92ZS48YnI+CjxjZW50ZXI+PGltZyBzcmM9"/uploadfile/Collfiles/59.jpg" alt="\">
Input consists of several test cases. Each case is specified on H + 1 lines. The first line specifies three non negative integers specifying the width W, the height H of the blurred image and the blurring distance D respectively where
(1<= W,H <= 10) and (D <= min(W/2,H/2)). The remaining H lines specify the gray-level of each pixel in the blurred image. Each line specifies W non-negative real numbers given up to the 2nd decimal place. The value of all the given real numbers will be less
Zero or more lines (made entirely of white spaces) may appear between cases. The last line of the input file consists of three zeros.
For each test case, print a W * H matrix of real numbers specifying the deblurred version of the image. Each element in the matrix should be approximated to 2 decimal places and right justified in a field of width 8. Separate the
output of each two consecutive test cases by an empty line. Do not print an empty line after the last test case. It is guaranteed that there is exactly one unique solution for every test case.
Sample Input
14 15 14 15
14 15 14 15
14 15 14 15
14 15 14 15
Sample Output
The Manhattan Distance (sometimes called the Taxicab distance) between
two points is the sum of the (absolute) difference of their coordinates.
The grid on the lower right illustrates the Manhattan distances from the grayed cell.
高斯消元法模板题,测试模板。
#pragma comment(linker, "/STACK:2400000")
#define INF 0x3f3f3f3f
#define eps 1e-8
#define pi acos(-1.0)
double s[20][20],a[200][200],x[200];
int Guass(){
int i,j,k,col,max_r;
for(k=0,col=0;k<equ&&col<k++,col++){
for(i=k+1;ifabs(a[max_r][col]))
if(fabs(a[max_r][col])<eps)return 0;
if(k!=max_r){
for(j=j<j++)
swap(a[k][j],a[max_r][j]);
swap(x[k],x[max_r]);
x[k]/=a[k][col];
for(j=col+1;j<j++)a[k][j]/=a[k][col];
a[k][col]=1;
for(i=0;i<i++)
x[i]-=x[k]*a[i][k];
for(j=col+1;j<j++)
a[i][j]-=a[k][j]*a[i][col];
a[i][col]=0;
int main()
//freopen("data.in","r",stdin);
//freopen("data.out","w",stdout);
int d,tt=0,m,n;
while(~scanf("%d%d%d",&m,&n,&d)&&(n+m+d)){
if(tt++)puts("");
for(int i=0;i<n;i++)
for(int j=0;j<m;j++)
scanf("%lf",&s[i][j]);
memset(a,0,sizeof(a));
equ=var=n*m;
for(int i=0;i<n;i++)
for(int j=0;j<m;j++){
int cnt=0;
for(int k=0;k<n;k++)
for(int p=0;p<m;p++)
if(abs(i-k)+abs(j-p)<=d){
a[i*m+j][k*m+p]=1;
x[i*m+j]=cnt*s[i][j];
// cout<<ha<<
for(int i=0;i<n;i++){
for(int j=0;j<m;j++)
printf ("%8.2lf", x[i*m+j]);hdu 4418 高斯消元解方程求期望
一个人在一条线段来回走(遇到线段端点就转变方向),现在他从起点出发,并有一个初始方向,
&&&&&&& 每次都可以走1, 2, 3 ..... m步,都有对应着一个概率。问你他走到终点的概率
&&&&&&& 方向问题很是问题,我们可以把线段改造成环,具体我们可以把除端点以外的点作为另一个半圆 和原来的线段拼成一个环,
方向就单一了,用dp[i]表示在i点的时候到达终点的期望步数,则dp[i]=dp[(i+1)%N]*p1+E[(i+2)%N]*p2+&E[(i+m)%N]*pm+1。
&&&&&&& 这里N为变成环以后的点数。注意到有些点是无法到达的,自然这些点的期望是无意义的,可以理解成正无穷,在实际列方程的&&&&&&&& 时候,我们不需要把这些点列入方程中去,这样避免解方程的时候出现问题。所以我们可以先从起点进行bfs,将能到达的点&&&&&&&&&&&& 进行标号, 搜完后,有标号的点都是方程的未知数。然后对每个能到达的点列一个方程,高斯消元解出dp[起点]就是答案。
#include &cstdio&
#include &cstring&
#include &cmath&
#include &queue&
#include &algorithm&
const int maxn = 203;
const double
eps = 1e-9;
//高斯消元白书模板
//n : 未知数个数,
a[][]为增广矩阵
//把解放在
bool gauss(double a[][maxn], int n) {
int i, j, k,
for (i = 0; i & i++) {
for (j = i + 1; j & j++)
if (fabs(a[j][i]) & fabs(a[r][i]))
if (fabs(a[r][i]) & eps)
if (r != i)
for (j = 0; j &= j++)
swap(a[r][j], a[i][j]);
//根据精度需要选择以下其一:
for (k = i + 1; k & k++) {
r = a[k][i] / a[i][j];
for (j = j &= j++)
a[k][j] -= r * a[i][j];
for (j = j &= j--)
for (k = i + 1; k & k++)
a[k][j] -= a[k][i] / a[i][i] * a[i][j];
//回代过程
for (i = n - 1; i &= 0; i--) {
for (j = i + 1; j & j++)
a[i][n] -= a[j][n] * a[i][j];
a[i][n] /= a[i][i];
int n, m, t, s, d, N;
double p[103];
int idx[maxn],
//idx给能到达的点标号,id为能到达的点的个数,也是方程未知数的个数
void bfs(int s) {
memset(idx, -1, sizeof(idx));
queue&int&
q.push(s);
idx[s] = id++;
while (!q.empty()) {
int u = q.front();
for (i = 1; i &= i++) {
if (fabs(p[i]) & eps)
int v = (u + i) % N;
if (idx[v] == -1) {
idx[v] = id++;
q.push(v);
double a[maxn][maxn];
int main() {
scanf(&%d&, &cas);
while (cas--) {
scanf(&%d%d%d%d%d&, &n, &m, &t, &s, &d);
for (i = 1; i &= i++) {
scanf(&%lf&, &p[i]);
p[i] /= 100;
if(s == t) {
//必须特判
printf(&0.00\n&);
N = (n - 1) && 1;
if (d == 1) s = N -
if (idx[t] == -1 && idx[N-t] == -1) {
printf(&Impossible !\n&);
//id变成了方程组未知数的个数
memset(a, 0, sizeof(a));
for(i = 0; i & N; i++)
if(~idx[i]) {
a[idx[i]][idx[i]] = 1;
if(i == t || i == N-t)
for(j = 1; j &= j++) {
int v = (i+j)%N;
if(idx[v] != -1) {
a[idx[i]][idx[v]] -= p[j];
a[idx[i]][id] += j*p[j];
if(gauss(a, id)) printf(&%.2f\n&, a[idx[s]][id]);
else printf(&Impossible !\n&);数值分析高斯消元法c++程序 - 下载频道 - CSDN.NET
&&&&数值分析高斯消元法c++程序
&数值分析高斯消元法c++程序
高斯消元C++程序,含注释,容易看懂程序
若举报审核通过,可奖励20下载分
被举报人:
LIUKUN1106
举报的资源分:
请选择类型
资源无法下载
资源无法使用
标题与实际内容不符
含有危害国家安全内容
含有反动色情等内容
含广告内容
版权问题,侵犯个人或公司的版权
*详细原因:
您可能还需要
Q.为什么我点的下载下不了,但积分却被扣了
A. 由于下载人数众多,下载服务器做了并发的限制。若发现下载不了,请稍后再试,多次下载是不会重复扣分的。
Q.我的积分不多了,如何获取积分?
A. 获得积分,详细见。
完成任务获取积分。
评价资源返积分。
论坛可用分兑换下载积分。
第一次绑定手机,将获得5个C币,C币可。
下载资源意味着您已经同意遵守以下协议
资源的所有权益归上传用户所有
未经权益所有人同意,不得将资源中的内容挪作商业或盈利用途
CSDN下载频道仅提供交流平台,并不能对任何下载资源负责
下载资源中如有侵权或不适当内容,
本站不保证本站提供的资源的准确性,安全性和完整性,同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
开发技术下载排行
积分不够下载该资源
如何快速获得积分?
你下载资源过于频繁,请输入验证码
如何快速获得积分?
你已经下载过该资源,再次下载不需要扣除积分
数值分析高斯消元法c++程序
所需积分:5
剩余积分:
VIP会员,免积分下载
会员到期时间:日
剩余下载次数:1000
VIP服务公告:

我要回帖

更多关于 高斯消去法 的文章

 

随机推荐