Exemple #1
3
TEST(OptimizationBfgsUpdate, bfgs_update_secant) {
  typedef stan::optimization::BFGSUpdate_HInv<> QNUpdateT;
  typedef QNUpdateT::VectorT VectorT;

  const unsigned int nDim = 10;
  QNUpdateT bfgsUp;
  VectorT yk(nDim), sk(nDim), sdir(nDim);

  // Construct a set of BFGS update vectors and check that
  // the secant equation H*yk = sk is always satisfied.
  for (unsigned int i = 0; i < nDim; i++) {
    sk.setZero(nDim);
    yk.setZero(nDim);
    sk[i] = 1;
    yk[i] = 1;

    bfgsUp.update(yk,sk,i==0);

    // Because the constructed update vectors are all orthogonal the secant
    // equation should be exactlty satisfied for all nDim updates.
    for (unsigned int j = 0; j <= i; j++) {
      sk.setZero(nDim);
      yk.setZero(nDim);
      sk[i - j] = 1;
      yk[i - j] = 1;

      bfgsUp.search_direction(sdir,yk);
      
      EXPECT_NEAR((sdir + sk).norm(),0.0,1e-10);
    }
  }
}
/// \brief		Unscented transform of process Sigma points
void UnscentedKalmanFilter::utf(vnl_matrix<double> X, vnl_vector<double> u,
	vnl_vector<double> &y, vnl_matrix<double> &Y, vnl_matrix<double> &P, vnl_matrix<double> &Y1)
{
	// determine number of sigma points
	unsigned int L = X.cols();
	// zero output matrices
	y.fill(0.0); Y.fill(0.0);

	// transform the sigma points and put them as columns in a matrix Y
	for( int k = 0; k < L; k++ )
	{
		vnl_vector<double> xk = X.get_column(k);
		vnl_vector<double> yk(N);
		f(xk,u,yk);
		Y.set_column(k,yk);
		// add each transformed point to the weighted mean
		y = y + Wm.get(0,k)*yk;
	}

	// create a matrix with each column being the weighted mean
	vnl_matrix<double> Ymean(N,L);
	for( int k = 0; k < L; k++ )
		Ymean.set_column(k,y);
	// set the matrix of difference vectors
	Y1 = Y-Ymean;
	// calculate the covariance matrix output
	vnl_matrix<double> WC(L,L,0.0);
	WC.set_diagonal(Wc.get_row(0));
	P = Y1*WC*Y1.transpose();
}
Exemple #3
0
TEST(OptimizationBfgsUpdate, BFGSUpdate_HInv_update) {
  typedef stan::optimization::BFGSUpdate_HInv<> QNUpdateT;
  typedef QNUpdateT::VectorT VectorT;

  const unsigned int nDim = 10;
  QNUpdateT bfgsUp;
  VectorT yk(nDim), sk(nDim), sdir(nDim);

  for (unsigned int i = 0; i < nDim; i++) {
    sk.setZero(nDim);
    yk.setZero(nDim);
    sk[i] = 1;
    yk[i] = 1;

    bfgsUp.update(yk,sk,i==0);
  }
}
Exemple #4
0
void testMat()
{
	int k=FreqSys(1,1)/FreqSys(1,2);
	//cout<<k<<endl;
	math::matrix<double> yu(4,4);
	for (int i=0;i<4;i++)
	{
		yu(0,i)=i+1;
		yu(i,0)=i+1;
		if (i==1)
		{
			yu(1,1)=5;yu(1,i+1)=9;yu(1,i+2)=10;
			yu(1+i,1)=9;yu(i+2,1)=10;
		}
		yu(2,2)=22;yu(2,3)=20;
		yu(3,2)=20;
		yu(3,3)=37;

	}
	//cout<<yu<<endl;

	math::matrix<double> yk(4,4);
	math::matrix<double> ol(4,1);
	math::matrix<double>* yyy=new math::matrix<double>[2];

	for (int i=0;i<4;i++)
	{
		for (int j=0;j<1;j++)
		{
			ol(i,j)=(i+1.2)+j*0.2;
		}
		//math::matrix<double> ols(4,1);
	}
	yyy[0]=ol;
	math::matrix<double>I(2,2);
	//cout<<yu<<endl;
	//cout<<InsertZeroCol(yu,0,1);
	for (int i=0;i<2;i++)
	{
		I(i,i)=12.0;
	}
	//cout<<Kronecker(yu,I,2);
}
Exemple #5
0
TEST(OptimizationBfgsUpdate, BFGSUpdate_HInv_search_direction) {
  typedef stan::optimization::BFGSUpdate_HInv<> QNUpdateT;
  typedef QNUpdateT::VectorT VectorT;

  const unsigned int nDim = 10;
  QNUpdateT bfgsUp;
  VectorT yk(nDim), sk(nDim), sdir(nDim);

  for (unsigned int i = 0; i < nDim; i++) {

    for (unsigned int j = 0; j <= i; j++) {
      sk.setZero(nDim);
      yk.setZero(nDim);
      sk[i - j] = 1;
      yk[i - j] = 1;

      bfgsUp.search_direction(sdir,yk);
      
    }
  }
}
void ChangeMasterKeyWidget::ykDetected(int slot, bool blocking)
{
    YkChallengeResponseKey yk(slot, blocking);
    m_ui->challengeResponseCombo->addItem(yk.getName(), QVariant(slot));
    m_ui->challengeResponseGroup->setEnabled(true);
}