当前位置: 首页>>代码示例>>C++>>正文


C++ matrix::size2方法代码示例

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


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

示例1: row_min

B row_min(const ublas::matrix<B>& M,int row)
{
  B min=M(row,0);
  for(int i=1;i<M.size2();i++)
    min = std::min(min,M(row,i));
  return min;
}
开发者ID:sibonli,项目名称:BAli-Phy,代码行数:7,代码来源:parsimony.C

示例2: makeParityCheck

ublas::vector<int> makeParityCheck(const ublas::vector<int> &dSource, const ublas::matrix<int> &H, const ublas::matrix<int> &L, const ublas::matrix<int> &U) {
  // Get matrix dimensions
  const unsigned int M = H.size1();
  const unsigned int N = H.size2();

  // Find B.dsource
  const ublas::vector<int> z(mod2(ublas::prod(ublas::subrange(H, 0, M, N - M, N), dSource)));

  //std::cout << "z=" << std::endl;
  //printVector<int>(z);

  //std::cout << "L=" << std::endl;
  //printMatrix<int>(L);

  //std::cout << "U=" << std::endl;
  //printMatrix<int>(U);

  // Parity check vector found by solving sparse LU
  const ublas::vector<int> x1(solve(L, z));
  //std::cout << "x1=" << std::endl;
  //printVector<int>(x1);

  const ublas::vector<int> x2(solve(U, x1));
  //std::cout << "x2=" << std::endl;
  //printVector<int>(x2);

  const ublas::vector<int> c(mod2(x2));

  return c;
}
开发者ID:ericdegroot,项目名称:gr-ldpc_ece535a,代码行数:30,代码来源:ldpc_umfpack.cpp

示例3: writeMatrix

void writeMatrix(const ublas::matrix<T> &A, const char *fileName) {
  std::ofstream fout(fileName, std::ofstream::out);

  for (unsigned int i = 0; i < A.size1(); i++) {
    for (unsigned int j = 0; j < A.size2(); j++) {
      fout << A(i, j);

      if (j + 1 < A.size2()) {
        fout << ",";
      }
    }

    fout << std::endl;
  }

  fout.close();
}
开发者ID:ericdegroot,项目名称:gr-ldpc_ece535a,代码行数:17,代码来源:ldpc_umfpack.cpp

示例4: printMatrix

void printMatrix(const ublas::matrix<T> &A) {
  for (unsigned int i = 0; i < A.size1(); i++) {
    for (unsigned int j = 0; j < A.size2(); j++) {
      std::cout << A(i, j);

      if (j + 1 < A.size2()) {
        std::cout << ", ";
      }
    }

    if (i + 1 < A.size1()) {
      std::cout << ";";
    }

    std::cout << std::endl;
  }
}
开发者ID:ericdegroot,项目名称:gr-ldpc_ece535a,代码行数:17,代码来源:ldpc_umfpack.cpp

示例5:

bool BenchmarkVienna<ScalarType>::is_equal(const ublas::matrix<ScalarType, orientation> &A,
                                           const ublas::matrix<ScalarType, orientation> &B) {
    for (std::size_t i = 0; i < A.size1(); ++i) {
        for (std::size_t j = 0; j < A.size2(); ++j) {
            if ( std::fabs(A(i,j) - B(i,j)) / B(i,j) > 1e-4 ) return false;
        }
    }
    return true;
}
开发者ID:lene,项目名称:lina,代码行数:9,代码来源:BenchmarkVienna.cpp

示例6: check_matrices

int check_matrices(const ublas::matrix< ScalarType >& ref_mat, const ublas::matrix< ScalarType >& mat) {

  std::size_t size1, size2;
  ScalarType eps = 0.00001;
  size1 = ref_mat.size1(); size2 = ref_mat.size2();
  if( (size1 != mat.size1()) || (size2 != mat.size2()) )
    return EXIT_FAILURE;

  for (unsigned int i = 0; i < size1; i++)
    for (unsigned int j = 0; j < size2; j++)
      if ( abs(ref_mat(i,j) - mat(i,j)) > eps ) {
        std::cout << "!!Verification failed at " << i <<" : "<< j
                  << "(expected: " << ref_mat(i,j) << " get: " << mat(i,j) << " )" << std::endl;
        return EXIT_FAILURE;
      }

  std::cout << "Everything went well!" << std::endl;
  return EXIT_SUCCESS;
}
开发者ID:YannCobigo,项目名称:viennacl-dev,代码行数:19,代码来源:spmdm.cpp

