Exemplo n.º 1
0
cMatrix cMatrix::Identity( int nDimension )
{
	cMatrix matRet(nDimension);
	for (int i = 0; i < nDimension; ++i)
	{
		for (int j = 0; j < nDimension; ++j)
		{
			matRet[i][j] = (i == j) ? 1.0f : 0.0f;
		}
	}
	return matRet;
}
Exemplo n.º 2
0
cMatrix cMatrix::Adjoint()
{
	cMatrix matRet(Dimension());
	for (int i = 0; i < Dimension(); ++i)
	{
		for (int j = 0; j < Dimension(); ++j)
		{
			matRet[i][j] = Cofactor(j, i);
		}
	}
	return matRet;
}
Exemplo n.º 3
0
cMatrix cMatrix::Transpose()
{
	cMatrix matRet(Dimension());
	for (int i = 0; i < Dimension(); ++i)
	{
		for (int j = 0; j < Dimension(); ++j)
		{
			matRet[i][j] = (*this)[j][i];
		}
	}
	return matRet;
}
Exemplo n.º 4
0
cMatrix cMatrix::operator*( float f )
{
	cMatrix matRet(Dimension());

	for (int i = 0; i < Dimension(); ++i)
	{
		for (int j = 0; j < Dimension(); ++j)
		{
			matRet[i][j] = (*this)[i][j] * f;
		}
	}

	return matRet;
}
Exemplo n.º 5
0
cMatrix cMatrix::operator-( cMatrix mat )
{
	cMatrix matRet(Dimension());

	for (int i = 0; i < Dimension(); ++i)
	{
		for (int j = 0; j < Dimension(); ++j)
		{
			matRet[i][j] = (*this)[i][j] - mat[i][j];
		}
	}

	return matRet;
}
Exemplo n.º 6
0
MAT trapz(MAT &matX,MAT &matY)
{
    MAT matRet(1,matX.nlength);//估计也用不到二维矩阵……这里先这样吧(不会写)
    if(matX.nlength!=matY.nlength || matX._row!=1 || matY._row!=1)
    {
        return MAT();
    }
    for(int i(1);i<matX.nlength;i++)
    {
        double val = 
            (matX.GetValue(0,i) - matX.GetValue(0,i-1))/*delta x*/
           *(matY.GetValue(0,i) + matY.GetValue(0,i-1))/*delta h*/
            /2 + matRet.GetValue(0,i-1);/*prev sum*/
        matRet.SetValue(0,i,val);
    }
    return matRet;
}
Exemplo n.º 7
0
cMatrix cMatrix::operator*( cMatrix mat )
{
	cMatrix matRet(Dimension());

	for (int i = 0; i < Dimension(); ++i)
	{
		for (int j = 0; j < Dimension(); ++j)
		{
			matRet[i][j] = 0;
			for (int k = 0; k < Dimension(); ++k)
			{
				matRet[i][j] += ((*this)[i][k] * mat[k][j]);
			}
		}
	}
	return matRet;
}