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


C++ Matrix::Cols方法代码示例

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


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

示例1: LayerActivation

bool SlaveTrainer::LayerActivation(double* up_ao, const double* low_ao, Matrix& w, const EActType eActType)
{
	if(!up_ao || !low_ao || w.IsNull())
		return false; 

	double e = 0.0; 
	for(int32_t j = 0; j < w.Cols(); j++) 
	{
		// forward propagation
		up_ao[j] = w[w.Rows()-1][j]; 	// bias
		for(int32_t i = 0; i < w.Rows() - 1; i++)
			up_ao[j] += w[i][j] * low_ao[i];

		// activation	
		if(eActType == _ACT_SOFTMAX)
			e += exp(up_ao[j]); 
		else
			up_ao[j] = Activation::Activate(up_ao[j], eActType); 
	}	
	if(eActType == _ACT_SOFTMAX)
	{ // softmax
		for(int32_t j = 0; j < w.Cols(); j++) 
			up_ao[j] = exp(up_ao[j]) / e; 
	}

	return true; 
}
开发者ID:fengyoung,项目名称:metis,代码行数:27,代码来源:SlaveTrainer.cpp

示例2: result

Matrix operator-(Matrix a,Matrix b){
	Matrix result(a.Rows(),a.Cols());
	for(int i = 0 ; i < a.Rows() ; i++)
		for( int j = 0 ; j < a.Cols() ; j++)
			result.Set(j,i,a.Get(j,i) - b.Get(j,i));
	return result;
}
开发者ID:stuwilkins,项目名称:QLaue,代码行数:7,代码来源:matrix.cpp

示例3: C

// C = A*b
Matrix operator*(const Matrix& A, const double b) {
  Matrix C(A.Rows(),A.Cols());
  for (size_t j=0; j<A.Cols(); j++)
    for (size_t i=0; i<A.Rows(); i++)
      C.data[j][i] = A.data[j][i] * b;
  return C;
}
开发者ID:Q-Tran,项目名称:High-performance-scientific-computing,代码行数:8,代码来源:matrix.cpp

示例4: M

Matrix operator*(const Matrix &left, const double right)
{
   Matrix M(left.Rows(), left.Cols());
   int i, j;
   for(i=0; i<left.Rows(); i++)
      for(j=0; j<left.Cols(); j++)
         M[i][j] = left[i][j] * right;
   return M;
}
开发者ID:JordanGraves,项目名称:TabMagic,代码行数:9,代码来源:Matrix.cpp

示例5: TransposeMatrix

Matrix TransposeMatrix(const Matrix& other)
{
   Matrix M(other.Cols(), other.Rows());
   int i, j;
   for(i=0; i<other.Rows(); i++)
      for(j=0; j<other.Cols(); j++)
         M[j][i] = other[i][j];
   return M;
}
开发者ID:JordanGraves,项目名称:TabMagic,代码行数:9,代码来源:Matrix.cpp

示例6: MatVec

// standard matrix-vector product
vector<double> MatVec(const Matrix& A, const vector<double>& v) {
  vector<double> res(0.0, A.Rows());
  if (A.Cols() != v.size()) {
    cerr << "MatVec: incompatible matrix/vector sizes in A*v\n";
  } else {
    for (size_t i=0; i<A.Rows(); i++) 
      for (size_t j=0; j<A.Cols(); j++)
	res[i] += A(i,j)*v[j];
  }
  return res;
}
开发者ID:Q-Tran,项目名称:High-performance-scientific-computing,代码行数:12,代码来源:matrix.cpp

示例7: Dot

// column/row vector dot product, something else for matrices?
double Dot(const Matrix& A, const Matrix& B) {
  double sum=0.0;
  if ((A.Cols() != B.Cols()) || (A.Rows() != B.Rows())) {
    cerr << "Dot error, matrix objects must be the same size\n";
  } else {
    for (size_t j=0; j<A.Cols(); j++) 
      for (size_t i=0; i<A.Rows(); i++)
	sum += A(i,j) * B(i,j);
  }
  return sum;
}
开发者ID:Q-Tran,项目名称:High-performance-scientific-computing,代码行数:12,代码来源:matrix.cpp

示例8: ScalarMultiply

Matrix ScalarMultiply(const Matrix &left, const Matrix &right)
{
   wxASSERT(left.Rows() == right.Rows());
   wxASSERT(left.Cols() == right.Cols());
   Matrix M(left.Rows(), left.Cols());
   int i, j;
   for(i=0; i<left.Rows(); i++)
      for(j=0; j<left.Cols(); j++)
         M[i][j] = left[i][j] * right[i][j];
   return M;
}
开发者ID:JordanGraves,项目名称:TabMagic,代码行数:11,代码来源:Matrix.cpp

示例9: v

