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

Jonathan Taylor jonathan.taylor at stanford.edu
Sat Aug 26 03:09:05 EDT 2017


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.



On Fri, Aug 25, 2017 at 11:41 PM, Nathaniel Smith <njs at pobox.com> wrote:

> On Fri, Aug 25, 2017 at 11:39 PM, Pauli Virtanen <pav at iki.fi> wrote:
> > pe, 2017-08-25 kello 23:08 -0700, Jonathan Taylor kirjoitti:
> >> I've got a largeish array that I have saved in a .MAT file that I
> >> need to
> >> use for
> >> matvec multiply several times.
> >>
> >> It seems that if I copy the array before running the matvec I get a
> >> significant speedup. Is this known?
> >
> > If you do the copy in a way such that the format of the matrix is
> > different (e.g. different sparse matrix format), then the speed can
> > differ. Check print(type(original_matrix), type(copied_matrix)).
>
> If it's a dense matrix, then it's also possible that the original
> matrix gets Fortran layout, and the copy is C layout. To test that you
> want: print(original_matrix.strides, copied_matrix.strides)
>
> -n
>
> --
> Nathaniel J. Smith -- https://vorpus.org
> _______________________________________________
> SciPy-Dev mailing list
> SciPy-Dev at python.org
> https://mail.python.org/mailman/listinfo/scipy-dev
>



-- 
Jonathan Taylor
Dept. of Statistics
Sequoia Hall, 137
390 Serra Mall
Stanford, CA 94305
Tel:   650.723.9230
Fax:   650.725.8977
Web: http://www-stat.stanford.edu/~jtaylo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20170826/96b03982/attachment.html>


More information about the SciPy-Dev mailing list