Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

## Matrix Rotation with MKL? Beginner
171 Views
Is this possible with MKL?
I want to rotate a matrix about its center by an arbitrary angle. However, it cannot resize the destination matrix, meaning it should clip and spots in the destination may be blank.
I have this algorithm in use employing TBB. But, I'm not doing an elegant job of optimizing - to the point where I'm hoping MKL can do the job for me. If there is no such thing - I'm going to start playing with Tiling sizes and loop unrolling in hopes of getting better performance out of my current implementation.
Current implementation:
//- sina = sin of angle
//- cosa = cos of angle
void operator() ( const tbb::blocked_range2d r ) const
{
double xOffset;
double yOffset;
int lineOffset;
int srcX;
int srcY;
for ( size_t row = r.rows().begin(); row != r.rows().end(); ++row )
{
const size_t colBegin = r.cols().begin();
xOffset = -(row * sina) + xHelper + (cosa * colBegin);
yOffset = (row * cosa) + yHelper + (sina * colBegin);
lineOffset = ( row * rowSpan ); //- all col values are offsets of this row
for( size_t col = colBegin; col != r.cols().end(); ++col, xOffset += cosa, yOffset += sina )
{
srcX = xOffset;
srcY = yOffset;
if( srcX >= 0 && srcX < colSpan && srcY >= 0 && srcY < rowSpan )
{
destData[col + lineOffset] = srcData[srcX + ( srcY * rowSpan )];
}
}
}
}
Is this possibly a givens rotation? I'm reading about it, but I'm not sure how to do the equivalent thing in MKL should it be that!
Thanks!  