[SciPy-Dev] scipy.io.loadmat and matvec multiply

Robert Kern robert.kern at gmail.com
Sat Aug 26 14:06:34 EDT 2017


On Sat, Aug 26, 2017 at 12:09 AM, Jonathan Taylor <
jonathan.taylor at stanford.edu> wrote:
>
> Yes, it's a dense 2500x2000 matrix.
>
> Loaded strides: (8, 16000)
>
> Copied strides: (20000, 8)
>
> So, matvec is just slower because of strides and where numpy retrieves
data? Is there a simple way to do this besides a copy? I can easily afford
the copy, just wondering.

It's not simpler, but the most efficient and idiomatic way to ensure
C-contiguity is to use np.ascontiguousarray(). This will make a copy only
if necessary.

--
Robert Kern
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20170826/45ee80fa/attachment.html>


More information about the SciPy-Dev mailing list