示例7: column

/// Extract column @c from the index-matrix @M
vector<int> get_column(const ublas::matrix<int>& M, int c)
{
  vector<int> column(M.size2(),-1);

  for(int i=0;i<column.size();i++)
    if (M(c,i) >= 0)
      column[i] = M(c,i);

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

示例8: homologies_total

long int homologies_total(const ublas::matrix<int>& M1) 
{
  long int total=0;

  for(int column=0;column<M1.size1();column++) 
    for(int i=0;i<M1.size2();i++)
      if (M1(column,i) != alphabet::gap and M1(column,i) != alphabet::unknown)
	total++;

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

示例9: recalcTotal

/**
 * @brief Utility funtion to doing scans for steady states.
 *
 * @param tot
 * @param g
 * @param S
 */
void recalcTotal( vector< double >& tot, ublas::matrix<double>& g, const double* S )
{
    assert( g.size1() == tot.size() );
    for ( size_t i = 0; i < g.size1(); ++i ) 
    {
        double t = 0.0;
        for ( unsigned int j = 0; j < g.size2(); ++j )
            t += g( i, j ) * S[j];
        tot[ i ] = t;
    }
}
开发者ID:2pysarthak,项目名称:moose-core-personal,代码行数:18,代码来源:SteadyStateBoost.cpp

示例10: check_matrices

int check_matrices(const ublas::matrix< ScalarType >& ref_mat, const ublas::matrix< ScalarType >& mat, ScalarType eps) {

  std::size_t size1, size2;
  size1 = ref_mat.size1(); size2 = ref_mat.size2();
  if( (size1 != mat.size1()) || (size2 != mat.size2()) )
    return EXIT_FAILURE;

  for (unsigned int i = 0; i < size1; i++)
    for (unsigned int j = 0; j < size2; j++)
    {
      ScalarType rel_error = std::abs(ref_mat(i,j) - mat(i,j)) / std::max(std::abs(ref_mat(i,j)), std::abs(mat(i,j)));
      if ( rel_error > eps ) {
        std::cout << "ERROR: Verification failed at (" << i <<", "<< j << "): "
                  << " Expected: " << ref_mat(i,j) << ", got: " << mat(i,j) << " (relative error: " << rel_error << ")" << std::endl;
        return EXIT_FAILURE;
      }
    }

  std::cout << "Everything went well!" << std::endl;
  return EXIT_SUCCESS;
}
开发者ID:andiselinger,项目名称:ViennaCL-1.5.2,代码行数:21,代码来源:spmdm.cpp

示例11: ublas_to_vector

void ublas_to_vector(const ublas::matrix<float> &mat, std::vector<double> &vec)
{
  vec.clear();
  for (size_t i=0; i < mat.size1(); i++)
  {
    for (size_t j=0; j < mat.size2(); j++)
    {
      vec.push_back(mat(i,j));
    }
  }

}
开发者ID:sjavdani,项目名称:statsproj,代码行数:12,代码来源:FeatureImageHandler.cpp

示例12: homologies_preserved

long int homologies_preserved(const ublas::matrix<int>& M1,const ublas::matrix<int>& M2,
				    const vector< vector<int> >& column_indices2)
{
  long int match=0;
  long int mismatch=0;

  for(int column=0;column<M1.size1();column++) 
    for(int i=0;i<M1.size2();i++)
      if (M1(column,i) != alphabet::gap and M1(column,i) != alphabet::unknown)
	for(int j=0;j<M1.size2();j++)
	  if (j != i) {
	    if (A_match(M1,column,i,j,M2,column_indices2))
	      match++;
	    else
	      mismatch++;
	  }
	
  assert(homologies_total(M1) == homologies_total(M2));
  assert(homologies_total(M1) == match + mismatch);

  return match;
}
开发者ID:sibonli,项目名称:BAli-Phy,代码行数:22,代码来源:alignment-util.C

示例13: mvnormpdf

ublas::vector<double> mvnormpdf(const ublas::matrix<double>& x, const  ublas::vector<double>& mu, const ublas::matrix<double>& Omega) {
  //! Multivariate normal density
  size_t p = x.size1();
  size_t n = x.size2();
  
  double f = sqrt(det(Omega))/pow(2.0*PI, p/2.0);
  // cout << "O: " << Omega << "\n";
  // cout << "f: " << f << "\n";
  ublas::matrix<double> e(p, n);
  e.assign(x - outer_prod(mu, ublas::scalar_vector<double>(n, 1)));
  e = element_prod(e, prod(Omega, e));

  return ublas::apply_to_all<functor::exp<double> > (-(ublas::matrix_sum(e, 0))/2.0)*f;
}
开发者ID:cliburn,项目名称:flow,代码行数:14,代码来源:distributions.cpp

示例14: reorderHMatrix

void reorderHMatrix(ublas::matrix<int> &H, ublas::matrix<int> &L, ublas::matrix<int> &U) {
  // Get matrix dimensions
  const unsigned int M = H.size1();
  const unsigned int N = H.size2();

  // Set a new matrix F for LU decomposition
  ublas::matrix<int> F(H);

  // Re-order the M x (N - M) submatrix
  for (unsigned int i = 0; i < M; i++) {
    int chosenCol = 0;

    // Create diagonally structured matrix using 'First' strategy
    for (unsigned int j = i; j < N; j++) {
      if (F(i, j) != 0) {
        chosenCol = j;
        break;
      }
    }

    //std::cout << "chosenCol=" << chosenCol << std::endl;
    //printMatrix<int>(H);

    // Re-ordering columns of F
    const ublas::vector<int> tmp1(ublas::column(F, i));
    ublas::column(F, i) = ublas::column(F, chosenCol);
    ublas::column(F, chosenCol) = tmp1;

    // Re-ordering columns of H
    const ublas::vector<int> tmp2(ublas::column(H, i));
    ublas::column(H, i) = ublas::column(H, chosenCol);
    ublas::column(H, chosenCol) = tmp2;

    // Fill the LU matrices column by column
    ublas::subrange(L, i, M, i, i + 1) = ublas::subrange(F, i, M, i, i + 1);
    ublas::subrange(U, 0, i + 1, i, i + 1) = ublas::subrange(F, 0, i + 1, i, i + 1);

    // There will be no rows operation at the last row
    if (i < M - 1) {
      // Find the later rows with non-zero elements in column i
      for (unsigned int k = i + 1; k < M; k++) {
        if (F(k, i) != 0) {
          // Add current row to the later rows which have a 1 in column i
	  ublas::row(F, k) = mod2(ublas::row(F, k) + ublas::row(F, i));
        }
      }
    }
  }  
}
开发者ID:ericdegroot,项目名称:gr-ldpc_ece535a,代码行数:49,代码来源:ldpc_umfpack.cpp

示例15: rankUsingBoost

unsigned int rankUsingBoost( ublas::matrix<double>& U )
{
    int numMols = U.size1();
    int numReacs = U.size2() - numMols;
    int i;
    // Start out with a nonzero entry at 0,0
    int leftCol = reorderRows( U, 0, 0 );

    for ( i = 0; i < numMols - 1; ++i )
    {
        eliminateRowsBelow( U, i, leftCol );
        leftCol = reorderRows( U, i + 1, leftCol );
        if ( leftCol == numReacs )
            break;
    }
    return i + 1;
}
开发者ID:2pysarthak,项目名称:moose-core-personal,代码行数:17,代码来源:SteadyStateBoost.cpp


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