structboost.column_norms_sq

structboost.column_norms_sq(sourcemat)[source]

Squared column norms ||x_j||^2 of the boosting design matrix.

Exposed so a caller that invokes allboost() repeatedly against the same sourcemat – which is what structboost.BAE.fit() does, once per training iteration – can compute this once and pass it back in. It is otherwise recomputed on every call, an O(n*p) pass that also allocates a full (n_samples, n_features) temporary.

Using this helper rather than open-coding the expression is what guarantees a hoisted value is bit-for-bit the one allboost would have computed itself.

einsum rather than (sourcemat**2).sum(axis=0): the latter materializes a full (n_samples, n_features) squared copy, 1.4 GB at 60k x 6k, purely to reduce it away again.

Parameters:

sourcemat (ndarray[tuple[Any, ...], dtype[floating]])

Return type:

ndarray[tuple[Any, …], dtype[floating]]