Open epapoutsellis opened 14 hours ago
Thanks for spotting this. Agree this can be seen as an inconsistency with but not sure if it is a bug though.
Numpy .dot
when called with a 2D array (such as x1.array
) does matrix-matrix multiplication (here matrix-vector since x2.array is 1D), see
https://numpy.org/devdocs/reference/generated/numpy.dot.html
which also suggests that .dot
is not preferred for matrix-matrix multiplication, instead recommends matmul
or @
.
CIL datacontainer's .dot
considers each element a vector and so determines that they have different length and thus cannot compute their inner product, which I think is our intended behaviour. Forcing the same behaviour of datacontainer's .dot
would imply that a datacontainer can represent a matrix, something that is generally represented by LinearOperator
.
It seems there is a discrepancy between numpy's convention of .dot
and the mathematical differences between a vector and linear operator and it is not clear that we'd want to align with numpy's convention here. Can I ask what you were trying to achieve by carrying out the dot operation?
@bosschmidt
There is a problem with
ImageData
multiplied withVectorData
returns
So when comparing shapes in https://github.com/TomographicImaging/CIL/blob/master/Wrappers/Python/cil/framework/data_container.py#L705
we should check
self.shape[1] == other.shape[0]
.