progress on basic multiply

This commit is contained in:
AustrianToast 2024-10-03 12:48:22 +02:00
parent 32541218bc
commit 2d9cc46a52
Signed by: AustrianToast
GPG Key ID: 174D780E041684FF
3 changed files with 38 additions and 9 deletions

12
main.c
View File

@ -4,11 +4,13 @@
int main(void) { int main(void) {
const uint8_t row_length = 5; const uint64_t row_length = 5;
const uint8_t column_length = 5; const uint64_t column_length = 5;
uint64_t matrix[row_length][column_length]; uint64_t matrix1[row_length][column_length];
uint64_t matrix2[row_length*2][column_length*2];
random_adjacency(row_length, column_length, matrix); random_adjacency(row_length, column_length, matrix1);
random_adjacency(row_length*2, column_length*2, matrix2);
print_matrix(row_length, column_length, matrix); print_matrix(row_length, column_length, matrix1);
} }

View File

@ -1,11 +1,26 @@
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
void print_matrix(const uint8_t row_length, const uint8_t column_length, const uint64_t matrix[row_length][column_length]) { void print_matrix(const uint64_t row_length, const uint64_t column_length,
for (uint8_t column_index=0; column_index < column_length; column_index++) { const uint64_t matrix[row_length][column_length]) {
for (uint8_t row_index=0; row_index < row_length; row_index++) {
for (uint64_t column_index=0; column_index < column_length; column_index++) {
for (uint64_t row_index=0; row_index < row_length; row_index++) {
printf("%lu ", matrix[row_index][column_index]); printf("%lu ", matrix[row_index][column_index]);
} }
printf("\n"); printf("\n");
} }
} }
int matrix_multiply_basic(const uint64_t row_length1,
const uint64_t column_length1,
const uint64_t matrix1[row_length1][column_length1],
const uint64_t row_length2,
const uint64_t column_length2,
const uint64_t matrix2[row_length2][column_length2],
uint64_t output_matrix[row_length1][column_length2]) {
int ret = 0;
return ret;
}

View File

@ -3,6 +3,18 @@
#include <stdint.h> #include <stdint.h>
void print_matrix(const uint64_t row_length, const uint64_t column_length, const uint64_t matrix[row_length][column_length]); void print_matrix(const uint64_t row_length, const uint64_t column_length,
const uint64_t matrix[row_length][column_length]);
// Takes three matrices, the first two will be multiplied and restult will be written to output_matrix.
// Matrix requirements are as specified in the parameters.
// Function return 0 on success and 1 on failure.
int matrix_multiply_basic(const uint64_t row_length1,
const uint64_t column_length1,
const uint64_t matrix1[row_length1][column_length1],
const uint64_t row_length2,
const uint64_t column_length2,
const uint64_t matrix2[row_length2][column_length2],
uint64_t output_matrix[row_length1][column_length2]);
#endif #endif