Skip to content

Add a Hadamard matrix of order 2060 - #42876

Merged
vbraun merged 6 commits into
sagemath:developfrom
dimpase:hadamard-2060
Oct 3, 2026
Merged

vbraun merged 6 commits into
sagemath:developfrom
dimpase:hadamard-2060

Conversation

@dimpase

@dimpase dimpase commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Summary

Add the Hadamard matrix of order 2060 using the orbit seed and Williamson quadruple from schneiderlo/hadamard-2060. The existing Cooper–Wallis constructor expands these data; the explicit matrix is not stored in Sage.

matrix.hadamard(2060) now constructs a normalized matrix, and the existence and construction-name queries recognize the order.

The doctests keep quick existence and construction-name checks. Full construction and normalized orthogonality checks for both the general and Cooper–Wallis entry points live in a parameterized pytest test marked longlong, following the existing graph-generator test convention. This removes the two expensive order-2060 constructions from doctest runs.

Verification

  • Both longlong pytest cases pass locally (about 34 seconds combined on macOS arm64).
  • All 10 Cooper–Wallis small-cases doctests pass; both order-2060 general-constructor query doctests pass. One unchanged order-668 doctest could not complete because this environment lacks the optional graph database.
  • Ruff and git diff --check pass.
  • Local runtime checks use the existing compiled Sage libraries, with the updated module loaded from this worktree; the editable environment could not rebuild automatically.

Fixes #42875.

Use the orbit seed and Williamson quadruple from schneiderlo/hadamard-2060 with the existing Cooper-Wallis construction. Expose the order through matrix.hadamard and test existence, construction name, and orthogonality.

Co-authored-by: Codex <codex@openai.com>
dimpase and others added 3 commits September 30, 2026 10:36
Show the matrix.hadamard(2060) entry point in examples, test the direct constructor separately, and name the author of the construction.

Co-authored-by: Codex <codex@openai.com>
Restore the description of the Cooper-Wallis construction and credit Loïc Schneider specifically for finding the input sequences and Williamson quadruple.

Co-authored-by: Codex <codex@openai.com>
Decode Loïc Schneider’s length-103 sequence seed in the existing small-cases constructor and reuse its order-5 Williamson quadruple. The generic Hadamard constructor now discovers order 2060 through the normal Cooper-Wallis path.

Co-authored-by: Codex <codex@openai.com>
@dimpase

dimpase commented Sep 30, 2026

Copy link
Copy Markdown
Member Author

@schneiderlo - your construction is being added to Sage here.

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Documentation preview for this PR (built with commit ca5c3dc; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@orlitzky

Copy link
Copy Markdown
Contributor

(Sorry @vbraun)

Even though the construction is now published and there are not too many ways to do the same thing, we should get confirmation from @schneiderlo before taking his code?

@dimpase

dimpase commented Sep 30, 2026 •

Copy link
Copy Markdown
Member Author

@orlitzky it's all done with blessings by @schneiderlo, we have been in email contact, and planning to write a joint note on this. It was an AI-assisted discovery, which I then was able to unroll into a small addition to our source code.

@orlitzky

orlitzky commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

The construction itself takes a very long time and adds two new "slow doctest" warnings to the CI. To avoid this I would recommend something like what I did in https://github.com/sagemath/sage/blob/develop/src/sage/graphs/generators/distance_regular.pyx#L540

I made some slight modifications to the files, and the construction takes 20 minutes on my machine:

$ time sage hadamard_2060.sage 
done, rows=2060, cols=2060

real	20m5.571s
user	4m44.476s
sys	16m41.562s

If I instead pickle a list of list of python ints and xz them, then decompressing, unpickling, and constructing a matrix from them takes only 16s:

$ time sage load-pickled.py 
done, rows=2060, cols=2060

real	0m16.106s
user	0m14.624s
sys	0m1.478s

(The compressed data file is only 106K, not 15M.)

Obviously we do still want to test the construction, but this can be done in pytest with a "longlong" marker so that it is only run by the CI, as in https://github.com/sagemath/sage/blob/develop/src/sage/graphs/generators/generators_test.py

@orlitzky

Copy link
Copy Markdown
Contributor

@orlitzky it's all done with blessings by @schneiderlo, we have been in email contact, and planning to write a joint note on this. It was an AI-assisted discovery, which I then was able to unroll into a small addition to our source code.

Ok, thanks, I just didn't see a license in the repo and was worried.

@schneiderlo

Copy link
Copy Markdown

Yes we had an email exchange, if needed I can add a license to my repo if needed (would MIT be ok? Or something else?) .

@dimpase

dimpase commented Sep 30, 2026

Copy link
Copy Markdown
Member Author

Yes we had an email exchange, if needed I can add a license to my repo if needed (would MIT be ok? Or something else?) .

MIT, or a 3-clause BSD, or anything GPL-compatible will be fine.

@orlitzky

Copy link
Copy Markdown
Contributor

Thanks, the license was the blocker, you can put back the positive review but know that it will add to my ongoing struggle to get the CI passing without warnings :)

