5

如何用C语言生成SOR格式文件?

 2 years ago
source link: https://ask.csdn.net/questions/7659868
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Ares362532 2022-03-11 07:02
采纳率: 50%
浏览 262
问题最晚将于03月18日16:00点分配酬金

如何用C语言生成SOR格式文件?

有OTDR测试数据,现在需要把数据转成SOR格式文件 。如何用C语言生成SOR格式文件?

问题知识点与官方知识档案匹配,可进一步学习相关知识

7条回答 默认 最新

chx_125 2022-03-14 09:22

你好,可以点击图片链接查看相关代码,希望可以采纳:





































评论 打赏 举报
急速光粒 2022-03-12 02:43

符合Bellcore 标准的OTDR文件,直接修改为SOR文件名。不符合的就需要软件转换才可以。

评论
解决 无用 1
打赏 举报

望采纳谢谢,现在才发现这个问题我还可以给你讲解的,跟上一个回答者的还是有些不一样的,希望能帮到你哦
#include "stdlib.h"

#include "stdio.h"

#include "conio.h"

#include "string.h"

#include "math.h"

#define N 100

void cre_sch int n,float *w,float a[N][N],float b[N],float lw[N][N],float fw[N] int i,j,k; float tmp1[N][N],tmp2[N][N],rev[N][N],tmp; for i 0;i n;i++ for j 0;j n;j++ if j i tmp1[i][j] a[i][j]; tmp2[i][j] 1-w a[i][j]; rev[i][j] 1; else if j i tmp1[i][j] wa[i][j]; tmp2[i][j] 0; rev[i][j] 0; else tmp1[i][j] 0; tmp2[i][j] -wa[i][j]; rev[i][j] 0; for j 0;j n;j++ for i 0;i n;i++ for k 0;k j;k++ if i j continue; if i j rev[i][k] 1/tmp1[j][j]; continue; rev[i][k]+ rev[j][k] -tmp1[i][j] ; for i 0;i n;i++ for j 0;j n;j++ tmp 0.0; for k 0;k n;k++ tmp+ rev[i][k]*tmp2[k][j]; lw[i][j] tmp; for i 0;i n;i++ tmp 0.0; for k 0;k n;k++ tmp+ wrev[i][k]*b[k]; fw[i] tmp; void Table int n,float a[N][N],float b[N],float *w int i,j;

float lw[N][N],fw[N];

printf "Please input the matrix A by row!\n" ; /请输入矩阵的行/ for i 0;i n;i++ printf "Row %d:",i+1 ;

for j 0;j n;j++ scanf "%f",&a[i][j] ; printf "Please input the vector b:" ; /请输入向量b/

for i 0;i n;i++ scanf "%f",&b[i] ; printf "Input w:" ; scanf "%f",w ; cre_sch n,w,a,b,lw,fw ; printf "\nThe matrix A and vector b:\n" ; /矩阵A和向量b/

for i 0;i n;i++ for j 0;j n;j++ printf "%10.5f",a[i][j] ; printf "%10.5f",b[i] ; printf "\n" ; printf "\nThe SOR iterative scheme matrix Lw & vector fw :\n" ;/*SOR迭代 矩阵lw和向量fw */ for i 0;i n;i++ for j 0;j n;j++ printf "%10.5f",lw[i][j] ; printf "%10.5f",fw[i] ; printf "\n" ; void init_vec int n,float x[N] int i; printf "\nPlease input the initial iteration vector x:" ; /请输入初始迭代向量x/ for i 0;i n;i++ scanf "%f",&x[i] ; printf "\nThe initial iteration vector x:\n" ; /初始迭代向量x/ for i 0;i n;i++ printf "%10.5f",x[i] ; printf "\n" ; void sor int n,float a[N][N],float b[N],float x[N],float w int i,j,k; float p; /精确度/ float tmp1,tmp2,x2[N];

printf "输入精确值:\n" ; scanf "%f",&p ; for k 0;;k++ for i 0;i n;i++ x2[i] x[i]; for i 0;i n;i++ tmp1 0.0; tmp2 0.0; for j 0;j i;j++ tmp1+ a[i][j]*x[j];


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK