Original Post
I apologize for posting all this code, but I see little alternative.
This should be a VERY simple application to put together - or so I thought. Then I started messing with templates. Regardless, I get an unresolved external symbol error for each function.
Any ideas??
/* SOMLattice Header
Robert Kirk Delisle
23 March 2004
Purpose: Defines the SOM Lattice containing the SOMCell nodes.
Responsible for creation and management of SOMCells
and training of the network
Modification History:
*/
#if !defined(SOMLattice_23March2004__INCLUDED)
#define SOMLattice_23March2004__INCLUDED
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <vector>
using namespace std;
#include "DataSet.h"
template<class SOMCellType> class CSOMLattice
{
private:
struct LatticeCell
{
long XPos; //the X-position within the lattice
long YPos; //the Y-position within the lattice
SOMCellType *Cell; //the actual cell itself
};
vector<LatticeCell> m_SOMCells; //the nodes of the SOM - assumed to be derived from CSOMCell
long m_lWidth; //width of the lattice
long m_lHeight; //height of the lattice
long m_lLatticeRadius; //topological radius of the SOM lattice
public:
CSOMLattice() {};
bool Initialize(long Width, long Height, long NumberOfWeights);
//primary lattice construction routine
bool Train(DataSet *data, long numIterations);
//function to start training the lattice
~CSOMLattice();
};
#endif
/* SOMLattice Implementation
Robert Kirk Delisle
24 March 2004
Purpose: Implements the SOM Lattice containing the SOMCell nodes.
Responsible for creation and management of SOMCells
and training of the network
Modification History:
*/
#include "stdafx.h"
#include "SOMLattice.h"
template<class SOMCellType> bool CSOMLattice<SOMCellType>::Initialize(long Width, long Height, long NumberOfWeights)
{
/* Robert Kirk DeLisle
24 March 2004
Purpose: Constructs the SOM lattice based upon the passed paramenters.
Parameters: Width - desired width of the lattice
Height - desired height of the lattice
Return: none
*/
bool bSuccess=true; //optimistic return
LatticeCell *currentCell;
long i,j; //loop indices
//make space for the cells
m_SOMCells = vector<LatticeCell*>(Width*Height);
try
{
//put cells into the lattice
for (i=0; i<Width; i++)
{
for (j=0; j<Height; j++)
{
currentCell = new LatticeCell;
currentCell->XPos=i;
currentCell->YPos=j;
currentCell->Cell = new SOMCellType(NumberOfWeights);
m_SOMCells.push_back(currentCell);
}
}
}
catch(...)
{
bSuccess=false;
}
return bSuccess;
}
template<class SOMCellType>bool CSOMLattice<SOMCellType>::Train(DataSet *data, long numIterations)
{
/* Robert Kirk DeLisle
24 March 2004
Purpose: Trains the SOM for the desired number of iterations.
One iteration is defined as comparison of one observation
and adjustment of weights. <this may be modified to an epoch.>
Parameters: data - pointer to the DataSet object from where to derive the observations
Return: true if successful
false otherwise
*/
return true;
}
template<class SOMCellType> CSOMLattice<SOMCellType>::~CSOMLattice()
{
/* Robert Kirk DeLisle
25 March 2004
Purpose: Release references as needed.
Parameters: none
Return: none
*/
int i; //loop index
for (i=0; i<m_SOMCells.size(); i++)
{
if (m_SOMCells[i] != 0)
{
delete m_SOMCells[i];
}
}
m_SOMCells.clear();
}
[edited by - KirkD on March 25, 2004 10:56:20 AM]
[edited by - KirkD on March 25, 2004 1:43:28 PM]