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

Function ecall_minimum

sgx_tf_ops/Enclave/Enclave.cpp:2003–2069  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2001}
2002
2003void ecall_minimum(float *input1,float *input2,int N,float *output){
2004 float *x1 = (float*)malloc(sizeof(float)*N);
2005 memset(x1, 0, sizeof(float)*N);
2006 for(int j=0;j<N;j++){
2007 x1[j] = 0.0f;
2008 float sum = input1[insert*N+j];
2009 float c = 0.0f;
2010 for(int i=0;i<Nt;i++){
2011 float y = input1[indexs[i]*N+j] - c;
2012 float t = sum + y;
2013 c = (t - sum) - y;
2014 sum = t;
2015 }
2016 x1[j] = sum;
2017 }
2018
2019 float *x2 = (float*)malloc(sizeof(float)*N);
2020 memset(x2, 0, sizeof(float)*N);
2021 for(int j=0;j<N;j++){
2022 x2[j] = 0.0f;
2023 float sum = input2[insert*N+j];
2024 float c = 0.0f;
2025 for(int i=0;i<Nt;i++){
2026 float y = input2[indexs[i]*N+j] - c;
2027 float t = sum + y;
2028 c = (t - sum) - y;
2029 sum = t;
2030 }
2031 x2[j] = sum;
2032 }
2033 for (int j = 0; j < N; j++) {
2034 x1[j] = x1[j] <= x2[j] ? x1[j] : x2[j];
2035 }
2036 float mean = 0.0f, std, mean_sqr = 0.0f;
2037 float c_mean = 0.0f, c_mean_sqr = 0.0f;
2038 for (int j = 0; j < N; j++) {
2039 float y = (x1[j]/static_cast<float>(N)) - c_mean;
2040 float t = mean + y;
2041 c_mean = (t - mean) - y;
2042 mean = t;
2043
2044 float y2 = (x1[j]*x1[j]/static_cast<float>(N)) - c_mean_sqr;
2045 float t2 = mean_sqr + y2;
2046 c_mean_sqr = (t2 - mean_sqr) - y2;
2047 mean_sqr = t2;
2048 }
2049 std = sqrtf(mean_sqr - mean * mean)/static_cast<float>(Nt);
2050 mean = mean/static_cast<float>(Nt);
2051 for(int i=0;i<N*(Ne-1);i++){
2052 output[i] =(x1[i%N] - gaussrand(mean, std))/static_cast<float>(Nt+1);
2053 }
2054 for(int j=N*(Ne-1);j<N*Ne;j++){
2055 output[j] = 0.0f;
2056 float sum = 0.0f;
2057 float c = 0.0f;
2058 for(int i=0;i<Nt;i++){
2059 float y = -1.0f * output[indexs[i]*N+(j-N*(Ne-1))] - c;
2060 float t = sum + y;

Callers 1

minimumFunction · 0.85

Calls 1

gaussrandFunction · 0.85

Tested by

no test coverage detected