(feat) load_next_matrix
This commit is contained in:
parent
e86009ecf5
commit
2654733c27
2 changed files with 12 additions and 0 deletions
10
matrix.c
10
matrix.c
|
|
@ -279,6 +279,14 @@ Matrix* matrix_load(char* file_string){
|
|||
printf("Could not open \"%s\"", file_string);
|
||||
exit(1);
|
||||
}
|
||||
Matrix * m = load_next_matrix(fptr);
|
||||
fclose(fptr);
|
||||
return m;
|
||||
|
||||
}
|
||||
|
||||
Matrix * load_next_matrix(FILE *fptr){
|
||||
|
||||
char buffer[MAX_BYTES];
|
||||
|
||||
fgets(buffer, MAX_BYTES, fptr);
|
||||
|
|
@ -321,6 +329,8 @@ Matrix* matrix_flatten(Matrix* matrix, int axis) {
|
|||
return result_matrix;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int matrix_argmax(Matrix* matrix) {
|
||||
// Expects a Mx1 matrix
|
||||
if (matrix->columns != 1){
|
||||
|
|
|
|||
2
matrix.h
2
matrix.h
|
|
@ -1,4 +1,5 @@
|
|||
#pragma once
|
||||
#include <stdio.h>
|
||||
|
||||
typedef struct {
|
||||
int rows, columns;
|
||||
|
|
@ -15,6 +16,7 @@ void matrix_print(Matrix *matrix);
|
|||
Matrix* matrix_copy(Matrix *matrix);
|
||||
void matrix_save(Matrix* matrix, char* file_string);
|
||||
Matrix* matrix_load(char* file_string);
|
||||
Matrix* load_next_matrix(FILE * fptr);
|
||||
|
||||
void matrix_randomize(Matrix* matrix, int n); // don't understand the usage of the n
|
||||
int matrix_argmax(Matrix* matrix);
|
||||
|
|
|
|||
Reference in a new issue