@dimpase you may be interested in #42768 as one of the few macOS users I know

@dimpase

dimpase commented Sep 30, 2026

Copy link
Copy Markdown
Member Author

@orlitzky - I just asked Codex 🤖 to help your troubles, so now you should review the update...

@dimpase
dimpase requested a review from orlitzky September 30, 2026 23:42
@orlitzky

orlitzky commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Thanks, it looks good to me if the CI passes (all jobs are currently queued). I can pickle the rows to speed up the method itself later on.

@orlitzky

orlitzky commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

As soon as I walked away, one more minor thing came to mind: the new hadamard_matrix_test.py should be added to py.install_sources(...) in src/sage/combinat/matrices/meson.build.

I don't remember why, but someone once decided that the pytest files should be installed. AFAIK all of the others are.

@dimpase

dimpase commented Oct 1, 2026

Copy link
Copy Markdown
Member Author

As soon as I walked away, one more minor thing came to mind: the new hadamard_matrix_test.py should be added to py.install_sources(...) in src/sage/combinat/matrices/meson.build.

I don't remember why, but someone once decided that the pytest files should be installed. AFAIK all of the others are.

done.

@schneiderlo

schneiderlo commented Oct 1, 2026 •

Copy link
Copy Markdown

I have updated the repo schneiderlo/hadamard-2060 and it is now MIT

@orlitzky

orlitzky commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

I think two days is long enough to wait for the CI to finish, setting back to positive.

vbraun pushed a commit to vbraun/sage that referenced this pull request Oct 3, 2026
Release Manager
sagemathgh-42876: Add a Hadamard matrix of order 2060
    
## Summary

Add the Hadamard matrix of order 2060 using the orbit seed and
Williamson quadruple from [schneiderlo/hadamard-
2060](https://github.com/schneiderlo/hadamard-2060). The existing
Cooper–Wallis constructor expands these data; the explicit matrix is not
stored in Sage.

`matrix.hadamard(2060)` now constructs a normalized matrix, and the
existence and construction-name queries recognize the order.

The doctests keep quick existence and construction-name checks. Full
construction and normalized orthogonality checks for both the general
and Cooper–Wallis entry points live in a parameterized pytest test
marked `longlong`, following the existing graph-generator test
convention. This removes the two expensive order-2060 constructions from
doctest runs.

## Verification

- Both `longlong` pytest cases pass locally (about 34 seconds combined
on macOS arm64).
- All 10 Cooper–Wallis small-cases doctests pass; both order-2060
general-constructor query doctests pass. One unchanged order-668 doctest
could not complete because this environment lacks the optional graph
database.
- Ruff and `git diff --check` pass.
- Local runtime checks use the existing compiled Sage libraries, with
the updated module loaded from this worktree; the editable environment
could not rebuild automatically.

Fixes sagemath#42875.
    
URL: sagemath#42876
Reported by: Dima Pasechnik
Reviewer(s): Michael Orlitzky
@vbraun
vbraun merged commit 8f0daf8 into sagemath:develop Oct 3, 2026
24 of 36 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.

add the construction of a Hadamard matrix of order 2060

4 participants