# marouane-35/scalable_gp architecture

> Architecture diagram of the GitHub repository marouane-35/scalable_gp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/marouane-35/scalable_gp
- Repository: https://github.com/marouane-35/scalable_gp

## Overview

h2pack-gp is a Python interface to a modified C H2Pack library for compressing kernel matrices in high-dimensional Gaussian-process workloads. The main workflow is to supply point coordinates and a kernel, build a hierarchical matrix, then use its fast matrix-vector product for computations such as Gaussian sampling; the wrapper also exposes approximation-error and memory statistics. Internally, tree partitioning and sampled-point basis construction produce the compressed representation. The README documents the high-level workflow and options; some library branches are included based on the source index, but their call details were not sampled.

Main entry points: [`H2Pack-master/pyh2pack/pyh2pack.c`](https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/pyh2pack/pyh2pack.c) (Python binding), [`h2pack_gp.py`](https://github.com/marouane-35/scalable_gp/blob/main/h2pack_gp.py) (Python API), [`H2Pack-master/src/H2Pack_build_with_sample_point.c`](https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/H2Pack_build_with_sample_point.c) (Sample-point build), [`H2Pack-master/src/H2Pack_matvec.c`](https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/H2Pack_matvec.c) (H² matvec)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_python["Python interface"]
  node_points["Point datasets<br/>[data.py]"]
  node_api["Python API<br/>[h2pack_gp.py]"]
  node_binding["Python binding<br/>[pyh2pack.c]"]
  node_diagnostics["Error and memory<br/>[h2pack_gp.py]"]
end

subgraph group_matrix["H² construction"]
  node_kernels["Kernel functions<br/>[pyh2pack_kernel.h]"]
  node_partition["Tree partitioning<br/>[H2Pack_partition.c]"]
  node_samplebuild["Sample-point build"]
  node_classicbuild["Classic H² build<br/>[H2Pack_build.c]"]
  node_compression["ID compression"]
end

subgraph group_compute["Matrix operations"]
  node_matvec["H² matvec<br/>[H2Pack_matvec.c]"]
  node_matmul["H² matmul<br/>[H2Pack_matmul.c]"]
  node_sampling["Gaussian sampling<br/>[h2pack_gp.py]"]
  node_hss["HSS conversion<br/>[H2Pack_SPDHSS_H2.c]"]
  node_ulv["HSS ULV solve<br/>[H2Pack_HSS_ULV.c]"]
  node_precond["AFN preconditioner<br/>[AFN_precond.c]"]
  node_periodic["Periodic operations"]
end

subgraph group_library["H2Pack internals"]
  node_h2state["H² matrix state"]
  node_simd["SIMD kernel layer<br/>[aster.h]"]
  node_fileio["Matrix file I/O<br/>[H2Pack_file_IO.c]"]
end

node_user(("Python caller"))

node_user -->|"selects data"| node_points
node_user -->|"calls build"| node_api
node_points -->|"supplies coordinates"| node_api
node_api -->|"creates H2Mat"| node_binding
node_binding -->|"builds matrix"| node_samplebuild
node_binding -.->|"selects build path"| node_classicbuild
node_samplebuild -->|"uses partitioning"| node_partition
node_classicbuild -->|"uses partitioning"| node_partition
node_samplebuild -->|"uses compression"| node_compression
node_samplebuild -.->|"evaluates kernel"| node_kernels
node_classicbuild -.->|"evaluates kernel"| node_kernels
node_binding -->|"holds matrix state"| node_h2state
node_binding -.->|"dispatches product"| node_matvec
node_binding -.->|"dispatches product"| node_matmul
node_binding -->|"exposes statistics"| node_diagnostics
node_api -->|"calls matvec"| node_matvec
node_api -->|"computes sample"| node_sampling
node_sampling -->|"iterates products"| node_matvec
node_api -->|"reports quality"| node_diagnostics
node_hss -->|"reads H² structure"| node_h2state
node_ulv -->|"uses matrix state"| node_h2state
node_precond -->|"uses matrix state"| node_h2state
node_matvec -.->|"uses kernels"| node_simd

click node_points "https://github.com/marouane-35/scalable_gp/blob/main/hmbench/data.py"
click node_api "https://github.com/marouane-35/scalable_gp/blob/main/h2pack_gp.py"
click node_binding "https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/pyh2pack/pyh2pack.c"
click node_kernels "https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/pyh2pack/pyh2pack_kernel.h"
click node_partition "https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/H2Pack_partition.c"
click node_samplebuild "https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/H2Pack_build_with_sample_point.c"
click node_classicbuild "https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/H2Pack_build.c"
click node_compression "https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/H2Pack_ID_compress.c"
click node_h2state "https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/H2Pack_aux_structs.h"
click node_matvec "https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/H2Pack_matvec.c"
click node_matmul "https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/H2Pack_matmul.c"
click node_diagnostics "https://github.com/marouane-35/scalable_gp/blob/main/h2pack_gp.py"
click node_sampling "https://github.com/marouane-35/scalable_gp/blob/main/h2pack_gp.py"
click node_hss "https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/H2Pack_SPDHSS_H2.c"
click node_ulv "https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/H2Pack_HSS_ULV.c"
click node_precond "https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/AFN_precond.c"
click node_periodic "https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/H2Pack_matvec_periodic.c"
click node_simd "https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/ASTER/include/aster.h"
click node_fileio "https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/H2Pack_file_IO.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_points,node_api,node_binding,node_diagnostics toneBlue
class node_kernels,node_partition,node_samplebuild,node_classicbuild,node_compression toneAmber
class node_matvec,node_matmul,node_sampling,node_hss,node_ulv,node_precond,node_periodic toneMint
class node_h2state,node_simd,node_fileio toneRose
class node_user toneIndigo
```

## Components

### Python interface

- [Point datasets](https://github.com/marouane-35/scalable_gp/blob/main/hmbench/data.py): `hmbench/data.py`
- [Python API](https://github.com/marouane-35/scalable_gp/blob/main/h2pack_gp.py): `h2pack_gp.py`
- [Python binding](https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/pyh2pack/pyh2pack.c): `H2Pack-master/pyh2pack/pyh2pack.c`
- [Error and memory](https://github.com/marouane-35/scalable_gp/blob/main/h2pack_gp.py): `h2pack_gp.py`

### H² construction

- [Kernel functions](https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/pyh2pack/pyh2pack_kernel.h): `H2Pack-master/pyh2pack/pyh2pack_kernel.h`
- [Tree partitioning](https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/H2Pack_partition.c): `H2Pack-master/src/H2Pack_partition.c`
- [Sample-point build](https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/H2Pack_build_with_sample_point.c): `H2Pack-master/src/H2Pack_build_with_sample_point.c`
- [Classic H² build](https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/H2Pack_build.c): `H2Pack-master/src/H2Pack_build.c`
- [ID compression](https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/H2Pack_ID_compress.c): `H2Pack-master/src/H2Pack_ID_compress.c`

### Matrix operations

- [H² matvec](https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/H2Pack_matvec.c): `H2Pack-master/src/H2Pack_matvec.c`
- [H² matmul](https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/H2Pack_matmul.c): `H2Pack-master/src/H2Pack_matmul.c`
- [Gaussian sampling](https://github.com/marouane-35/scalable_gp/blob/main/h2pack_gp.py): `h2pack_gp.py`
- [HSS conversion](https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/H2Pack_SPDHSS_H2.c): `H2Pack-master/src/H2Pack_SPDHSS_H2.c`
- [HSS ULV solve](https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/H2Pack_HSS_ULV.c): `H2Pack-master/src/H2Pack_HSS_ULV.c`
- [AFN preconditioner](https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/AFN_precond.c): `H2Pack-master/src/AFN_precond.c`
- [Periodic operations](https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/H2Pack_matvec_periodic.c): `H2Pack-master/src/H2Pack_matvec_periodic.c`

### H2Pack internals

- [H² matrix state](https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/H2Pack_aux_structs.h): `H2Pack-master/src/H2Pack_aux_structs.h`
- [SIMD kernel layer](https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/ASTER/include/aster.h): `H2Pack-master/src/ASTER/include/aster.h`
- [Matrix file I/O](https://github.com/marouane-35/scalable_gp/blob/main/H2Pack-master/src/H2Pack_file_IO.c): `H2Pack-master/src/H2Pack_file_IO.c`

### Other components

- **Python caller**

## Connections

- Python caller → Point datasets: selects data
- Python caller → Python API: calls build
- Point datasets → Python API: supplies coordinates
- Python API → Python binding: creates H2Mat (evidence: `h2pack_gp.py`)
- Python binding → Sample-point build: builds matrix (evidence: `H2Pack-master/pyh2pack/pyh2pack.c`)
- Python binding → Classic H² build: selects build path
- Sample-point build → Tree partitioning: uses partitioning (evidence: `H2Pack-master/src/H2Pack_build_with_sample_point.c`)
- Classic H² build → Tree partitioning: uses partitioning (evidence: `H2Pack-master/src/H2Pack_build.c`)
- Sample-point build → ID compression: uses compression (evidence: `H2Pack-master/src/H2Pack_build_with_sample_point.c`)
- Sample-point build → Kernel functions: evaluates kernel
- Classic H² build → Kernel functions: evaluates kernel
- Python binding → H² matrix state: holds matrix state (evidence: `H2Pack-master/pyh2pack/pyh2pack.c`)
- Python binding → H² matvec: dispatches product
- Python binding → H² matmul: dispatches product
- Python binding → Error and memory: exposes statistics
- Python API → H² matvec: calls matvec
- Python API → Gaussian sampling: computes sample (evidence: `h2pack_gp.py`)
- Gaussian sampling → H² matvec: iterates products (evidence: `h2pack_gp.py`)
- Python API → Error and memory: reports quality (evidence: `h2pack_gp.py`)
- HSS conversion → H² matrix state: reads H² structure (evidence: `H2Pack-master/src/H2Pack_SPDHSS_H2.c`)
- HSS ULV solve → H² matrix state: uses matrix state (evidence: `H2Pack-master/src/H2Pack_HSS_ULV.c`)
- AFN preconditioner → H² matrix state: uses matrix state (evidence: `H2Pack-master/src/AFN_precond.c`)
- H² matvec → SIMD kernel layer: uses kernels
