1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Add QR decomposition to HAL

This commit is contained in:
Vladislav Sovrasov
2016-08-23 16:35:03 +03:00
parent d102ea96c0
commit dfe4519c07
10 changed files with 348 additions and 5 deletions
+22 -4
View File
@@ -1238,9 +1238,6 @@ bool cv::solve( InputArray _src, InputArray _src2arg, OutputArray _dst, int meth
return result;
}
if( method == DECOMP_QR )
method = DECOMP_SVD;
int m = src.rows, m_ = m, n = src.cols, nb = _src2.cols;
size_t esz = CV_ELEM_SIZE(type), bufsize = 0;
size_t vstep = alignSize(n*esz, 16);
@@ -1268,7 +1265,6 @@ bool cv::solve( InputArray _src, InputArray _src2arg, OutputArray _dst, int meth
if( is_normal )
bufsize += n*nb*esz;
if( method == DECOMP_SVD || method == DECOMP_EIG )
bufsize += n*5*esz + n*vstep + nb*sizeof(double) + 32;
@@ -1321,6 +1317,28 @@ bool cv::solve( InputArray _src, InputArray _src2arg, OutputArray _dst, int meth
else
result = hal::Cholesky64f(a.ptr<double>(), a.step, n, dst.ptr<double>(), dst.step, nb);
}
else if( method == DECOMP_QR )
{
Mat rhsMat;
if( is_normal || m == n )
{
src2.copyTo(dst);
rhsMat = dst;
}
else
{
rhsMat = Mat(m, nb, type);
src2.copyTo(rhsMat);
}
if( type == CV_32F )
result = hal::QR32f(a.ptr<float>(), a.step, a.rows, a.cols, rhsMat.cols, rhsMat.ptr<float>(), rhsMat.step, NULL) != 0;
else
result = hal::QR64f(a.ptr<double>(), a.step, a.rows, a.cols, rhsMat.cols, rhsMat.ptr<double>(), rhsMat.step, NULL) != 0;
if (rhsMat.rows != dst.rows)
rhsMat.rowRange(0, dst.rows).copyTo(dst);
}
else
{
ptr = alignPtr(ptr, 16);