#!/usr/bin/env python # (C) 2000 Huaiyu Zhu <hzhu@users.sourceforge.net>. Licence: GPL # $Id: test_multiply.py,v 1.1.1.1 2000/06/03 23:56:50 hzhu Exp $ """ Test various types of multiplication """ from MatPy.Matrix import * a = ones((1,3)) b = ones((3,1)) print a print b print "-"*40 print a * 3. print 3. * a print b * 2. print 2. * b print "-"*40 print a * b print b * a print "-"*40 a = ones((2,3)) b = ones((3,2)) print a print b print "-"*40 print a * 3. print 3. * a print b * 2. print 2. * b print "-"*40 print a * b print b * a print "-"*40
Result obtained with
>>> from MatPy.tests import test_multiply
[ 1 1 1 ] [ 1 1 1 ] ---------------------------------------- [ 3 3 3 ] [ 3 3 3 ] [ 2 2 2 ] [ 2 2 2 ] ---------------------------------------- [ 3 ] [ 1 1 1 1 1 1 1 1 1 ] ---------------------------------------- [ 1 1 1 1 1 1 ] [ 1 1 1 1 1 1 ] ---------------------------------------- [ 3 3 3 3 3 3 ] [ 3 3 3 3 3 3 ] [ 2 2 2 2 2 2 ] [ 2 2 2 2 2 2 ] ---------------------------------------- [ 3 3 3 3 ] [ 2 2 2 2 2 2 2 2 2 ] ----------------------------------------