/******************************************************
Programmer : JSD
Language : C++
Compiler : g++
Operating System : UNIX
Platform : OMEGA
Course : UTA CSE 2320-501 Alg&DS Spring 2001
Assignment : Homework #1
Assigned : Wednesday, January 24, 2001
Due : Wednesday, February 7, 2001
File Name : HW_1_Driver.cxx
Files used :
:
:
Concepts : group code construction and matrix verification
Purpose : driver file containing main and
: global functions
******************************************************/
// Running a test to learn to use Perforce
// This line added by Deehru
// This line added by Nimesh
#ifndef HW_1_Driver_cxx
#define HW_1_Driver_cxx
//#include "HW_1_MF.cxx"
#include <fstream>
#include <iostream>
#include <string>
#define inputFileNumber 1
#define matrixBase 2
#define numCArguments 2
/*****************************************************
Function Name : main
Inputs : int, int, char array
Returns : nothing
Purpose : provides control functionality
*****************************************************/
main(int argc, char *argv[])
{
cout << "This is line number " << __LINE__ << " of the file "
<< __FILE__ << " which was compiled on " << __DATE__
<< "at time " << __TIME__ << ".\n\n";
cout << "This program takes as input the filename of the file" << "\n"
<< "containing a given matrix. It is understood" << "\n"
<< "that the rightmost columnSize-rowSize columns form a" << "\n"
<< "square identity sub-matrix. The first line of the file" << "\n"
<< "indicates the number of rows, the second line denotes" << "\n"
<< "the number of columns, and the third line contains the" << "\n"
<< "first row of the actual matrix.\n\n"
<< "The program's output is in four parts:" << "\n"
<< "1) Group Codes constructed from the input matrix;" << "\n"
<< "2) Determine if input matrix is single error detecting;" << "\n"
<< "3) Determine if input matrix is single error correcting;" << "\n"
<< "4) Calculation of the MINIMUM Hamming distance for" << "\n"
<< " the group code obtained in 1) above." << "\n\n";
if(argc != numCArguments)
{
cout << "a.out input_file_name\n";
exit(1);
}
else
cout << "Number of command line arguments is " << argc << ".\n";
ifstream inFile(argv[inputFileNumber], ios::in);
if(!inFile)
{
cout << "Unable to open the input file " << argv[inputFileNumber]
<< ".\n";
exit(2);
}
else
cout << "Input file " << argv[inputFileNumber] << " open for reading.\n";
int matrixRowSize,
matrixColSize,
gpCodeRowSize,
gpCodeColSize,
infColSize,
mRow, mCol,
gRow, gCol;
inFile >> matrixRowSize;
inFile >> matrixColSize;
gpCodeRowSize = matrixBase ^ (matrixColSize - matrixRowSize);
gpCodeColSize = matrixColSize;
infColSize = matrixColSize - matrixRowSize;
mRow = 0;
mCol = 0;
gRow = 0;
gCol = 0;
bool Matrix[matrixRowSize, matrixColSize];
bool GpCode[gpCodeRowSize, gpCodeColSize];
//Build "U" matrix information bits
for ( int iC = 0; iC < infColSize; iC++ )
{
for ( int iR = 0; iR < gpCodeRowSize; iR++ )
{
GpCode[iR, iC] = gRow % (matrixBase ^ iC);
}
};
//Load "H" matrix from file
for ( int mR = 0; mR < matrixRowSize; mRow++ )
{
for ( int mC = 0; mC < matrixColSize; mCol++ )
{
inFile >> Matrix[mR, mC];
}
};
//Print "H" matrix from array in memory
for ( int mR = 0; mR < matrixRowSize; mRow++ )
{
for ( int mC = 0; mC < matrixColSize; mCol++ )
{
cout << Matrix[mR, mC] << ' ';
}
cout << "\n";
};
cout << "\n";
//Print "U" matrix from array in memory
for ( int gR = 0; gR < gpCodeRowSize; gR++ )
{
for ( int gC = 0; gC < gpCodeColSize; gC++ )
{
cout << GpCode[gR, gC] << ' ';
}
cout << "\n";
};
}
#endif