#!/usr/bin/env python
# (C) 2000 Huaiyu Zhu <hzhu@users.sourceforge.net>. Licence: GPL
# $Id: test_linear.py,v 1.4 2000/07/26 20:58:27 hzhu Exp $
"""
Test linear algebra for Matrix module
"""
from MatPy.Matrix import *
from MatPy.mfuncs import sqrtm,expm,logm
print "-"*40, "matrix functions"
A = rand((3,3))
print A.typecode, norm(A + A - 2* A)
print norm(A*A*A / A /(A*A) - eye(3))
print norm(A**2 - A*A)
B = sqrtm(A)
print B
print B.typecode, norm(A - B*B), mnorm(A - B*B)
x = rand((3,1))
y = A*x
print solve(A,y)
print y.T/A.T
C = logm(A)
D = expm(C)
print C.typecode, D.typecode, norm(D-A)
|