| 1808 | } |
| 1809 | |
| 1810 | void ecall_maximum(float *input1,float *input2,int N,float *output){ |
| 1811 | float *x1 = (float*)malloc(sizeof(float)*N); |
| 1812 | memset(x1, 0, sizeof(float)*N); |
| 1813 | for(int j=0;j<N;j++){ |
| 1814 | x1[j] = 0.0f; |
| 1815 | float sum = input1[insert*N+j]; |
| 1816 | float c = 0.0f; |
| 1817 | for(int i=0;i<Nt;i++){ |
| 1818 | float y = input1[indexs[i]*N+j] - c; |
| 1819 | float t = sum + y; |
| 1820 | c = (t - sum) - y; |
| 1821 | sum = t; |
| 1822 | } |
| 1823 | x1[j] = sum; |
| 1824 | } |
| 1825 | |
| 1826 | float *x2 = (float*)malloc(sizeof(float)*N); |
| 1827 | memset(x2, 0, sizeof(float)*N); |
| 1828 | for(int j=0;j<N;j++){ |
| 1829 | x2[j] = 0.0f; |
| 1830 | float sum = input2[insert*N+j]; |
| 1831 | float c = 0.0f; |
| 1832 | for(int i=0;i<Nt;i++){ |
| 1833 | float y = input2[indexs[i]*N+j] - c; |
| 1834 | float t = sum + y; |
| 1835 | c = (t - sum) - y; |
| 1836 | sum = t; |
| 1837 | } |
| 1838 | x2[j] = sum; |
| 1839 | } |
| 1840 | |
| 1841 | for (int j = 0; j < N; j++) { |
| 1842 | x1[j] = x1[j] >= x2[j] ? x1[j] : x2[j]; |
| 1843 | } |
| 1844 | |
| 1845 | float mean = 0.0f, std, mean_sqr = 0.0f; |
| 1846 | float c_mean = 0.0f, c_mean_sqr = 0.0f; |
| 1847 | for (int j = 0; j < N; j++) { |
| 1848 | float y = (x1[j]/static_cast<float>(N)) - c_mean; |
| 1849 | float t = mean + y; |
| 1850 | c_mean = (t - mean) - y; |
| 1851 | mean = t; |
| 1852 | |
| 1853 | float y2 = (x1[j]*x1[j]/static_cast<float>(N)) - c_mean_sqr; |
| 1854 | float t2 = mean_sqr + y2; |
| 1855 | c_mean_sqr = (t2 - mean_sqr) - y2; |
| 1856 | mean_sqr = t2; |
| 1857 | } |
| 1858 | std = sqrtf(mean_sqr - mean * mean)/static_cast<float>(Nt); |
| 1859 | mean = mean/static_cast<float>(Nt); |
| 1860 | for(int i=0;i<N*(Ne-1);i++){ |
| 1861 | output[i] =(x1[i%N] - gaussrand(mean, std))/static_cast<float>(Nt+1); |
| 1862 | } |
| 1863 | for(int j=N*(Ne-1);j<N*Ne;j++){ |
| 1864 | output[j] = 0.0f; |
| 1865 | float sum = 0.0f; |
| 1866 | float c = 0.0f; |
| 1867 | for(int i=0;i<Nt;i++){ |