Download sce_native.c from bbkdevops/Fiber-MoE-Symplectic-Gating-Research: direct link, hf CLI and curl.
- Browser
- Download file 1.86 kB
-
https://huggingface.co/bbkdevops/Fiber-MoE-Symplectic-Gating-Research/resolve/5610692870fe30df6545f55960977dd89497da20/sce_native.c
- Command line
-
hf download hf://bbkdevops/Fiber-MoE-Symplectic-Gating-Research@5610692870fe30df6545f55960977dd89497da20/sce_native.c
-
curl -L -o sce_native.c https://huggingface.co/bbkdevops/Fiber-MoE-Symplectic-Gating-Research/resolve/5610692870fe30df6545f55960977dd89497da20/sce_native.c
1.86 kB
| extern "C" { | |
| static inline uint64_t fmix64(uint64_t k) { | |
| k ^= k >> 33; | |
| k *= 0xff51afd7ed558ccdULL; | |
| k ^= k >> 33; | |
| k *= 0xc4ceb9fe1a85ec53ULL; | |
| k ^= k >> 33; | |
| return k; | |
| } | |
| SCE_API void sce_holographic_hash(const char* data, size_t len, char* out_hex) { | |
| uint64_t h = 0x100000001b3ULL; | |
| const uint8_t* ptr = (const uint8_t*)data; | |
| for (size_t i = 0; i < len; ++i) { | |
| h = (h ^ ptr[i]) * 0xCBF29CE484222325ULL; | |
| } | |
| h = fmix64(h); | |
| snprintf(out_hex, 17, "%016llx", (unsigned long long)h); | |
| } | |
| SCE_API void sce_symplectic_step(double* z, double* z_dot, const double* u, int n, double omega, double dt) { | |
| double omega_sq = omega * omega; | |
| double two_omega = 2.0 * omega; | |
| for (int i = 0; i < n; ++i) { | |
| double acc = omega_sq * (u[i] - z[i]) - two_omega * z_dot[i]; | |
| z_dot[i] += acc * dt; | |
| z[i] += z_dot[i] * dt; | |
| } | |
| } | |
| SCE_API double sce_lyapunov_eval(const double* x, const double* P, int dim) { | |
| double v = 0.0; | |
| for (int i = 0; i < dim; ++i) { | |
| double row_sum = 0.0; | |
| for (int j = 0; j < dim; ++j) { | |
| row_sum += P[i * dim + j] * x[j]; | |
| } | |
| v += x[i] * row_sum; | |
| } | |
| return v; | |
| } | |
| SCE_API int sce_ucb_prune(const double* v_mean, const double* v_std, double kappa, double tau, int* out_mask, int n) { | |
| int pruned_count = 0; | |
| for (int i = 0; i < n; ++i) { | |
| double ucb = v_mean[i] + kappa * v_std[i]; | |
| if (ucb < tau) { | |
| out_mask[i] = 0; | |
| pruned_count++; | |
| } else { | |
| out_mask[i] = 1; | |
| } | |
| } | |
| return pruned_count; | |
| } | |
| } | |