This commit is contained in:
wangfiox 2024-08-16 12:37:09 +08:00
parent 8114ffaf1f
commit ea4d6425d2
12 changed files with 600316 additions and 0 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1
wa/input/h-3-01.in Normal file

File diff suppressed because one or more lines are too long

1
wa/input/h-3-02.in Normal file

File diff suppressed because one or more lines are too long

1
wa/input/h-3-03.in Normal file

File diff suppressed because one or more lines are too long

600001
wa/input/h-7-01.in Normal file

File diff suppressed because it is too large Load Diff

85
wa/sy/h-3-01.sy Normal file
View File

@ -0,0 +1,85 @@
//#include "sylib.h"
int m = 800;
int n = 800;
int data[800][800];
int corr[800][800];
int mean[800];
int stddev[800];
void kernel_correlation(int m, int n,
int data[][800],
int corr[][800],
int mean[],
int stddev[])
{
int i, j, k;
j = 0;
while (j < m) {
mean[j] = 0;
i = 0;
while (i < n) {
mean[j] =mean[j]+ data[i][j];
i = i +1;
}
mean[j] = mean[j] / n;
j = j + 1;
}
j = 0;
while(j < m) {
stddev[j] = 0;
i= 0;
while(i < n) {
stddev[j] =stddev[j]+ (data[i][j] - mean[j]) * (data[i][j] - mean[j]);
i = i +1;
}
stddev[j] = stddev[j] / n;
stddev[j] = stddev[j] * stddev[j];
if (stddev[j] <= 1) {
stddev[j] = 1;
}
j = j + 1;
}
i =0;
while (i < n) {
j = 0;
while (j < m)
{
data[i][j] = data[i][j] - mean[j];
data[i][j] = data[i][j] / (n * n * stddev[j]);
j = j + 1;
}
i = i +1;
}
i = 0;
while (i < m-1)
{
corr[i][i] = 1;
j = i +1;
while (j < m)
{
corr[i][j] = 0;
k =0;
while (k < n) {
corr[i][j] = corr[i][j] + (data[k][i] * data[k][j]);
k = k +1;
}
corr[j][i] = corr[i][j];
j = j +1;
}
i = i +1;
}
corr[m-1][m-1] = 1;
}
int main()
{
getarray(data);
starttime();
kernel_correlation (m, n, data, corr, mean, stddev);
stoptime();
putarray(m*m, corr);
return 0;
}

85
wa/sy/h-3-02.sy Normal file
View File

@ -0,0 +1,85 @@
//#include "sylib.h"
int m = 800;
int n = 800;
int data[800][800];
int corr[800][800];
int mean[800];
int stddev[800];
void kernel_correlation(int m, int n,
int data[][800],
int corr[][800],
int mean[],
int stddev[])
{
int i, j, k;
j = 0;
while (j < m) {
mean[j] = 0;
i = 0;
while (i < n) {
mean[j] =mean[j]+ data[i][j];
i = i +1;
}
mean[j] = mean[j] / n;
j = j + 1;
}
j = 0;
while(j < m) {
stddev[j] = 0;
i= 0;
while(i < n) {
stddev[j] =stddev[j] + (data[i][j] - mean[j]) * (data[i][j] - mean[j]);
i = i +1;
}
stddev[j] = stddev[j] / n;
stddev[j] = stddev[j] * stddev[j];
if (stddev[j] <= 1) {
stddev[j] = 1;
}
j = j + 1;
}
i =0;
while (i < n) {
j = 0;
while (j < m)
{
data[i][j] = data[i][j] - mean[j];
data[i][j] = data[i][j] / (n * n * stddev[j]);
j = j + 1;
}
i = i +1;
}
i = 0;
while (i < m-1)
{
corr[i][i] = 1;
j = i +1;
while (j < m)
{
corr[i][j] = 0;
k =0;
while (k < n) {
corr[i][j] = corr[i][j] + (data[k][i] * data[k][j]);
k = k +1;
}
corr[j][i] = corr[i][j];
j = j +1;
}
i = i +1;
}
corr[m-1][m-1] = 1;
}
int main()
{
getarray(data);
starttime();
kernel_correlation (m, n, data, corr, mean, stddev);
stoptime();
putarray(m*m, corr);
return 0;
}

85
wa/sy/h-3-03.sy Normal file
View File

@ -0,0 +1,85 @@
//#include "sylib.h"
int m = 800;
int n = 800;
int data[800][800];
int corr[800][800];
int mean[800];
int stddev[800];
void kernel_correlation(int m, int n,
int data[][800],
int corr[][800],
int mean[],
int stddev[])
{
int i, j, k;
j = 0;
while (j < m) {
mean[j] = 0;
i = 0;
while (i < n) {
mean[j] =mean[j] + data[i][j];
i = i +1;
}
mean[j] = mean[j] / n;
j = j + 1;
}
j = 0;
while(j < m) {
stddev[j] = 0;
i= 0;
while(i < n) {
stddev[j] =stddev[j] + (data[i][j] - mean[j]) * (data[i][j] - mean[j]);
i = i +1;
}
stddev[j] = stddev[j] / n;
stddev[j] = stddev[j] * stddev[j];
if (stddev[j] <= 1) {
stddev[j] = 1;
}
j = j + 1;
}
i =0;
while (i < n) {
j = 0;
while (j < m)
{
data[i][j] = data[i][j] - mean[j];
data[i][j] = data[i][j] / (n * n * stddev[j]);
j = j + 1;
}
i = i +1;
}
i = 0;
while (i < m-1)
{
corr[i][i] = 1;
j = i +1;
while (j < m)
{
corr[i][j] = 0;
k =0;
while (k < n) {
corr[i][j] = corr[i][j] + (data[k][i] * data[k][j]);
k = k +1;
}
corr[j][i] = corr[i][j];
j = j +1;
}
i = i +1;
}
corr[m-1][m-1] = 1;
}
int main()
{
getarray(data);
starttime();
kernel_correlation (m, n, data, corr, mean, stddev);
stoptime();
putarray(m*m, corr);
return 0;
}

45
wa/sy/h-7-01.sy Normal file
View File

@ -0,0 +1,45 @@
float i_buf[10000000];
float o_buf[10000000];
float newtons_sqrt(float n) {
const float prec = 0.0000000001;
if (n <= 0) {
return 0;
}
float x = n;
float r = (n + 1) * 0.5;
float d;
if (x < r) {
d = r - x;
} else {
d = x - r;
}
while (d > prec) {
r = (x + n / x) * 0.5;
if (x < r) {
d = r - x;
} else {
d = x - r;
}
x = r;
}
return r;
}
int main() {
int n = getfarray(i_buf);
starttime();
int i = 0;
while (i < n) {
o_buf[i] = newtons_sqrt(i_buf[i]);
i = i + 1;
}
stoptime();
putfarray(n, o_buf);
return 0;
}