| 4482 | } |
| 4483 | |
| 4484 | void ecall_divi(float* input1,float* input2, int N1,int N2,int* shape1, int* shape2 ,float* output){ |
| 4485 | float *x1 = (float*)malloc(sizeof(float)*N1); |
| 4486 | memset(x1, 0, sizeof(float)*N1); |
| 4487 | for(int j=0;j<N1;j++){ |
| 4488 | x1[j] = 0.0f; |
| 4489 | float sum = input1[insert*N1+j]; |
| 4490 | float c = 0.0f; |
| 4491 | for(int i=0;i<Nt;i++){ |
| 4492 | float y = input1[indexs[i]*N1+j] - c; |
| 4493 | float t = sum + y; |
| 4494 | c = (t - sum) - y; |
| 4495 | sum = t; |
| 4496 | } |
| 4497 | x1[j] = sum; |
| 4498 | } |
| 4499 | float *x2 = (float*)malloc(sizeof(float)*N2); |
| 4500 | memset(x2, 0, sizeof(float)*N2); |
| 4501 | for(int j=0;j<N2;j++){ |
| 4502 | x2[j] = 0.0f; |
| 4503 | float sum = input2[insert*N2+j]; |
| 4504 | float c = 0.0f; |
| 4505 | for(int i=0;i<Nt;i++){ |
| 4506 | float y = input2[indexs[i]*N2+j] - c; |
| 4507 | float t = sum + y; |
| 4508 | c = (t - sum) - y; |
| 4509 | sum = t; |
| 4510 | } |
| 4511 | x2[j] = sum; |
| 4512 | } |
| 4513 | if(shape1[1] > shape2[1]){ |
| 4514 | int M = shape1[0]/Ne; |
| 4515 | int C = shape1[1]; |
| 4516 | int L = shape1[2]; |
| 4517 | for(int i=0;i<M;i++){ |
| 4518 | for(int j=0;j<C;j++){ |
| 4519 | for(int k=0;k<L;k++){ |
| 4520 | x1[i*C*L+j*L+k] = x1[i*C*L+j*L+k]/(x2[i*L+k]+1e-10f); |
| 4521 | } |
| 4522 | } |
| 4523 | } |
| 4524 | float mean = 0.0f, std, mean_sqr = 0.0f; |
| 4525 | float c_mean = 0.0f, c_mean_sqr = 0.0f; |
| 4526 | |
| 4527 | for (int j = 0; j < N1; j++) { |
| 4528 | float y = (x1[j]/static_cast<float>(N1)) - c_mean; |
| 4529 | float t = mean + y; |
| 4530 | c_mean = (t - mean) - y; |
| 4531 | mean = t; |
| 4532 | |
| 4533 | float y2 = (x1[j]*x1[j]/static_cast<float>(N1)) - c_mean_sqr; |
| 4534 | float t2 = mean_sqr + y2; |
| 4535 | c_mean_sqr = (t2 - mean_sqr) - y2; |
| 4536 | mean_sqr = t2; |
| 4537 | } |
| 4538 | std = sqrtf(mean_sqr - mean * mean)/static_cast<float>(Nt); |
| 4539 | mean = mean/static_cast<float>(Nt); |
| 4540 | for(int i=0;i<N1*(Ne-1);i++){ |
| 4541 | output[i] =(x1[i%N1] - gaussrand(mean, std))/static_cast<float>(Nt+1); |