[Numpy-discussion] size of a specific dimension of a numpy array

2010-03-17 Thread gerardo.berbeglia
I would like to know a simple way to know the size of a given dimension of a numpy array. Example A = numpy.zeros((10,20,30),float) The size of the second dimension of the array A is 20. Thanks. -- View this message in context: http://old.nabble.com/size-of-a-specific-dimension-of-a-numpy-

[Numpy-discussion] How to fix the diagonal values of a matrix

2010-03-16 Thread gerardo.berbeglia
How can i take out the diagonal values of a matrix and fix them to zero? Example: input: [[2,3,4],[3,4,5],[4,5,6]] output: [[0,3,4],[3,0,5],[4,5,0]] Thanks. -- View this message in context: http://old.nabble.com/How-to-fix-the-diagonal-values-of-a-matrix-tp27917991p27917991.html Sent from th

[Numpy-discussion] basic numpy array operation

2010-03-15 Thread gerardo.berbeglia
Suppose i have an array A of length n I want a variable b to be an array consisting of the first k elements of A and variable c to be an array with the last n-k elements of A. How do you do this? Example A = np.array([1,2,3,4,5,6]), k = 2 b = [1,2] c=[3,4,5,6] Thanks. -- View this message in

[Numpy-discussion] matrix operation.

2010-03-15 Thread gerardo.berbeglia
I have another matrix operations which seems a little more complicated. Let A be an n x n matrix and let S be a subset of {0,...,n-1}. Assume S is represented by a binary vector s, with a 1 at the index i if i is in S. (e.g. if S={0,3} then s = [1,0,0,1]) I re-post the question because the examp

[Numpy-discussion] matrix division without a loop

2010-03-12 Thread gerardo.berbeglia
Hello, I want to "divide" an n x n (2-dimension) numpy array matrix A by a n (1-dimension) array d as follows: Take n = 2. Let A= 2 3 1 10 and let d = [ 3 2 ] Then i would like to have "A/d" = 2/3 3/3 1/2 10/2 This is to avoid loops to i

[Numpy-discussion] matrix operation

2010-03-12 Thread gerardo.berbeglia
Hello, I want to "divide" an n x n (2-dimension) numpy array matrix A by a n (1-dimension) array d as follows: Take n = 2. Let A= 2 3 1 10 and let d = [ 3 2 ] Then i would like to have "A/d" = 2/3 3/3 1/2 10/2 This is to avoid loops t