Hi folks,

I'm just starting with python and =
I'm having a=20
few problems, which I suspect are rather simple-minded.

1. I was looking for some sparse matrix functions =
that would=20
let me compute the eigen vectors of a rather large matrix in a =
reasonable amount=20
of time. I have found the eigen value functions in the numeric =
library and=20
I have found some linear algebra routines that allow sparse matrices, =
but I do=20
not see a way to combine these. I ended up saving the matrix as =
ascii,=20
editing it using word, reading it using excel, and then importing it to=20
matlab. There has to be a better way.

2. After having processed it in matlab, I am having =
trouble=20
figuring out how to get the result back into python. Does anyone =
have a=20
routine to read matlab *.mat files? Array has a fromfile method, =
but I=20
cannot seem to make it work. Once I resize the array (using =
reshape), the=20
fromfile method disappears from the object. I succeeded in getting =
something read into an array but it was gibberish. I was reading =
an ascii=20
file.

I have read a couple of the posted tutorials on =
using=20
matrices, but basically I am confused. I would greatly appreciate =
a couple=20
of pointers to get my head straight. Thanks for your =
time.

Herb

Herbert L. Roitblat, Ph.D.

Department of Psychology

University of Hawaii

------=_NextPart_000_000E_01BE8CEA.6ADD8190--
From jhauser@ifm.uni-kiel.de Fri Apr 23 10:11:21 1999
From: jhauser@ifm.uni-kiel.de (jhauser@ifm.uni-kiel.de)
Date: Fri, 23 Apr 1999 11:11:21 +0200 (CEST)
Subject: [Matrix-SIG] Sorting arrays lexicographically by row
In-Reply-To: <371C64A9.9B7F7C1C@erols.com>
References: <371C64A9.9B7F7C1C@erols.com>
Message-ID: <14112.14251.599737.610662@lisboa>
There is argsort, with which one can try to build a custom
sort-function.
But the most easy and probably also efficient method is to use pythons
list sort.
The conversion from an array to a list of lists cost nearly no
time. The sorting on lists is definetly very good optimized.
So use:
>>> a
array([[3, 1],
[3, 0],
[2, 1],
[1, 0],
[2, 2]])
>>> b=a.tolist()
>>> b.sort()
>>> array(b)
array([[1, 0],
[2, 1],
[2, 2],
[3, 0],
[3, 1]])
The steps in between are needed, because the methods do not return
arrays.
HTH,
__Janko
Edward C. Jones writes:
> Here is a small piece of Python code:
>
> arr = [[3,1], [3,0], [2,1], [1,0], [2,2]]
> arr.sort()
> print arr
>
> The output is:
>
> [[1, 0], [2, 1], [2, 2], [3, 0], [3, 1]]
>
> Can I do this (lexicographic) type of sorting using NumPy on a
> NumPy array?
>
> Thanks,
> Ed Jones
>
>
>
> _______________________________________________
> Matrix-SIG maillist - Matrix-SIG@python.org
> http://www.python.org/mailman/listinfo/matrix-sig
>
From mxu1@broadway.GC.cuny.edu Fri Apr 23 15:09:17 1999
From: mxu1@broadway.GC.cuny.edu (mxu1@broadway.GC.cuny.edu)
Date: Fri, 23 Apr 1999 10:09:17 -0400
Subject: [Matrix-SIG] Reading and handling matrices
In-Reply-To: roitblat's message of Thu, 22 Apr 1999 18:03:24 -1000.
<001101be8d3e$3c899190$bef07fce@0gl1u.pixi.com>
Message-ID: <199904231409.KAA00761@star.future.com>
Hi,
I have some codes for reading matlab4 binary files to and from python and it
only handles 2d full matrices. This is a part of my interface to Octave, a
matlab clone.
I will clean it up and post the code.
But other way is to use pymat, you can find it in the web page.
--
Min Xu
City College of NY, CUNY
Email: mxu1@email.gc.cuny.edu
minxu@sci.ccny.cuny.edu
Tel: (O) (212) 650-6865
(O) (212) 650-5046
(H) (212) 690-2119
--
Min Xu
City College of NY, CUNY
Email: mxu1@email.gc.cuny.edu
minxu@sci.ccny.cuny.edu
Tel: (O) (212) 650-6865
(O) (212) 650-5046
(H) (212) 690-2119
From hinsen@cnrs-orleans.fr Fri Apr 23 16:28:57 1999
From: hinsen@cnrs-orleans.fr (Konrad Hinsen)
Date: Fri, 23 Apr 1999 17:28:57 +0200
Subject: [Matrix-SIG] Reading and handling matrices
In-Reply-To: <001101be8d3e$3c899190$bef07fce@0gl1u.pixi.com>
(roitblat@hawaii.edu)
References: <001101be8d3e$3c899190$bef07fce@0gl1u.pixi.com>
Message-ID: <199904231528.RAA22325@chinon.cnrs-orleans.fr>
> 1. I was looking for some sparse matrix functions that would let me
> compute the eigen vectors of a rather large matrix in a
> reasonable amount of time. I have found the eigen value functions
> in the numeric library and I have found some linear algebra
> routines that allow sparse matrices, but I do not see a way to
> combine these. I ended up saving the matrix as ascii, editing it
Does that mean that your matrices are sparse? In that case, you should
use appropriate techniques, but... the problem with sparse matrices is
that there are so many different kinds of them, each requiring special
handling. Sparse matrix libraries usually require the user to provide
a matrix-vector multiplication routine. This routine has to use the
calling conventions of the library and is thus very likely impossible
to write in Python, even if performance were not a problem.
What this means is that I don't expect to find general sparse matrix
support in a Python package any time soon. Important special cases
could of course be handled.
If by any chance your matrices have the structure of second-derivative
matrices of finite-range potentials, I could provide a corresponding
sparse-matrix implementation with interfaces to ARPACK for finding
eigenvalues. In fact, it's in my Molecular Modelling Toolkit
(http://starship.python.net/crew/hinsen/mmtk.html)
--
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hinsen@cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69
Rue Charles Sadron | Fax: +33-2.38.63.15.17
45071 Orleans Cedex 2 | Deutsch/Esperanto/English/
France | Nederlands/Francais
-------------------------------------------------------------------------------
From Oliphant.Travis@mayo.edu Fri Apr 23 19:24:31 1999
From: Oliphant.Travis@mayo.edu (Travis Oliphant)
Date: Fri, 23 Apr 1999 13:24:31 -0500 (CDT)
Subject: [Matrix-SIG] Reading and handling matrices.
Message-ID: