Skip to content

add smooth clamping operator - #47

Merged
nmbader merged 3 commits into
masterfrom
mbader/clamp-c1-operator
Jul 10, 2026
Merged

nmbader merged 3 commits into
masterfrom
mbader/clamp-c1-operator

Conversation

@nmbader

@nmbader nmbader commented Jul 9, 2026

Copy link
Copy Markdown
Member

JopClampC1: smooth bounded projection operator

This PR adds JopClampC1, a nonlinear Jet operator for pointwise bounded projection with consistent forward, Jacobian, and adjoint-Jacobian actions.

  • Acts like a hard clamp outside [lo, hi]
  • Acts like the identity in the interior
  • Replaces the sharp clamp corners with a cubic transition layer of width δ = transition * (hi - lo) near each bound, making the operator C1

Why this is useful:

  • preserves practical bound enforcement,
  • avoids derivative jumps from hard clamping,
  • gives cleaner and more stable linearization behavior for optimization and testing.

The accompanying tests cover:

  • forward correctness,
  • Jacobian linearity and dot-product consistency,
  • O(μ) and O(μ²) linearization rates in the smooth case,
  • and the expected loss of smooth asymptotics for hard-clamp boundary crossing.

@codecov

codecov Bot commented Jul 9, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.93548% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.73%. Comparing base (51d413c) to head (c36b1a9).

Files with missing lines Patch % Lines
src/jop_clamp_c1.jl 91.93% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #47      +/-   ##
==========================================
- Coverage   95.94%   95.73%   -0.22%     
==========================================
  Files          40       41       +1     
  Lines        1086     1148      +62     
==========================================
+ Hits         1042     1099      +57     
- Misses         44       49       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jkwashbourne-oss jkwashbourne-oss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you fix the coverage issue? might be missing a test?

@nmbader

nmbader commented Jul 10, 2026

Copy link
Copy Markdown
Member Author

no missing tests just miscounting from codecov that misses lines of loop end when simd is used

@nmbader
nmbader merged commit f72248f into master Jul 10, 2026
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants