#!/usr/bin/python

print "WARNING. old version"
print "a new version of this file (ssaTest.py) may be found at"
print "simtk.org (project msmtools)."

from ssaTools import *
from ssaCalculator import ssaCalculator
from scipy import matrix
 
#a = TransitionCountMatrix( "../matrices/run1-matrix100" )
#A = TransitionMatrix( a )

def testDecomp( count=1, dim=4 ):
	i = 0
	while i < count :
		
		C = makemat( dim )
		C = C + matrix(C).T
		T = normalizeRows( C )
		
		A = charpolmatrix( T ) 
		( P, L, U, Q ) = decompose( A )

		# make bloody sure everything is type 'matrix'
		# this means we can use * for matrix multiplication
		T = matrix( T )
		A = matrix( A )
		P = matrix( P )
		L = matrix( L )
		U = matrix( U )
		Q = matrix( Q )

		# Q.A.Q = P.L.U ?
		print "--"
		show( T, "T" )
		show( Q*A*Q, "QAQ" )
		show( P*L*U, "PLU" )
		M = P*L*U - Q*A*Q
		show( M, "M" )
		print "--"
		i += 1

# a supervillin matrix
m = openmat( "test/supervillin200ns.mat" )
calc = ssaCalculator( 10, m, -.5, evalList=[0,1,2,3,4], nNewSamples=1000 )

# the alanine dipeptide matrix
#m = openmat( "testmat" )
#calc = ssaCalculator( 0.1, m, 1./6. - 1., evalList=[0,1,2,3,4,5], nNewSamples=1000, automatic=True, timeUnits="ps" )

calc.displayContributions( bling=True )

#print mathform( calc.avgEvals )
#print
#print mathform( calc.varianceContributions, format="%e" )
#print	
