Esempio n. 1
0
void verify_is_approx_upto_permutation(const VectorType& vec1, const VectorType& vec2)
{
  typedef typename NumTraits<typename VectorType::Scalar>::Real RealScalar;

  VERIFY(vec1.cols() == 1);
  VERIFY(vec2.cols() == 1);
  VERIFY(vec1.rows() == vec2.rows());
  for (int k = 1; k <= vec1.rows(); ++k)
  {
    VERIFY_IS_APPROX(vec1.array().pow(RealScalar(k)).sum(), vec2.array().pow(RealScalar(k)).sum());
  }
}
Esempio n. 2
0
void verify_is_approx_upto_permutation(const VectorType& vec1, const VectorType& vec2)
{
  typedef typename VectorType::Scalar Scalar;
  typedef typename NumTraits<Scalar>::Real RealScalar;

  VERIFY(vec1.cols() == 1);
  VERIFY(vec2.cols() == 1);
  VERIFY(vec1.rows() == vec2.rows());
  
  Index n = vec1.rows();
  RealScalar tol = test_precision<RealScalar>()*test_precision<RealScalar>()*numext::maxi(vec1.squaredNorm(),vec2.squaredNorm());
  Matrix<RealScalar,Dynamic,Dynamic> diffs = (vec1.rowwise().replicate(n) - vec2.rowwise().replicate(n).transpose()).cwiseAbs2();
  
  VERIFY( find_pivot(tol, diffs) );
}
Esempio n. 3
0
void getIndecesSmallerGreater(const VectorType &gt_vector, float thresh, MatrixTypeUint &found_smaller_indeces,MatrixTypeUint & found_greater_indeces ){


    unsigned int n_samples = gt_vector.rows();
    MatrixTypeUint found_greater_indeces_temp = MatrixTypeUint::Zero(n_samples,1);
    MatrixTypeUint found_smaller_indeces_temp = MatrixTypeUint::Zero(n_samples,1);


    unsigned int i_found_great = 0;
    unsigned int i_found_small = 0;
    for(unsigned int i_sample = 0; i_sample<n_samples; i_sample++){
        if(gt_vector(i_sample)>=thresh){
            found_greater_indeces_temp(i_found_great) = i_sample;
            i_found_great++;
        }
        else{
            found_smaller_indeces_temp(i_found_small) = i_sample;
            i_found_small++;
        }
    }

    found_greater_indeces = found_greater_indeces_temp.head(i_found_great);
    found_smaller_indeces = found_smaller_indeces_temp.head(i_found_small);




}
Esempio n. 4
0
void testTriangularProduct(const MatrixType& m, const VectorType& v, double tol)
{
  typedef typename MatrixType::RealScalar RealScalar;
  MatrixType m1;
  VectorType v1, v2, v3;
  RealScalar p;

  for (int i=0; i < g_repeat; ++i) {
    generateTriangularMatrix<MatrixType>::run(m1, m.rows());
    MatrixPowerTriangular<MatrixType> mpow(m1);

    v1 = VectorType::Random(v.rows(), v.cols());
    p = internal::random<RealScalar>();

    v2.noalias() = mpow(p) * v1;
    v3.noalias() = mpow(p).eval() * v1;
    std::cout << "testTriangularProduct: error powerm = " << relerr(v2, v3) << '\n';
    VERIFY(v2.isApprox(v3, static_cast<RealScalar>(tol)));
  }
}