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

C++ matrix_t类代码示例

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

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



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

示例1: normalizeRM

  void normalizeRM(matrix_t & Q, StateMap const & staMap, float subs)
  {
    vector_t equiFreq = deriveEquiFreqForReversibleRM(Q);
    HammingDistance hammingDistance(staMap);
    number_t normConst = 0;
    for (unsigned i = 0; i < Q.size1(); ++ i)
      for (unsigned j = 0; j < Q.size2(); ++ j)
	normConst += equiFreq(i) * Q(i,j) * hammingDistance(i,j);

    Q = Q * (subs / normConst);
  }
开发者ID:jakob-skou-pedersen,项目名称:phy,代码行数:11,代码来源:RateMatrix.cpp


示例2: output_matrix

void output_matrix(ostream& out, matrix_t& M, unsigned n) {
	out << "matrix_t M[" << n << "] = {\n";
	for (unsigned i=0; i<M.size1(); ++i) {
		out << "\t{ ";
		out << M(i,0);
		for (unsigned j=1; j<M.size2() ; ++j)
			out << ',' << M(i,j);
		out << " },\n";
	}
	out << "}\n";
}
开发者ID:burdges,项目名称:PathMeasure,代码行数:11,代码来源:pathmeasure.cpp


示例3: nonZeroDiagonalEntryOrDie

  unsigned nonZeroDiagonalEntryOrDie(matrix_t const & Q)
  {
    assert( Q.size1() == Q.size1() ); // Q is quadratic

    for (unsigned i = 0; i < Q.size1(); i++)
      if (Q(i, i) != 0.0)
	return i;

    errorAbort("All zero diagonal entries. Bails out.");
    return 0; // will never reach this, only to quiet compiler
  }
开发者ID:jakob-skou-pedersen,项目名称:phy,代码行数:11,代码来源:RateMatrix.cpp


示例4: color_matrix_transform

 color_matrix_transform(matrix_t const & matrix)
   : matrix_(matrix)
 {
   if (matrix.shape()[0] == 3 && matrix.shape()[1] == 3)
   {
     // TODO make specialization for 3x3 matrix
     matrix_.resize(boost::extents[4][5]);
     matrix_[3][3] = 1;
   }
   else
     BOOST_ASSERT(matrix.shape()[0] == 4 && matrix.shape()[1] == 5);
 }
开发者ID:asuradaimao,项目名称:Walfas,代码行数:12,代码来源:color_matrix.hpp


示例5: getrf

// LU factorization of a general matrix A.  
//    Computes an LU factorization of a general M-by-N matrix A using
//    partial pivoting with row interchanges. Factorization has the form
//    A = P*L*U.
//    a       (IN/OUT - matrix(M,N)) On entry, the coefficient matrix A to be factored. On exit, the factors L and U from the factorization A = P*L*U.
//    ipivot  (OUT - vector(min(M,N))) Integer vector. The row i of A was interchanged with row IPIV(i).
//    info    (OUT - int)
//   0   :  successful exit
//   < 0 :  If INFO = -i, then the i-th argument had an illegal value.
//   > 0 :  If INFO = i, then U(i,i) is exactly zero. The  factorization has been completed, but the factor U is exactly singular, and division by zero will occur if it is used to solve a system of equations.
int getrf (matrix_t& a, pivot_t& ipivot)
{
	matrix_t::value_type* _a = a.data().begin();
	int _m = int(a.size1());
	int _n = int(a.size2());
	int _lda = _m;	// minor size
	int _info;

	rawLAPACK::getrf (_m, _n,	_a, _lda, ipivot.data().begin(), _info);

	return _info;
}
开发者ID:GangDesign,项目名称:open_ptrack,代码行数:22,代码来源:uLAPACK.hpp


示例6: svd_hint_from_most_similar

vector_t
svd_hint_from_most_similar(
    index_t  const user, 
    matrix_t const & sim, 
    matrix_t const & P, 
    matrix_t const & Q)
{
    stack::fe_asserter dummy{};
    vector_ll_t neighbors{std::min<index_t>(10,sim.get_rows())};
    vector_t    weights{std::min<index_t>(10,sim.get_rows())};
    most_similar(user, neighbors, weights, sim);
    return svd_hint(neighbors, weights, P, Q);
}
开发者ID:malaggan,项目名称:svdattack,代码行数:13,代码来源:svd_hint.cpp


