Math_lol/libmatrix.h
2025-02-14 12:59:12 +01:00

113 lines
2.1 KiB
C

#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "libmatrix.c"
/* HaltAndCatchFire
*
* displays a custom errormassage and exits the program
*/
void haltAndCatchFire(const char* message);
/* MatrixIsQuadratical
*
* Checks if width == height, else complaints and exits the progam
*/
void matrixIsQuadratical(struct matrix *m);
/* MatrixNew
*
* Allocates a new matrix by size x and y
*/
void matrixNew(struct matrix *dest, uint16_t size_x, uint16_t size_y);
/* MatrixFree
*
* Free's a matrix'es array and itself
*/
void maxtrixFree(struct matrix *m);
/* MatrixNewFromUser
*
* Same as MatrixNew, but queries the user
* for input to fill the matrix
*/
void matrixNewFromUser(struct matrix *dest, uint16_t size_x, uint16_t size_y);
/* MatrixPrint
*
* Prints the given matrix in a nice format
* and a custom given display name
*/
void matrixPrint(struct matrix *m, const char* name);
/* MatrixIdentity
*
* Creates a Identitiy matrix, if the matrix is quadratical
*/
void matrixIdentity(struct matrix *m);
/* MatrixFill
*
* Fills the matrix with a value
*/
void matrixFill(struct matrix *m, float value);
/* MatrixDet
*
* Calculated the determinant of the matrix
*/
float matrixDet(struct matrix *m);
/* MatrixRound
*
* Rounds every entry in the matrix
*/
void matrixRound(struct matrix *m);
/* MatrixAdd
*
* Adds two matricies together and store it in dest
* dest get's initialized with the size of a
*
* a and b have to be equal in size
*/
void matrixAdd(struct matrix *a, struct matrix *b, struct matrix *dest);
/* MatrixMultiply
*
* Multiply two matricies together and store it in dest
* dest get's initialized with the size of a.height, b.with
*
* a and b have to be compatible for multiplication
*/
void matrixMultiply(struct matrix *a, struct matrix *b, struct matrix *dest);
/* MatrixMultiplyByNumber
*
* Multiply the entire array by a fixed value
*/
void matrixMultiplyByNumber(struct matrix *m, float value);
void matrixPow(float *matrix, float value);
void matrixTranspose(float *matrix);