Beispiel #1
0
void Kernel::computeKernel(MMatrix &K, const MMatrix &X, const MMatrix &X2) const
{
	assert(K.rowsMatch(X) && K.sizeCol() == X2.sizeRow());
 	
	for(size_t i = 0; i < K.sizeRow(); i++)
	{
		for(size_t j = 0; j < K.sizeCol(); j++)
		{
			K.assign(computeElement(X, i, X2, j), i, j);
		}
	}
}
Beispiel #2
0
MMatrix* AMCParser::loadMocapData(std::string filePath,AMC_OPTIONS opts)
{
	std::ifstream loader(filePath);
	if(loader.fail())
		return false;
	std::string strContent;
	while(strContent != "1")
		std::getline(loader,strContent);

	std::vector<std::vector<float>> RawData;
 	while(!loader.eof())
	{
		int curDOF = 0;
		std::vector<float> pose(mTotalDOF);
		std::getline(loader,strContent);
 
		while(strContent.length() && (strContent[0] <= '0' || strContent[0] >'9'))
		{
			std::stringstream filter(strContent);
			filter >> strContent;
			while(!filter.eof())			
				filter >> pose[curDOF++];
			std::getline(loader,strContent);
		}
		RawData.push_back(pose);
	}

	MMatrix *data = new MMatrix(RawData.size(),RawData[0].size());
	for(size_t i = 0;i < data->sizeRow(); i++)
		for(size_t j = 0; j < data->sizeCol(); j++)
			data->assign(RawData[i][j],i,j);

	return data;
}
Beispiel #3
0
void Kernel::computeDiag(MMatrix &d, const MMatrix &X) const
{
 	assert(X.rowsMatch(d) && d.sizeCol()== 1);
 	size_t nRows = X.sizeRow(); 
	for(size_t t = 0; t < nRows; t++)
	 	 d.assign(computeDiagElement(X,t),t);  
}
Beispiel #4
0
void Transformable::getParams(MMatrix& matParams) const
{
	assert(matParams.sizeCol() == 1 && matParams.sizeRow() == getNumParams());
	for(size_t i = 0; i < matParams.sizeCol(); i++)
	{
		matParams.assign(getParam(i), i);
	}
}
Beispiel #5
0
void Kernel::computeKernel(MMatrix& K, const MMatrix& X, const MMatrix& X2, size_t row) const
{
	assert(K.rowsMatch(X) && K.sizeCol() == 1);
 	
	for(size_t i = 0; i < K.sizeRow(); i++)
	{
 		K.assign(computeElement(X,i,X2,row),i, 0);
	}
}
Beispiel #6
0
void Transformable::setParams(MMatrix& matParams)
{
	assert(matParams.sizeCol() == 1 && matParams.sizeRow() == getNumParams());
	 
	for(size_t i = 0; i < matParams.sizeCol(); i++)
	{
		setParam(matParams.get(i),i);
	}
}
Beispiel #7
0
void Kernel::getGradientParams(MMatrix &g, const MMatrix &X, const MMatrix &X2,const MMatrix &cvGrad,bool regularise) const
{
	assert(g.sizeRow() == 1 && g.sizeCol() == mhps.size());

 	for(size_t t = 0; t < mhps.size(); t++)
	{
		g.assign(getGradientParam(t,X,X2,cvGrad),t);
	}
	if(regularise)
	{
	//	AddPriorGrad(g);
	}
}
Beispiel #8
0
void Transformable::getGradientTransParams(MMatrix& matGrad) const
{
	assert(matGrad.sizeCol() == 1 && matGrad.sizeRow() == getNumParams());
	
	getGradientParams(matGrad);
	size_t unParamsNum = getNumTransform();
	for(size_t i = 0; i < unParamsNum; i++)  
	{
		double tdVal  = matGrad.get(i);
		double tdValX = getParam(i);
		matGrad.assign(tdVal * m_vTransform[i]->Gradient(tdValX),i);
	}
}
Beispiel #9
0
void Kernel::getGradTransParams(MMatrix& g, const MMatrix& X, const MMatrix& cvGrd, bool regularise) const
{
	assert(g.sizeRow()==1);
	assert(g.sizeCol()== mhps.size());
 
	getGradientParams(g, X,cvGrd, regularise);
   
	for(size_t i = 0; i < getNumTransform(); i++)
	{
		double val = g.get(i);
 		double param = getParam(i);
 		g.assign(val * getGradientTransform(param, i),i);
	}
}
Beispiel #10
0
void  Kernel::getDiagGradientParams(MMatrix &g, const MMatrix &X, const MMatrix &covGrad,bool regularise) const
{
 	MMatrix xi(1, X.sizeCol());
    MMatrix cvGradi(1, 1);
    MMatrix gtemp(1, g.sizeCol());
	g.zeroElements();
	for(size_t i = 0; i < X.sizeRow(); i++)
    {
      xi.copyRowRow(0, X, i);
      cvGradi.copyRowRow(0, covGrad, i);
      cvGradi.setSymmetric(true);
      getGradientParams(gtemp, xi, cvGradi, regularise);
      g.axpy(gtemp, 1.0);
    }
}
Beispiel #11
0
void Kernel::computeKernel(MMatrix &K, const MMatrix &X) const
{
	assert(K.rowsMatch(X) && K.isSquare());

	for(size_t i = 0; i < K.sizeRow(); i++)
	{
		for(size_t j = 0; j < i; j++)
		{
			double k = computeElement(X, i, X, j);
	 		K.assign(k,i,j);
			K.assign(k,j,i);
		}
		K.assign(computeDiagElement(X,i), i, i);
	}
	
}
Beispiel #12
0
void Kernel::getGradientX(std::vector<MMatrix*>&gX, const MMatrix &X,const MMatrix &X2,bool addG) const
{
	for(size_t t = 0; t < X.sizeRow(); t++)
		getGradientX(*gX[t],X,t,X2,addG);
}