# sachit-juneja/mactensor architecture

> Architecture diagram of the GitHub repository sachit-juneja/mactensor, 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/sachit-juneja/mactensor
- Repository: https://github.com/sachit-juneja/mactensor

## Overview

MacTensor is a C++ machine-learning library: callers provide matrices and use its linear-algebra core, classical supervised and unsupervised algorithms, or neural-network APIs to fit models and make predictions. The README describes these as the library’s principal capabilities; the source index and excerpts support the shown module dependencies, but not every internal call. `src/main.cpp` is a diagnostics executable rather than a general user-facing workflow.

Main entry points: [`src/main.cpp`](https://github.com/sachit-juneja/mactensor/blob/main/src/main.cpp) (Diagnostics runner), [`src/dl/engine.cpp`](https://github.com/sachit-juneja/mactensor/blob/main/src/dl/engine.cpp) (Autograd engine), [`src/ml/decision_tree.cpp`](https://github.com/sachit-juneja/mactensor/blob/main/src/ml/decision_tree.cpp) (Decision trees), [`src/ml/kmeans.cpp`](https://github.com/sachit-juneja/mactensor/blob/main/src/ml/kmeans.cpp) (K-Means)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Linear Algebra Core"]
  node_matrix["Matrix operations<br/>[matrix.cpp]"]
  node_diagnostics["Diagnostics runner<br/>[main.cpp]"]
end

subgraph group_supervised["Supervised Learning"]
  node_linear["Linear regression"]
  node_logistic["Logistic regression"]
  node_tree["Decision trees<br/>[decision_tree.cpp]"]
  node_boosting["Gradient boosting"]
end

subgraph group_unsupervised["Unsupervised Learning"]
  node_kmeans["K-Means<br/>[kmeans.cpp]"]
  node_gmm["Gaussian mixtures<br/>[gmm.cpp]"]
  node_pca["PCA<br/>[pca.cpp]"]
end

subgraph group_dl["Deep Learning"]
  node_autograd["Autograd engine<br/>[engine.cpp]"]
  node_layers["Neural layers<br/>[layers.cpp]"]
  node_mlp["MLP model<br/>[model.cpp]"]
  node_optimizers["Optimizers<br/>[optimizers.cpp]"]
end

node_caller(("Library caller"))

node_caller -->|"uses"| node_matrix
node_caller -->|"fits and predicts"| node_linear
node_caller -->|"fits and predicts"| node_logistic
node_caller -->|"fits and predicts"| node_tree
node_caller -->|"fits and predicts"| node_boosting
node_caller -->|"clusters data"| node_kmeans
node_caller -->|"fits mixtures"| node_gmm
node_caller -->|"projects data"| node_pca
node_caller -->|"builds network"| node_mlp
node_matrix -->|"provides matrix type"| node_autograd
node_autograd -->|"supports layers"| node_layers
node_layers -->|"composes layers"| node_mlp
node_autograd -->|"updates values"| node_optimizers
node_tree -->|"supplies weak learners"| node_boosting
node_kmeans -->|"initializes clusters"| node_gmm
node_diagnostics -->|"tests regression"| node_linear
node_diagnostics -->|"tests trees"| node_tree
node_diagnostics -->|"tests boosting"| node_boosting
node_diagnostics -->|"tests clustering"| node_kmeans
node_diagnostics -->|"tests projection"| node_pca
node_diagnostics -->|"tests mixtures"| node_gmm

click node_matrix "https://github.com/sachit-juneja/mactensor/blob/main/src/core/matrix.cpp"
click node_diagnostics "https://github.com/sachit-juneja/mactensor/blob/main/src/main.cpp"
click node_linear "https://github.com/sachit-juneja/mactensor/blob/main/src/ml/linear_regression.cpp"
click node_logistic "https://github.com/sachit-juneja/mactensor/blob/main/src/ml/logistic_regression.cpp"
click node_tree "https://github.com/sachit-juneja/mactensor/blob/main/src/ml/decision_tree.cpp"
click node_boosting "https://github.com/sachit-juneja/mactensor/blob/main/src/ml/gradient_boosting.cpp"
click node_kmeans "https://github.com/sachit-juneja/mactensor/blob/main/src/ml/kmeans.cpp"
click node_gmm "https://github.com/sachit-juneja/mactensor/blob/main/src/ml/gmm.cpp"
click node_pca "https://github.com/sachit-juneja/mactensor/blob/main/src/ml/pca.cpp"
click node_autograd "https://github.com/sachit-juneja/mactensor/blob/main/src/dl/engine.cpp"
click node_layers "https://github.com/sachit-juneja/mactensor/blob/main/src/dl/layers.cpp"
click node_mlp "https://github.com/sachit-juneja/mactensor/blob/main/src/dl/model.cpp"
click node_optimizers "https://github.com/sachit-juneja/mactensor/blob/main/src/dl/optimizers.cpp"

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_matrix,node_diagnostics toneBlue
class node_linear,node_logistic,node_tree,node_boosting toneAmber
class node_kmeans,node_gmm,node_pca toneMint
class node_autograd,node_layers,node_mlp,node_optimizers toneRose
class node_caller toneIndigo
```

## Components

### Linear Algebra Core

- [Matrix operations](https://github.com/sachit-juneja/mactensor/blob/main/src/core/matrix.cpp): `src/core/matrix.cpp`
- [Diagnostics runner](https://github.com/sachit-juneja/mactensor/blob/main/src/main.cpp): `src/main.cpp`

### Supervised Learning

- [Linear regression](https://github.com/sachit-juneja/mactensor/blob/main/src/ml/linear_regression.cpp): `src/ml/linear_regression.cpp`
- [Logistic regression](https://github.com/sachit-juneja/mactensor/blob/main/src/ml/logistic_regression.cpp): `src/ml/logistic_regression.cpp`
- [Decision trees](https://github.com/sachit-juneja/mactensor/blob/main/src/ml/decision_tree.cpp): `src/ml/decision_tree.cpp`
- [Gradient boosting](https://github.com/sachit-juneja/mactensor/blob/main/src/ml/gradient_boosting.cpp): `src/ml/gradient_boosting.cpp`

### Unsupervised Learning

- [K-Means](https://github.com/sachit-juneja/mactensor/blob/main/src/ml/kmeans.cpp): `src/ml/kmeans.cpp`
- [Gaussian mixtures](https://github.com/sachit-juneja/mactensor/blob/main/src/ml/gmm.cpp): `src/ml/gmm.cpp`
- [PCA](https://github.com/sachit-juneja/mactensor/blob/main/src/ml/pca.cpp): `src/ml/pca.cpp`

### Deep Learning

- [Autograd engine](https://github.com/sachit-juneja/mactensor/blob/main/src/dl/engine.cpp): `src/dl/engine.cpp`
- [Neural layers](https://github.com/sachit-juneja/mactensor/blob/main/src/dl/layers.cpp): `src/dl/layers.cpp`
- [MLP model](https://github.com/sachit-juneja/mactensor/blob/main/src/dl/model.cpp): `src/dl/model.cpp`
- [Optimizers](https://github.com/sachit-juneja/mactensor/blob/main/src/dl/optimizers.cpp): `src/dl/optimizers.cpp`

### Other components

- **Library caller**

## Connections

- Library caller → Matrix operations: uses (evidence: `README.md`)
- Library caller → Linear regression: fits and predicts (evidence: `README.md`)
- Library caller → Logistic regression: fits and predicts (evidence: `README.md`)
- Library caller → Decision trees: fits and predicts (evidence: `README.md`)
- Library caller → Gradient boosting: fits and predicts (evidence: `README.md`)
- Library caller → K-Means: clusters data (evidence: `README.md`)
- Library caller → Gaussian mixtures: fits mixtures (evidence: `README.md`)
- Library caller → PCA: projects data (evidence: `README.md`)
- Library caller → MLP model: builds network (evidence: `README.md`)
- Matrix operations → Autograd engine: provides matrix type
- Autograd engine → Neural layers: supports layers
- Neural layers → MLP model: composes layers
- Autograd engine → Optimizers: updates values
- Decision trees → Gradient boosting: supplies weak learners
- K-Means → Gaussian mixtures: initializes clusters (evidence: `src/ml/gmm.cpp`)
- Diagnostics runner → Linear regression: tests regression (evidence: `src/main.cpp`)
- Diagnostics runner → Decision trees: tests trees (evidence: `src/main.cpp`)
- Diagnostics runner → Gradient boosting: tests boosting (evidence: `src/main.cpp`)
- Diagnostics runner → K-Means: tests clustering (evidence: `src/main.cpp`)
- Diagnostics runner → PCA: tests projection (evidence: `src/main.cpp`)
- Diagnostics runner → Gaussian mixtures: tests mixtures (evidence: `src/main.cpp`)
