From bc4215edfd34590c8078b3bb459005807d36c5cf Mon Sep 17 00:00:00 2001 From: Jasper Date: Mon, 1 Sep 2025 20:10:12 +0200 Subject: Merge row-swap and col-swap --- matrix.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'matrix.h') diff --git a/matrix.h b/matrix.h index 63f1441..aa95771 100644 --- a/matrix.h +++ b/matrix.h @@ -16,6 +16,11 @@ typedef enum { MATRIX_NONE } MatrixType; +typedef enum { + MATRIX_SWAP_ROWS, + MATRIX_SWAP_COLS +} MatrixSwapType; + typedef struct { double *xs; size_t m; @@ -32,10 +37,8 @@ char *matrix_to_str(const Matrix *mat); Matrix *matrix_id(size_t n); Matrix *matrix_const(size_t m, size_t n, double x); Matrix *matrix_copy (const Matrix *mat); -Matrix *matrix_swap_rows(const Matrix *mat, size_t i, size_t j); -void matrix_swap_rows1(Matrix *mat, size_t i, size_t j); -Matrix *matrix_swap_cols(const Matrix *mat, size_t i, size_t j); -void matrix_swap_cols1(const Matrix *mat, size_t i, size_t j); +Matrix *matrix_swap(const Matrix *mat, MatrixSwapType t, size_t i, size_t j); +void matrix_swap1(Matrix *mat, MatrixSwapType t, size_t i, size_t j); double matrix_trace(const Matrix *mat); Matrix *matrix_transpose(const Matrix *mat); Matrix *matrix_add(const Matrix *A, const Matrix *B); -- cgit v1.2.3