MCPcopy Create free account
hub / github.com/conflow-dev/ConFlow / ecall_abs

Function ecall_abs

sgx_tf_ops/Enclave/Enclave.cpp:988–1049  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

986}
987
988void ecall_abs(float *input,int N,float *output){
989 float *x = (float*)malloc(sizeof(float)*N);
990 memset(x, 0, sizeof(float)*N);
991 for(int j=0;j<N;j++){
992 x[j] = 0.0f;
993 float sum = input[insert*N+j];
994 float c = 0.0f;
995 for(int i=0;i<Nt;i++){
996 float y = input[indexs[i]*N+j] - c;
997 float t = sum + y;
998 c = (t - sum) - y;
999 sum = t;
1000 }
1001 x[j] = sum;
1002
1003 }
1004
1005 for (int j = 0; j < N; j++) {
1006 if(fabs(x[j]) < 1e-7f){
1007 x[j] = 0.0f;
1008 }
1009 else if(x[j] >= 1e-7f){
1010 x[j] = x[j];
1011 }
1012 else{
1013 x[j] = -1.0f * x[j];
1014 }
1015 }
1016
1017 float mean = 0.0f, std, mean_sqr = 0.0f;
1018 float c_mean = 0.0f, c_mean_sqr = 0.0f;
1019 for (int j = 0; j < N; j++) {
1020 float y = (x[j]/static_cast<float>(N)) - c_mean;
1021 float t = mean + y;
1022 c_mean = (t - mean) - y;
1023 mean = t;
1024
1025 float y2 = (x[j]*x[j]/static_cast<float>(N)) - c_mean_sqr;
1026 float t2 = mean_sqr + y2;
1027 c_mean_sqr = (t2 - mean_sqr) - y2;
1028 mean_sqr = t2;
1029 }
1030 std = sqrtf(fabs(mean_sqr - mean * mean))/static_cast<float>(Nt);
1031 mean = mean/static_cast<float>(Nt);
1032 for(int i=0;i<N*(Ne-1);i++){
1033 output[i] =(x[i%N] - gaussrand(mean, std))/static_cast<float>(Nt+1);
1034 }
1035 for(int j=N*(Ne-1);j<N*Ne;j++){
1036 output[j] = 0.0f;
1037 float sum = 0.0f;
1038 float c = 0.0f;
1039 for(int i=0;i<Nt;i++){
1040 float y = -1.0f * output[indexs[i]*N+(j-N*(Ne-1))] - c;
1041 float t = sum + y;
1042 c = (t - sum) - y;
1043 sum = t;
1044 }
1045 output[j] =x[j-N*(Ne-1)] + sum;

Callers 1

abs1Function · 0.85

Calls 1

gaussrandFunction · 0.85

Tested by

no test coverage detected