/* Function: GetInverseMatrix
 * -----------------
 *		Description: Returns the inverse matrix of a square matrix
 *
 *		Arguments:
 *			Arg1: (SMatrix) Original matrix to be inversed
 *
 *		Returns: (SMatrix) Inverse matrix
 *
 *		Author: Jacob Hull
 */
SMatrix* GetInverseMatrix( SMatrix* qMatrix )
{
	SMatrix* qReturnMatrix;
	
	if( qMatrix->m_iRows != qMatrix->m_iColumns )
	{
		return NULL;
	}
	else if( qMatrix->m_iRows == 2 )
	{
		qReturnMatrix = CreateMatrix( qMatrix->m_iRows, qMatrix->m_iColumns );
		
		qReturnMatrix->m_ppdMatrix[0][0] = qMatrix->m_ppdMatrix[1][1];
		qReturnMatrix->m_ppdMatrix[1][1] = qMatrix->m_ppdMatrix[0][0];
		
		qReturnMatrix->m_ppdMatrix[0][1] = -1 * qMatrix->m_ppdMatrix[0][1];
		qReturnMatrix->m_ppdMatrix[1][0] = -1 * qMatrix->m_ppdMatrix[1][0];
		
		double dDet = (double)DeterminantOfMatrix( qMatrix );
		
		MultiplyByConstant( qReturnMatrix, 1.f/dDet );
	}
	else
	{
		qReturnMatrix = GetCoFactorMatrix( qMatrix );
	
		TransposeSquareMatrix( qReturnMatrix );
	
		double dDet = (double)DeterminantOfMatrix( qMatrix );
	
		MultiplyByConstant( qReturnMatrix, 1.f/(double)dDet );
	}
	
	return qReturnMatrix;
}
Beispiel #2
0
 /// 求n阶矩阵的逆矩阵
 bool InverseMatrix(double** matrix, double** inverseMatirx, int row, int column)
 {
	 int i, j, x, y, k, l;
	 double **SP = NULL, **AB = NULL, **TempMatrix = NULL, X;
	 if(matrix == NULL || inverseMatirx == NULL || row <= 0 || column != row)
	 {
		 printf("matrix cannot be inversed !!!!\n");
		 return false;
	 }

	 SP = (double **)malloc(row*sizeof(double*));
	 AB = (double **)malloc(row*sizeof(double*));
	 TempMatrix = (double **)malloc(row*sizeof(double*));
	 X = DeterminantOfMatrix(matrix, row, column);
	 if(X == 0)
	 {
		 printf("det==0,matrix cannot be inversed !!!!\n");
		 return false;
	 }
	 X = 1/X;

	 for(i = 0; i < row; i++) 
	 {
		 SP[i] = (double *)malloc(column*sizeof(double));
		 AB[i] = (double *)malloc(column*sizeof(double));
		 TempMatrix[i] = (double *)malloc(column*sizeof(double));
	 }

	 //求矩阵伴随矩阵
	 for(i = 0; i < row; i++)
	 {
		 for(j = 0; j < column; j++)
		 {
			 for(k = 0; k < row; k++)
				 for(l = 0; l <column; l++)
					 TempMatrix[k][l] = matrix[k][l];	//TempMatrix变成matrix;
			 {
				 for(x = 0; x < column; x++)
					 TempMatrix[(i*column+x)/row][(i*column+x)%row] = 0;
				 for(y = 0; y < row; y++)
					 TempMatrix[y][j]=0;
				 TempMatrix[(int)((i*column+j)/row)][(i*column+j)%row] = 1;
				 SP[(int)((i*column+j)/row)][(i*column+j)%row] = DeterminantOfMatrix(TempMatrix, row, column);
				 AB[(int)((i*column+j)/row)][(i*column+j)%row] = X * SP[(int)((i*column+j)/row)][(i*column+j)%row];
			 }
		 }
	 }
	 transpositionMatrix(AB, inverseMatirx, row, column);

	 freeMyMatrix(AB,row,column);
	 freeMyMatrix(SP,row,column);
	 freeMyMatrix(TempMatrix,row,column);

	 return true;
 }
/* Function: DeterminantOfMatrix
 * -----------------
 *		Description: Returns the determinant of a square matrix
 *
 *		Arguments:
 *			Arg1: (SMatrix) Matrix with which to find determinant.
 *
 *		Returns: (int) Determinant of a matrix
 *
 *		Author: Jacob Hull
 */
