# New package: NewtonCQK.jl

**URL:** <https://discourse.julialang.org/t/new-package-newtoncqk-jl/136254>\
**Category:** Optimization (Mathematical)\
**Created:** [March 18, 2026, 1:49pm UTC](https://discourse.julialang.org/t/new-package-newtoncqk-jl/136254 "2026-03-18T13:49:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pjssilva](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pjssilva/32/4238_2.png) [@pjssilva](https://discourse.julialang.org/u/pjssilva)\
**Post date:** [March 18, 2026, 1:49pm UTC](https://discourse.julialang.org/t/new-package-newtoncqk-jl/136254/1 "2026-03-18T13:49:34Z")

</div>

Hi,

I would like to announce a new Julia package named [NewtonCQK.jl](https://github.com/pjssilva/NewtonCQK.jl). It implements a semismooth Newton method to solve the Continuous Quadratick Knapsack problem

\min\_x \frac{1}{2}x^tDx - a^tx \quad \text{s.t.} \quad b^tx = r, \ l \leq x \leq u,

where D is a positve diagonal, a, b, l, u are vectors and r is a scalar. You can think of it as “projecting onto the intersection of a box and a hyperplane”.

The implementation has many features:

- It has specialized code for projecting onto a Simplex and onto a \ell\_1 ball.
- It is fast. Faster than Condat implementation for the Simplex and \ell\_1 ball and almost as fast as the original C code for the general case.
- It allows to return the solution as a sparse vector (nonzero coordinate indexes and values) or as a full vector.
- It can use multiple threads (thanks to `OhMyThread.jl`) in a multicore setting. It scales very well for large problems (up to consuming all memory bandwidth).
- It can run on NVidia GPUs (it should be trivial to make it run on AMD GPUs too, but I don’t have one to test). For the general case the GPU implementation is up to 185 faster than the serial code for very large problems (10^8 variables).
- It allows for hotstart: it can use the last point in an iterative procedure (where it is called at each iteration) that has potential for further speed up.

The implementation is described in a [technical report that is submitted for publication](https://arxiv.org/abs/2603.15910).

At this moment it is only available directly from Github, but I plan to add the package to the registry soon. It still needs better documentation and tests.

Fun fact: what is faster for n=10^9, call `zero(n)` or project a random n-dimensional vector onto the unit Simplex? If you accept the solution as a sparse vector, the projection is faster.

Have fun!
