int main() { Matrix *A = make_matrix(3, 4); consecutive_matrix(A); printf("A\n"); print_matrix(A); Matrix *C = add_matrix_func(A, A); printf("A + A\n"); print_matrix(C); Matrix *B = make_matrix(4, 3); increment_matrix(B, 1); printf("B\n"); print_matrix(B); Matrix *D = mult_matrix_func(A, B); printf("D\n"); print_matrix(D); destroy_matrix(A); destroy_matrix(B); destroy_matrix(C); destroy_matrix(D); return 0; }
int main() { int i; Matrix *A = make_matrix(3, 4); consecutive_matrix(A); printf("A\n"); print_matrix(A); Matrix *C = add_matrix_func(A, A); printf("A + A\n"); print_matrix(C); Matrix *B = make_matrix(4, 3); increment_matrix(B, 1); printf("B\n"); print_matrix(B); Matrix *D = mult_matrix_func(A, B); printf("D\n"); print_matrix(D); double sum = matrix_sum1(A); printf("sum = %lf\n", sum); sum = matrix_sum2(A); printf("sum = %lf\n", sum); printf("A\n"); print_matrix(A); double *sums = row_sum(A); for (i=0; i<A->rows; i++) { printf("row %d\t%lf\n", i, sums[i]); } // should print 6, 22, 38 double *sums2 = col_sum(A); for (i=0; i<A->cols; i++) { printf("col %d\t%lf\n", i, sums2[i]); } Matrix *E = make_matrix(3, 3); E->data[0][0] = 2; E->data[0][1] = 7; E->data[0][2] = 6; E->data[1][0] = 9; E->data[1][1] = 5; E->data[1][2] = 1; E->data[2][0] = 4; E->data[2][1] = 3; E->data[2][2] = 8; printf("E\n"); print_matrix(E); printf("Magic matrix?: %d \n", is_magic_square(E)); return 0; }
int main() { int i; Matrix *A = make_matrix(3, 4); consecutive_matrix(A); printf("A\n"); print_matrix(A); Matrix *C = add_matrix_func(A, A); printf("A + A\n"); print_matrix(C); Matrix *B = make_matrix(4, 3); increment_matrix(B, 1); printf("B\n"); print_matrix(B); Matrix *D = mult_matrix_func(A, B); printf("D\n"); print_matrix(D); double sum = matrix_sum1(A); printf("sum(A) = %lf\n", sum); sum = matrix_sum2(A); printf("sum2(A) = %lf\n", sum); double *sums = row_sum(A); for (i=0; i<A->rows; i++) { printf("row %d\t%lf\n", i, sums[i]); } // should print 6, 22, 38 Matrix *E = make_matrix(3,3); increment_matrix(E, 1); printf("\nE "); if (is_magic_square(E)) { printf("is magic! Whizzam!\n"); } else { printf("isn't magic...\n"); } print_matrix(E); return 0; }
int main() { int i; Matrix *A = make_matrix(3, 4); consecutive_matrix(A); printf("A\n"); print_matrix(A); Matrix *C = add_matrix_func(A, A); printf("A + A\n"); print_matrix(C); Matrix *B = make_matrix(4, 3); increment_matrix(B, 1); printf("B\n"); print_matrix(B); Matrix *D = mult_matrix_func(A, B); printf("D\n"); print_matrix(D); double sum = matrix_sum1(A); printf("sum = %lf\n", sum); sum = matrix_sum2(A); printf("sum = %lf\n", sum); double *sums = row_sum(A); for (i=0; i<A->rows; i++) { printf("row %d\t%lf\n", i, sums[i]); } // should print 6, 22, 38 //Test matrix Matrix *E = make_matrix(3, 3); increment_matrix(E, 1); int magic1 = is_magic_square(A); //Not Magic int magic2 = is_magic_square(B); //Not Magic int magic3 = is_magic_square(E); //Magic printf("Magic Matrix result: %d , %d , %d \n", magic1, magic2, magic3); return 0; }