#!/usr/bin/env python
# (C) 2000 Huaiyu Zhu <hzhu@users.sourceforge.net>. Licence: GPL
# $Id: test_scalar.py,v 1.3 2000/09/13 01:52:36 hzhu Exp $
"""
Test basic operations for Scalar module
"""
from MatPy.Matrix import *
a = Matrix(2.)
A = rand((2,3))
print a
print A
print A.__tadd__(a)
print a.__tadd__(A)
print "-"*40
from MatPy.Scalar import *
nums = [1, 2., -3, -3.0, Scalar(1), Scalar(2.0), Scalar(1j), Scalar(1.j)]
for i in nums:
for j in nums: print "%7s" % `i*j`,
print
print Scalar(3)*Scalar(0.99) < Scalar(1) + Scalar(2) \
== Scalar(3.) < Scalar(3) + 1e-12
Result obtained with
>>> from MatPy.tests import test_scalar
[ 2 ]
[ 0.829 0.126 0.782
0.112 0.00821 0.746 ]
[ 2.83 2.13 2.78
2.11 2.01 2.75 ]
[ 2.83 2.13 2.78
2.11 2.01 2.75 ]
----------------------------------------
1 2.0 -3 -3.0 1 2.0 1j 1j
2.0 4.0 -6.0 -6.0 2.0 4.0 2j 2j
-3 -6.0 9 9.0 -3 -6.0 -3j -3j
-3.0 -6.0 9.0 9.0 -3.0 -6.0 -3j -3j
1 2.0 -3 -3.0 1 2.0 1j 1j
2.0 4.0 -6.0 -6.0 2.0 4.0 2j 2j
1j 2j -3j -3j 1j 2j (-1+0j) (-1+0j)
1j 2j -3j -3j 1j 2j (-1+0j) (-1+0j)
1