검색어 입력폼

# Crout factorization

등록일 2005.01.01 한컴오피스 (hwp) | 2페이지 | 가격 1,000원

## 소개글

Crout factorization 수치해석 기법입니다. 과제수행시 참고하세요.

Visual C++ 6.0
1.5G 노트북

## 본문내용

/*
Crout factorization.
*/
#include<stdio.h>
#include<math.h>
main(){
int i,j,k;
float A[3][3]={{1,-1,0},{-2,4,-2},{0,-1,2}};
float L[3][3]={{0,0,0},{-2,0,0},{0,-1,0}};
float U[3][3]={{1,0,0},{0,1,0},{0,0,1}};
float b[3]={0,-1,1.5}, x[3]={0,0,0}, y[3]={0,0,0},t=0;
L[0][0]=A[0][0];
U[0][1]=A[0][1]/L[0][0];
for(i=1;i<2;i++){
L[i][i]=A[i][i]-L[i][i-1]*U[i-1][i];
U[i][i+1] = A[i][i+1]/L[i][i];
}
L[2][2]=A[2][2] - A[2][1]*U[1][2];
y[0] = b[0]/L[0][0];
for(i=1;i<3;i++){
y[i]=(b[i]-L[i][i-1]*y[i-1])/L[i][i];
}
x[2]=y[2];
for(i=1;i>=0;i--){
x[i]=y[i]-U[i][i+1]*x[i+1];
}
printf("A Matrix\n");
for(j=0;j<3;j++){
for(k=0;k<3;k++){
printf("%3.3f ",A[j][k]);
}
printf("\n");
}
printf("L Matrix\n");
for(j=0;j<3;j++){
for(k=0;k<3;k++){
printf("%3.3f ",L[j][k]);
}
printf("\n");
}
printf("\U Matrix\n");
for(j=0;j<3;j++){
for(k=0;k<3;k++){
printf("%3.3f ",U[j][k]);
}
printf("\n");