• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ ublas::matrix类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中boost::numeric::ublas::matrix的典型用法代码示例。如果您正苦于以下问题:C++ matrix类的具体用法?C++ matrix怎么用?C++ matrix使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了matrix类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: for_each

inline void for_each(boost::numeric::ublas::matrix<T> & mat, Fun f){
    for(auto it1 = mat.begin1(); it1 < mat.end1(); ++it1){
        for(auto it = it1.begin(); it < it1.end(); ++it){
            f(*it);
        }
    }
}
开发者ID:adevress,项目名称:hadoken,代码行数:7,代码来源:ublas.hpp


示例2: fill_boost_matrix_from_munkres_matrix

void fill_boost_matrix_from_munkres_matrix (boost::numeric::ublas::matrix <T> & boost_matrix, const Matrix <T> & matrix)
{
    const int dimention = std::min (boost_matrix.size1 (), boost_matrix.size2 () );
    for (int i = 0; i < dimention; ++i) {
        for (int j = 0; j < dimention; ++j) {
            boost_matrix (i, j) = matrix (i, j);
        }
    }
};
开发者ID:buiksat,项目名称:aau_multi_robot,代码行数:9,代码来源:boost_matrix.cpp


示例3: det_chol

    double det_chol(const ublas::matrix<double,F,A> &m)
	// Compute determinant of Cholesky matrix. 
    {
        assert(m.size1() == m.size2());
        double d = 1.;
        for (size_t i=0; i < m.size1(); ++i)
            d *= m(i,i);
        return d;
    }
开发者ID:Aaaaaaare,项目名称:beliefbox,代码行数:9,代码来源:cholesky.hpp


示例4: summOffDiagonal2

double summOffDiagonal2(boost::numeric::ublas::matrix<double> &S) {
	double sum = 0;
	for (int i = 0; i < S.size1(); i++) {
		for (int j = i + 1; j < S.size2(); j++)
		{
			sum += abs(S(i, j));
		}
	}
	return sum;
}
开发者ID:NikiforovAll,项目名称:JacobiEigenvalueAlgorithm,代码行数:10,代码来源:Util.cpp


示例5: diameter

double diameter(const ublas::matrix<double>& D)
{
  double total = 0;
  for(int i=0;i<D.size1();i++)
    for(int j=0;j<i;j++)
      total += D(i,j);
  
  int N = D.size1() * (D.size1() - 1) /2;

  return total/N;
}
开发者ID:sibonli,项目名称:BAli-Phy,代码行数:11,代码来源:alignment-median.C


示例6: printMatrix

void printMatrix(boost::numeric::ublas::matrix<int> matrix) {
    for (unsigned int i=0; i < matrix.size1(); i++) {
        for (unsigned int j=0; j < matrix.size2(); j++) {
            cout << matrix(i, j);
            if(j+1 != matrix.size2()) {
                cout << "\t";
            }    
        }
        cout << endl;
    }
}
开发者ID:romanarranz,项目名称:AC,代码行数:11,代码来源:libraryboost.cpp


示例7: convert_boost_matrix_to_munkres_matrix

Matrix <T> convert_boost_matrix_to_munkres_matrix (const boost::numeric::ublas::matrix <T> & boost_matrix)
{
    const int dimention = std::min (boost_matrix.size1 (), boost_matrix.size2 () );
    Matrix <T> matrix (dimention, dimention);
    for (int i = 0; i < dimention; ++i) {
        for (int j = 0; j < dimention; ++j) {
            matrix (i, j) = boost_matrix (i, j);
        }
    }

    return matrix;
};
开发者ID:buiksat,项目名称:aau_multi_robot,代码行数:12,代码来源:boost_matrix.cpp


示例8: determinant

double determinant( bnu::matrix<double>& m ) {
    bnu::permutation_matrix<std ::size_t> pm(m.size1());
    double det = 1.0;
    if( bnu::lu_factorize(m,pm) ) {
        det = 0.0;
    } else {
        for(int i = 0; i < m.size1(); i++)
            det *= m(i,i); // multiply by elements on diagonal
        det = det * determinant_sign( pm );
    }
    return det;
}
开发者ID:zernexz,项目名称:posys2,代码行数:12,代码来源:invert_matrix.hpp


示例9: is_symmetric

	bool is_symmetric(const ublas::matrix<double, F, A> &m)
	{
		if (m.size1() != m.size2())
			return false;

		for (size_t i = 0; i < m.size1(); ++i)
			for (size_t j = i+1; j < m.size2(); ++j)
				if (m(i,j) != m(j,i))
					return false;

		return true;
	}
开发者ID:Aaaaaaare,项目名称:beliefbox,代码行数:12,代码来源:symmetry.hpp


示例10: inverted

