Compare commits

...

2 Commits

Author SHA1 Message Date
Miguel M 65f0c1dc95 Removed stb since it was unused 2023-04-26 15:11:05 +01:00
Miguel M b3de17e14d Matrix parsing based on compile-time information 2023-04-26 14:24:57 +01:00
4 changed files with 19 additions and 1906 deletions

File diff suppressed because it is too large Load Diff

View File

@ -39,8 +39,10 @@ void DebugPrintGrid(matrix_t *grid);
//
// 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.
//
// <row length> <whitespace separated entries>
matrix_t ParseMatrix(void);
// Arguments:
// row_len The number of entries in one row.
matrix_t ParseMatrix(size_t row_len);
#endif // ACED__MATRIX_H_

View File

@ -1,12 +1,21 @@
#include "../includes/matrix.h"
// #define STB_DS_IMPLEMENTATION
// #define STBDS_NO_SHORT_NAMES
// #include "../contrib/stb/stb_ds.h"
// Temporarily defined here.
// Later, should be defined upon compilation, with -D flag (for gcc).
#define A_OUTPUTS 3
#define B_OUTPUTS 3
#define A_INPUTS 3
#define B_INPUTS 3
int main(int argc, char *argv[])
{
matrix_t grid = ParseMatrix();
DebugPrintGrid(&grid);
size_t a_out = A_OUTPUTS;
size_t b_out = B_OUTPUTS;
size_t a_in = A_INPUTS;
size_t b_in = B_INPUTS;
size_t row_len = ((a_out-1)*(b_out-1)*a_in*b_in + (a_out-1)*a_in +
(b_out-1)*b_in);
matrix_t matrix = ParseMatrix(row_len);
return 0;
}

View File

@ -104,11 +104,8 @@ matrix_bufs_t compact_buffers(matrix_t *matrix) {
// what we have is contiguous blocks of strings, structured as
//
// <string length> <characters...>
matrix_t ParseMatrix(void)
matrix_t ParseMatrix(size_t row_len)
{
size_t row_len;
scanf("%zu", &row_len);
size_t data_cap = 32; // Initial value is arbitrary.
size_t data_len = 0; // Number of characters written so far.
size_t entries_len = 0; // Number of strings written so far.