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


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

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


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

示例1: determinant

double determinant(Matrix& A)
{
	if ((A.m_rows != A.m_columns) || A.m_rows<1)//no need to check columns too for <1
	{
		return 0;
	}
	else if (A.m_rows == 1){ return A.mat[0]; }
	//else if (A.m_rows == 2)
	//{
	//	//		 A
	//	//		[ 0  1 ]
	//	//		[ 2  3 ]
	//	//
	//	return (A.mat[0] * A.mat[3] - A.mat[1] * A.mat[2]);
	//}
	else
	{
		double det=0;

		for (int i = 0; i < A.m_columns; i++)
		{
			Matrix temp = A;
			double coefficient = pow(-1.0, i)*A.mat[i];

			temp.DeleteColumn(i);
			temp.DeleteRow(0);

			det += coefficient*determinant(temp);//recursion here :D
		}

		return det;
	}

}
开发者ID:Ic3C0ld,项目名称:ComputerGraphics,代码行数:34,代码来源:matrix.cpp

示例2: inverse

Matrix Matrix::inverse()
{
	if (determinant(*this) == 0 || (m_rows != m_columns)) //Actually need to check too if max(Coffactors[])* 1/det ->OVERFLOW
	{
		return *this;//do nothing
	}
	else
	{
		Matrix Cofactors(m_rows, m_columns);

		//Compute the Coffactor elementes
		for (int i = 0; i < Cofactors.m_columns; i++)
		{
			for (int j = 0; j < Cofactors.m_rows; j++)
			{
				Matrix temp = *this;
				double coefficient = pow(-1.0, i + j)  /* *A.mat[j*A.m_columns + i]*/;

				temp.DeleteColumn(i);
				temp.DeleteRow(j);

				Cofactors.mat[j*m_columns + i] = coefficient*determinant(temp);

			}
		}

		Matrix Inverse = Cofactors.traspose() / determinant(*this);

		return Inverse;
	}



}
开发者ID:Ic3C0ld,项目名称:ComputerGraphics,代码行数:34,代码来源:matrix.cpp

示例3: invert

void invert(Matrix& A)
{
	if (determinant(A) == 0 || (A.m_rows!=A.m_columns)) //Actually need to check too if max(Coffactors[])* 1/det ->OVERFLOW
	{
		
	}
	else
	{
		Matrix Cofactors(A.m_rows, A.m_columns);

		//Compute the Coffactor elementes
		for (int i = 0; i < Cofactors.m_columns; i++)
		{
			for (int j = 0; j < Cofactors.m_rows; j++)
			{
				Matrix temp = A;
				double coefficient = pow(-1.0, i + j) ;

				temp.DeleteColumn(i);
				temp.DeleteRow(j);

				Cofactors.mat[j*A.m_columns + i] = coefficient*determinant(temp);

			}
		}

		Matrix Inverse = Cofactors.traspose() / determinant(A);

		A = Inverse;
	}
	

}
开发者ID:Ic3C0ld,项目名称:ComputerGraphics,代码行数:33,代码来源:matrix.cpp

示例4: Diagnostics

void NormalEquations::Diagnostics()
{
    CalculateResiduals();
    CalculateCovariances();

    cholesky.BackSubst(residuals);

    rawQ = residuals.InnerProduct(cholesky.x);
    Q = sqrt(2.0 * rawQ) - sqrt(2.0 * residuals.dim - 1.0);

    Qi.Dimension(residuals.dim);

    Matrix M;
    Vector v, r;
    Cholesky chol;

    for (int i = 0; i < residuals.dim; i++)
    {
        M = varMatrix;

        v = M[i];
        M.DeleteColumn(i);
        M.DeleteRow(i);
        v.DeleteDimension(i);
        chol.Decompose(M);

        chol.BackSubst(v);

        double var = varMatrix[i][i] - v.InnerProduct(chol.x);

        r = residuals;
        r.DeleteDimension(i);

        chol.BackSubst(r);
        Qi[i] = residuals[i] - v.InnerProduct(chol.x);
        Qi[i] = Qi[i] * Qi[i] / var;
    }
}
开发者ID:ernfrid,项目名称:polymutt,代码行数:38,代码来源:MathNormal.cpp


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