xtensor-blas icon indicating copy to clipboard operation
xtensor-blas copied to clipboard

Improve handling of empty arrays in dot and solve

Open ghost opened this issue 5 years ago • 0 comments

At the moment, at least dot and solve seems to handle empty arrays improperly compared to NumPy.

dot

xt::xarray<double> a = xt::ones<double>({ 1, 2, 0, 1});
xt::xarray<double> b = xt::ones<double>({ 1, 0 });
auto result = xt::linalg::dot(a, b);
access violation - cblas_ddot

NumPy:

a = numpy.ones([1, 2, 0, 1])
b = numpy.ones([1, 0])
numpy.dot(a, b)
array([], shape=(1, 2, 0, 0), dtype=float64)

solve

auto a = xt::ones<double>({ 0, 0 });
auto b = xt::ones<double>({ 0 });
auto result = xt::linalg::solve(a, b);
C++ runtime assertion failed
File: gesv.tcc
Line: 98

Expression: info>=0

Numpy:

a = numpy.ones([0, 0])
b = numpy.ones([0])
numpy.linalg.solve(a, b)
array([], dtype=float64)

ghost avatar May 22 '19 11:05 ghost