本文整理汇总了C++中boost::numeric::ublas::matrix类的典型用法代码示例。如果您正苦于以下问题:C++ matrix类的具体用法?C++ matrix怎么用?C++ matrix使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了matrix类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
}
示例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);
}
}
};
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
};
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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";
}
示例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();
}
示例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);
}