Description of the "Matrix operations" program



"Matrix operations" is a batch program written in C. It can perform 8 different matrix operations. The actual operation can be selected by command line parameters. Depending on the chosen operation the program reads one or two matrix(es) from input files called "INPUT1" and "INPUT2" (case sensitive). The program always generates one result matrix in a file called "OUTPUT" (case sensitive).

An input or an output file is plain ASCII file that represents one matrix in the following format:

Number_of_rowsNumber_of_columns 
Element_1,1Element_1,2...
Element_2,1Element_2,2...
...

For example the following input / output matrix
1.1 1.2 1.3
2.1 2.2 2.3
can be represented by the file

2 3
1.11.21.3
2.12.22.3

The binary executable program and two sample input matrix files can be downloaded from here:
The binary executable can be controlled by command line parameters. At most 3 parameters can be specified for an execution:

Operation_code [Operation_specific_parameter] [V]

An operation code,   a parameter depending on the chosen operation,   an optional V (verbose) flag

In verbose mode the program writes its input matrix(es), the selected operation and the result matrix to the standard output. The result matrix is always written into the file called "OUTPUT".

The supported matrix operations and the corresponding command line parameters are the following:

Operation Operation code Operation specific parameter Description
Add A   OUTPUT = INPUT1 + INPUT2
Substruct S   OUTPUT = INPUT1 - INPUT2
Multiply M   OUTPUT = INPUT1 * INPUT2
Reverse Multiply R   OUTPUT = INPUT2 * INPUT1
Transpose T   OUTPUT = Transpose of INPUT1
Constant multiply C A floating value OUTPUT = Floating value * INPUT1
Line of L An integer value OUTPUT = Selected line of INPUT1
Column of C An integer value OUTPUT = Selected column of INPUT1

E.g. to multiply the INPUT1 and INPUT2 matrixes into an OUTPUT matrix the program must be started as (on Linux platform):

./matrix_operations M     or       ./matrix_operations M V

Supposed that matrix_operations, INPUT1 and INPUT2 files are available in the current working directory. The OUTPUT matrix file will be created by the program in the working directory as well.