int DeterminantOfMatrix( SMatrix* qMatrix )
{
	if( qMatrix->m_iRows != qMatrix->m_iColumns )
	{
		return 0;
	}
	else if( qMatrix->m_iRows == 2 )
	{
		return( ( qMatrix->m_ppdMatrix[0][0] * qMatrix->m_ppdMatrix[1][1] ) - ( qMatrix->m_ppdMatrix[0][1] * qMatrix->m_ppdMatrix[1][0] ) );
	}
	else
	{
		int iMult = 1;
		int iProduct = 0;
		
		SMatrix* qSubMatrix = CreateMatrix( qMatrix->m_iRows - 1, qMatrix->m_iRows - 1 );

		for( int i = 0; i < qMatrix->m_iRows; ++i )
		{		
			for( int j = 0; j < ( qMatrix->m_iRows - 1 ); ++j )
			{
				int iSpace = 0;
				for( int k = 0; k < qMatrix->m_iRows; ++k )
				{
					if( k == i )
					{
						iSpace = 1;
					}
					else
					{
						qSubMatrix->m_ppdMatrix[j][k-iSpace] = qMatrix->m_ppdMatrix[j+1][k];
					}
				}
			}
			iProduct += iMult * ( qMatrix->m_ppdMatrix[0][i] * DeterminantOfMatrix( qSubMatrix ) );
			iMult *= -1;
		}
		
		FreeMatrix( qSubMatrix );
		
		return iProduct;
	}
	
	return 0;
}
/* Function: GetCoFactorMatrix
 * -----------------
 *		Description: Returns the cofactor matrix of a square matrix
 *
 *		Arguments:
 *			Arg1: (SMatrix) Matrix with which to find cofactor matrix
 *
 *		Returns: (SMatrix) Cofactor matrix
 *
 *		Author: Jacob Hull
 */
