progress on basic multiply
This commit is contained in:
parent
32541218bc
commit
2d9cc46a52
12
main.c
12
main.c
@ -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);
|
||||||
}
|
}
|
||||||
|
21
matrix.c
21
matrix.c
@ -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;
|
||||||
|
}
|
||||||
|
14
matrix.h
14
matrix.h
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user