ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> numpy-discussion
numpy-discussion
[Numpy-discussion] Tensor-like product with extra indices?
by Huaiyu Zhu other posts by this author
Sep 13 2002 8:46AM messages near this date
Re: [Numpy-discussion] Attributes vs functions in numarray. | Re: [Numpy-discussion] Tensor-like product with extra indices?
Two related questions:

1. Suppose  B = ravel(A) and
            B[i] corresponds to A[i0,i1,...].

   Are there named functions that map the indices

        (i0,i0,...) ->  i

   and back?  This is assuming A.shape = (m0,m1,...) is known.

2. Suppose the above function is called ravel_index and its
   inverse unravel_index.

   Given a list of matrices [A0, A1, ...] is there a function that
   calculates a matrix B such that

        B[i,j]  = A0[i0,j] * A1[i1,j] * ...

   where i = ravel_index(i0, i1, ...).

   What about the inverse function that turns B into C such that

        C[i0,i1,...,j] = A0[i0,j] * A1[i1,j] * ...


I've considered reshape, ravel, take, put, outerproct but couldn't come
up with a combination to do it without a for-loop on j and a for-loop on
[A0,A1,...].

The above two questions I need answers right now.  But I can imagine a
need for a more general operations in the future.  Given a sequence of
arrays [A0,A1,...], produce a tensor product by picking certain indices
from each array (like i0,i1 above), while keeping some other indices
fixed (like j above).  For example, the above could be written as

        B = tensor_like([A0,A1...], [(0,None,None,...), ...,
                                (None,....,None,0), (1,1,...1)])

As another example, if len(A.shape)==3 then

        transpose(A) == tensor_like([A], [(2,), (1,), (0,)])


Huaiyu



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@[...].net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Thread:
Huaiyu Zhu
Konrad Hinsen
Huaiyu Zhu

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved