一键导入
cross-language-demo-porting
Patterns for porting Python radar detection demo to C++, Lua, Julia — CLI args, framework APIs, 1-based indexing, missing bindings
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Patterns for porting Python radar detection demo to C++, Lua, Julia — CLI args, framework APIs, 1-based indexing, missing bindings
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Add device information query functions through HAL → ins:: API → language bindings
Add --device all/--timer/--info CLI flags to demos across all languages for competition scoring
Add composite signal operators using existing primitives (no dedicated backend kernels needed)
How to port a cusignal Python/CUDA module to ins::signal C++ using Insight7 primitives and HAL
Profile and optimize binding language (Lua/Julia/Python) demo performance to match or exceed C++ baseline
busted loads _insight.so from ~/.luarocks/lib first, not build/ — must copy .so after rebuild
| name | cross-language-demo-porting |
| description | Patterns for porting Python radar detection demo to C++, Lua, Julia — CLI args, framework APIs, 1-based indexing, missing bindings |
| source | auto-skill |
| extracted_at | 2026-06-06T22:24:57.582Z |
Use the same algorithm across all languages: echo simulation → pulse_compression → pulse_doppler → ca_cfar → target extraction. Only the API syntax differs.
Use these core functions for Task 1:
| Step | API | Python | C++ | Lua | Julia |
|---|---|---|---|---|---|
| Pulse compression | pulse_compression(x, template) | ins.signal.pulse_compression() | signal::pulse_compression() | ins.signal.pulse_compression() | Insight.signal.pulse_compression() |
| Doppler | pulse_doppler(x, window, nfft) | same | same | same | same |
| CFAR | ca_cfar(energy, guard, ref, pfa) | same | same | same (returns pair) | same (returns tuple) |
| Ambiguity fn | ambgfun(x, fs, prf) | pass fs=, prf= kwargs | signal::ambgfun(x, fs, prf) | ins.signal.ambgfun(x, fs, prf) | Insight.signal.ambgfun(x, fs, prf) |
Each language uses its native CLI parsing:
strcmp loop over argv (no getopt dependency)arg table (global, 1-indexed)ARGS (global, 1-indexed)Args: --device cpu|gpu, --seed N, --iterations N
seed(seed_val) — variable name seed shadows the function; use seed_valcandidates.push_back({i, r}) — brace-init list not convertible to struct; construct explicitly: TargetInfo ti; ti.d=i; ti.r=r; result.targets.push_back(ti);fft::fftshift, fft::fftfreq — need fft:: namespace prefixSlice(start, stop) — Slice() with no args = full slice ::array.slice({Slice(), Slice(start, stop)}) — use slice() method, not operator[]copy_from_() for assigning views — view.copy_from_(src)mul(arr, scalar) doesn't exist; wrap scalar: full({1}, scalar_val, dtype, place)arr["1:6"] gives elements at 1-based positions 1..5 (stop exclusive). NOT arr["0:5"].arr.numel, arr.shape, arr.dtype are properties (no parentheses). arr:get(i), arr:item() are methods.^ operator not overloaded for arrays — use a * a for square// not integer division — use math.floor(a / b)Array() params in C++ functions need sol::optional<Array> wrapper to avoid segfaultarr["1:6"] works, returns viewins.signal.ca_cfar() returns a pair-like table: result[1] = threshold, result[2] = detectionsset_device(Int64(0)) for CPU, set_device(Int64(1)) for GPU. No CPUPlace()/GPUPlace().Insight.real_part(arr) not Insight.real(arr). Same for imag_part.Insight.item(arr, 0) — requires index arg (0-based), not Insight.item(arr)Insight.mean(arr, axis=0, keepdims=true) — uses keyword argsInsight.signal.get_window("hamming", n, fftbins=false) — keyword arg fftbins+(::InsightArray, ::Number), -(::InsightArray, ::Number), /(::InsightArray, ::Number) — must be added to Insight.jlInsight.slice(arr, dim, start, stop) where start/stop are 1-based and stop is exclusive. Binding must convert: Int64(start-1), Int64(stop-1) for 0-based C++.from_data(arr) creates on CPU regardless of set_device. Use Insight.to(arr, 1) to transfer to GPU.Insight.jl exports.Common pattern across all languages:
energy and detections to CPUdetections array for true cells# Python pattern — use 2D broadcasting
slow_times = arange(N_PULSES) * T_PRF
pulses = zeros([N_PULSES, N], complex128)
for delay, doppler in zip(delays, dopplers):
delayed_1d = zeros([N], complex128)
delayed_1d[ds:] = S_TX[0:N-ds] # delayed copy
phase = 2*PI*doppler*slow_times
rot = to_complex(cos(phase), sin(phase))
pulses = pulses + reshape(delayed_1d, [1, N]) * reshape(rot, [N_PULSES, 1])
pulses = pulses + to_complex(noise_r, noise_i)
When a function doesn't exist in a language binding:
insight_julia_capi.cpp, then bind in Insight.jlsol::optional<> in insight_lua.cpp.def() in insight_py.cpp