- use Matrix, linear algebra library Eigen 3.2.2

git-svn-id: http://moon:8086/svn/software/trunk/projects/RBM@23 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2014-10-12 14:30:40 +00:00
parent 7b1a713adc
commit 19c69ac02a
13 changed files with 246 additions and 359 deletions
+10 -20
View File
@@ -48,11 +48,11 @@ DrawComponent::DrawComponent (int width, int height)
//[Constructor] You can add your own custom stuff here..
// m_pG = new Graphics(m_image);
m_pData = new double[width*height];
memset(m_pData, 0, m_width*m_height*sizeof(double));
m_data.resize(width*height);
Noise_Init(&noise, 0x3231);
m_pG->setImageResamplingQuality(Graphics::lowResamplingQuality);
clear();
//[/Constructor]
}
@@ -65,7 +65,6 @@ DrawComponent::~DrawComponent()
//[Destructor]. You can add your own custom destruction code here..
m_pG = nullptr;
m_pData = nullptr;
//[/Destructor]
}
@@ -195,7 +194,7 @@ void DrawComponent::drawAt(int x, int y, bool setColor)
{
if (setColor)
{
if (m_pData[index] > 0.0)
if (m_data[index] > 0.0)
{
m_currData = 0.0;
m_currColor = (Colours::black);
@@ -206,7 +205,7 @@ void DrawComponent::drawAt(int x, int y, bool setColor)
m_currColor = (Colours::white);
}
}
m_pData[index] = m_currData;
m_data[index] = m_currData;
m_pG->setColour (m_currColor);
}
}
@@ -219,35 +218,26 @@ void DrawComponent::drawAt(int x, int y, bool setColor)
void DrawComponent::clear()
{
double *pData = m_pData;
for (int i=0; i < m_width*m_height; i++)
{
*(pData++) = 0;
}
setData(m_pData);
m_data.fill(0);
setData(m_data);
}
const double* DrawComponent::getData ()
const VectorXd& DrawComponent::getData ()
{
return m_pData;
return m_data;
}
void DrawComponent::setData (const double *pData)
void DrawComponent::setData (const VectorXd& data)
{
double a;
for (int i=0; i < m_width*m_height; i++)
{
m_pData[i] = pData[i];
}
for (int i=0; i < m_height; i++)
{
for (int j=0; j < m_width; j++)
{
a = std::min<double>(std::max<double>(*pData, 0), 1);
a = std::min<double>(std::max<double>((double)data[i*m_width + j], 0), 1);
m_pG->setColour(Colour(Colours::white).greyLevel(a));
m_pG->fillRect(m_scaleX*j, m_scaleY*i, m_scaleX, m_scaleY);
pData++;
}
}
repaint();