- changed status to resolved
Cannot pass a submatrix to a template function that uses rows/columns selection
Issue #248
resolved
Using blaze I can write this:
template <typename Matrix1, typename Matrix2>
double func_1(const Matrix1 &m1, const Matrix2 &m2)
{
return blaze::sum(m1 % m2);
}
int main() {
blaze::DynamicMatrix<double> m{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};
blaze::DynamicMatrix<double> k{{1, 1}, {0, 0}};
std::cout<<func_1(blaze::submatrix(m,0,0,2,2), k)<<std::endl;
}
I also can have a rows selection in my template function:
template <typename Matrix1, typename Matrix2>
double func_2(const Matrix1 &m1, const Matrix2 &m2)
{
return blaze::sum(blaze::rows(
m1, [](std::size_t i) { return i * 2; }, m2.rows()) %
m2);
}
int main() {
blaze::DynamicMatrix<double> m{{1, 2}, {5, 6}, {9, 10}};
blaze::DynamicMatrix<double> k{{1, 1}, {0, 0}};
std::cout<<func_2(m, k)<<std::endl;
}
I like to call func_2
with a submatrix
of m
, having:
template <typename Matrix1, typename Matrix2>
double func_2(const Matrix1 &m1, const Matrix2 &m2)
{
return blaze::sum(blaze::rows(
m1, [](std::size_t i) { return i * 2; }, m2.rows()) %
m2);
}
int main() {
blaze::DynamicMatrix<double> m{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};
blaze::DynamicMatrix<double> k{{1, 1}, {0, 0}};
func_2(blaze::submatrix(m,0,0,3,2), k);
}
I get this error:
1>c:\repos\vcpkg\installed\x64-windows\include\blaze\math\views\rows\dense.h(426): error C2338: Submatrix type detected
1>c:\repos\vcpkg\installed\x64-windows\include\blaze\math\views\rows.h(469): note: see reference to class template instantiation 'blaze::Rows<MT,true,true,false,P>' being compiled
1> with
1> [
1> MT=blaze::Submatrix<blaze::DynamicMatrix<double,false>,blaze::unaligned,false,true>,
1> P=func_2::<lambda_f4e6f1cd2443dc9a922ca509b7130f73>
1> ]
1>c:\repos\blaze_app_1\prog.cpp(1808): note: see reference to function template instantiation 'decltype(auto) blaze::rows<MT,false,func_2::<lambda_f4e6f1cd2443dc9a922ca509b7130f73>,,0x0>(const blaze::Matrix<MT,false> &,P,size_t)' being compiled
1> with
1> [
1> MT=blaze::Submatrix<blaze::DynamicMatrix<double,false>,blaze::unaligned,false,true>,
1> P=func_2::<lambda_f4e6f1cd2443dc9a922ca509b7130f73>
1> ]
1>c:\repos\blaze_app_1\prog.cpp(1838): note: see reference to function template instantiation 'double func_2<ReturnType,blaze::DynamicMatrix<double,false>>(const Matrix1 &,const Matrix2 &)' being compiled
1> with
1> [
1> Matrix1=ReturnType,
1> Matrix2=blaze::DynamicMatrix<double,false>
1> ]
1>c:\repos\vcpkg\installed\x64-windows\include\blaze\math\views\check.h(138): note: see reference to class template instantiation 'blaze::Check<false>' being compiled
1>c:\repos\vcpkg\installed\x64-windows\include\blaze\math\views\check.h(121): note: see reference to class template instantiation 'blaze::Check<true>' being compiled
1>c:\repos\hpx\hpx\parallel\execution_policy.hpp(648): note: see reference to class template instantiation 'hpx::parallel::execution::parallel_policy_executor<hpx::launch>' being compiled
1>Done building project "app1.vcxproj" -- FAILED.
Comments (2)
-
reporter -
- Log in to comment
resolved as I updated my blaze