Function to write out a row
This commit is contained in:
parent
5b41def60a
commit
c5f5a5f1ff
21
src/main.c
21
src/main.c
|
@ -1,6 +1,6 @@
|
|||
#include <stdio.h>
|
||||
#include "../includes/matrix.h"
|
||||
|
||||
|
||||
// Temporarily defined here.
|
||||
// Later, should be defined upon compilation, with -D flag (for gcc).
|
||||
#define A_OUTPUTS 3
|
||||
|
@ -8,6 +8,21 @@
|
|||
#define A_INPUTS 3
|
||||
#define B_INPUTS 3
|
||||
|
||||
void PrintRow(matrix_t *matrix, size_t row) {
|
||||
for (size_t entry = 0; entry < matrix->row_len; entry ++) {
|
||||
size_t head_idx = *((matrix->entries_head) + (row * matrix->row_len) + entry);
|
||||
matrix_data_t *head = matrix->data_head + head_idx;
|
||||
size_t len = *head;
|
||||
for (ptrdiff_t i = 1; i < len+1; i++) {
|
||||
printf("%c", *(char*)(head + i));
|
||||
}
|
||||
if (entry != matrix->row_len - 1) {
|
||||
printf(", ");
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
size_t a_out = A_OUTPUTS;
|
||||
|
@ -17,5 +32,9 @@ int main(int argc, char *argv[])
|
|||
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);
|
||||
size_t row_count = matrix.entries_len / row_len;
|
||||
for (size_t row = 0; row < row_count; row++) {
|
||||
PrintRow(&matrix, row);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue