GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
Functions
gp_matrix.h File Reference

Two dimensional vector. More...

#include <core/gp_compiler.h>
#include <utils/gp_vec.h>

Go to the source code of this file.

Functions

static void * gp_matrix_new (size_t cols, size_t rows, size_t unit)
 Allocates a matrix.
 
static size_t gp_matrix_idx (size_t rows, size_t col, size_t row)
 Returns an index into the vector that holds the matrix data.
 
static void * gp_matrix_cols_ins (void *self, size_t rows, size_t col, size_t len)
 Inserts len columns at the offset col into the matrix.
 
static void * gp_matrix_cols_del (void *self, size_t rows, size_t col, size_t len)
 Deletes len columns at the offset col from the matrix.
 
void * gp_matrix_rows_ins (void *self, size_t cols, size_t rows, size_t row, size_t len)
 Inserts len rowss at the offset row into the matrix.
 
void * gp_matrix_rows_del (void *self, size_t cols, size_t rows, size_t row, size_t len)
 Deletes len rows at the offset col from the matrix.
 
static void gp_matrix_free (void *self)
 Frees the matrix.
 

Detailed Description

Two dimensional vector.

Implements very simple matrix abstraction on the top of a gp_vec.

The matrix is stored in an linear array one row after another.

The caller is supposed to maintain number of columns and rows and the library provides is a set of high level functions to reallocate and reshuffle the matrix elements.

Definition in file gp_matrix.h.

Function Documentation

◆ gp_matrix_cols_del()

static void * gp_matrix_cols_del ( void *  self,
size_t  rows,
size_t  col,
size_t  len 
)
inlinestatic

Deletes len columns at the offset col from the matrix.

Parameters
selfA matrix.
rowsNumber of rows.
colColumn index to delete the columns from.
lenHow many columns we should delete.
Returns
Returns a pointer to the matrix data.

Definition at line 80 of file gp_matrix.h.

References gp_vec_del().

◆ gp_matrix_cols_ins()

static void * gp_matrix_cols_ins ( void *  self,
size_t  rows,
size_t  col,
size_t  len 
)
inlinestatic

Inserts len columns at the offset col into the matrix.

Parameters
selfA matrix.
rowsNumber of rows.
colColumn index to insert the columns into.
lenHow many columns we should insert.
Returns
Returns a pointer to the matrix data.

Definition at line 65 of file gp_matrix.h.

References gp_vec_ins().

◆ gp_matrix_free()

static void gp_matrix_free ( void *  self)
inlinestatic

Frees the matrix.

Parameters
selfA matrix.

Definition at line 116 of file gp_matrix.h.

References gp_vec_free().

◆ gp_matrix_idx()

static size_t gp_matrix_idx ( size_t  rows,
size_t  col,
size_t  row 
)
inlinestatic

Returns an index into the vector that holds the matrix data.

Parameters
rowsNumber of rows.
colColumn index.
rowRow index.
Returns
Returns an index into a vector.

Definition at line 50 of file gp_matrix.h.

◆ gp_matrix_new()

static void * gp_matrix_new ( size_t  cols,
size_t  rows,
size_t  unit 
)
inlinestatic

Allocates a matrix.

Parameters
colsNumber of columns.
rowsNumber of rows.
unitA size of a matrix element.
Returns
Returns a pointer to the matrix data.

Definition at line 36 of file gp_matrix.h.

References gp_vec_new().

◆ gp_matrix_rows_del()

void * gp_matrix_rows_del ( void *  self,
size_t  cols,
size_t  rows,
size_t  row,
size_t  len 
)

Deletes len rows at the offset col from the matrix.

Parameters
selfA matrix.
colsNumber of columns.
rowsNumber of rows.
rowRow index to delete the rows from.
lenHow many rows we should delete.
Returns
Returns a pointer to the matrix data.

◆ gp_matrix_rows_ins()

void * gp_matrix_rows_ins ( void *  self,
size_t  cols,
size_t  rows,
size_t  row,
size_t  len 
)

Inserts len rowss at the offset row into the matrix.

Parameters
selfA matrix.
colsNumber of columns.
rowsNumber of rows.
rowRow index to delete the rows from.
lenHow many rows we should insert.
Returns
Returns a pointer to the matrix data.