{"id":35212176,"url":"https://github.com/math-hiyoko/wavelet-matrix","last_synced_at":"2026-03-16T06:31:13.686Z","repository":{"id":328062183,"uuid":"1110929476","full_name":"math-hiyoko/wavelet-matrix","owner":"math-hiyoko","description":"wavelet-matrix library for Python","archived":false,"fork":false,"pushed_at":"2026-03-15T13:01:20.000Z","size":285,"stargazers_count":39,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-16T02:34:29.550Z","etag":null,"topics":["algorithms","pypi-package","python","range-query","wavelet-matrix"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/wavelet-matrix","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/math-hiyoko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-06T00:13:16.000Z","updated_at":"2026-03-15T12:57:01.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/math-hiyoko/wavelet-matrix","commit_stats":null,"previous_names":["math-hiyoko/wavelet-matrix"],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/math-hiyoko/wavelet-matrix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/math-hiyoko%2Fwavelet-matrix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/math-hiyoko%2Fwavelet-matrix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/math-hiyoko%2Fwavelet-matrix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/math-hiyoko%2Fwavelet-matrix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/math-hiyoko","download_url":"https://codeload.github.com/math-hiyoko/wavelet-matrix/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/math-hiyoko%2Fwavelet-matrix/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30570734,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-16T06:02:37.763Z","status":"ssl_error","status_checked_at":"2026-03-16T06:02:14.913Z","response_time":96,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["algorithms","pypi-package","python","range-query","wavelet-matrix"],"created_at":"2025-12-29T19:25:05.623Z","updated_at":"2026-03-16T06:31:13.671Z","avatar_url":"https://github.com/math-hiyoko.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wavelet Matrix\n\n[![CI](https://github.com/math-hiyoko/wavelet-matrix/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/math-hiyoko/wavelet-matrix/actions/workflows/CI.yml)\n[![codecov](https://codecov.io/gh/math-hiyoko/wavelet-matrix/graph/badge.svg?token=TXBR7MF2CP)](https://codecov.io/gh/math-hiyoko/wavelet-matrix)\n![PyPI - Version](https://img.shields.io/pypi/v/wavelet-matrix)\n![PyPI - License](https://img.shields.io/pypi/l/wavelet-matrix)\n![PyPI - PythonVersion](https://img.shields.io/pypi/pyversions/wavelet-matrix)\n![PyPI - Implementation](https://img.shields.io/pypi/implementation/wavelet-matrix)\n![PyPI - Types](https://img.shields.io/pypi/types/wavelet-matrix)\n[![PyPI Downloads](https://static.pepy.tech/personalized-badge/wavelet-matrix?period=total\u0026units=INTERNATIONAL_SYSTEM\u0026left_color=GRAY\u0026right_color=GREEN\u0026left_text=PyPI%20downloads)](https://pepy.tech/projects/wavelet-matrix)\n![PyPI - Format](https://img.shields.io/pypi/format/wavelet-matrix)\n![Rust](https://img.shields.io/badge/powered%20by-Rust-orange)\n![Unsafe](https://img.shields.io/badge/unsafe-0-success)\n![GitHub Repo stars](https://img.shields.io/github/stars/math-hiyoko/wavelet-matrix)\n\n\nHigh-performance Wavelet Matrix implementation powered by Rust,  \nsupporting fast rank / select / range queries over indexed sequences  \n\n- PyPI: https://pypi.org/project/wavelet-matrix\n- Document: https://math-hiyoko.github.io/wavelet-matrix\n- Repository: https://github.com/math-hiyoko/wavelet-matrix\n\n## Features:\n- Fast rank, select, quantile\n- Rich range queries (freq / sum / top-k / min / max)\n- Optional dynamic updates (insert / remove / update)\n- Safe Rust (no unsafe)\n\n## Installation\n```bash\npip install wavelet-matrix\n```\n\n## WaveletMatrix\nWaveletMatrix indexes a static sequence of integers,  \nenabling fast queries where runtime depends on bit-width, not data size.\n```python\nfrom wavelet_matrix import WaveletMatrix\n\ndata = [5, 4, 5, 5, 2, 1, 5, 6, 1, 3, 5, 0]\nwm = WaveletMatrix(data)\n```\n\n### Frequency Queries\n#### Count occurrences (rank)\n```python\nwm.rank(value=5, end=9)\n# 4\n```\n\n#### Find position (select)\n```python\nwm.select(value=5, kth=4)\n# 6\n```\n\n### Order Statistics\n#### k-th smallest value (quantile)\n```python\nwm.quantile(start=2, end=12, kth=8)\n# 5\n```\n\n### Range Aggregation\n#### Sum values (range_sum)\n```python\nwm.range_sum(start=2, end=8)\n# 24\n```\n\n#### Count values in [lower, upper) (range_freq)\n```python\nwm.range_freq(start=1, end=9, lower=4, upper=6)\n# 4\n```\n\n#### List values with counts (range_list)\n```python\nwm.range_list(start=1, end=9, lower=4, upper=6)\n# [{'value': 4, 'count': 1}, {'value': 5, 'count': 3}]\n```\n\n### Top-K Queries\n#### Most frequent values (topk)\n```python\nwm.topk(start=1, end=10, k=2)\n# [{'value': 5, 'count': 3}, {'value': 1, 'count': 2}]\n```\n\n#### Extreme values (range_maxk / range_mink)\n```python\nwm.range_maxk(start=1, end=9, k=2)\n# [{'value': 6, 'count': 1}, {'value': 5, 'count': 3}]\nwm.range_mink(start=1, end=9, k=2)\n# [{'value': 1, 'count': 2}, {'value': 2, 'count': 1}]\n```\n\n### Boundary Queries\n```python\nwm.prev_value(start=1, end=9, upper=7)\n# 6\nwm.next_value(start=1, end=9, lower=4)\n# 4\n```\n\n## DynamicWaveletMatrix\nDynamicWaveletMatrix supports mutable sequences with insert/remove/update.\n\n### Trade-off:\n- Higher overhead\n- Values must fit within max_bit\n\n```python\nfrom wavelet_matrix import DynamicWaveletMatrix\n\ndwm = DynamicWaveletMatrix(data, max_bit=4)\n```\n\n### Insert\n```python\ndwm.insert(index=4, value=8)\n```\n\n#### Remove\n```python\ndwm.remove(index=4)\n```\n\n#### Update\n```python\ndwm.update(index=4, value=5)\n# or dwm[4] = 5\n```\n\n## Safety\n- Powered by safe Rust\n- Memory-safe by design\n\n## Development\n\n### Running Tests\n\n```bash\npip install -e \".[test]\"\ncargo test --all --release\npytest\n```\n\n### Formating Code\n```bash\npip install -e \".[dev]\"\ncargo fmt\nruff format\n```\n\n### Generating Docs\n```bash\npdoc wavelet_matrix \\\n      --output-directory docs \\\n      --no-search \\\n      --docformat markdown \\\n      --template-directory pdoc_templates\n```\n\n## References\n\n- Francisco Claude, Gonzalo Navarro, Alberto Ordóñez,  \n  The wavelet matrix: An efficient wavelet tree for large alphabets,  \n  Information Systems,  \n  Volume 47,  \n  2015,  \n  Pages 15-32,  \n  ISSN 0306-4379,  \n  https://doi.org/10.1016/j.is.2014.06.002.  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmath-hiyoko%2Fwavelet-matrix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmath-hiyoko%2Fwavelet-matrix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmath-hiyoko%2Fwavelet-matrix/lists"}