aced/includes/matrix.h

39 lines
1.1 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef ACED_INCLUDES_MATRIX_H_
#define ACED_INCLUDES_MATRIX_H_
#include <stddef.h>
#include "../includes/data.h"
// Struct representing the input matrix.
typedef struct {
// Number of elements in one row.
size_t row_len;
// Pointer to the buffer containing the matrix's entries.
data_t *head;
// Number of entries in the matrix.
size_t len;
} matrix_t;
// Prints a debug view of a `matrix_t` to standard output.
void DebugPrintMatrix(matrix_t *matrix);
// Prints a row of a `matrix_t` to standard output.
void PrintMatrixRow(matrix_t *matrix, size_t row);
// Parse a matrix from the standard input.
//
// This function parses an extended matrix (C|l), where C is an n×m matrix, and
// l is an m-sized column vector. This input is given in standard input as
// whitespace separated entries.
//
// Arguments:
// row_len The number of entries in one row.
matrix_t ParseMatrix(size_t row_len);
// Releases the memory associated to the given matrix.
//
// Usage after free results in undefined behaviour.
void MatrixFree(matrix_t *matrix);
#endif // ACED_INCLUDES_MATRIX_H_