from UserArray import UserArray, _as_array
from Numeric import matrixmultiply

class Matrix(UserArray):
    def __mul__(self, other):
	return self.__return_constructor__(matrixmultiply(self.array, _as_array(other)))

    def __rmul__(self, other):
	return self.__return_constructor__(matrixmultiply(_as_array(other), self.array))

    def __pow__(self, other):
	raise TypeError, "x**y not implemented for matrices x"

    def __rpow__(self, other):
	raise TypeError, "x**y not implemented for matrices y"


if __name__ == '__main__':
	from Numeric import *
	m = Matrix( [[1,2,3],[11,12,13],[21,22,23]])
	print m*m
	print m.array*m.array
	print transpose(m)
