示例#1
0
文件: qmat.cpp 项目: krips89/robocomp
/**
 * \brief Matrix to matrix product operator; \f$ C = this * A \f$
 *
 * IPP coge (columnas, filas) en las llamadas
 * @param A matrix factor for operation
 * @return QMat New matrix result
 */
QMat QMat::operator * ( const QMat & A ) const
{
// 	printf("Operator *: (%d,%d) x (%d,%d)\n", rows, cols, A.rows, A.cols);
	QMat C=zeros( rows, A.nCols() );
	if ( cols != A.nRows())
	{
		QString ex= "QMat::operator* - a.cols!=b.rows";
		throw ex;
	}
	else
	{
#ifdef COMPILE_IPP
	ippmMul_mm_32f ( toDataConst(), cols*sizeof ( T ), sizeof ( T ), cols, rows, A.toDataConst(), A.nCols() *sizeof ( T ), sizeof ( T ), A.nCols(), A.nRows(), C.toData(), C.nCols() *sizeof ( T ), sizeof ( T ) );
#else
	for(int i=0;i<rows;i++)
	{
		for(int j=0;j<A.cols;j++)
		{
			C(i,j)=0;
			for(int k=0;k<cols;k++)
			{
				C(i,j) += operator()(i,k)*A(k,j);
			}
// 			printf("%f ", C(i,j));
		}
// 		printf("\n");
	}
#endif
	}
	return C;
}
示例#2
0
文件: qmat.cpp 项目: krips89/robocomp
/**
 * \brief Matrix Subtraction operator: \f$ C = this - A \f$
 * @param A Matrix subtrahend
 * @return QMat Operation result
 */
QMat QMat::operator- ( const QMat & A ) const
{
	Q_ASSERT ( equalSize ( *this, A ));
	QMat C ( rows,cols );
#ifdef COMPILE_IPP
	ippmSub_mm_32f ( toDataConst(), cols*sizeof ( T ), sizeof ( T ), A.toDataConst(), cols*sizeof ( T ), sizeof ( T ), C.toData(), cols*sizeof ( T ), sizeof ( T ), cols, rows );
#else
 	for(int r=0; r<A.rows; r++)
 		for(int c=0; c<A.cols; c++)
 			C(r, c) = A(r,c) - operator()(r, c);
#endif	
	return C;
}