# cran/chngpt architecture

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

- Interactive diagram: https://gitdiagram.com/cran/chngpt
- Repository: https://github.com/cran/chngpt

## Overview

chngpt is an R package for change-point modeling and inference, with R-facing model, test, simulation, and performance modules and a substantial C++ numerical backend. The tree suggests the user workflow begins with model fitting or a test and may continue to inference or simulation, but the README excerpt does not document these flows and the R sources were not sampled, so those connections are omitted. The graph preserves the visible C++ engine/helper relationship and groups the core numerical headers; unsampled R capabilities are represented without guessed wiring.

Main entry points: [`src/fastgrid_helper.h`](https://github.com/cran/chngpt/blob/master/src/fastgrid_helper.h) (Search helper interface), [`src/matrix.h`](https://github.com/cran/chngpt/blob/master/src/matrix.h) (Matrix storage and views), [`src/ide.h`](https://github.com/cran/chngpt/blob/master/src/ide.h) (Matrix solvers), [`src/la.h`](https://github.com/cran/chngpt/blob/master/src/la.h) (Linear algebra)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_r_api["R interfaces"]
  node_fit["Change-point models<br/>[chngptm.R]"]
  node_hinge["Hinge models<br/>[double.hinge.R]"]
end

subgraph group_inference["Inference and simulation"]
  node_tests["Change-point tests<br/>[chngpt.test.R]"]
  node_tests2["Two-stage tests<br/>[chngpt.test.2.R]"]
  node_hingetest["Hinge tests<br/>[hinge.test.R]"]
  node_antoch["Antoch test<br/>[antoch.test.R]"]
  node_performance["Performance measures<br/>[performance.R]"]
  node_simchngpt["Model simulations<br/>[sim.chngpt.R]"]
  node_simhinge["Hinge simulations<br/>[sim.hinge.R]"]
  node_simulations["Simulation utilities<br/>[simulations.R]"]
end

subgraph group_cpp_engine["C++ search engine"]
  node_engine["Grid search routines<br/>[fastgrid2.cc]"]
  node_engine_variants["Search variants"]
  node_engine_helper["Search helper interface<br/>[fastgrid_helper.h]"]
end

subgraph group_numerics["Numerical foundations"]
  node_matrix["Matrix storage and views<br/>[matrix.h]"]
  node_iterators["Matrix iterators"]
  node_data_block["Matrix data blocks<br/>[datablock.h]"]
  node_algorithms["Matrix algorithms<br/>[algorithm.h]"]
  node_linear_algebra["Linear algebra<br/>[la.h]"]
  node_solvers["Matrix solvers<br/>[ide.h]"]
  node_distributions["Probability distributions<br/>[distributions.h]"]
  node_random["Random variates<br/>[rng.h]"]
  node_statistics["Matrix statistics<br/>[stat.h]"]
  node_math["Scalar and matrix math<br/>[smath.h]"]
  node_lapack["LAPACK interface<br/>[lapack.h]"]
  node_errors["Error handling<br/>[error.h]"]
  node_definitions["Core definitions<br/>[defs.h]"]
end

node_user(("R package user"))

node_engine -->|"uses declarations"| node_engine_helper
node_engine_variants -->|"uses declarations"| node_engine_helper
node_matrix -->|"uses storage"| node_data_block
node_matrix -->|"uses iterators"| node_iterators
node_algorithms -->|"operates on"| node_matrix
node_linear_algebra -->|"operates on"| node_matrix
node_solvers -->|"operates on"| node_matrix
node_engine_helper -->|"uses matrices"| node_matrix
node_engine_helper -->|"uses distributions"| node_distributions
node_engine_helper -->|"uses statistics"| node_statistics
node_engine_helper -->|"uses operations"| node_linear_algebra
node_engine_helper -->|"uses solvers"| node_solvers
node_engine_helper -->|"uses functions"| node_math
node_random -->|"uses distribution functions"| node_distributions
node_matrix -->|"uses definitions"| node_definitions
node_matrix -->|"uses checks"| node_errors
node_linear_algebra -->|"uses solvers"| node_solvers
node_solvers -->|"calls routines"| node_lapack

click node_fit "https://github.com/cran/chngpt/blob/master/R/chngptm.R"
click node_hinge "https://github.com/cran/chngpt/blob/master/R/double.hinge.R"
click node_tests "https://github.com/cran/chngpt/blob/master/R/chngpt.test.R"
click node_tests2 "https://github.com/cran/chngpt/blob/master/R/chngpt.test.2.R"
click node_hingetest "https://github.com/cran/chngpt/blob/master/R/hinge.test.R"
click node_antoch "https://github.com/cran/chngpt/blob/master/R/antoch.test.R"
click node_performance "https://github.com/cran/chngpt/blob/master/R/performance.R"
click node_simchngpt "https://github.com/cran/chngpt/blob/master/R/sim.chngpt.R"
click node_simhinge "https://github.com/cran/chngpt/blob/master/R/sim.hinge.R"
click node_simulations "https://github.com/cran/chngpt/blob/master/R/simulations.R"
click node_engine "https://github.com/cran/chngpt/blob/master/src/fastgrid2.cc"
click node_engine_variants "https://github.com/cran/chngpt/tree/master/src"
click node_engine_helper "https://github.com/cran/chngpt/blob/master/src/fastgrid_helper.h"
click node_matrix "https://github.com/cran/chngpt/blob/master/src/matrix.h"
click node_iterators "https://github.com/cran/chngpt/blob/master/src/matrix_random_access_iterator.h"
click node_data_block "https://github.com/cran/chngpt/blob/master/src/datablock.h"
click node_algorithms "https://github.com/cran/chngpt/blob/master/src/algorithm.h"
click node_linear_algebra "https://github.com/cran/chngpt/blob/master/src/la.h"
click node_solvers "https://github.com/cran/chngpt/blob/master/src/ide.h"
click node_distributions "https://github.com/cran/chngpt/blob/master/src/distributions.h"
click node_random "https://github.com/cran/chngpt/blob/master/src/rng.h"
click node_statistics "https://github.com/cran/chngpt/blob/master/src/stat.h"
click node_math "https://github.com/cran/chngpt/blob/master/src/smath.h"
click node_lapack "https://github.com/cran/chngpt/blob/master/src/lapack.h"
click node_errors "https://github.com/cran/chngpt/blob/master/src/error.h"
click node_definitions "https://github.com/cran/chngpt/blob/master/src/defs.h"

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_fit,node_hinge,node_user toneBlue
class node_tests,node_tests2,node_hingetest,node_antoch,node_performance,node_simchngpt,node_simhinge,node_simulations toneAmber
class node_engine,node_engine_variants,node_engine_helper toneMint
class node_matrix,node_iterators,node_data_block,node_algorithms,node_linear_algebra,node_solvers,node_distributions,node_random,node_statistics,node_math,node_lapack,node_errors,node_definitions toneRose
```

## Components

### R interfaces

- [Change-point models](https://github.com/cran/chngpt/blob/master/R/chngptm.R): `R/chngptm.R`
- [Hinge models](https://github.com/cran/chngpt/blob/master/R/double.hinge.R): `R/double.hinge.R`

### Inference and simulation

- [Change-point tests](https://github.com/cran/chngpt/blob/master/R/chngpt.test.R): `R/chngpt.test.R`
- [Two-stage tests](https://github.com/cran/chngpt/blob/master/R/chngpt.test.2.R): `R/chngpt.test.2.R`
- [Hinge tests](https://github.com/cran/chngpt/blob/master/R/hinge.test.R): `R/hinge.test.R`
- [Antoch test](https://github.com/cran/chngpt/blob/master/R/antoch.test.R): `R/antoch.test.R`
- [Performance measures](https://github.com/cran/chngpt/blob/master/R/performance.R): `R/performance.R`
- [Model simulations](https://github.com/cran/chngpt/blob/master/R/sim.chngpt.R): `R/sim.chngpt.R`
- [Hinge simulations](https://github.com/cran/chngpt/blob/master/R/sim.hinge.R): `R/sim.hinge.R`
- [Simulation utilities](https://github.com/cran/chngpt/blob/master/R/simulations.R): `R/simulations.R`

### C++ search engine

- [Grid search routines](https://github.com/cran/chngpt/blob/master/src/fastgrid2.cc): `src/fastgrid2.cc`
- [Search variants](https://github.com/cran/chngpt/tree/master/src): `src`
- [Search helper interface](https://github.com/cran/chngpt/blob/master/src/fastgrid_helper.h): `src/fastgrid_helper.h`

### Numerical foundations

- [Matrix storage and views](https://github.com/cran/chngpt/blob/master/src/matrix.h): `src/matrix.h`
- [Matrix iterators](https://github.com/cran/chngpt/blob/master/src/matrix_random_access_iterator.h): `src/matrix_random_access_iterator.h`
- [Matrix data blocks](https://github.com/cran/chngpt/blob/master/src/datablock.h): `src/datablock.h`
- [Matrix algorithms](https://github.com/cran/chngpt/blob/master/src/algorithm.h): `src/algorithm.h`
- [Linear algebra](https://github.com/cran/chngpt/blob/master/src/la.h): `src/la.h`
- [Matrix solvers](https://github.com/cran/chngpt/blob/master/src/ide.h): `src/ide.h`
- [Probability distributions](https://github.com/cran/chngpt/blob/master/src/distributions.h): `src/distributions.h`
- [Random variates](https://github.com/cran/chngpt/blob/master/src/rng.h): `src/rng.h`
- [Matrix statistics](https://github.com/cran/chngpt/blob/master/src/stat.h): `src/stat.h`
- [Scalar and matrix math](https://github.com/cran/chngpt/blob/master/src/smath.h): `src/smath.h`
- [LAPACK interface](https://github.com/cran/chngpt/blob/master/src/lapack.h): `src/lapack.h`
- [Error handling](https://github.com/cran/chngpt/blob/master/src/error.h): `src/error.h`
- [Core definitions](https://github.com/cran/chngpt/blob/master/src/defs.h): `src/defs.h`

### Other components

- **R package user**

## Connections

- Grid search routines → Search helper interface: uses declarations (evidence: `src/fastgrid2.cc`)
- Search variants → Search helper interface: uses declarations (evidence: `src/M10.cc`)
- Matrix storage and views → Matrix data blocks: uses storage (evidence: `src/matrix.h`)
- Matrix storage and views → Matrix iterators: uses iterators (evidence: `src/matrix.h`)
- Matrix algorithms → Matrix storage and views: operates on (evidence: `src/algorithm.h`)
- Linear algebra → Matrix storage and views: operates on (evidence: `src/la.h`)
- Matrix solvers → Matrix storage and views: operates on (evidence: `src/ide.h`)
- Search helper interface → Matrix storage and views: uses matrices (evidence: `src/fastgrid_helper.h`)
- Search helper interface → Probability distributions: uses distributions (evidence: `src/fastgrid_helper.h`)
- Search helper interface → Matrix statistics: uses statistics (evidence: `src/fastgrid_helper.h`)
- Search helper interface → Linear algebra: uses operations (evidence: `src/fastgrid_helper.h`)
- Search helper interface → Matrix solvers: uses solvers (evidence: `src/fastgrid_helper.h`)
- Search helper interface → Scalar and matrix math: uses functions (evidence: `src/fastgrid_helper.h`)
- Random variates → Probability distributions: uses distribution functions (evidence: `src/rng.h`)
- Matrix storage and views → Core definitions: uses definitions (evidence: `src/matrix.h`)
- Matrix storage and views → Error handling: uses checks (evidence: `src/matrix.h`)
- Linear algebra → Matrix solvers: uses solvers (evidence: `src/la.h`)
- Matrix solvers → LAPACK interface: calls routines (evidence: `src/ide.h`)
