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


C++ Mat::copy方法代码示例

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


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

示例1: mxSymEig

/* symmeig -- computes eigenvalues of a dense symmetric matrix
	-- mat_a **must** be symmetric on entry
	-- eigenvalues stored in out
	-- mat_q contains orthogonal matrix of eigenvectors
	-- returns vector of eigenvalues
  -- je pense: if mat_q is NULL, eigenvectors won't be computed
*/
void mxSymEig(Mat * mat_a, Mat * mat_q, Vec * out)
{
  Mat *tmp = new Mat(mat_a->m, mat_a->n);
  tmp->copy(mat_a);

  Vec *b = new Vec(mat_a->m - 1);
  Vec *diag = new Vec(mat_a->m);
  Vec *beta = new Vec(mat_a->m);

  mxHFactor(tmp, diag, beta);
  if (mat_q)
    mxMakeHQ(tmp, diag, beta, mat_q);

  int i;
  for (i = 0; i < mat_a->m - 1; i++)
  {
    out->ptr[i] = tmp->ptr[i][i];
    b->ptr[i] = tmp->ptr[i][i + 1];
  }
  out->ptr[i] = tmp->ptr[i][i];

  mxTriEig(out, b, mat_q);

  delete beta;
  delete diag;
  delete b;
  delete tmp;
}
开发者ID:Dandelion0124,项目名称:smartalbum,代码行数:35,代码来源:mx_sym_eig.cpp

示例2: clone

  virtual MutableMat *copy(bool prefer_dense) const
  {
#if 0
    MutableMat *result = new MutableMat;
    Mat *m = mat.copy();
    result->mat.grab(m);
    return result;
#endif
    return clone();
  }
开发者ID:ChristineJost,项目名称:M2,代码行数:10,代码来源:mutablemat.hpp

示例3: ProcessOffline

bool SpeechRec::ProcessOffline(data_format inpf, data_format outpf, void *inpSig, int sigNBytes, Mat<float> *inpMat, Mat<float> *outMat)
{
	assert((int)inpf < (int)outpf);
	assert(outMat || outpf == dfStrings);
	assert(inpMat || inpf == dfWaveform);

	Mat<float> *paramMat = 0;
	Mat<float> *posteriorsMat = 0;

	// waveform -> parameters
	int nFrames;
	if(inpf == dfWaveform)
	{
		if(!ConvertWaveformFormat(waveFormat, inpSig, sigNBytes, &waveform, &waveformLen))
			return false;

		nFrames = (waveformLen > actualParams->GetVectorSize() ? (waveformLen - actualParams->GetVectorSize()) / actualParams->GetStep() + 1 : 1);
				
		actualParams->AddWaveform(waveform, waveformLen);
			
		if(outpf == dfParams)
		{
			paramMat = outMat;
		}
		else
		{
			paramMat = new Mat<float>; 
			if(!paramMat)
			{
				MERROR("Insufficient memory\n");
				return false;
			}
		}
		if(actualParams->GetNParams() != paramMat->columns() || nFrames != paramMat->rows())
		   paramMat->init(nFrames, actualParams->GetNParams());

		int fr = 0;
		while(actualParams->GetFeatures(params))
		{				
			FrameBasedNormalization(params, actualParams->GetNParams());
			paramMat->set(fr, fr, 0, actualParams->GetNParams() - 1, params);
			fr++;
		}

		if(outpf == dfParams)
			return true;
	}

	// sentence based normalization
	if(inpf == dfWaveform || inpf == dfParams)
	{
		if(inpf == dfParams)
			paramMat = inpMat;

                if(paramMat->columns() < actualParams->GetNParams())
                {
			MERROR("Invalid dimensionality of parameter vectors\n");
			return false;
                }
		else if(paramMat->columns() > actualParams->GetNParams())
		{
			Mat<float> *tmpMat = new Mat<float>;
			tmpMat->init(paramMat->rows(), actualParams->GetNParams());
			tmpMat->copy(*paramMat, 0, paramMat->rows() - 1, 0, actualParams->GetNParams() - 1, 
                                                   0, paramMat->rows() - 1, 0, actualParams->GetNParams() - 1);
			delete paramMat;
			paramMat = tmpMat;
			inpMat = paramMat;
		}

		SentenceBasedNormalization(paramMat);
	}

	// parameters -> posteriors
	if(outpf == dfPosteriors && !mTrapsEnabled)
        {
		MERROR("The 'traps' module have to be enabled for generating posteriors\n");
		return false;
        }

	if((inpf == dfWaveform || inpf == dfParams) && mTrapsEnabled)
	{
		if(inpf == dfParams)
			paramMat = inpMat;

		if(outpf == dfPosteriors)
		{
			posteriorsMat = outMat;
		}
		else
		{
			posteriorsMat = new Mat<float>;
			if(!posteriorsMat)
			{
				if(inpf != dfParams)
						delete paramMat;
				MERROR("Insufficient memory\n");
				return false;
			}
		}
//.........这里部分代码省略.........
开发者ID:alongwithyou,项目名称:PhnRec,代码行数:101,代码来源:srec.cpp


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