[MATRIX-SIG] A proposal (LONG) - "reverse of take" revisited
Konrad Hinsen
hinsen@ibs.ibs.fr
Wed, 2 Jul 1997 20:22:20 +0200
> I would like to see block capability added to NumPy. Memory management,
Much of it is already there! You just have to play around with shapes.
Example: I frequently work with matrices that logically consist of 3x3
blocks. For some operations I must work on the blocks, for others on
the whole matrix. So here we go:
matrix_of_blocks = zeros((n, 3, n, 3), Float)
big_matrix = reshape(matrix_of_blocks, (3*n, 3*n))
Since reshape() returns a reference sharing the same data space,
I can use the two arrays interchangeably.
The only restriction is that the blocks must be of equal size.
> * A slice that does not make a copy, so I can modify a part of an image.
That's what indexing already does!
> * Efficiently view a big array as an array of blocks (each an array
> itself) and vice versa.
> * Convert an array of arrays to and from a big array.
Possible with restrictions (see above).
> * The ability to extract, insert, and manipulate sub-blocks of blocks.
Within the same restrictions, simply done by indexing.
Question: do you see a need for supporting non-equal-sized blocks?
That could become very messy.
--
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hinsen@ibs.ibs.fr
Laboratoire de Dynamique Moleculaire | Tel.: +33-4.76.88.99.28
Institut de Biologie Structurale | Fax: +33-4.76.88.54.94
41, av. des Martyrs | Deutsch/Esperanto/English/
38027 Grenoble Cedex 1, France | Nederlands/Francais
-------------------------------------------------------------------------------
_______________
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________