Example #1
0
int main() 
{
    // create a source of data
    T data[ROWS][COLS] = {{1,2},{3,4}};

    // declare and initialize the matrices
    matrix  a,b;
    a = create_initvals(ROWS, COLS, data);
    b = create_empty(ROWS, COLS);

    // display the results of copying b to a
    printf("Setting b = a\n");
    equate(&a, &b);
    printf("\n Matrix a:");
    matrix_print(a);
    printf("\n Matrix b:");
    matrix_print(b);

    // display the results of adding a and b
    printf("\n a+b:");
    matrix_print(add(a,b));

    // display the results of transposing matrix a
    // After implementing the transpose function, uncomment the next line
    printf("\n a':");
    matrix_print(transpose(a));
    
    // If you created it, you destroy it
    destroy(a);
    destroy(b);

    return 0;
}
Example #2
0
int main()
{
    T data[ROWS][COLS] = {{1,2},{3,4}};
    matrix  a,b;
    a = create_initvals(ROWS, COLS, data);
    b = create_empty(ROWS, COLS);
    printf("Setting b = a\n");
    equate(&a,&b);
    printf("\n Matrix a:");
    matrix_print(a);
    printf("\n Matrix b:");
    matrix_print(b);
    printf("\n a+b:");
    matrix_print(add(a,b));

    // After implementing the transpose function, uncomment the next line
    printf("\n a':");
    matrix_print(transpose(a));

    // If you created it, you destroy it
    destroy(a);
    destroy(b);

    return 0;
}
Example #3
0
int main()
{
    static T data[] = {1,2,3,4,5,6,7,8,9,10,11,12};
    matrix  a,b;
    a = create_initvals(4,3,data);
    b = create_empty(4,3);
    equate(&a,&b);
    printf("\n Matrix a:");
    matrix_print(a);
    printf("\n Matrix b:");
    matrix_print(b);
    printf("\n a+b:");
    matrix_print(add(a,b));
    printf("\n a transposed:");
    matrix_print(transpose(a));
    printf("\n a+b transposed:");
    matrix_print(transpose(add(a,b)));
    return 0;
}