Matrix Library

matrix.h is a C library for advanced matrix calculations. It provides various functions to perform operations such as matrix addition, subtraction, multiplication, transposition, inversion, and more. This library is suitable for numerical computing and scientific applications.

Features

Installation

Linux

  1. Clone the Repository
    git clone https://github.com/rubikproxy/matrix.h
    cd matrix.h
  2. Build and Install the Library
    chmod +x install_matrix_lib.sh
    ./install_matrix_lib.sh

    This script will:

    • Clean up previous builds
    • Compile the source code
    • Create a static library
    • Install the library and header files
    • Update the library cache
  3. Verify the Installation
    ls /usr/local/lib/libmatrix.a
    ls /usr/local/include/matrix.h

macOS

  1. Clone the Repository
    git clone https://github.com/rubikproxy/matrix.h
    cd matrix.h
  2. Build the Library
    make
  3. Install the Library
    sudo cp libmatrix.a /usr/local/lib/
    sudo cp include/matrix.h /usr/local/include/
    sudo ranlib /usr/local/lib/libmatrix.a
  4. Verify the Installation
    ls /usr/local/lib/libmatrix.a
    ls /usr/local/include/matrix.h

Windows

  1. Clone the Repository
    git clone https://github.com/rubikproxy/matrix.h
    cd matrix.h
  2. Build the Library
    gcc -Iinclude -Wall -Wextra -c src/matrix.c -o src/matrix.o
    ar rcs libmatrix.a src/matrix.o
  3. Install the Library
    mkdir "C:\Program Files\MatrixLib"
    copy libmatrix.a "C:\Program Files\MatrixLib"
    copy include\matrix.h "C:\Program Files\MatrixLib"
  4. Set Environment Variables
    setx LIBRARY_PATH "C:\Program Files\MatrixLib"
  5. Verify the Installation
    dir "C:\Program Files\MatrixLib"

Usage

Example Code

Here’s an example demonstrating how to use the library:

  1. Create a Source File
    #include 
    #include 
    
    int main() {
        // Create matrices
        Matrix *a = create_matrix(2, 2);
        Matrix *b = create_matrix(2, 2);
    
        // Initialize matrices
        set_matrix_element(a, 0, 0, 1);
        set_matrix_element(a, 0, 1, 2);
        set_matrix_element(a, 1, 0, 3);
        set_matrix_element(a, 1, 1, 4);
    
        set_matrix_element(b, 0, 0, 5);
        set_matrix_element(b, 0, 1, 6);
        set_matrix_element(b, 1, 0, 7);
        set_matrix_element(b, 1, 1, 8);
    
        // Add matrices
        Matrix *c = add_matrices(a, b);
    
        // Print result
        print_matrix(c);
    
        // Deallocate matrices
        free_matrix(a);
        free_matrix(b);
        free_matrix(c);
    
        return 0;
    }
  2. Compile and Run
    gcc -o matrix_example matrix_example.c -L/usr/local/lib -lmatrix
    ./matrix_example

Function Reference

Detailed documentation for each function is provided in the matrix.h header file.

Contributing

How to Contribute

We welcome contributions! You can help by submitting issues, improving documentation, or adding new features. Please follow our contribution guidelines in the repository.

Contribution Guidelines

Sponsorship