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


C++ SMatrix类代码示例

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


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

示例1: GetElem

bool SMatrix::CutIn2_Vertical(SMatrix& Left,SMatrix& Right,int iCol)
{
  int i,j;

   if (nCol()==0)
   {
	    Left.ReSize(0,0);
	   Right.ReSize(0,0);
	   return TRUE;
   }

   if(iCol>nCol()||iCol<0) return FALSE;

    if(!Left.ReSize(nRow(),iCol,ERRORVAL))
		return FALSE;

   if(!Right.ReSize(nRow(),nCol()-iCol,ERRORVAL))
	   return FALSE;

	   for(i=0;i<nRow();i++)
          for(j=0;j<iCol;j++)
               Left[i][j] = GetElem(i,j);
       
	   for(i=0;i<nRow();i++)
		   for(j=0;j<Right.nCol();j++)
			  Right[i][j] = GetElem(i,j+iCol);
			   
   return TRUE;
}
开发者ID:wsysuper,项目名称:Synthesizer,代码行数:29,代码来源:SMatrix.cpp

示例2: assert

/**
 * Divide the matrix by the given matrix. The matrixes must be the same size
 * this is checked via assertions. We perform the division by multiplication
 * of the inverse so this is a costly operation.
 *
 * @param im The matrix to divide by
 */
SMatrix SMatrix::operator /( const SMatrix &im ) const
{
    assert( this->getCols() == im.getCols() && "Amount of Columns Differ");
    assert( this->getRows() == im.getRows() && "Amount of Rows Differ" );

    return (*this) * inv ( im );
}
开发者ID:WearableComputerLab,项目名称:LibWCL,代码行数:14,代码来源:SMatrix.cpp

示例3: DGraphicAcquireSMD

void CMoon::ParseBlock( const CVarBlockParser::_VariableBlock *pBlock_ )
{
	if( pBlock_==NULL ) { return; }

	pBlock_->GetBool( "Active", m_bActive );
	
	if( pBlock_->GetString( "MeshFile", m_strMeshName ) )
	{
		HGRPOBJ hMesh = DGraphicAcquireSMD( SFullName( DCtrlGrp()->GroupEnvironment, m_strMeshName ), DGraphicStore::StaticMesh );
		if( !hMesh.IsValid() )
		{
			hMesh = DGraphicAcquireSMD( m_strMeshName, DGraphicStore::StaticMesh );
		}
		LoadMesh( hMesh );
	}
	if( pBlock_->GetVector( "Translation", m_vTranslation ) )
	{
		SMatrix mat;
		mat.SetTranslation( m_vTranslation );
		Transform( mat );
	}
	bool bMoonFace;
	if( pBlock_->GetBool( "MoonFace", bMoonFace ) )
	{
		SetMoonFace( bMoonFace );
	}
	SColor Color;
	if( pBlock_->GetColor( "Color", Color ) )
	{
		SetColor( Color );
	}
	pBlock_->GetRealNumber( "FillRate", m_fFillRate );
	pBlock_->GetRealNumber( "RisingRate", m_fRisingRate );
	pBlock_->GetRealNumber( "Pitch", m_fPitch );
}
开发者ID:RaoMiao,项目名称:freestyle,代码行数:35,代码来源:CMoon.cpp

示例4: GKMeansPreprocess

void IndexEncoding::GKMeansPreprocess(
	const SMatrix<double> &matDictionary, 
	int num_dic_each_partition, 
	SMatrix<double>  &matPrecomputed) const
{
	int num_all_centers = matDictionary.Rows();

	matPrecomputed.AllocateSpace(num_all_centers, num_all_centers);

	int dim = matDictionary.Cols();

	for (int i = 0; i < num_all_centers; i++)
	{
		for (int j = 0; j < num_all_centers; j++)
		{
			const double* pi = matDictionary[i];
			const double* pj = matDictionary[j];

			matPrecomputed[i][j] = dot(pi, pj, dim);
		}
	}

	for (int i = 0; i < num_all_centers; i++)
	{
		matPrecomputed[i][i] = matPrecomputed[i][i] * 0.5;
	}

}
开发者ID:amsword,项目名称:gkmeans,代码行数:28,代码来源:IndexEncoding.cpp

示例5: equal

bool SMatrix::equal(const SMatrix& otherMat) const
{
   if(cols == otherMat.getCols() && rows == otherMat.getRows())
       return true;
   else
       return false;
}
开发者ID:brownbagspecial,项目名称:School-Work,代码行数:7,代码来源:SMatrix.cpp

示例6: MultiDictionaryPreprocess

void IndexEncoding::MultiDictionaryPreprocess(const SMatrix<double> &matDictionary, 
											  int num_dic_each_partition, 
											  SMatrix<double> &matPrecomputed) const
{
	int num_all_words = matDictionary.Rows();
	int dim = matDictionary.Cols();

	matPrecomputed.AllocateSpace(num_all_words, num_all_words);
	for (int i = 0; i < num_all_words; i++)
	{
		for (int j = 0; j <= i; j++)
		{
			matPrecomputed[i][j] = dot(
				matDictionary[i], 
				matDictionary[j], 
				dim);
		}
	}
	for (int i = 0; i < num_all_words; i++)
	{
		for (int j = i + 1; j < num_all_words; j++)
		{
			matPrecomputed[i][j] = matPrecomputed[j][i];
		}
	}
}
开发者ID:amsword,项目名称:gkmeans,代码行数:26,代码来源:IndexEncoding.cpp

示例7: multiplicable

bool multiplicable(const SMatrix& m1, const SMatrix& m2)
{
   if( m1.getRows() == m2.getCols())
      return true;
   else
      return false;
}
开发者ID:brownbagspecial,项目名称:School-Work,代码行数:7,代码来源:SMatrix.cpp

示例8: DLogWriteSystem

bool DDynamicActor::Collision_IntersectCheck( int )
{
	DLogWriteSystem(" Collision_IntersectCheck : %p", this );
	
	SVector Location = m_Locus.Location;
	SVector Start = Physics::g_vStart;
	if( m_dwColFlag & CF_COLLIDEDBY_ROOT_INTERNAL )
	{
		Location = GMath.ZeroVector;
		SMatrix Matrix = (this->m_matRootMatrixForCollision * m_Locus.LocalToWorld).Inverse();
		Start = Matrix.TransformVector( Physics::g_vStart );
	}

	SVector vExtent = Physics::g_vExtent + this->m_vExtent;
	SVector Delta = Start - Location;
	if( Abs(Delta.Y) >= vExtent.Y ) return false;

	float DeltaSquared2D = Delta.SizeSquared2D();
	float RadiusSquared = Square(vExtent.X);
	if( DeltaSquared2D >= RadiusSquared ) return false;

	float Overlap = appSqrt( RadiusSquared ) - appSqrt( DeltaSquared2D );
	if( Overlap <= Physics::g_SingleResult.m_fTime ) return false;

	Physics::g_SingleResult.m_nActorIndex	= m_dwID;
	Physics::g_SingleResult.m_nMeshIndex	= -1;
	Physics::g_SingleResult.m_fTime		= Overlap;
	Delta.Y = 0.f;
	Physics::g_SingleResult.m_vNormal		= Delta.SafeNormal();
	Physics::g_SingleResult.m_vContactPoint= m_Locus.Location + this->m_vExtent.X * Physics::g_SingleResult.m_vNormal;
	Physics::g_SingleResult.m_ActorType	= this->m_ActorType;
	return true;
}
开发者ID:RaoMiao,项目名称:freestyle,代码行数:33,代码来源:DDynamicActor.cpp

示例9: same_order

bool same_order(const SMatrix& m1, const SMatrix& m2)
{
   if(m1.getRows() == m2.getRows() && m1.getCols() == m2.getCols())
       return true;
   else
       return false;
}
开发者ID:brownbagspecial,项目名称:School-Work,代码行数:7,代码来源:SMatrix.cpp

示例10: m

/**
 * Multiply one matrix by the other - the matrixes are the same size
 * Multiplication is done: this * im
 *
 * @param im The matrix to multiply by
 */
SMatrix SMatrix::operator *( const SMatrix &im ) const
{
    SMatrix m ( im.getRows());
    m.storeProduct( *this, im );

    return m;
}
开发者ID:WearableComputerLab,项目名称:LibWCL,代码行数:13,代码来源:SMatrix.cpp

示例11: throw

/**
 *Overloading the '*' operator. Only works when matrix a's columns are equal to matrix b's 
 *rows, otherwise there is a size error.
 *Returns a new matrix equal to a * b
 *
 */
SMatrix operator*(const SMatrix& a, const SMatrix& b) throw(MatrixError) {
   if(a.cols() != b.rows()) {    //Check whether a's columns are equal to b's rows
      throw MatrixError("Matrix size error");      //if not throw size error
   } 
   
   SMatrix c(a.rows(),b.cols());    //dimensions of new matrix 
   
   for(auto it = a.ridx_.cbegin();it != a.ridx_.cend();++it) {    //Loop through a's rows
      int row = it->first;
      int nElements = it->second.first + it->second.second;
      for(SMatrix::size_type i = 0; i < b.cols(); ++i) {    //Loop through b's columns
         int col = i;   
         int val = 0;
         for(int pos = it->second.first; pos < nElements; ++pos) {   //Loop through a's columns
            val += a.vals_[pos] * b(a.cidx_[pos],i);      //adding the multiplications to 
         }                                                  //val
         if(val != 0) {
            c.setVal(row,col,val);
         }

      }
   }

   return c;
}
开发者ID:jaortiz,项目名称:cplusplus,代码行数:31,代码来源:unOptimised.cpp

示例12: inv

/**
 * Inverse the given matrix
 *
 * @param im The matrix to invert
 */
SMatrix inv ( const SMatrix &im )
{
    SMatrix m ( im.getRows() );

    m.storeInverse ( im );

    return m;
}
开发者ID:WearableComputerLab,项目名称:LibWCL,代码行数:13,代码来源:SMatrix.cpp

示例13: reflTrans

void reflTrans(const mlgeo &g, double k0, double theta, int pol, 
				cdouble *r, double *R, cdouble *t, double *T) {
	SMatrix S = new SMatrix(g, k0, k0 * sin(theta));
	*r = S->S21(0, g.N, pol);
	*t = S->S11(0, g.N, pol);
	*R = (*r) * conj(*r); 
	*T = real(sqrt(g.eps(N))) / real(sqrt(g.eps(0))) * (*t) * conj(*t); 
}
开发者ID:odmiller,项目名称:MultilayerEM,代码行数:8,代码来源:fieldFunctions.cpp

示例14: Jointer_bottom

bool SMatrix::Jointer_bottom(SMatrix& other)
{
	if(other.nCol()!=nCol()) return FALSE;
	
	if(!AddRows(other.nRow(),ERRORVAL))
		return FALSE;	
	
return Paste(other,nRow()-other.nRow(),0);
}
开发者ID:wsysuper,项目名称:Synthesizer,代码行数:9,代码来源:SMatrix.cpp

示例15: Max

void GDynamicActor::RenderShadow( void )
{
	if( m_pShadow )
	{
		float fMinX, fMaxX, fMinZ, fMaxZ;
		SVector vExtent;
		vExtent.X = vExtent.Z = Max( (m_vMeshMax.X-m_vMeshMin.X), (m_vMeshMax.Z-m_vMeshMin.Z) );
		vExtent.Y = (m_vMeshMax.Y-m_vMeshMin.Y);

		if( vExtent.X<m_vExtent.X ) { vExtent.X = vExtent.Z = m_vExtent.X; }
		if( vExtent.Y<m_vExtent.Y ) { vExtent.Y = m_vExtent.Y; }
		vExtent.Y *= 1.2f; // for jumping
		m_pShadow->RangeRectGet( fMinX, fMinZ, fMaxX, fMaxZ, m_Locus.Location, vExtent*m_Locus.Scale*0.6f );

		SMatrix matUnit;
		matUnit.SetIdentity();
		m_pShadow->MakeVtxIdx(fMinX, fMinZ, fMaxX, fMaxZ);
		m_pShadow->MakeStart( matUnit );
		m_pShadow->MakeEnd();

		/*
		DTerrain *pTer = DTerrain::StaticGetTerrain( m_Locus.Location.X, m_Locus.Location.Y, m_Locus.Location.Z );
		if( pTer )
		{
			pTer->GetShadowVertex( m_Locus.Location, fMinX, fMinZ, fMaxX, fMaxZ, m_pShadow->GetVertexInterface(), m_pShadow->GetIndexInterface() );
			m_pShadow->MakeStart( pTer->m_matUnitToWorld );
			m_pShadow->MakeEnd();
		}
		*/
	}
	else if( m_pApproxShadow )
	{
		float fMinX, fMaxX, fMinZ, fMaxZ;
		SVector vExtent;
		vExtent.X = vExtent.Z = Max( (m_vMeshMax.X-m_vMeshMin.X), (m_vMeshMax.Z-m_vMeshMin.Z) );
		vExtent.Y = (m_vMeshMax.Y-m_vMeshMin.Y);

		if( vExtent.X<m_vExtent.X ) { vExtent.X = vExtent.Z = m_vExtent.X; }
		if( vExtent.Y<m_vExtent.Y ) { vExtent.Y = m_vExtent.Y; }
		m_pApproxShadow->RangeRectGet( fMinX, fMinZ, fMaxX, fMaxZ, m_Locus.Location, vExtent*m_Locus.Scale*0.6f );

		SMatrix matUnit;
		matUnit.SetIdentity();
		m_pApproxShadow->MakeVtxIdx(fMinX, fMinZ, fMaxX, fMaxZ);
		m_pApproxShadow->Render( matUnit );

		/*
		DTerrain *pTer = DTerrain::StaticGetTerrain( m_Locus.Location.X, m_Locus.Location.Y, m_Locus.Location.Z );
		if( pTer )
		{
			pTer->GetShadowVertex( m_Locus.Location, fMinX, fMinZ, fMaxX, fMaxZ, m_pApproxShadow->GetVertexInterface(), m_pApproxShadow->GetIndexInterface() );
			m_pApproxShadow->Render( pTer->m_matUnitToWorld );
		}
		*/

	}
}
开发者ID:RaoMiao,项目名称:freestyle,代码行数:57,代码来源:GDynamicActor.cpp


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