From 47f6bced79afc2edfa8c2e8f1b2c196fbe9c1ffa Mon Sep 17 00:00:00 2001 From: wirawan Date: Thu, 14 Jul 2011 19:00:59 +0000 Subject: [PATCH] * wpylib.math.linalg: Added initial module for linear-algebra convenience functions, objects, and submodules. --- math/linalg/__init__.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 math/linalg/__init__.py diff --git a/math/linalg/__init__.py b/math/linalg/__init__.py new file mode 100644 index 0000000..4528bec --- /dev/null +++ b/math/linalg/__init__.py @@ -0,0 +1,27 @@ +# $Id: __init__.py,v 1.1 2011-07-14 19:00:59 wirawan Exp $ +# +# wpylib.math.linalg main module +# Created: 20110714 +# Wirawan Purwanto +# +""" +wpylib.math.linalg + +Provides convenience functions for linear algebra things beyond what's +already provided by numpy. + +""" + +import numpy + +def matmul(*Mats): + """Do successive matrix product. For example, + matmul(A,B,C,D) + will evaluate a matrix multiplication ((A*B)*C)*D . + The matrices must be of matching sizes.""" + p = numpy.dot(Mats[0], Mats[1]) + for M in Mats[2:]: + p = numpy.dot(p, M) + return p + +