示例7: est_factor

vector_t /* user_factor */
est_factor(
    vector_ll_t const & neighbors,
    vector_t    const & weights, 
    matrix_t    const & P)
{
    stack::fe_asserter dummy1{};
    scoped_timer dummy(std::string(__func__));

    vector_t user_factor{P.get_cols()};

    for(int i = 0; i < neighbors.get_len(); i++)
        user_factor += weights[i] * P.get_row_clone(neighbors[i]);
    return user_factor.normalize_2();
}
开发者ID:malaggan,项目名称:svdattack,代码行数:15,代码来源:svd_hint.cpp


示例8: filtra

void matrix_t::filtra(matrix_t& M, matrix_item_t it, double precision){
    matrix_inx_t m = get_m();
    matrix_inx_t n = get_n();
    M.redimensiona(m, n);
    for (int i = 1; i < m; i++) {
        for (int j = 1; j < n ; j++) {
            if (M.igual(get_matrix_item(i, j),it,precision) == true) {
                M.set_matrix_item(i, j, get_matrix_item(i, j));
            } else {
                matrix_item_t x = 0.00000;
                M.set_matrix_item(i, j, x);
            }
        }
    }
}
开发者ID:JonasLopezMesa,项目名称:cpp_AEDA_matrices_punto_flotante_y_abstraccion,代码行数:15,代码来源:matrices_3.cpp


示例9: applyGaussian

