(# File: matrixIn.m
 #
 # Sha Rabii 22-Jan-1997
 # Sha Rabii 15-Oct-1997, added initialize statements to allow re-reading
 #                        of the file when a FOR statement is used.
 #)

#include <stdlib.h>

MODEL matrixIn

    stream parameter file;
    matrix output y;
    char in[255], rows[255], cols[255];
    int rowi, coli, i, j;

INITIALIZE

    rewind (file);
    if (fscanf(file, "%s %s\n", cols, rows) < 0) return;
    rowi = atoi(rows);
    coli = atoi(cols);
    y = matrix(coli, rowi);
    Enable();

EXECUTE

    for (i=0; i<rowi; i++) {
      for (j=0; j<coli; j++) {
        if (fscanf(file, "%s\n", in) < 0) return;
        (y)[j][i] = atof(in);
      }
    }

    y = y;			(# trigger y #)

END
