Discussion: Introducing new operators for matrix computation

Moshe Zadka moshez at math.huji.ac.il
Sat Jul 15 03:28:00 EDT 2000


On Sat, 15 Jul 2000, Huaiyu Zhu wrote:

> That's the beauty of numerical computation, because all kinds of
> applications, from animation on your screen to controlling satallite in
> space to analysing molecular structures to calculating consumer preference
> could all be expressed in the language of linear algebra.  (Mathematicians
> study spaces more abstract than linear spaces, but you wouldn't want to hear
> about them before appreciating the usefulness of linear algebra.) For
> example, all deterministic procedures are functions, and most functions we
> see are simply points in an (infinite dimensional) space.

So? You refuse to understand, so let me iterate this once more -- less
people are doing numeric computation than web programming. Python does
*not* cater to specific domain in the core, no matter the popularity.
Linear algebra is great, but I don't want Python to support it by growing
a mess of symbols only it would use.

Now that we have that clear, let's get something useful done. Here's how
to solve the element-wise/matrix-wise problem neatly:

define two classes:

class ElementWiseMatrix:

	pass # all numeric operations are done element-wise

	def Matrix(self):
		return MatrixWiseMatrix(self.data)

class MatrixWiseMatrix:

	pass # all numeric operations are done matrix-wise

	def Element(self):
		return ElementWiseMatrix(self.data)

(operations between the two are an error)

Now, your

B*[sin(A*x+b).*(A*y)/3]/C 

Is spelled

(Assume all matrices are originall matrix-wise)

# sin() already works element by element, unless you define
# sin(A) = A-(A^3/3!)+(A^5/5!)-....
B*(sin(A*x+b).Element()*(A*y).Element()/3)/C

--
Moshe Zadka <moshez at math.huji.ac.il>
There is no GOD but Python, and HTTP is its prophet.
http://advogato.org/person/moshez





More information about the Python-list mailing list