Skip to main content

rotation_matrix

Function rotation_matrix 

pub fn rotation_matrix(dim: usize) -> Vec<f64>
Expand description

A fixed orthogonal d × d rotation that mixes every axis into every other, row-major: the DCT-IV matrix R[k][j] = √(2/d)·cos(π(2k+1)(2j+1)/(4d)).

Three properties, all of which the fixture needs and none of which is tuned:

  • Orthogonal, by the classical DCT-IV identity (RᵀR = I — asserted in this module’s tests to 1e-12, and it is its own inverse). No eigensolver, no Gram–Schmidt, no numerical fragility in the benchmark crate.
  • Maximally mixing: every entry is bounded by √(2/d) (0.498 at d = 8), so no rotated axis can be close to a coordinate axis. That is the property the headline rests on — a rotation that left one axis nearly coordinate-aligned would leave the problem partly separable and hand an axis-aligned searcher a foothold. A product of Givens rotations with ad-hoc angles does not guarantee this (a golden-ratio angle schedule leaves a 0.926 component at d = 8, measured), and picking the angle constant that happens to minimize the worst entry would be fitting the fixture.
  • No constant row, unlike DCT-II, whose first row is the box diagonal.

The rotation is a pure function of dim, so it is the same on every machine and every run.