/* ex1.c
 * Peter Webb, Aug. 1995
 * Example 1 from the documentation: Creating Matrices
 */

#include <stdio.h>
#include "matlab.h"

static double real_data[] = {  1, 2, 3, 4, 5, 6 };
static double cplx_data[] = {  7, 8, 9, 10, 11, 12 };

main()
{
    /* Create two matrices */

    Matrix *mat0 = mxCreateFull(2, 3, 0);
    Matrix *mat1 = mxCreateFull(3, 2, 1);

    memcpy(mxGetPr(mat0), real_data, 6 * sizeof(double));

    memcpy(mxGetPr(mat1), real_data, 6 * sizeof(double));
    memcpy(mxGetPi(mat1), cplx_data, 6 * sizeof(double));

    /* Print the matrices */

    mlfPrintMatrix(mat0);
    mlfPrintMatrix(mat1);

    /* Free the matrices */

    mxFreeMatrix(mat0);
    mxFreeMatrix(mat1);
    exit(0);
}