matrix<double> BoostMatrixFacade::invert(const boost::numeric::ublas::matrix<double> matrix)
{
    boost::numeric::ublas::matrix<double> inverted(matrix.size1(), matrix.size2());
    cpu_invert(matrix, inverted);

    for( int i = 0; i < inverted.size1(); i++ )
        for( int j = 0; j < inverted.size2(); j++ )
            if( isnan(inverted(i, j)) )
                inverted(i, j) = 0;

    return inverted;
}
开发者ID:idaohang,项目名称:glonass-sdkm,代码行数:12,代码来源:boost_matrix_facade.cpp


示例11: createImgMap

cv::Mat Bridge::createImgMap(const boost::numeric::ublas::matrix<STATE> &groundMap) {
    cv::Mat ground(groundMap.size1(), groundMap.size2(), CV_8UC3, cv::Scalar(0, 0, 0));
    for (unsigned int i = 0; i < groundMap.size1(); ++i) {
        for (unsigned int j = 0; j < groundMap.size2(); ++j) {
            if (groundMap(i, j) == 0) {
                ground.at<cv::Vec3b>(i, j) = cv::Vec3b(0, 0, 0);
            } else {
                ground.at<cv::Vec3b>(i, j) = cv::Vec3b(255, 255, 255);
            }
        }
    }
    return ground;
}
开发者ID:Ernyoke,项目名称:VREP_Pathfinding,代码行数:13,代码来源:Bridge.cpp


示例12: assert

const boost::numeric::ublas::matrix<double>
  FixedLagSmootherKalmanFilter::CreateTermA(
  const int lag,
  const int state_size)
{
  //
  assert(lag > 0 && "Term A is not needed for a lag of zero");
  const boost::numeric::ublas::matrix<double> v
    = Matrix::SimplifyVectorOfMatrix(CreateComplexTermA(lag,state_size));
  assert(lag * state_size == boost::numeric_cast<int>(v.size1()));
  assert(  1 * state_size == boost::numeric_cast<int>(v.size2()));
  return v;
}
开发者ID:markwiering,项目名称:ProjectRichelBilderbeek,代码行数:13,代码来源:fixedlagsmootherkalmanfilter.cpp


示例13: pprint

      void pprint(const boost::numeric::ublas::matrix<double>& m) {
	cout << "[";
	for( uint r=0; r < m.size1(); r++) {
	  for( uint c=0; c < m.size2(); c++) {
	    cout << m(r,c);
	    if(c == m.size2()-1 && r != m.size1()-1) 
	      cout << "\n ";
	    else if(c != m.size2()-1)
	      cout << " , ";
	  }
	}
	cout << "]\n";
      }
开发者ID:bilian1995,项目名称:Delite,代码行数:13,代码来源:OptiML.hpp


示例14: serialize

inline void serialize(json_output_handler& os, const boost::numeric::ublas::matrix<double>& A)
{
    os.begin_array();
    for (size_t i = 0; i < A.size1(); ++i)
    {
        os.begin_array();
        for (size_t j = 0; j < A.size2(); ++j)
        {
            os.value(A(i, j));
        }
        os.end_array();
    }
    os.end_array();
}
开发者ID:gusev-vitaliy,项目名称:jsoncons,代码行数:14,代码来源:my_any_specializations.hpp


示例15: resize

void resize(ublas::matrix<int>& M1,int s1,int s2,int clear=0)
{
  ublas::matrix<int> M2(s1,s2);

  for(int i=0;i<M2.size1();i++)
    for(int j=0;j<M2.size2();j++)
      M2(i,j) = clear;

  for(int i=0;i<M1.size1() and i<M2.size1();i++)
    for(int j=0;j< M1.size2() and j<M2.size2();j++)
      M2(i,j) = M1(i,j);

  M1.swap(M2);
}
开发者ID:,项目名称:,代码行数:14,代码来源:


示例16: FixedMatrix

	FixedMatrix( const boost::numeric::ublas::matrix<TYPE> &boost_matrix ) throw ( std::logic_error & ) {
		if( boost_matrix.size1() == ROWS && boost_matrix.size2() == COLS ) {
			for( size_t m = 0; m < ROWS; m++ ) {
				for( size_t n = 0; n < COLS; n++ ) {
					this->elem( n, m ) = boost_matrix( m, n );
				}
			}
		} else {
			LOG( Runtime, error ) << "The size of the boost matrix ("
								  << boost_matrix.size1() << ", " << boost_matrix.size2()
								  << ") does not coincide with the size of the isis matrix (" << ROWS << ", " << COLS << ").";
			throw( std::logic_error( "Size mismatch" ) );
		}
	};
开发者ID:Rollmops,项目名称:isis,代码行数:14,代码来源:matrix.hpp


示例17: jacobiSync