SMatrix* GetCoFactorMatrix( SMatrix* qMatrix )
{
	SMatrix* qReturnMatrix;
	if( qMatrix->m_iRows != qMatrix->m_iColumns )
	{
		return NULL;
	}
	
	qReturnMatrix = CreateMatrix( qMatrix->m_iRows, qMatrix->m_iColumns );
	
	SMatrix* qSubMatrix = CreateMatrix( qMatrix->m_iRows - 1, qMatrix->m_iColumns - 1 );
	
	for( int i = 0; i < qMatrix->m_iRows; ++i )
	{	
		for( int j = 0; j < qMatrix->m_iRows; ++j )
		{
			int iXSpace = 0;
			
			for( int x = 0; x < ( qMatrix->m_iRows - 1 ); ++x )
			{
				if( i == x )
				{
					iXSpace = 1;
				}
				
				int iYSpace = 0;
				for( int y = 0; y < ( qMatrix->m_iRows - 1 ); ++y )
				{	
					if( j == y )
					{
						iYSpace = 1;
					}
					qSubMatrix->m_ppdMatrix[x][y] = qMatrix->m_ppdMatrix[iXSpace+x][iYSpace+y];
				}
			}
			int iMult = ( pow( -1, i ) / pow( -1, j ) );
			qReturnMatrix->m_ppdMatrix[i][j] = iMult * DeterminantOfMatrix( qSubMatrix );
		}
	}
	
	FreeMatrix( qSubMatrix );
	
	return qReturnMatrix;
}
int main()
{	
	char** ppchReactants = NULL;
	int iReactantCounter = 0;
	
	SMatrix* qElementEquations = CreateMatrix( 0, 0 );
	char** ppchElementNames = NULL;
	int iElementCounter = 0;
	
	SMatrix* qMatrixB = CreateMatrix( 0, 0 );
	
	int iChangePoint;
	int iCount = 0;
	
	char* pchInput;
	pchInput = (char*)malloc( sizeof( char ) * 64 );
	memset( pchInput, ' ', 64 );
	printf( "Please enter the reactants one at a time.\nPlease use () to denote subscript.\nH(2)O for example. When finished enter '>'.\n\n" );
	
	int iMult = 1;
	
	while( 1 )
	{
		if( iMult == 1 )
		{
			printf( "Enter reactant:\n" );
		}
		else
		{
			printf( "Enter product:\n" );
		}
		scanf( "%s", pchInput );
		
		if( pchInput[0] == '>' )
		{
			if( iMult == 1 )
			{
				iChangePoint = iCount;
				iMult = -1;
				memset( pchInput, ' ', 64 );
				continue;
			}
			else
			{
				break;
			}
		}
		
		++iCount;
		
		int iLength = 0;
		while( pchInput[iLength] != ' ' )
		{
			++iLength;
		}
		pchInput[iLength-1] = '\0';
		
		++iReactantCounter;
		ppchReactants = (char**)realloc( ppchReactants, sizeof( char* ) * iReactantCounter );
		ppchReactants[iReactantCounter-1] = (char*)malloc( sizeof( char ) * iLength );
		memcpy( ppchReactants[iReactantCounter-1], pchInput, iLength );
		
		int iPass = 0;
		for( int i = 0; i < (iLength-1); ++i )
		{
			int iIncrement = 0;
			if( ( pchInput[i] >= 65 ) && ( pchInput[i] <= 90 ) )
			{
				if( ( pchInput[i+1] >= 97 ) && ( pchInput[i+1] <= 122 ) )
				{
					char* pchName = (char*)malloc( sizeof( char ) * 3 );
					pchName[0] = pchInput[i];
					pchName[1] = pchInput[i+1];
					pchName[2] = '\0';
					iIncrement += 1;
					
					int iAmount = 1;
					
					if( ( pchInput[i+2] == '(' ) && ( ( pchInput[i+3] >= 48 ) && ( pchInput[i+3] <= 57 ) )  )
					{
						iIncrement += 1;
						char* chNumberBuffer = (char*)malloc( sizeof( char ) * 10 );
						for( int j = 3; j <= 10; ++j )
						{
							iIncrement += 1;
							if( pchInput[i+j] == ')' )
							{
								break;
							}
							chNumberBuffer[j-3] = pchInput[i+j];
						}
						iAmount = atoi( chNumberBuffer );
						free( chNumberBuffer );
					}
					
					int iPlace = -1;
					for( int j = 0; j < iElementCounter; ++j )
					{
						if( !strcmp( pchName, ppchElementNames[j] ) )
						{
							iPlace = j;
						}
					}
					
					if( iPlace == -1 )
					{
						++iElementCounter;
						ppchElementNames = (char**)realloc( ppchElementNames, sizeof( char* ) * iElementCounter );
						ppchElementNames[iElementCounter-1] = (char*)malloc( sizeof( char ) * 3 );
						memcpy( ppchElementNames[iElementCounter-1], pchName, 3 );
						
						qElementEquations->m_iRows = iElementCounter;
						qElementEquations->m_ppdMatrix = (double**)realloc( qElementEquations->m_ppdMatrix, sizeof( double * ) * iElementCounter );
						if( !iPass )
						{
							for( int j = 0; j < iElementCounter; ++j )
							{
								qElementEquations->m_iColumns = iReactantCounter;
								qElementEquations->m_ppdMatrix[j] = (double*)realloc( qElementEquations->m_ppdMatrix[j], sizeof( double ) * iReactantCounter );
								qElementEquations->m_ppdMatrix[j][iReactantCounter-1] = 0;
							}
						}
						else
						{
							qElementEquations->m_ppdMatrix[iElementCounter-1] = (double*)malloc( sizeof( double ) * iReactantCounter );
						}
						memset( qElementEquations->m_ppdMatrix[iElementCounter-1], 0, sizeof( double ) * ( iReactantCounter - 1 ) );
						qElementEquations->m_ppdMatrix[iElementCounter-1][iReactantCounter-1] = ( iMult * iAmount );
					}
					else
					{
						if( !iPass )
						{
							for( int j = 0; j < iElementCounter; ++j )
							{
								qElementEquations->m_iColumns = iReactantCounter;
								qElementEquations->m_ppdMatrix[j] = (double*)realloc( qElementEquations->m_ppdMatrix[j], sizeof( double ) * iReactantCounter );
								qElementEquations->m_ppdMatrix[j][iReactantCounter-1] = 0;
							}
						}
						qElementEquations->m_ppdMatrix[iPlace][iReactantCounter-1] = ( iMult * iAmount );
					}
					
					free( pchName );
				}
				else
				{
					char* pchName = (char*)malloc( sizeof( char ) * 2 );
					pchName[0] = pchInput[i];
					pchName[1] = '\0';
					
					int iAmount = 1;
					
					if( ( pchInput[i+1] == '(' ) && ( ( pchInput[i+2] >= 48 ) && ( pchInput[i+2] <= 57 ) ) )
					{
						iIncrement += 1;
						char* chNumberBuffer = (char*)malloc( sizeof( char ) * 10 );
						for( int j = 2; j <= 9; ++j )
						{
							iIncrement += 1;
							if( pchInput[i+j] == ')' )
							{
								break;
							}
							chNumberBuffer[j-2] = pchInput[i+j];
						}
						iAmount = atoi( chNumberBuffer );
						free( chNumberBuffer );
					}
					
					int iPlace = -1;
					for( int j = 0; j < iElementCounter; ++j )
					{
						if( !strcmp( pchName, ppchElementNames[j] ) )
						{
							iPlace = j;
						}
					}
					
					if( iPlace == -1 )
					{
						++iElementCounter;
						ppchElementNames = (char**)realloc( ppchElementNames, sizeof( char* ) * iElementCounter );
						ppchElementNames[iElementCounter-1] = (char*)malloc( sizeof( char ) * 2 );
						memcpy( ppchElementNames[iElementCounter-1],pchName, 2 );
						
						qElementEquations->m_iRows = iElementCounter;
						qElementEquations->m_ppdMatrix = (double**)realloc( qElementEquations->m_ppdMatrix, sizeof( double* ) * iElementCounter );
						if( !iPass )
						{
							for( int j = 0; j < iElementCounter; ++j )
							{
								qElementEquations->m_iColumns = iReactantCounter;
								qElementEquations->m_ppdMatrix[j] = (double*)realloc( qElementEquations->m_ppdMatrix[j], sizeof( double ) * iReactantCounter );
								qElementEquations->m_ppdMatrix[j][iReactantCounter-1] = 0;
							}
						}
						else
						{
							qElementEquations->m_iColumns = iReactantCounter;
							qElementEquations->m_ppdMatrix[iElementCounter-1] = (double*)malloc( sizeof( double ) * iReactantCounter );
						}
						memset( qElementEquations->m_ppdMatrix[iElementCounter-1], 0, sizeof( double ) * ( iReactantCounter - 1 ) );
						qElementEquations->m_ppdMatrix[iElementCounter-1][iReactantCounter-1] = ( iMult * iAmount );
					}
					else
					{
						if( !iPass )
						{
							for( int j = 0; j < iElementCounter; ++j )
							{
								qElementEquations->m_iColumns = iReactantCounter;
								qElementEquations->m_ppdMatrix[j] = (double*)realloc( qElementEquations->m_ppdMatrix[j], sizeof( double ) * iReactantCounter );
								qElementEquations->m_ppdMatrix[j][iReactantCounter-1] = 0;
							}
						}
						qElementEquations->m_ppdMatrix[iPlace][iReactantCounter-1] = ( iMult * iAmount );
					}
					
					free( pchName );
				}
			}
			if( pchInput[i] == '(' )
			{
				int iCompoundLength = 1;
				int iParenCounter = 0;
				
				for( int j = 0; j < 64; ++j )
				{
					++iCompoundLength;
					if( pchInput[i+j] == '(' )
					{
						++iParenCounter;
					}
					
					if( pchInput[i+j] == ')' )
					{
						--iParenCounter;
					}
					
					if( iParenCounter == 0 )
					{
						break;
					}
				}
				
				iIncrement += ( iCompoundLength - 2 );
				
				char* pchName = (char*)malloc( sizeof( char ) * iCompoundLength );
				for( int j = 0; j < ( iCompoundLength ); ++j )
				{
					pchName[j] = pchInput[i+j];
				}
				pchName[iCompoundLength-1] = '\0';
				
				int iAmount = 1;
				
				if( ( pchInput[i+iCompoundLength-1] == '(' ) && ( ( pchInput[i+iCompoundLength] >= 48 ) && ( pchInput[i+iCompoundLength] <= 57 ) ) )
				{
					++iIncrement;
					char* chNumberBuffer = (char*)malloc( sizeof( char ) * 10 );
					for( int j = 0; j <= 9; ++j )
					{
						++iIncrement;
						if( pchInput[i+iCompoundLength+j] == ')' )
						{
							break;
						}
						chNumberBuffer[j] = pchInput[i+iCompoundLength+j];
					}
					iAmount = atoi( chNumberBuffer );
					free( chNumberBuffer );
				}
					
				int iPlace = -1;
				for( int j = 0; j < iElementCounter; ++j )
				{
					if( !strcmp( pchName, ppchElementNames[j] ) )
					{
						iPlace = j;
					}
				}

				if( iPlace == -1 )
				{
					++iElementCounter;
					ppchElementNames = (char**)realloc( ppchElementNames, sizeof( char* ) * iElementCounter );
					ppchElementNames[iElementCounter-1] = (char*)malloc( sizeof( char ) * iCompoundLength );
					memcpy( ppchElementNames[iElementCounter-1], pchName, iCompoundLength );
					
					qElementEquations->m_iRows = iElementCounter;
					qElementEquations->m_ppdMatrix = (double**)realloc( qElementEquations->m_ppdMatrix, sizeof( double* ) * iElementCounter );
					if( !iPass )
					{
						for( int j = 0; j < iElementCounter; ++j )
						{
							qElementEquations->m_iColumns = iReactantCounter;
							qElementEquations->m_ppdMatrix[j] = (double*)realloc( qElementEquations->m_ppdMatrix[j], sizeof( double ) * iReactantCounter );
							qElementEquations->m_ppdMatrix[j][iReactantCounter-1] = 0;
						}
					}
					else
					{
						qElementEquations->m_iColumns = iReactantCounter;
						qElementEquations->m_ppdMatrix[iElementCounter-1] = (double*)malloc( sizeof( double ) * iReactantCounter );
					}
					memset( qElementEquations->m_ppdMatrix[iElementCounter-1], 0, sizeof( double ) * ( iReactantCounter - 1 ) );
					qElementEquations->m_ppdMatrix[iElementCounter-1][iReactantCounter-1] = ( iMult * iAmount );
				}
				else
				{
					if( !iPass )
					{
						for( int j = 0; j < iElementCounter; ++j )
						{
							qElementEquations->m_iColumns = iReactantCounter;
							qElementEquations->m_ppdMatrix[j] = (double*)realloc( qElementEquations->m_ppdMatrix[j], sizeof( double ) * iReactantCounter );
							qElementEquations->m_ppdMatrix[j][iReactantCounter-1] = 0;
						}
					}
					qElementEquations->m_ppdMatrix[iPlace][iReactantCounter-1] = ( iMult * iAmount );
				}
				
				free( pchName );
			}
			i+=iIncrement;
			++iPass;
		}
		memset( pchInput, ' ', 64 );
	}
	
	free( pchInput );
	
	qMatrixB->m_iRows = iElementCounter;
	qMatrixB->m_iColumns = 1;
	qMatrixB->m_ppdMatrix = (double**)malloc( sizeof( double* ) * iElementCounter );
	for( int i = 0; i < iElementCounter; ++i )
	{
		qMatrixB->m_ppdMatrix[i] = (double*)malloc( sizeof( double ) * 1 );
		qMatrixB->m_ppdMatrix[i][0] = fabs( qElementEquations->m_ppdMatrix[i][iReactantCounter-1] );
		qElementEquations->m_ppdMatrix[i] = (double*)realloc( qElementEquations->m_ppdMatrix[i], sizeof( double ) * ( iReactantCounter - 1 ) );
	}
	--iReactantCounter;
	--qElementEquations->m_iColumns;
	
	/*
	printf( "\nElement Equation Matrix:\n" );
	for( int i = 0; i < iElementCounter; ++i )
	{
		printf( "%s [", ppchElementNames[i] );
		for( int j = 0; j < ( iReactantCounter + 1 ); ++j )
		{
			if( j == iReactantCounter )
			{
				printf( " = %6.2f ", qMatrixB->m_ppdMatrix[i][0] );
				continue;
			}
			printf( " %6.2f ", qElementEquations->m_ppdMatrix[i][j] );
		}
		printf( "]\n" );
	}
	*/
	
	SMatrix* qMatrixA = SquareMatrix( qElementEquations );
	
	/*
	printf( "\nMatrix A:\n" );
	for( int i = 0; i < qMatrixA->m_iRows; ++i )
	{
		for( int j = 0; j < qMatrixA->m_iRows; ++j )
		{
			printf( "%6.2f", qMatrixA->m_ppdMatrix[i][j] );
		}
		printf( "\n" );
	}
	*/
	
	/*
	printf( "\nMatrix B:\n" );
	for( int i = 0; i < iElementCounter; ++i )
	{
		printf( "%6.2f\n", qMatrixB->m_ppdMatrix[i][0] ); 
	}
	*/
	
	SMatrix* qMatrixAInverse = GetInverseMatrix( qMatrixA );
	
	/*
	printf( "\nMatrix A Inverse:\n" );
	for( int i = 0; i < qMatrixAInverse->m_iRows; ++i )
	{
		for( int j = 0; j < qMatrixAInverse->m_iRows; ++j )
		{
			printf( "%6.2f", qMatrixAInverse->m_ppdMatrix[i][j] );
		}
		printf( "\n" );
	}
	*/
	
	double dDet = (double)DeterminantOfMatrix( qMatrixA );
	
	SMatrix* qFirstMatrix = MultiplyMatrixes( qMatrixAInverse, qMatrixB );
	
	/*
	printf( "\nMatrix A^-1 * Matrix B:\n" );
	for( int i = 0; i < qFirstMatrix->m_iRows; ++i )
	{
		printf( "%6.2f\n", 	qFirstMatrix->m_ppdMatrix[i][0] );
	}
	*/
	
	/*
	printf( "\nDeterminant of Matrix A: %.0f\n", fDet );
	*/

	MultiplyByConstant( qFirstMatrix, dDet );
	
	int iGCDArray[100];
	for( int i = 0; i < ( iReactantCounter + 1 ); ++i )
	{
		if( i != ( iReactantCounter ) )
		{
			iGCDArray[i] = qFirstMatrix->m_ppdMatrix[i][0];
		}
		else
		{
			iGCDArray[i] = dDet;
		}
	}
	
	int iGCD = GreatestCommonDenominatorArray( iGCDArray, ( iReactantCounter + 1 ) );
	
	/*
	printf( "\n( Matrix A^-1 * Matrix B ) * det( Matrix A ):\n" );
	for( int i = 0; i < iSquare; ++i )
	{
		printf( "%6.2f\n", ppdFirstMatrix[i][0] );
	}
	*/
	
	printf( "\nYour final solution is:\n" );
	int iFirst = 1;
	for( int i = 0; i < iChangePoint; ++i )
	{
		if( iFirst )
		{
			printf( "%.0f", fabs( qFirstMatrix->m_ppdMatrix[i][0] / iGCD ) );
			printf( "%s", ppchReactants[i] );
			iFirst = 0;
		}
		else
		{
			printf( " + " );
			printf( "%.0f", fabs( qFirstMatrix->m_ppdMatrix[i][0] / iGCD ) );
			printf( "%s", ppchReactants[i] );
		}
	}
	printf( " -> " );
	iFirst = 1;
	for( int i = iChangePoint; i < (iReactantCounter+1); ++i )
	{
		if( i != ( iReactantCounter ) )
		{
			if( iFirst )
			{
				printf( "%.0f", fabs( qFirstMatrix->m_ppdMatrix[i][0] / iGCD ) );
				printf( "%s", ppchReactants[i] );
				iFirst = 0;
			}
			else
			{
				printf( " + " );
				printf( "%.0f", fabs( qFirstMatrix->m_ppdMatrix[i][0] / iGCD ) );
				printf( "%s", ppchReactants[i] );
			}
		}
		else
		{
			if( iFirst )
			{
				printf( "%.0f", fabs( dDet / iGCD ) );
				printf( "%s", ppchReactants[i] );
			}
			else
			{
				printf( " + " );
				printf( "%.0f", fabs( dDet / iGCD ) );
				printf( "%s", ppchReactants[i] );
			}
		}
	}
	
	FreeMatrix( qElementEquations );
	FreeMatrix( qMatrixB );
	FreeMatrix( qMatrixA );
	FreeMatrix( qMatrixAInverse );
	FreeMatrix( qFirstMatrix );
	
	// ppchElementNames
	for( int i = 0; i < iElementCounter; ++i )
	{
		free( ppchElementNames[i] );
	}
	free( ppchElementNames );
	
	//Free ppchReactants
	for( int i = 0; i < ( iReactantCounter + 1 ); ++i )
	{
		free( ppchReactants[i] );
	}
	free( ppchReactants );
	
	return 0;
}