This is a small utility program I wrote for my design project.
As an argument, this program will take a file, containing a 36x36 matrix, consisting of 1 (ones) and 0 (zeros), parse it to retrieve a list of 6 digit binary numbers, convert those numbers into decimal format and write it to the output file as a 6 6x6 matrices.
- If
mean
is passed as a third argument to the program, it will find a mean of matrix values and write an result as a 6*6 matrix.
Clarification:
for 6 6x6 matrices
res -- resulting matrix //2d matrix in -- input array of matrices //3d matrix
res[i][j] = ((in[n][i][1] + .... + in[n][i][6]) / 6) //mean value
- if
distrib
is passed as a third argument to the program, it will create a 6x7 “frequency distribution” matrix of values at intervals of 30 – how many 1’s are there per each 30 values.
Clarification:
for interval of 5 and 2x5 matrix
An input of:
1 0 1 1 0 0 0 1 0 1
Would yield a resulting:
3 2
-
Compile the program (make sure the script has approporiate permissions)
./compile
-
Run the program
./matrix_converter *input file* [mean]
-
Results will be written into the result.txt file
-
Results with the
mean
parameter will be writter into the results_mean.txt file -
Results with the
distrib
parameter will be writter into the results_distrib.fdf file
-
The digits in the input matrix should be divided by spaces, with no extra spaces of symbols at the end of the line
Example:
0 1 1 1 0 1 0 0 0
-
Only 36x36 input matrix is valid
-
Apart from basic argument error checking, there isn’t a proper error handling system (file content, map validity etc.), so if the program crashes, you have most likely supplied an incorrect input matrix.