[go: up one dir, main page]

Skip to content

gemm gives the wrong result for a submatrix of dimension 1

The following code produces different results even when they should be the same

math::array<complex, 2> mat({10, 2}, 1.0);
math::array<complex, 2> vec({10, 1}, -2.0);

mat({0, 10}, {1, 2}) = vec;
			
using boost::multi::blas::hermitized;
			
auto olap1 = boost::multi::blas::gemm(hermitized(mat), vec);

auto olap2 = boost::multi::blas::gemm(hermitized(mat({0, 10}, {0, 1})), vec); //this one gives the wrong result

math::array<complex, 2> mat2 = mat({0, 10}, {0, 1});
auto olap3 = boost::multi::blas::gemm(hermitized(mat2), vec);

std::cout << olap1[0][0] << "\t" << olap2[0][0] << '\t' << olap3[0][0] << std::endl;

the problem is with passing a subarray object. When making an explicit copy, it works fine. It only fails for dimension 1.

Edited by Alfredo Correa
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information