#include <stdio.h>
#include <stdlib.h>

#include "matrix_lib.h"

int main(int argc, char** argv) {
    if (argc < 3) {
        printf("This program requires two data files.\n");
        return 1;
    }

    // Open datafile for reading.
    FILE* datafile = fopen(argv[1], "r");
    if (datafile == NULL) {
        printf("Error opening file.\n");
        return 2;
    }


    // Make our two new matrices
    Matrix a = readMatrix(datafile);
    fclose(datafile);

    datafile = fopen(argv[2], "r");
    if (datafile == NULL) {
        printf("Error opening file.\n");
        return 2;
    }
    Matrix b = readMatrix(datafile);
    fclose(datafile);

    Matrix sum = addMatrix(a, b);

    printf("Sum of matrix\n");
    printMatrix(a);
    printf("And matrix\n");
    printMatrix(b);
    printf("Is matrix\n");
    printMatrix(sum);

    Matrix dot = dotProduct(a, b);
    printf("Dot product is matrix\n");
    printMatrix(dot);

    freeMatrix(a);
    freeMatrix(b);
    freeMatrix(sum);
    freeMatrix(dot);

    return 0;

}