Vector operator*(const Matrix &left, const Vector &right)
{
   wxASSERT(left.Cols() == right.Len());
   Vector v(left.Rows());
   int i, j;
   for(i=0; i<left.Rows(); i++) {
      v[i] = 0.0;
      for(j=0; j<left.Cols(); j++)
         v[i] += left[i][j] * right[j];
   }
   return v;
}
开发者ID:JordanGraves,项目名称:TabMagic,代码行数:12,代码来源:Matrix.cpp

示例10:

Matrix operator*(const Matrix &mat1, const Matrix &mat2)
{
	Matrix result;
	for (int ix = 0; ix < mat1.Rows(); ++ix) {
		for (int jx = 0; jx < mat1.Cols(); ++jx) {
			result(ix, jx) = 0;
			for (int kx = 0; kx < mat1.Cols(); ++kx)
				result(ix, jx) += mat1(ix, kx) * mat2(kx, jx);
		}
	}
	return result;
}
开发者ID:chester39,项目名称:EssentialCpp,代码行数:12,代码来源:4.5.cpp

示例11: MatrixConcatenateCols

Matrix MatrixConcatenateCols(const Matrix& left, const Matrix& right)
{
   wxASSERT(left.Rows() == right.Rows());
   Matrix M(left.Rows(), left.Cols() + right.Cols());
   int i, j;
   for(i=0; i<left.Rows(); i++) {
      for(j=0; j<left.Cols(); j++)
         M[i][j] = left[i][j];
      for(j=0; j<right.Cols(); j++)
         M[i][j+left.Cols()] = right[i][j];
   }
   return M;
}
开发者ID:JordanGraves,项目名称:TabMagic,代码行数:13,代码来源:Matrix.cpp

示例12: MatrixMultiply

Matrix MatrixMultiply(const Matrix &left, const Matrix &right)
{
   wxASSERT(left.Cols() == right.Rows());
   Matrix M(left.Rows(), right.Cols());
   int i, j, k;
   for(i=0; i<left.Rows(); i++)
      for(j=0; j<right.Cols(); j++) {
         M[i][j] = 0.0;
         for(k=0; k<left.Cols(); k++)
            M[i][j] += left[i][k] * right[k][j];
      }
   return M;
}
开发者ID:JordanGraves,项目名称:TabMagic,代码行数:13,代码来源:Matrix.cpp

示例13: BackSub

// backward substitution on U*x = b, returning x as a new vector<double>
//    U and b remain unchanged in this operation
vector<double> BackSub(const Matrix& U, const vector<double>& b) {
  if (U.Rows() != b.size() || U.Rows() != U.Cols()) {
    cerr << "BackSub error, illegal matrix/vector dimensions\n";
    cerr << "  Matrix is " << U.Rows() << " x " << U.Cols() 
	 << ",  rhs is " << b.size() << " x 1\n";
    return vector<double>(0);
  }

  // create output vector, call existing BackSub routine, and return
  vector<double> x(0.0, U.Cols());
  if (BackSub(U, x, b) != 0)
    cerr << "BackSub Warning: error in BackSub call\n";
  return x;
}
开发者ID:Q-Tran,项目名称:High-performance-scientific-computing,代码行数:16,代码来源:matrix.cpp

示例14: FwdSub

// forward substitution on L*x = b, returning x as a new vector<double>
//    L and b remain unchanged in this operation
vector<double> FwdSub(const Matrix& L, const vector<double>& b) {
  // check that matrix sizes match
  if (L.Rows() != b.size() || L.Rows() != L.Cols()) {
    cerr << "FwdSub error, illegal matrix/vector dimensions\n";
    cerr << "  Matrix is " << L.Rows() << " x " << L.Cols() 
	 << ",  rhs is " << b.size() << " x 1\n";
    return vector<double>(0);
  }

  // create output vector and return
  vector<double> x(0.0, L.Cols());
  if (FwdSub(L, x, b) != 0)
    cerr << "FwdSub Warning: error in FwdSub call\n";
  return x;
}
开发者ID:Q-Tran,项目名称:High-performance-scientific-computing,代码行数:17,代码来源:matrix.cpp

示例15: exp

    //exponential of a matrix (element-wise)
Matrix exp(const Matrix& A){

    size_t zeros = UNDEFINED;
    Matrix E(A.Rows(), A.Cols());
    
    for (size_t a = 0; a < A.Rows(); a++)
        for (size_t b = 0; b < A.Cols(); b++) {
            E.M[a * (A.Cols()) + b] = exp(A.M[a * (A.Cols()) + b]);
            CheckZero(&zeros, E.M[a * (A.Cols()) + b]);
        }
    
    if (zeros == ZERO)
        E._isZero = true;
    
    return E;
}
开发者ID:ForceBru,项目名称:Matrix,代码行数:17,代码来源:Matrix.cpp


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