#!/usr/bin/env python
# (C) 2000 Huaiyu Zhu <hzhu@users.sourceforge.net>. Licence: GPL
# $Id: test_elem.py,v 1.1 2000/09/18 06:23:31 hzhu Exp $
"""
Test cross operations for Matrix module
"""
from MatPy.Matrix import ones,norm
a = ones((1,3))*2.
b = ones((3,1))*3.
def checkequal(x, y):
print x
print y
assert norm(x-y) == 0
print "-"*40
checkequal(a~+b, b~+a)
checkequal(a~-b, -(b~-a))
print "-"*40
checkequal (a~*b, b~*a)
checkequal (a~/b, 1~/(b~/a))
print "-"*40
checkequal(a~+1, 1~+a)
checkequal(a~-1, -(1~-a))
print "-"*40
checkequal (a~*3, 3~*a)
checkequal (a~/3, 1~/(3~/a))
print "-"*40
try:
print a+b
print b+a
print a+b
print b+a
except ValueError:
print "These do not work, as expected"
print "-"*40
print a*b
print b*a
try:
print a/b
print b/a
except ValueError:
print "These should work with generalized inverse. Need new code."
|