[BACK]Return to mpmat.rr CVS log [TXT][DIR] Up to [local] / OpenXM / src / asir-contrib / testing / noro

File: [local] / OpenXM / src / asir-contrib / testing / noro / mpmat.rr (download)

Revision 1.2, Fri Jan 15 06:09:09 2010 UTC (14 years, 4 months ago) by noro
Branch: MAIN
CVS Tags: R_1_3_1-2, RELEASE_1_3_1_13b, HEAD
Changes since 1.1: +36 -1 lines

*** empty log message ***

def printsys(F,V,Name) {
	D = map(dp_ptod,F,V);
	output(Name);
	print(length(V),0); print(" ",0); print(length(F));
	map(printpoly,D);
	output();
}

def printpoly(F)
{
	for ( I = 0, T = F; T; T = dp_rest(T), I++ );
	print(I);
	for ( T = F; T; T = dp_rest(T) ) {
		print(dp_hc(T),0); print(" ",0); print(dp_etov(dp_ht(T)));
	}
}

def allmat(F,V,O,Name) {
	printsys(F,V,Name);
	G = nd_gr_trace(F,V,1,1,O);
	N = length(V);
	T = ttttt;
	for ( I = 0; I < N; I++ ) {
		NameI = Name+rtostr(I+1);
		UI = minipoly_mat(G,V,O,V[I],T);
		utabout(UI,NameI);
	}
}

def utabout(U,Name)
{
	output(Name);
	M = U[0][0];
	D = U[0][1];
	F = U[1];
	N = size(M)[0];
	for ( I = 0; I < N; I++ ) {
		for ( J = 0; J < N; J++ ) { print(M[I][J],0);  print(" ",0); }
		print("");
	}
	print("");
	print(D);
	print("");
	for ( D = deg(F,var(F)), I = 0; I <= D; I++ ) {
		print(I,0); print(" ",0); print(coef(F,I));
	}
	output();
}

def minipoly_mat(G,V,O,V1,V0)
{
	if ( !zero_dim(hmlist(G,V,O),V,O) )
		error("tolex : ideal is not zero-dimensional!");

	N = length(V);
	dp_ord(O);

	HM = hmlist(G,V,O);
	MB = dp_mbase(map(dp_ptod,HM,V));
	Mat = utabtomat(G,V,V1,MB);

	for ( J = 0; ; J++ ) {
		M = lprime(J);
		if ( !valid_modulus(HM,M) )
			continue;
		MP = minipolym(G,V,O,V1,V0,M);
		MP = subst(MP,V0,V1);
		for ( D = deg(MP,V1), TL = [], J = 0; J <= D; J++ )
			TL = cons(V1^J,TL);
		NF = gennf(G,TL,V,O,V1,1)[0];
		R = tolex_main(V,O,NF,[MP],M,MB);
		return [Mat,sqpart(subst(ptozp(R[0]),V1,V0))];
	}
}

def utabtomat(G,V,V1,MB)
{
	Len = length(G); PS = vector(Len);
	for ( I = 0, T = G; T != []; T = cdr(T), I++ ) PS[I] = dp_ptod(car(T),V);
	for ( I = Len - 1, GI = []; I >= 0; I-- ) GI = cons(I,GI);
	N = length(MB);
	U = dp_ptod(V1,V);
	UTAB = newvect(N);
	for ( I = 0; I < N; I++ ) {
		UTAB[I] = [MB[I],remove_cont(dp_true_nf(GI,U*MB[I],PS,1))];
		if ( dp_gr_print() )
			print(".",2);
	}
	if ( dp_gr_print() )
		print("");

	M = matrix(N,N);
	for ( I = 0, LCM = 1; I < N; I++ ) LCM = ilcm(UTAB[I][1][1],LCM);	
	for ( I = 0; I < N; I++ ) {
		F = UTAB[I][1][0]; Mul = LCM/UTAB[I][1][1];
		for ( K = 0; K < N; K++ )
			if ( MB[K] == dp_ht(F) ) {
				M[K][I] = Mul*dp_hc(F);
				F = dp_rest(F);
			}
	}
	return [M,LCM];
}

def sqpart(F)
{
	G = gcd(F,diff(F,var(F)));
	return sdiv(F,G);
}
end$