Skip to content

manakcodes/matxlib-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

28 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

matxlib-cpp

matxlib-cpp

A lightweight, minimal C++ library for matrix abstractions, arithmetic, and analytical utilities.

πŸ“¦ About

matxlib-cpp is a header-only matrix library built in C++. It's written from scratch as a personal project to understand how such libraries work under the hood. It supports basic matrix creation, manipulation, and arithmetic, descriptive and statistical operations.

⚠️ NOTE : This library is made for learning purposes and doesn't guarantee high performance or full numerical stability like professional libraries.


πŸ“Œ Features

  • πŸ“ Matrix Construction: basic creation, initialization, and memory management
  • βž• Arithmetic Operations: element-wise and scalar operations (add, subtract, multiply, divide)
  • πŸ“Š Descriptive Statistics: mean, min, max, sum, and other aggregations
  • πŸ” Transformations: transpose, sparse matrix representation, etc.
  • 🧠 Utility Functions: clean utility wrappers, macros and ERROR_CODES.
  • πŸ–¨οΈ Input/Output: easy matrix display and input
  • πŸ“‚ Modular Design: every operation is split into clear, reusable headers
  • βš™οΈ Self-contained: no external dependencies

βš™οΈ Library Requirements

  • C++ Compiler with support for C++11 or higher (e.g., g++, clang++, or MSVC)
  • Make (optional) if using the provided Makefile
  • Git to clone the repository (or download ZIP manually)

No external libraries or dependencies are required β€” it’s built with standard C++ only.


πŸ—οΈ Tools And Tech Used:

g++ Git GitHub Bash VS Code Xcode


πŸ› οΈ Project Setup (First-Time Use):

  1. Open your terminal (or command prompt).

  2. Navigate to the directory where you want to place the project (e.g., Desktop).

    cd ~/Desktop
  3. Paste the following command in the terminal (or command prompt):

    git clone https://github.com/manakcodes/matxlib-cpp.git
  4. Include the following header in your C++ program to use the library (or adjust the path accordingly).

    #include "matxlib-cpp/matxlib.hpp"
  5. You can use the library in your C++ programs like you normally do in any code editor or IDE (e.g., VSCode, CLion, Vim, Atom etc.).


πŸ™ Every Time You Start a New Project:

After the first-time setup, follow these steps each time you use the library in a new C++ project:

  1. Make sure your project file (e.g., your_file.cpp) is in the same directory level or you correctly reference the path to the library (or adjust the path accordingly).

  2. Include the following header:

    #include "matxlib-cpp/matxlib.hpp"
  3. Compile with g++ or your preferred compiler. If needed, link any required flags or paths:

    g++ main.cpp -o main
    ./main
  4. You’re good to go !


πŸ“ EXAMPLES

#include "matxlib-cpp/matxlib.hpp"

int main() {
    size_t rows = 3;
    size_t cols = 3;
    MATRIX* m = new MATRIX(rows, cols);
    m->RandomizeMatrixInt(1, 10);
    m->PrintMatrix();
    delete m;
    return 0;
}
+------------+------------+------------+
| 5.0000     | 1.0000     | 6.0000     |
+------------+------------+------------+
| 5.0000     | 9.0000     | 6.0000     |
+------------+------------+------------+
| 7.0000     | 8.0000     | 10.0000    |
+------------+------------+------------+

more examples soon to be added in a dedicated examples/ folder.


❓ Why It Exists

I built matxlib-cpp simply because I wanted to create my own matrix library from scratch - as a fun learning project to explore C++ and better understand how things work under the hood.


πŸ“ Directory Structure

.
β”œβ”€β”€ assets  # <-- ASCII art, configuration macros, and images
β”‚   β”œβ”€β”€ configurations.hpp
β”‚   β”œβ”€β”€ details.hpp
β”‚   β”œβ”€β”€ matxlib-cpp-ascii.jpg
β”‚   └── matxlib-cpp.jpg
β”œβ”€β”€ include  # <-- core library headers
β”‚   β”œβ”€β”€ arithmetic  # <-- arithmetic operations on matrices
β”‚   β”‚   β”œβ”€β”€ add_a_scalar_to_matrix.hpp
β”‚   β”‚   β”œβ”€β”€ add_matrix.hpp
β”‚   β”‚   β”œβ”€β”€ divide_matrix_by_a_scalar.hpp
β”‚   β”‚   β”œβ”€β”€ multiply_matrix_by_a_scalar.hpp
β”‚   β”‚   β”œβ”€β”€ multiply_matrix_element_wise.hpp
β”‚   β”‚   β”œβ”€β”€ multiply_matrix.hpp
β”‚   β”‚   β”œβ”€β”€ subtract_matrix.hpp
β”‚   β”‚   └── subtract_scalar_from_matrix.hpp
β”‚   β”œβ”€β”€ core  # <-- MATRIX class, ctor/dtor, accessors, etc
β”‚   β”‚   β”œβ”€β”€ class.hpp
β”‚   β”‚   β”œβ”€β”€ constructor.hpp
β”‚   β”‚   β”œβ”€β”€ destructor.hpp
β”‚   β”‚   β”œβ”€β”€ error_codes.hpp
β”‚   β”‚   └── getters_and_setters.hpp
β”‚   β”œβ”€β”€ descriptive  # <-- descriptive statistics and summaries
β”‚   β”‚   └── descriptive_methods.hpp
β”‚   β”œβ”€β”€ io  # <-- Input/Output utilities
β”‚   β”‚   └── input_output_matrix.hpp
β”‚   β”œβ”€β”€ statistics  # <-- statistical functions
β”‚   β”‚   └── statistics_methods.hpp
β”‚   β”œβ”€β”€ transforms  # <-- MATRIX transformations
β”‚   β”‚   β”œβ”€β”€ sparse_matrix.hpp
β”‚   β”‚   └── transpose_matrix.hpp
β”‚   └── utility  # <-- miscellaneous utilities
β”‚       └── utility_matrix.hpp
β”œβ”€β”€ LICENSE  # <-- LICENSE
β”œβ”€β”€ Main.cpp  # <-- Main
β”œβ”€β”€ Makefile  # <-- Makefile
β”œβ”€β”€ matxlib.hpp  # <-- ** MAIN INCLUDE HEADER **
β”œβ”€β”€ README.md  # <-- you are here :)
└── test.cpp  # <-- tester file

10 directories, 28 files

πŸͺͺ LICENSE

This project is licensed under the MIT License - see LICENSE for details.