int jacobiSync(
	boost::numeric::ublas::matrix<double> &S,
	boost::numeric::ublas::vector<double> &e,
	boost::numeric::ublas::matrix<double>  &U,
	int &iter,
	bool isOptimized)
{
	iter = 0;
	int col, row;
	bool iterating = true;
	int n = S.size1();
	if (S.size2() != n)
	{
		return -1;
	}
	boost::numeric::ublas::matrix<double> M(n, n);
	e = boost::numeric::ublas::zero_vector<double>(n);
	U = boost::numeric::ublas::identity_matrix<double>(n, n);
	while (iterating)
	{
		M = S;
		abs(M);
		iter++;
		for (int k = 0; k < n; k++)
		{
			M(k, k) = 0;
		}
		findMax(M, row, col);
		if (row == col)
		{
			for (int i = 0; i < n; i++) e(i) = S(i, i);
			return 0;
		}
		double Smax = S(row, col);
		if (isOptimized) {
			rotateColRowJacobi(S, row, col);
		}
		else {
			rotateRowCol(S, U, row, col);
		}
		//cout<<row<<" row|col "<<col <<" sum: "<< sumOffDiagonal(S) << endl;
		//if (Smax < _EPS * norm_frobenius(S)) iterating = false;
		if (sumOffDiagonal(S) < _EPS) iterating = false;
	}

	for (int i = 0; i < n; i++) e(i) = S(i, i);

	return 0;
}
开发者ID:NikiforovAll,项目名称:JacobiEigenvalueAlgorithm,代码行数:49,代码来源:JacobiSync.cpp


示例18: invert

 bool invert(const boost::numeric::ublas::matrix<T>& input, boost::numeric::ublas::matrix<T>& inverse) {

   // create a working copy of the input
   boost::numeric::ublas::matrix<T> A(input);

   // create a permutation matrix for the LU-factorization
   boost::numeric::ublas::permutation_matrix<std::size_t> pm(A.size1());

   // perform LU-factorization
   typename boost::numeric::ublas::matrix<T>::size_type res = boost::numeric::ublas::lu_factorize(A, pm);
   if( res != 0 ){
     LOG_FREE(Info, "boost.ublas", "boost::numeric::ublas::lu_factorize returned res = " << res <<
                    ", A = " << A << ", pm = " << pm << " for input = " << input);
     return false;
   }

   // create identity matrix of "inverse"
   inverse.assign(boost::numeric::ublas::identity_matrix<T>(A.size1()));

   // backsubstitute to get the inverse
   try {
     boost::numeric::ublas::lu_substitute(A, pm, inverse);
   }catch (std::exception& e){
     LOG_FREE(Info, "boost.ublas", "boost::numeric::ublas::lu_substitute threw exception '" << e.what() <<
                    "' for A = " << A << ", pm = " << pm);
     return false;
   }

   return true;
 }
开发者ID:ChengXinDL,项目名称:OpenStudio,代码行数:30,代码来源:Matrix.hpp


示例19: determineRowOfFace

int SAFForwardingTable::determineRowOfFace(int face_id, boost::numeric::ublas::matrix<double> tab, std::vector<int> faces)
{
  // check if table fits to faces
  if(tab.size1 () != faces.size ())
  {
    fprintf(stderr, "Error the number of faces dont correspond to the table!\n");
    return FACE_NOT_FOUND;
  }

  if(std::find(faces.begin (), faces.end (), face_id) == faces.end ())
  {
    fprintf(stderr, "Face Not Found!!!\n");
    return FACE_NOT_FOUND;
  }

  //determine row of face
  int faceRow = FACE_NOT_FOUND;
  std::sort(faces.begin(), faces.end());//order

  int rowCounter = 0;
  for(std::vector<int>::iterator i = faces.begin (); i != faces.end() ; ++i)
  {
    //fprintf(stderr, "*i=%d ; face_id=%d\n",*i,face_id);
    if(*i == face_id)
    {
      faceRow = rowCounter;
      break;
    }
    rowCounter++;
  }
  return faceRow;
}
开发者ID:danposch,项目名称:NFD,代码行数:32,代码来源:safforwardingtable.cpp


示例20: matrix_compare

ScalarType matrix_compare(ublas::matrix<ScalarType>& res,
                            ublas::matrix<ScalarType>& ref)
{
    ScalarType diff = 0.0;
    ScalarType mx = 0.0;

    for(std::size_t i = 0; i < res.size1(); i++)
    {
        for(std::size_t j = 0; j < res.size2(); j++)
        {
            diff = std::max(diff, std::abs(res(i, j) - ref(i, j)));
            mx = std::max(mx, res(i, j));
        }
    }

    return diff / mx;
}
开发者ID:andiselinger,项目名称:viennacl-dev,代码行数:17,代码来源:qr_method.cpp



注:本文中的boost::numeric::ublas::matrix类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ublas::vector类代码示例发布时间:2022-05-31
下一篇:
C++ mpi::communicator类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap