473,404 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Python linear algebra module -- requesting comments on interface


Hi, I'm in the process of writing a Python linear
algebra module.

The current targeted interface is:

http://oregonstate.edu/~barnesc/temp/linalg/

The interface was originally based on Raymond
Hettinger's
Matfunc [1]. However, it has evolved so that now it
is
nearly identical to JAMA [2], the Java matrix library.

I am soliticing comments on this interface.

Please post up any criticism that you have. Even
small
things -- if something isn't right, it's better to fix
it now than later.

I have not made source code available yet, since the
current code is missing the decompositions and doesn't
match the new interface. I'm in the process of
rewritting the code to match the new interface. You
can e-mail me and ask for the old code if you're
curious
or skeptical.

[1]. http://users.rcn.com/python/download/python.htm
[2]. http://math.nist.gov/javanumerics/jama/

---------------------------------------------
Brief comparison with Numeric
---------------------------------------------

Numeric and linalg serve different purposes.

Numeric is intended to be a general purpose array
extension. It takes a "kitchen sink" approach,
and includes every function which could potentially
be useful for array manipulations.

Linalg is intended to handle real/complex vectors
and matrices, for scientific and 3D applications.
It has a more restricted scope. Because it is
intended for 3D applications, it is optimized
for dimension 2, 3, 4 operations.

For the typical matrix operations, the linalg
interface is much intuitive than Numeric's. Real
and imaginary components are always cast to
doubles, so no headaches are created if a matrix
is instantiated from a list of integers. Unlike
Numeric, the * operator performs matrix
multiplication, A**-1 computes the matrix inverse,
A == B returns True or False, and the 2-norm and
cross product functions exist.

As previously stated, linalg is optimized for
matrix arithmetic with small matrices (size 2, 3, 4).

A (somewhat out of date) set of microbenchmarks [3]
[4]
show that linalg is roughly an order of magnitude
faster than Numeric for dimension 3 vectors and
matrices.

[3].
Microbenchmarks without psyco:
http://oregonstate.edu/~barnesc/temp/
numeric_vs_linalg_prelim-2005-09-07.pdf

[4].
Microbenchmarks with psyco:
http://oregonstate.edu/~barnesc/temp/
numeric_vs_linalg_prelim_psyco-2005-09-07.pdf

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Sep 9 '05 #1
5 2786
C. Barnes wrote:
Hi, I'm in the process of writing a Python linear
algebra module.

The current targeted interface is:
http://oregonstate.edu/~barnesc/temp/linalg/


Is this going to become free software. If yes, what license
will you use?
So my suggestions:

In cases like these ones:

random_matrix(m, n=-1)
zero_matrix(m, n=-1)

... I think it's better to set the default value to "None"
instead of a number:

random_matrix(m, n=None)
zero_matrix(m, n=None)

IMHO, this is more intuitive and more "pythonic".

I also suggest to make the "random function" choosable:

random_matrix(m, n=None, randfunc=random.random)
random_vector(n, randfunc=random.random)

This way it's more easy for those who want another range
of numbers, or want another kind of distribution of the
random numbers.
At the top of your documentation, there is a link "overview",
which is broken:

See _overview_ for a quick start.
Greets,

Volker

--
Volker Grabsch
---<<(())>>---
\frac{\left|\vartheta_0\times\{\ell,\kappa\in\Re\} \right|}{\sqrt
[G]{-\Gamma(\alpha)\cdot\mathcal{B}^{\left[\oint\!c_\hbar\right]}}}
Sep 9 '05 #2
Since one of the module's targeted applications is for 3D applications,
I think there should be some specific support for applying the
Matrix-vector product operation to a sequence of vectors instead of
only one at a time -- and it should be possible to optimize the
module's code for this common case.

I'd also like to see some special specific errors defined and raised
from the Matrix det(), inverse(), and transpose() methods when the
operation is attempted on an ill-formed matrices (e.g. for non-square,
non-invertible, singular cases). This would allow client code to handle
errors better.

Very nice work overall, IMHO.

Best,
-Martin

Sep 9 '05 #3
Connelly,

Apologies, my first message was sent in error.

I like your general setup. You appear to permit matrix operations,
which the folk at Numeric and, later, numarray did not.

My own package, PyMatrix, has similar aims to yours but it may be slower
as it is based on numarray.

My package is just about ready for another release but I'm toiling to
improve the documentation. I felt that it could be of value to
newcomers to matrices and so my new documentation is more long-winded
than yours. Your overview sets the whole thing out very neatly.

I have made use of Python's properties for transpose, inverse etc. This
uses abbreviations and avoids redundant parentheses.

My work was based on the ideas of Huaiyu Zhu, who developed MatPy:
http://matpy.sourceforge.net/

You might be interested in looking at PyMatrix:
http://www3.sympatico.ca/cjw/PyMatrix/

Best wishes,

Colin W.

C. Barnes wrote:
Hi, I'm in the process of writing a Python linear
algebra module.

The current targeted interface is:

http://oregonstate.edu/~barnesc/temp/linalg/

The interface was originally based on Raymond
Hettinger's
Matfunc [1]. However, it has evolved so that now it
is
nearly identical to JAMA [2], the Java matrix library.

I am soliticing comments on this interface.

Please post up any criticism that you have. Even
small
things -- if something isn't right, it's better to fix
it now than later.

I have not made source code available yet, since the
current code is missing the decompositions and doesn't
match the new interface. I'm in the process of
rewritting the code to match the new interface. You
can e-mail me and ask for the old code if you're
curious
or skeptical.

[1]. http://users.rcn.com/python/download/python.htm
[2]. http://math.nist.gov/javanumerics/jama/

---------------------------------------------
Brief comparison with Numeric
---------------------------------------------

Numeric and linalg serve different purposes.

Numeric is intended to be a general purpose array
extension. It takes a "kitchen sink" approach,
and includes every function which could potentially
be useful for array manipulations.

Linalg is intended to handle real/complex vectors
and matrices, for scientific and 3D applications.
It has a more restricted scope. Because it is
intended for 3D applications, it is optimized
for dimension 2, 3, 4 operations.

For the typical matrix operations, the linalg
interface is much intuitive than Numeric's. Real
and imaginary components are always cast to
doubles, so no headaches are created if a matrix
is instantiated from a list of integers. Unlike
Numeric, the * operator performs matrix
multiplication, A**-1 computes the matrix inverse,
A == B returns True or False, and the 2-norm and
cross product functions exist.

As previously stated, linalg is optimized for
matrix arithmetic with small matrices (size 2, 3, 4).

A (somewhat out of date) set of microbenchmarks [3]
[4]
show that linalg is roughly an order of magnitude
faster than Numeric for dimension 3 vectors and
matrices.

[3].
Microbenchmarks without psyco:
http://oregonstate.edu/~barnesc/temp/
numeric_vs_linalg_prelim-2005-09-07.pdf

[4].
Microbenchmarks with psyco:
http://oregonstate.edu/~barnesc/temp/
numeric_vs_linalg_prelim_psyco-2005-09-07.pdf

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Sep 9 '05 #4
On Fri, 9 Sep 2005 04:58:43 -0700 (PDT), "C. Barnes" <co************@yahoo.com> wrote:

Hi, I'm in the process of writing a Python linear
algebra module.

The current targeted interface is:

http://oregonstate.edu/~barnesc/temp/linalg/

The interface was originally based on Raymond
Hettinger's
Matfunc [1]. However, it has evolved so that now it
is
nearly identical to JAMA [2], the Java matrix library.

I am soliticing comments on this interface.

Please post up any criticism that you have. Even
small
things -- if something isn't right, it's better to fix
it now than later.

Wondering whether you will be supporting OpenGL-style matrices and
operations for graphics. UIAM they permit optimizations in both
storage and operations due to the known zero and one element values
that would appear in full matrix representations of the same.

http://www.rush3d.com/reference/open...appendixg.html

Also wondering about some helper function to measure sensitivity of
..solve results when getting near-singular, but maybe that's an
out-side-of-the package job.

From a quick look, it looks quite nice ;-)

Regards,
Bengt Richter
Sep 10 '05 #5
nice interface, but with 3d apps i prefer cgkit's approach, which has
vec3, vec4, mat3, mat4 and quat types with lots of useful functions for
3d graphics (like mat4.looakAt(pos, target, up) or mat3.toEulerXYZ())

there are other libs with similar types and functions:
cgkit (http://cgkit.sourceforge.net/)
pyogre (http://www.ogre3d.org/wiki/index.php/PyOgre)
panda3d (http://panda3d.org/)

Sep 11 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ravi | last post by:
Hi, I did some googling, and found that there doesn't seem to be a pure python MySQL communication module. There is one for perl however, Net::MySQL. I was wondering if there was a specific...
0
by: barnesc | last post by:
Thanks for your commentary. The module will be public domain. I fixed the broken link (epydoc was inserting backslashes in URLs), changed the default arguments to None as you suggested, and...
0
by: Bernard Xhumga | last post by:
hello, I present my work : a freeware, (Language C, GnuPlot). Linear algebra : (fractions, 30 packages). http://www.geocities.com/xhungab/package.html The purpose of this work is to verify...
1
by: Casey Hawthorne | last post by:
Is the only way to connect Python and Lua through a C interface? -- Regards, Casey
0
by: Nico Grubert | last post by:
Hi there, I wrote a short python script that sends an email using python's email module and I am using Python 2.3.5. The problem is, that umlauts are not displayed properly in some email...
4
by: Con | last post by:
Hi, how does properly install the Python MySQL db module for Mac OS X? I was only able to locate the Win32 modules. Thanks in advance, -Conrad
1
by: Jon Harrop | last post by:
What would be the most efficient matrix representation for linear algebra on .NET? I recently benchmarked a 2D array, a flat array and an array of arrays and got the following performance...
1
by: Michal Kwiatkowski | last post by:
Hi, I'm working on Pythoscope, a unit test generator for Python and stumbled into the following problem. I need a way to analyze and modify Python AST tree, but without loosing source code...
8
by: Fett | last post by:
I am trying to find a wrapper to do linear programming within python. I am using an ubuntu machine and I have apt-get'd lp_solve, which works just fine. If someone knows of a wrapper that will work...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
tracyyun
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.