本文整理汇总了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;
}
示例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 );
}
示例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 );
}
示例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;
}
}
示例5: equal
bool SMatrix::equal(const SMatrix& otherMat) const
{
if(cols == otherMat.getCols() && rows == otherMat.getRows())
return true;
else
return false;
}
示例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];
}
}
}
示例7: multiplicable
bool multiplicable(const SMatrix& m1, const SMatrix& m2)
{
if( m1.getRows() == m2.getCols())
return true;
else
return false;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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 );
}
*/
}
}