Hi,
I have the following code that has been running fine in Sage 6.5––Sage 7.2 on both my Mac OS 10.10.5 and a Unix system. I just tried upgrading to Sage 7.3 on my Mac, and it no longer works correctly. It doesn't crash, it just gives wrong answers.
I will copy the code below, but it reminds me of the issue I had when I posted the following question: https://ask.sagemath.org/question/9943/homology-of-simplicial-complexes/
The code below is complicated, but the output of sampler(n) is supposed to be a random Q-acyclic simplicial complex with n vertices. So if I write
S=sampler(12)
S.homology()
I should expect to see something like
{0: 0, 1: 0, 1: 0} or {0: 0, 1: C2, 1: 0} as outputs,
but definitely not {0: 0, 1: Z, 2: Z}
The homology should be trivial or finite groups. But in Sage 7.3 on my Mac, I get Z parts in the homology. I thought my code was broken at first, but copying and pasting it back into Sage 7.2 on my Mac, it seems to work fine.
@cached_function
def f(X):
return (X.transpose() * X).inverse()
def ortho(X):
X.set_immutable()
return X*f(X)* X.transpose()
def TR(M):
D=M.diagonal()
X=GeneralDiscreteDistribution(D)
return X.get_random_element()
def shrink(X,Q,n):
W=Q[:,n]
W.set_immutable()
X2=X-W*f(W)*W.transpose()*X
X3=X2.transpose().echelon_form().transpose()
return X3[:,0:X3.ncols()-1]
def sampler(N):
S=range(1,N+1)
Z = SimplicialComplex(Set(range(1, N+1)).subsets(3))
L=list(Z.n_faces(2))
T=Z.n_skeleton(1)
C=Z.chain_complex()
M=C.differential(2).dense_matrix().transpose()
M2=M.transpose().echelon_form().transpose()
R=M2.rank()
X=M2[:,0:R]
Q=ortho(X)
n=TR(Q)
T.add_face(list(L[n]))
T2 = SimplicialComplex(T.facets())
T=T2
j = binomial(N,2) - N
for i in range(j):
X=shrink(X,Q,n)
Q=ortho(X)
n=TR(Q)
T.add_face(list(L[n]))
T1 = SimplicialComplex(T.facets())
return(T1)