-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcubiclinear.c
88 lines (71 loc) · 1.13 KB
/
cubiclinear.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define F(X) C0+(C1*X)+(C2*X*X)+(C3*X*X*X)
#define MAX 11
int main()
{
double b[MAX][1];
double x[]={0.0,0.2,0.4,0.6,0.8,1.0,1.2,1.4,1.6,1.8,2.0};
double fx[]={1.0,1.04,1.16,1.36,1.64,2.0,2.44,2.96,3.56,4.24,5.0};
for(int i=0;i<MAX;i++)
{
b[i][0]=fx[i];
}
double a[MAX][4];
for(int i=0;i<MAX;i++)
{
a[i][0]=1;
a[i][1]=x[i];
a[i][2]=x[i]*x[i];
a[i][3]=x[i]*x[i]*x[i];
}
for(int i=0;i<MAX;i++)
{
for(int j=0;j<4;j++)
{
printf("%9.6lf ",a[i][j]);
}
puts("");
}
double at[4][MAX];
for(int i=0;i<MAX;i++)
{
for(int j=0;j<4;j++)
{
at[0][i]=a[i][0];
at[1][i]=a[i][1];
at[2][i]=a[i][2];
at[3][i]=a[i][3];
}
}
puts("");
puts("transpose");
for(int i=0;i<4;i++)
{
for(int j=0;j<MAX;j++)
{
printf("%9.6lf ",at[i][j]);
}
puts("");
}
// multiplication
double multi[4][4];
for(int i=0;i<4;i++)
{
for(int j=0;j<4;j++)
{
multi[i][j]=0;
}
}
for(int i=0;i<4;i++)
{
for(int j=0;j<MAX;j++)
{
for(int k=0;k<4;k++)
{
multi[i][k]=;
}
}
}
}