static void applyGaussian(matrix_t& m) {
	matrix_t::array_type& arr = m.data();
	double sig = *std::max_element(arr.begin(), arr.end());

	BOOST_FOREACH(double& v, arr) {
		v = std::exp(-v * v / (2 * sig * sig));
	}
开发者ID:caomw,项目名称:corrtrans3d,代码行数:7,代码来源:SpectralEmbedding.cpp


示例10: stack_assert

// mult X * D
matrix_t diag_t::left_mult(matrix_t const &X) const
{
    stack::fe_asserter fe{};
    stack_assert(diagonal.get_len() == X.get_cols());

    matrix_t ret = X.clone();

    if(ret.get_rows() < ret.get_cols())
        for(size_t r = 0; r < ret.get_rows(); r++)
            ret[r] *= diagonal;
    else
        for(size_t c = 0; c < ret.get_cols(); c++)
            ret.get_col(c) *= diagonal[c];

    return ret;
}
开发者ID:malaggan,项目名称:dense_matrix,代码行数:17,代码来源:diag_t_op.cpp


示例11: multi2

void multi2(const matrix_t &A, const matrix_t &B, matrix_t &C)
{
    size_t n = A.size(); 
    float **__restrict__ const da = A.data;
    float **__restrict__ const db = B.data;
    float **__restrict__ dc = C.data;

    const size_t chunk_size = 8;
    const size_t chunks = n / chunk_size;

#pragma omp parallel for num_threads(8)
    for(size_t i = 0; i < n; ++i)
    {
        __m256 a_line, b_line, c_line, r_line;
        for(size_t k = 0; k < n; ++k)
        {
            float c = da[i][k];
            a_line = _mm256_set_ps(c, c, c, c, c, c, c, c);
            for(size_t j = 0; j < chunks; ++j)
            {
                float mc[32] __attribute__((aligned(32))); 
                b_line = _mm256_load_ps(&db[k][j * chunk_size]);
                c_line = _mm256_load_ps(&dc[i][j * chunk_size]);
                r_line = _mm256_mul_ps(a_line, b_line);  
                r_line = _mm256_add_ps(r_line, c_line);
                _mm256_store_ps(&dc[i][j * chunk_size], r_line);
            } 

            for(size_t j = chunk_size * chunks; j < n; ++j)
            {
                dc[i][j] += c * db[k][j];
            }
        }
    }
}
开发者ID:Song-Li,项目名称:Parallel_tests,代码行数:35,代码来源:immint.cpp


示例12: search

bool search(matrix_t &matrix, int x, int y, string needle, int start_index, bool scan) {
  int x_max = matrix.size() - 1;
  int y_max = matrix[0].size() - 1;

  if (x < 0 || x > x_max) return false;
  if (y < 0 || y > y_max) return false;

  if (needle.size() == start_index) {
    return true;
  }

  if (matrix[x][y] == needle[start_index]) {
    int original_char = matrix[x][y];
    matrix[x][y] = '.';
    for (int i = 0; i < 8; ++i) {
      bool found = search(matrix, x + search_x[i], y + search_y[i], needle, start_index + 1, false);
      if (found) return true;
    }
    matrix[x][y] = original_char;
  }

  if (scan) {
    if (y < y_max) {
      return search(matrix, x, y + 1, needle, start_index, true);
    } else if (x < x_max) {
      return search(matrix, x + 1, 0, needle, start_index, true);
    }
  }

  return false;
}
开发者ID:kashyapp,项目名称:the-kitchen-sink,代码行数:31,代码来源:search.cpp


示例13: geqrf

// QR Factorization of a MxN General Matrix A.
//    a       (IN/OUT - matrix(M,N)) On entry, the coefficient matrix A. On exit , the upper triangle and diagonal is the min(M,N) by N upper triangular matrix R.  The lower triangle, together with the tau vector, is the orthogonal matrix Q as a product of min(M,N) elementary reflectors.
//    tau     (OUT - vector (min(M,N))) Vector of the same numerical type as A. The scalar factors of the elementary reflectors.
//    info    (OUT - int)
//   0   : function completed normally
//   < 0 : The ith argument, where i = abs(return value) had an illegal value.
int geqrf (matrix_t& a, vector_t& tau)
{
	int              _m = int(a.size1());
	int              _n = int(a.size2());
	int              _lda = int(a.size1());
	int              _info;

	// make_sure tau's size is greater than or equal to min(m,n)
	if (int(tau.size()) < (_n<_m ? _n : _m) )
		return -104;

	int ldwork = _n*_n;
	vector_t dwork(ldwork);
	rawLAPACK::geqrf (_m, _n, a.data().begin(), _lda, tau.data().begin(), dwork.data().begin(), ldwork, _info);

	return _info;
}
开发者ID:GangDesign,项目名称:open_ptrack,代码行数:23,代码来源:uLAPACK.hpp


示例14: matrixMul

matrix_t matrixMul(const matrix_t & matrixA, const matrix_t & matrixB) {
    auto dimension = matrixA.size();

	assert(matrixA.size() == dimension);
	assert(matrixA[0].size() == dimension);
	assert(matrixB.size() == dimension);
	assert(matrixB[0].size() == dimension);

	matrix_t matrixC(dimension, typename matrix_t::value_type(dimension, 0));//0ed matrix

	for(int x{0}; x < dimension; ++x)
	for(int i{0}; i < dimension; ++i)
	for(int y{0}; y < dimension; ++y)
		matrixC[x][y] += matrixA[x][i] * matrixB[i][y];

	return matrixC;//move semantics ftw
}
开发者ID:CCJY,项目名称:coliru,代码行数:17,代码来源:main.cpp


示例15: mkFactor

  void NormalMeanPostFactor::mkFactor(matrix_t &m) const{
    //Remember to convert to index space
    boost::math::normal dist( (postmean_-minv_)*bins_/(maxv_-minv_), 
			      std::sqrt(postvar_)*bins_/(maxv_-minv_) );
    for(int i = 0; i < m.size2(); ++i){
      m(0,i) = cdf(dist, i+1)-cdf(dist,i);
    }
  }
开发者ID:jakob-skou-pedersen,项目名称:phy,代码行数:8,代码来源:Factors.cpp


示例16: matrixMulTiled

matrix_t matrixMulTiled(const matrix_t & matrixA, const matrix_t & matrixB) {
	auto dimension = matrixA.size();

	assert(matrixA.size() == dimension);
	assert(matrixA[0].size() == dimension);
	assert(matrixB.size() == dimension);
	assert(matrixB[0].size() == dimension);

	matrix_t matrixC(dimension, typename matrix_t::value_type(dimension, 0));//0ed matrix

	const int m{8};//256bit
	const size_t n{dimension - dimension % m};
	int start{0};

	if(n >= m) {
		for (int i{0}; i < n; i+=m)
		for (int j{0}; j < n; j+=m)
		for (int k{0}; k < n; k+=m)
		for (int s{0}; s < m; s++)
		for (int t{0}; t < m; t++)
		for (int u{0}; u < m; u++)
			matrixC[i + s][j + t] += matrixA[i + s][k + u] * matrixB[k + u][j + t];
		start = n;
	}

	//finalize calculations within tiles
	for(int x{0}; x < n; ++x)
	for(int i{start}; i < dimension; ++i)
	for(int y{0}; y < n; ++y)
		matrixC[x][y] += matrixA[x][i] * matrixB[i][y];

	//calculate remaining rows
	for(int x{start}; x < dimension; ++x)
	for(int i{0}; i < dimension; ++i)
	for(int y{0}; y < dimension; ++y)
		matrixC[x][y] += matrixA[x][i] * matrixB[i][y];

	//calculate remaining elements (remaining columns without already calculated rows)
	for(int x{0}; x < n; ++x)
	for(int i{0}; i < dimension; ++i)
	for(int y{start}; y < dimension; ++y)
		matrixC[x][y] += matrixA[x][i] * matrixB[i][y];

	return matrixC;//move semantics ftw
}
开发者ID:CCJY,项目名称:coliru,代码行数:45,代码来源:main.cpp


示例17: Print

void Print(const matrix_t& m)
{
    for (unsigned i = 0; i < m.size(); i++) {
        for (unsigned j = 0; j < m[i].size(); j++) {
            cout << m[i][j] << " ";
        }
        cout << endl;
    }
}
开发者ID:dragosht,项目名称:courses,代码行数:9,代码来源:mul.cpp


示例18: AbstractBaseFactor

 AbstractFullyParameterizedFactor::AbstractFullyParameterizedFactor(string const & type, string const & id, matrix_t const & m, matrix_t const & pseudoCounts, matrix_t const & funBMat) 
   : AbstractBaseFactor(type, id, m.size1(), m.size2()), m_(m), pseudoCounts_(pseudoCounts), funBMat_(funBMat)
 {
   if (pseudoCounts.size1() != 0) {
     assert(pseudoCounts.size1() == size1_); 
     assert(pseudoCounts.size2() == size2_); 
   }
   if (funBMat.size1() != 0) {
     assert(funBMat.size1() == size1_); 
     assert(funBMat.size2() == size2_); 
   }
 }
开发者ID:jakob-skou-pedersen,项目名称:phy,代码行数:12,代码来源:Factors.cpp


示例19: deriveEquiFreqs

  void deriveEquiFreqs(matrix_t const & Q, vector_t & equiFreq)
  {
    unsigned size = Q.size1();

    for (unsigned int j = 0; j < size; j++)
      if (equiFreq(j) == 0 && Q(j, j) != 0.0 )
	for (unsigned int i = 0; i < size; i++) 
	  if (equiFreq(i) != 0.0 && Q(j, i) != 0.0 )
	    equiFreq(j) = equiFreq(i) * Q(i, j) / Q(j, i);
  }
开发者ID:jakob-skou-pedersen,项目名称:phy,代码行数:10,代码来源:RateMatrix.cpp


示例20: gaussSeidelIteration

matrix_t gaussSeidelIteration(const matrix_t & grid) {
	auto dimension = grid.size();

	assert(grid[0].size() == dimension);

	auto gridCopy = grid;

	for(int x{1}; x < dimension - 1; ++x)
	for(int y{1}; y < dimension - 1; ++y)
		gridCopy[x][y] += 0.25 * (grid[x-1][y] + grid[x][y-1] + grid[x][y+1] + grid[x+1][y]);

	return gridCopy;
}
开发者ID:CCJY,项目名称:coliru,代码行数:13,代码来源:main.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ matrix_type类代码示例发布时间:2022-05-31
下一篇:
C++ matrix_expression类代码示例发布时间: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