How add a column to a 2d array/matrix in numarray???
The unelegant way I found was to:
1. Create a new array with an extra column (e.g. using 'zeros' function).
2. Copy original array into new array.
3. Copy new column into last column.
Is there a slicker way to do this?
Chris 4 2692
In article <bf************ **************@ posting.google. com>, se******@spawar .navy.mil (Christian Seberino) wrote: How add a column to a 2d array/matrix in numarray???
The unelegant way I found was to:
1. Create a new array with an extra column (e.g. using 'zeros' function). 2. Copy original array into new array. 3. Copy new column into last column.
Is there a slicker way to do this?
Try numarray.resize
-- Russell
Thanks for the reply. I appreciate all the help I can get. Your suggestion
of using resize is excellent for adding *rows* but does not seem
right for *columns*. Here is an example: a
array([[ 0, 1, 2, 3, 4, 5],
[ 6, 7, 8, 9, 10, 11],
[12, 13, 14, 15, 16, 17]])
a.resize((4,6)) a
array([[ 0, 1, 2, 3, 4, 5],
[ 6, 7, 8, 9, 10, 11],
[12, 13, 14, 15, 16, 17],
[ 0, 1, 2, 3, 4, 5]])
a.resize((4,7)) a
array([[ 0, 1, 2, 3, 4, 5, 6],
[ 7, 8, 9, 10, 11, 12, 13],
[14, 15, 16, 17, 0, 1, 2],
[ 3, 4, 5, 0, 1, 2, 3]])
Do you see how adding an extra row left old rows intact but
adding an extra column messes up old columns? (i.e.
data in (1,1) position is not the same after adding a column)
Chris
"Russell E. Owen" <no@spam.invali d> wrote in message news:<c6******* ***@nntp6.u.was hington.edu>... In article <bf************ **************@ posting.google. com>, se******@spawar .navy.mil (Christian Seberino) wrote:
How add a column to a 2d array/matrix in numarray???
The unelegant way I found was to:
1. Create a new array with an extra column (e.g. using 'zeros' function). 2. Copy original array into new array. 3. Copy new column into last column.
Is there a slicker way to do this?
Try numarray.resize
-- Russell
At some point, se******@spawar .navy.mil (Christian Seberino) wrote: Thanks for the reply. I appreciate all the help I can get. Your suggestion of using resize is excellent for adding *rows* but does not seem right for *columns*.
If rows works, you could do transpose/resize/transpose.
--
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke
|cookedm(at)phy sics(dot)mcmast er(dot)ca
David
Thanks. That was pretty clever methinks.
Chris
co**********@ph ysics.mcmaster. ca (David M. Cooke) wrote in message news:<87******* *****@arbutus.p hysics.mcmaster .ca>... At some point, se******@spawar .navy.mil (Christian Seberino) wrote:
Thanks for the reply. I appreciate all the help I can get. Your suggestion of using resize is excellent for adding *rows* but does not seem right for *columns*.
If rows works, you could do transpose/resize/transpose. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Faheem Mitha |
last post by:
Dear People,
I have the current modest goal. Given a user defined class, I want to
creata an array of instances of that class.
Consider the following class.
class cell:
def setrow(self,row):
self.row = row
|
by: Curzio Basso |
last post by:
Hi all,
I was wondering what is the best way to compute the mean vector of a
matrix. Currently I'm doing this:
>>> data.shape
(117027, 8)
>>> mean = (numarray.add.reduce(data, axis=1))/(data.shape)
but maybe there is a faster way?
|
by: Chris P. |
last post by:
Hi. I have a very simple task to perform and I'm having a hard time
doing it.
Given an array called 'x' (created using the numarray library), is
there a single command that rounds each of its elements to the nearest
integer? I've already tried something like
>>> x_rounded = x.astype(numarray.Int)
but that only truncates each element (i.e. '5.9' becomes '5').
I've read over all the relevant numarray documentation, and it
|
by: Zhang Le |
last post by:
Hi,
I did a small benchmark of matrix-vector multiply operation using
Numeric module. I'm a bit suprised to find matrix*col-vector is much
faster than row-vector*matrix. I wonder whether other people have
observed this fact too, and why?
Below is the code I used, with output from my machine.
python bench.py
running 1000 iterations of matrix multiply of row 1000-vector
|
by: Jeff K |
last post by:
Can you pass an int array by reference to a function and modify
selective elements?
Here is my code:
#include <stdio.h>
#define COLUMNSIZE 30
#define ASIZE 5
int calcfldpos(int *row, int *column, int *numArray)
| |
by: Anthony Liu |
last post by:
I am talking about the 'take' method of numarray.
See here for more info:
http://stsdas.stsci.edu/numarray/Doc/node33.html
If I initialize a matrix 'mymatrix' by zeros((3,3),
type="Float64"), I get a 3*3 matrix of all zeros.
Look:
|
by: Anthony Liu |
last post by:
I am using numarray.
Suppose I have
>>> p = array(range(25), shape=(5,5))
>>> p
array(,
,
,
,
|
by: =?iso-8859-1?B?TWF0dGlhcyBCcuRuZHN0cvZt?= |
last post by:
Hello!
I'm trying to find what package I should use if I want to:
1. Create 3d vectors.
2. Normalize those vectors.
3. Create a 3x3 rotation matrix from a unit 3-d vector and an angle in
radians.
4. Perform matrix multiplication.
|
by: Bas |
last post by:
On Sep 22, 10:02 am, Al Kabaila <akaba...@pcug.org.auwrote:
That argument might have been valid 3 years ago, but as already said
by others, Numeric and Numarray are deprecated. Numpy should be the
only thing needed for new users. I suggest you investigate a little
bit more the next time you make such efforts, since this fact should
be widely known among the users of the mentioned packages, see e.g.
the huge warning at the numarray page:...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |