Skip to content
Snippets Groups Projects
Select Git revision
  • 5a418a40e3e19d4f4c1bd1f9430c0bdeb7c85579
  • main default protected
2 results

matrix.h

Blame
  • user avatar
    Florian Burgener authored
    5a418a40
    History
    matrix.h 1.14 KiB
    /**
     * @file matrix.h
     * @author Florian Burgener
     * @brief Header de librairie matrix.
     * @version 1.0
     * @date 2021-11-16
     *
     * @copyright Copyright (c) 2021
     *
     */
    
    #ifndef MATRIX_HEADER
    #define MATRIX_HEADER
    #include <math.h>
    #include <stdbool.h>
    #include <stdint.h>
    
    typedef enum _error_code {
        ok,
        err
    } error_code;
    
    typedef struct _matrix {
        int32_t m, n;
        int32_t **data;
    } matrix;
    
    error_code matrix_alloc(matrix *mat, int32_t m, int32_t n);
    error_code matrix_init(matrix *mat, int32_t m, int32_t n, int32_t val);
    error_code matrix_destroy(matrix *mat);
    error_code matrix_init_from_array(matrix *mat, int32_t m, int32_t n, int32_t data[], int32_t s);
    error_code matrix_clone(matrix *cloned, const matrix mat);
    error_code matrix_transpose(matrix *transposed, const matrix mat);
    error_code matrix_print(const matrix mat);
    error_code matrix_extract_submatrix(matrix *sub, const matrix mat, int32_t m0, int32_t m1, int32_t n0, int32_t n1);
    bool matrix_is_equal(matrix mat1, matrix mat2);
    error_code matrix_get(int32_t *elem, const matrix mat, int32_t ix, int32_t iy);
    error_code matrix_set(matrix mat, int32_t ix, int32_t iy, int32_t elem);
    
    #endif