text:
isSectorValid:= proc(n, mbar, mubar, mbarbar)
	local result, debug;
	#Tells you wether the sector is empty or not
	if n < mbar*(mbar-1)/2 + mubar*(mubar-1)/2 then
		result:= false;
		debug:= "not enough boxes";
	end if:
	return result;
end proc:

genN1spart:= proc(n,m)
	local sparts;
	sparts:= genN2spart(n,0, m,0);
	if sparts = [[],[],[],[]] then return [[],[]]; end if;
	sparts:= map(x-> x[3..4], sparts);
	return sparts;
end proc:

isSpartValid:= proc(spart, debug:=0) local spartphi, spartthe, spartzed, spartpt;
	#tells you wether a spart is valid or not.
	if type(spart, list) <> true then
		return false;
	end if;
	if nops(spart) <> 4 then
			return false;
		end if;
		#Some local vars
		spartpt :=  spart[1];
		spartphi:=  spart[2];
		spartthe:=  spart[3];
		spartzed:=  spart[4];
		#Conditions on constituting partitions
		if MakeUnique(sort(spartphi)) <> sort(spartphi) then return false; end if;
		if MakeUnique(sort(spartthe)) <> sort(spartthe) then return false; end if;
		if min(FlattenOnce(spart)) < 0 then return false; end if;
		return true;
end proc:

giveSpartSector:= proc(spart::pN2spart)
		local n, mbar, mubar, mbarbar;
	#Takes a spart and returns the sector
		n := add(k, k in Flatten(spart));
		mbarbar:= nops(spart[1]);
		mbar:= nops(spart[2]);
		mubar:= nops(spart[3]);
		return [n, mbar, mubar, mbarbar];
end proc:

genN2spart:= proc(n, mbar, mubar, mbarbar, mode:=[1,2,3])
	local degreePT, ptSparts, spartPhi, spartThe, spartZed, degreePhi, degreeThe, degreeZed, sparts, newsparts, T, phiSparts, thetaSparts, zedSparts, part_of_n, ones_list;
	#Returns all the spart in a given sector
	#Initializing the number of boxes in each subpart
	sparts:= [];
	degreePT := n -mubar*(mubar-1)/2 - mbar*(mbar-1)/2;
	degreePhi:= n - degreePT;
	degreeThe:= n-degreePhi;
	degreeZed:= 0;
	if degreePT < 0 then return [[],[],[],[]]; end if;
	while degreePT >=0 do
		ptSparts:= partition(degreePT+mbarbar);
		ptSparts:= map(x-> if nops(x) <> mbarbar then NULL; else x; end if, ptSparts);
		ones_list:= map(x-> [seq(1, j=1..nops(x))], ptSparts);
		ptSparts:= ptSparts - ones_list;
		ptSparts:= map(x-> Reverse(x), ptSparts);

		degreePhi:= n - degreePT;
		while degreePhi >= mbar*(mbar-1)/2 do
			#All the dispart with degreePhi starting High
			phiSparts:=genSpartDist(degreePhi,mbar);

			degreeThe:=n-degreePhi-degreePT;
			while degreeThe >= mubar*(mubar-1)/2 do
				degreeZed:= n - degreePhi - degreeThe -degreePT;

				thetaSparts:= genSpartDist(degreeThe,mubar);
				#zedSparts:= Reverse(partition(degreeZed));
				part_of_n:= partition(degreeZed);
				zedSparts:= map(x-> Reverse(x), part_of_n);
				#Update the list of sparts
				T:=cartprod([ptSparts, phiSparts, thetaSparts, zedSparts]);
				newsparts:= [];
				while not T[finished] do newsparts:= [op(newsparts),T[nextvalue]()] end do;
				sparts:= [op(sparts), op(newsparts)];

				degreeThe:= degreeThe-1;
			end do:
			degreePhi:= degreePhi-1;
		end do:
	degreePT:= degreePT-1;
	end do:
return(spart_sort(sparts, mode));
end proc:

spart_sort:= proc(sparts, mode:=[1,2,3])
	local scores, k, j, out, perms, dom_score;
	scores:=[];
	for k in sparts do
		dom_score:=add(j, j in map(x->if `<` = sCompareDominance(k, x, mode) then 1; else 0; end if, sparts));
		scores:=[op(scores), dom_score];
	end do:
	perms:=sort(scores, output=permutation);
	out:= map(x->sparts[x], perms);
	return out;
end proc:

super_pol_sort:= proc(expr, the_symbol, sector, mode:=[1,2,3])
	local sort_vec;
	sort_vec:= map(x-> the_symbol[op(x)], genN2spart(op(sector), mode));
	return sort(expr, sort_vec);
end proc:

list_sort:= proc(in1, in2)
	if sCompareDominance([op(in1)], [op(in2)]) = `>` then return true; else return false; end if;
end proc:

genSpartDist:=proc(n,ell, debug:=0)
		local part_list, one_list;
	#Generates all the sparts with distinct parts including the zeros
	part_list:= Reverse(partition(n+ell));
	if debug <> 0 then print(part_list); end if;
		part_list:= map(x-> if nops(x) <> ell then NULL; else x; end if, part_list);
	if debug <> 0 then print(part_list); end if;
		part_list:= map(x-> if FindRepetitions(x) <> [] then NULL; else Reverse(x); end if, part_list);
	if debug <> 0 then print(part_list); end if;
	one_list:= map(x-> [seq(1, i=1..(nops(x)))], part_list);
		#part_list:= map(x-> Reverse(x - [seq(1, i=1..nops(x))]), part_list);
	part_list:= part_list - one_list;
		return part_list;
end proc:

switch_notation:= proc(spart, numbering:=a, uniquenum:=0, mode:=[1,2,3])
	local phis, thetas, phithetas, zeds, Lambda, pts, newLambda, counter,k;
	# exchange a spart for the other notation ( [] [] [] ) --> ( 4T, 3C, ...)
	pts := spart[1];
	if nops(spart[1])<>0 then pts := map(x-> [x, "TC", numbering^(x+1)], pts); end if;
	phis:= spart[2];
	if nops(spart[2])<>0 then phis:= map( x-> [x,"T",numbering^(x)], phis); end if;
	thetas:= spart[3];
	if nops(spart[3])<>0 then thetas:= map(x-> [x,"C", numbering^(x)], thetas); end if;
	zeds:= spart[4];
	if nops(spart[4])<>0 then zeds:= map(x-> [x,"", numbering^(x)], zeds); end if;
	Lambda:= Reverse(sort([op(pts),op(phis), op(thetas), op(zeds)]));
	if uniquenum=0 then
		newLambda:=[];
		counter:=1;
		for k from 1 to nops(Lambda) do
			if (op(2,Lambda[k]) = "T") or (op(2,Lambda[k]) = "C") then
				newLambda:=[op(newLambda), [op(Lambda[k]), numbering[counter]]];
				counter:= counter + 1;
			else
				newLambda:= [op(newLambda), [op(Lambda[k]), numbering]];
			end if;
		end do:
		Lambda:=newLambda;
		#Lambda:= map(x->
		#if (op(2,Lambda[x]) = "T") or (op(2,Lambda[x]) = "C")  then
		#[op(Lambda[x]), numbering[x]];
		#else
		#[op(Lambda[x]), numbering]; end if, [seq(k, k=1..nops(Lambda))]);
	else
		Lambda:= map(x->
		[op(Lambda[x]), numbering[x]]
		, [seq(k, k=1..nops(Lambda))]);
	end if;
	if mode <> [1,2,3] then
		Lambda:= sort_switch(Lambda, mode);
	end if;
	return Lambda;
end proc:

sort_switch:= proc(sw_spart, mode:=[1,2,3])
	local orig, perm, sublist, switched;
	orig:= ["TC", "T", "C"];
	perm:= subs({1="TC", 2="T", 3="C"}, mode);
	sublist:= {perm[1]="C0", perm[2]="B0", perm[3]="A0"};
	switched:= subs(sublist, sw_spart);
	switched:= Reverse(sort(switched));
	sublist:= {"C0"=perm[1], "B0"=perm[2], "A0"=perm[3]};
	switched:= subs(sublist, switched);
	return switched;
end proc:

reverse_notation:= proc(spart)
	local phis, thetas, phithetas, zeds, Lambda;
	phis:= 		Reverse(sort(map(x-> if x[2] = "T" then x[1]; else NULL; end if, spart)));
	thetas:= 	Reverse(sort(map(x-> if x[2] = "C" then x[1]; else NULL; end if, spart)));
	phithetas:= 	Reverse(sort(map(x-> if x[2] = "TC" then x[1]; else NULL; end if, spart)));
	zeds:= 		Reverse(sort(map(x-> if x[2] = "" then x[1]; else NULL; end if, spart)));
	Lambda:=	[phithetas,phis,thetas,zeds];
	return Lambda;
end proc:

#n-tupple aka compositions
#compositions
compare_bruhat:= proc(composition1, composition2)
	local compart, cumul_part1, cumul_part2, max_length, is1greater2, is1smaller2;
	# compare the weight of two composition, not really the bruhat order, it's the order defined in Baker, T. H., & Forrester, P. J. (1996). Non-Symmetric Jack Polynomials and Integral Kernels, 33. Quantum Algebra. Retrieved from http://arxiv.org/abs/q-alg/9612003
	compart:= compare_dominance(Reverse(sort(composition1)), Reverse(sort(composition2)));
	if composition1 = composition2 then return `=`; end if;
	if compart = `>` then
		return compart;
	elif compart = `<` then
		return compart;
	elif compart = `Non-comparable` then
		return compart;
	elif compart= `=` then
		cumul_part1:= PartialSums(composition1);
		cumul_part2:= PartialSums(composition2);
		max_length:= min(nops(cumul_part1), nops(cumul_part2));
		is1greater2 := map(x-> if op(x, cumul_part1) >= op(x, cumul_part2) then true; else false; end if, [seq(i, i=1..max_length)]);
		is1smaller2 := map(x-> if op(x, cumul_part1) <= op(x, cumul_part2) then true; else false; end if, [seq(i, i=1..max_length)]);

		if false in is1greater2 then
			if false in is1smaller2 then
						return `Non-comparable`;
				else
						return `<`;
			end if;
		else
				return `>`;
			end if;
	end if;
return `ErrorInBruhat`;
end proc:

genCompositions:=proc(weight, complength)
	local allcomp;
	allcomp:= [seq(op(composition(weight,k)),k=1..complength)];
	allcomp:= map(x-> if nops(x) < complength then [op(x),seq(0, k=1..(complength-nops(x)))]; else x; end if, allcomp);
	allcomp:= map(x-> permute(x), allcomp);
	allcomp:= FlattenOnce(allcomp);
	allcomp:= MakeUnique(allcomp);
	return allcomp;
end proc:

give_smallerComps:= proc(composition)
	local weight, allcomp, smallercomp;
	weight:= add(k, k in composition);
	allcomp:= genCompositions(weight, nops(composition));
	smallercomp:= map(x-> if compare_bruhat(composition, x) = `>` then x; else NULL; end if, allcomp);
	return smallercomp;
end proc:

compare_dominance:= proc(part1, part2, TEST:=NULL)
	local cumul_part1, cumul_part2, max_length, is1greater2, is1smaller2;
	#Normal dominance ordering comparision
	if part1=part2 then return `=`; end if;
	if add(i,i in part1) <> add(i,i in part2) then return `Non-comparable`; end if;
	cumul_part1:= PartialSums(part1);
	cumul_part2:= PartialSums(part2);
	if TEST <> NULL then
		if nops(part1) > nops(part2) then
			return `>`;
		else
			return `<`;
		end if;
	end if;
	max_length:= min(nops(cumul_part1), nops(cumul_part2));
	is1greater2 := map(x-> if op(x, cumul_part1) >= op(x, cumul_part2) then true; else false; end if, [seq(i, i=1..max_length)]);
	is1smaller2 := map(x-> if op(x, cumul_part1) <= op(x, cumul_part2) then true; else false; end if, [seq(i, i=1..max_length)]);
#debug

	if false in is1greater2 then
		if false in is1smaller2 then
			return `Non-comparable`;
		else
			return `<`;
		end if;
	else
		return `>`;
	end if;
end proc:

ell:= proc(spart)
	local ell_out;
	#Returns the length of a spart
	ell_out:= nops(Flatten(spart));
	return ell_out;
end proc:

lambda_box:= proc(spart)
	#removes circles from diagram
	return eliminate_zeros(sort(Flatten(spart), `>`));
end proc:

lambda_phitheta:= proc(spart)
	local phis, thetas, zeds, pts, ones;
	#removes h-circle, convert v-circle into boxes
	pts:= spart[1];
	ones:= [seq(1, k=1..nops(pts))];
	pts:= pts+ones;
	phis:= eliminate_zeros(spart[2]);
	thetas:= eliminate_zeros(spart[3]);
	zeds:= spart[4];
	return sort(Flatten([pts, phis, thetas, zeds]), `>`);
end proc:

lambda_phitheta_phi:= proc(spart)
	local pts, phis, thetas, zeds, ones;
	#removes h-circle, convert v-circle into boxes
	pts:= spart[1];
	ones:= [seq(1, k=1..nops(pts))];
	pts:= pts+ones;
	phis:= spart[2];
	ones:= [seq(1, k=1..nops(phis))];
	phis:= phis+ones;
	thetas:= eliminate_zeros(spart[3]);
	zeds:= spart[4];
	return sort(Flatten([pts, phis, thetas, zeds]), `>`);
end proc:

lambda_phitheta_phi_theta:= proc(spart)
	local pts, phis, thetas, zeds, ones;
	#removes h-circle, convert v-circle into boxes
	pts:= spart[1];
	ones:= [seq(1, k=1..nops(pts))];
	pts:= pts+ones;
	phis:= spart[2];
	ones:= [seq(1, k=1..nops(phis))];
	phis:= phis+ones;
	thetas:= spart[3];
	ones:= [seq(1, k=1..nops(thetas))];
	thetas:= thetas+ones;
	zeds:= spart[4];
	return sort(Flatten([pts, phis, thetas, zeds]), `>`);
end proc:

lambda_circle:= proc(spart, circs)
	local sector, pts, phis, thetas, zeds, partition, theseq;
	sector:= giveSpartSector(spart);
	pts:= spart[1];
	phis:= spart[2];
	thetas:= spart[3];
	zeds := spart[4];
	if 1 in circs then
		theseq:= [seq(1, k=1..sector[-1])];
		pts:= pts+theseq;
	end if:
	if 2 in circs then
		theseq:= [seq(1, k=1..sector[2])];
		phis:= phis+theseq;
	end if:
	if 3 in circs then
		theseq:= [seq(1, k=1..sector[3])];
		thetas:= thetas+theseq;
	end if:
	partition:= Flatten([pts, phis, thetas, zeds]);
	partition:= Reverse(sort(partition));
	return eliminate_zeros(partition);
end proc:

star_quatuor:= proc(spart, mode:=[1,2,3])
	local gradation, quatuor;
	#Self explanatory
	#Allowed modes:
	# [TC, T, C]=[1,2,3](Normal), [TC, C, T]=[1,3,2], [T, C, TC]=2,3,1, [T, TC, C]=[2,1,3]...
	gradation:= [ seq(mode[1..k], k=0..3) ];
	quatuor:= map(x-> lambda_circle(spart,x), gradation);
	return quatuor;
	#return [ lambda_box(spart), lambda_phitheta(spart), lambda_phitheta_phi(spart), lambda_phitheta_phi_theta(spart)];
end proc:

eliminate_zeros:= proc(a_list)
	#Removes 0's from a list
	return map(x-> if x = 0 then NULL; else x; end if, a_list);
end proc:

conjugate_part:= proc(part)
	local eat_part, new_part, len, ones;
	eat_part:= part;
	new_part:= [];
	len := nops(part);
	while len <> 0 do
		len := nops(eat_part);
		ones := [seq(1,j=1..len)];
		eat_part := eliminate_zeros(eat_part - ones);
		if len <> 0 then new_part := [op(new_part), len]; end if;
	end do:
	return new_part;
end proc:

sCompareDominance:= proc(spart1, spart2, mode:=[1,2,3])
	local quatuor1, quatuor2, quatuor_dom; option remember;
	#Compares the dominance of two sparts
	if spart1 = spart2 then return `=`; end if;
	quatuor1:= star_quatuor(spart1, mode);
	quatuor2:= star_quatuor(spart2, mode);
	quatuor_dom:=map(x-> compare_dominance(quatuor1[x], quatuor2[x]), [1,2,3,4]);
	if 	`Non-comparable` in quatuor_dom then return `Non-comparable`;
	elif 	`>` in quatuor_dom and `<` in quatuor_dom then return `Non-comparable`;
	elif	`>` in quatuor_dom then return `>`;
	elif	`<` in quatuor_dom then return `<`;
	else	return "This should not happen, error in sCompareDominance";
	end if;
end proc:

sKeep_smaller_sparts:= proc(spart, sparts, mode:=[1,2,3]) local compared_dominance, list_indices, smaller_sparts;
	#Given a spart and a list of sparts, returns all the sparts within the set that are smaller than then one given
	compared_dominance:= map(x-> sCompareDominance(spart, x, mode), sparts);
	list_indices:= [seq(k, k=1..nops(sparts))];
	smaller_sparts:= map(x-> if compared_dominance[x] = `>` then sparts[x]; else NULL; end if, list_indices);
	return smaller_sparts;
end proc:

give_greatest_spart:= proc(sparts, mode:=[1,2,3]) local k, dominance_of_spart;
	#Given a set of sparts, returns the highest one in the dominance ordering
	for k in sparts do
		dominance_of_spart:=map(x-> if x <> k then sCompareDominance(k, x, mode); else NULL; end if, sparts);
		if MakeUnique(dominance_of_spart) = [`>`] then return k; end if;
	end do:
end proc:

give_smallest_spart:= proc(sparts, mode:=[1,2,3]) local k, dominance_of_spart;
	#Given a set of sparts, returns the lowest one in the dominance ordering
	for k in sparts do
		dominance_of_spart:=map(x-> if x <> k then sCompareDominance(k, x, mode); else NULL; end if, sparts);
		if MakeUnique(dominance_of_spart) = [`<`] then return k; end if;
	end do:
end proc:

arm_part:= proc(i,j,part)
	#i is the row
	#j is the column
	return part[i]-j;
end proc:
co_arm_part:= proc(i,j,part)
	return j-1;
end proc:
co_leg_part:= proc(i,j,part)
	return i-1;
end proc:
leg_part:= proc(i,j,part)
	#i is the row
	#j is the column
	return conjugate_part(part)[j] - i;
end proc:
Jack_norm:= proc(spart, mode:=[1,2,3])
	local quatuor, spart0, spart1, spart2, spart3, spart_sector, M3, switched, nb_parts, B0, Btc, Bt, Bc, B1,B2,B3, ncoeff0, ncoeff1, ncoeff2, ncoeff3, the_coeff, pt_part, pt_distPart, zeta1;
	spart_sector:= giveSpartSector(spart);
	quatuor := star_quatuor(spart, mode);
	M3:= spart_sector[2] + spart_sector[3] + spart_sector[4];
	spart0:= quatuor[1];
	spart1:= quatuor[2];
	spart2:= quatuor[3];
	spart3:= quatuor[4];
	switched := switch_notation(spart, a, 0, mode);
	nb_parts := nops(switched);
	B0 := map(x-> if switched[x][2] = "" then seq([x,j], j=1..switched[x][1]); else NULL; end if, [seq(k, k=1..nb_parts)]);
	Btc := map(x-> if switched[x][2] = "TC" then seq([x,j], j=1..switched[x][1]); else NULL; end if, [seq(k, k=1..nb_parts)]);
	Bt := map(x-> if switched[x][2] = "T" then seq([x,j], j=1..switched[x][1]); else NULL; end if, [seq(k, k=1..nb_parts)]);
	Bt := map(x-> if x[2]-1 in spart[2] then NULL; else x; end if, Bt);
	Bc := map(x-> if switched[x][2] = "C" then seq([x,j], j=1..switched[x][1]); else NULL; end if, [seq(k, k=1..nb_parts)]);
	Bc := map(x-> if x[2]-1 in spart[3] then NULL; else x; end if, Bc);
	if mode[1] = 1 then
		B1:= Btc;
	elif mode[1] = 2 then
		B1:= Bt;
	elif mode[1] = 3 then
		B1:= Bc;
	end if;
	if mode[2] = 1 then
		B2:= Btc;
	elif mode[2] = 2 then
		B2:= Bt;
	elif mode[2] = 3 then
		B2:= Bc;
	end if;
	if mode[3] = 1 then
		B3:= Btc;
	elif mode[3] = 2 then
		B3:= Bt;
	elif mode[3] = 3 then
		B3:= Bc;
	end if;
	ncoeff0:= map(x->(leg_part(op(x),spart3) + alpha*(arm_part(op(x), spart0) + 1))/(leg_part(op(x),spart0) + 1 + alpha*arm_part(op(x), spart3)), B0);
	ncoeff1:= map(x->(leg_part(op(x),spart0) + alpha*(arm_part(op(x), spart0) + 1))/(leg_part(op(x),spart1) + 1 + alpha*arm_part(op(x), spart3)), B1);
	ncoeff2:= map(x->(leg_part(op(x),spart1) + alpha*(arm_part(op(x), spart0) + 1))/(leg_part(op(x),spart2) + 1 + alpha*arm_part(op(x), spart3)), B2);
	ncoeff3:= map(x->(leg_part(op(x),spart2) + alpha*(arm_part(op(x), spart0) + 1))/(leg_part(op(x),spart3) + 1 + alpha*arm_part(op(x), spart3)), B3);
	the_coeff:= mul(x, x in ncoeff0);
	the_coeff:= the_coeff*mul(x, x in ncoeff1);
	the_coeff:= the_coeff*mul(x, x in ncoeff2);
	the_coeff:= the_coeff*mul(x, x in ncoeff3);
	pt_part:= spart[1];
	pt_distPart:= {op(pt_part)};
	zeta1:= mul(factorial(Occurrences(i,pt_part)), i in pt_distPart);
	return factor(1/zeta1*alpha^(M3)*the_coeff);
end proc:

down_hook:= proc(spart, mode:=[1,2,3])
	local quatuor, spart0, spart1, spart2, spart3, spart_sector, M3, switched, nb_parts, B0, Btc, Bt, Bc, B1,B2,B3, ncoeff0, ncoeff1, ncoeff2, ncoeff3, the_coeff, pt_part, pt_distPart, zeta1;
	spart_sector:= giveSpartSector(spart);
	quatuor := star_quatuor(spart, mode);
	M3:= spart_sector[2] + spart_sector[3] + spart_sector[4];
	spart0:= quatuor[1];
	spart1:= quatuor[2];
	spart2:= quatuor[3];
	spart3:= quatuor[4];
	switched := switch_notation(spart, a, 0, mode);
	nb_parts := nops(switched);
	B0 := map(x-> if switched[x][2] = "" then seq([x,j], j=1..switched[x][1]); else NULL; end if, [seq(k, k=1..nb_parts)]);
	Btc := map(x-> if switched[x][2] = "TC" then seq([x,j], j=1..switched[x][1]); else NULL; end if, [seq(k, k=1..nb_parts)]);
	Bt := map(x-> if switched[x][2] = "T" then seq([x,j], j=1..switched[x][1]); else NULL; end if, [seq(k, k=1..nb_parts)]);
	Bt := map(x-> if x[2]-1 in spart[2] then NULL; else x; end if, Bt);
	Bc := map(x-> if switched[x][2] = "C" then seq([x,j], j=1..switched[x][1]); else NULL; end if, [seq(k, k=1..nb_parts)]);
	Bc := map(x-> if x[2]-1 in spart[3] then NULL; else x; end if, Bc);
	if mode[1] = 1 then
		B1:= Btc;
	elif mode[1] = 2 then
		B1:= Bt;
	elif mode[1] = 3 then
		B1:= Bc;
	end if;
	if mode[2] = 1 then
		B2:= Btc;
	elif mode[2] = 2 then
		B2:= Bt;
	elif mode[2] = 3 then
		B2:= Bc;
	end if;
	if mode[3] = 1 then
		B3:= Btc;
	elif mode[3] = 2 then
		B3:= Bt;
	elif mode[3] = 3 then
		B3:= Bc;
	end if;
	ncoeff0:= map(x->(leg_part(op(x),spart0) + 1 + alpha*arm_part(op(x), spart3)), B0);
	ncoeff1:= map(x->(leg_part(op(x),spart1) + 1 + alpha*arm_part(op(x), spart3)), B1);
	ncoeff2:= map(x->(leg_part(op(x),spart2) + 1 + alpha*arm_part(op(x), spart3)), B2);
	ncoeff3:= map(x->(leg_part(op(x),spart3) + 1 + alpha*arm_part(op(x), spart3)), B3);
	the_coeff:= mul(x, x in ncoeff0);
	the_coeff:= the_coeff*mul(x, x in ncoeff1);
	the_coeff:= the_coeff*mul(x, x in ncoeff2);
	the_coeff:= the_coeff*mul(x, x in ncoeff3);
	pt_part:= spart[1];
	pt_distPart:= {op(pt_part)};
	zeta1:= mul(factorial(Occurrences(i,pt_part)), i in pt_distPart);
	return factor(zeta1*the_coeff);
	#return the_coeff;
end proc:


text:
(*
 Copyright (C) 2017 M.A.L. Marques

 This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0. If a copy of the MPL was not distributed with this
 file, You can obtain one at http://mozilla.org/MPL/2.0/.
*)

(* type: mgga_exc *)
(* prefix:
  mgga_x_mn12_params *params;

  assert(p->params != NULL);
  params = (mgga_x_mn12_params * ) (p->params);
*)

$define lda_x_params
$include "lda_x.mpl"

mn12_omega_x := 2.5:
mn12_gamma_x := 0.004:

mn12_vx := (rs, z) -> 1/(1 + rs/(mn12_omega_x*RS_FACTOR)*(2/(1 + z))^(1/3)):
mn12_ux := x -> mn12_gamma_x*x^2/(1 + mn12_gamma_x*x^2):
mn12_wx := t -> (K_FACTOR_C - t)/(K_FACTOR_C + t):

mn12_pol1  := t-> params_a_c[ 1] + params_a_c[ 2]*mn12_wx(t) + params_a_c[ 3]*mn12_wx(t)^2 + params_a_c[ 4]*mn12_wx(t)^3
  + params_a_c[ 5]*mn12_wx(t)^4 + params_a_c[ 6]*mn12_wx(t)^5:
mn12_pol2  := t-> params_a_c[ 7] + params_a_c[ 8]*mn12_wx(t) + params_a_c[ 9]*mn12_wx(t)^2 + params_a_c[10]*mn12_wx(t)^3
   + params_a_c[11]*mn12_wx(t)^4:
mn12_pol3  := t-> params_a_c[12] + params_a_c[13]*mn12_wx(t) + params_a_c[14]*mn12_wx(t)^2 + params_a_c[15]*mn12_wx(t)^3:
mn12_pol4  := t-> params_a_c[16] + params_a_c[17]*mn12_wx(t) + params_a_c[18]*mn12_wx(t)^2:
mn12_pol5  := t-> params_a_c[19] + params_a_c[20]*mn12_wx(t) + params_a_c[21]*mn12_wx(t)^2 + params_a_c[22]*mn12_wx(t)^3
   + params_a_c[23]*mn12_wx(t)^4:
mn12_pol6  := t-> params_a_c[24] + params_a_c[25]*mn12_wx(t) + params_a_c[26]*mn12_wx(t)^2 + params_a_c[27]*mn12_wx(t)^3:
mn12_pol7  := t-> params_a_c[28] + params_a_c[29]*mn12_wx(t) + params_a_c[30]*mn12_wx(t)^2:
mn12_pol8  := t-> params_a_c[31] + params_a_c[32]*mn12_wx(t) + params_a_c[33]*mn12_wx(t)^2 + params_a_c[34]*mn12_wx(t)^3:
mn12_pol9  := t-> params_a_c[35] + params_a_c[36]*mn12_wx(t) + params_a_c[37]*mn12_wx(t)^2:
mn12_pol10 := t-> params_a_c[38] + params_a_c[39]*mn12_wx(t) + params_a_c[40]*mn12_wx(t)^2:

mn12_f := (rs, z, x, u, t) ->
  + mn12_pol1(t)
  + mn12_pol2(t)*mn12_ux(x)
  + mn12_pol3(t)*mn12_ux(x)^2
  + mn12_pol4(t)*mn12_ux(x)^3
  + mn12_pol5(t)*mn12_vx(rs, z)
  + mn12_pol6(t)*mn12_ux(x)*mn12_vx(rs, z)
  + mn12_pol7(t)*mn12_ux(x)^2*mn12_vx(rs, z)
  + mn12_pol8(t)*mn12_vx(rs, z)^2
  + mn12_pol9(t)*mn12_ux(x)*mn12_vx(rs, z)^2
  + mn12_pol10(t)*mn12_vx(rs, z)^3:

f := (rs, z, xt, xs0, xs1, u0, u1, t0, t1) ->
  mgga_exchange_nsp(mn12_f, rs, z, xs0, xs1, u0, u1, t0, t1):

ext: mpl


text:
(*
 Copyright (C) 2017 M.A.L. Marques

 This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0. If a copy of the MPL was not distributed with this
 file, You can obtain one at http://mozilla.org/MPL/2.0/.
*)

(* type: lda_exc *)
(* prefix:
  lda_x_params *params;

  assert(p->params != NULL);
  params = (lda_x_params * )(p->params);
*)

$ifdef lda_x_params
params_a_alpha := 1:
$endif

f_lda_x := (rs, z) ->
  + params_a_alpha*my_piecewise3(screen_dens(rs,  z), 0, lda_x_spin(rs,  z))
  + params_a_alpha*my_piecewise3(screen_dens(rs, -z), 0, lda_x_spin(rs, -z)):
f       := (rs, z) -> f_lda_x(rs, z):


text:
# MarSystemComposite
# Type = Series
# Name = playbacknet

# MarControls = 19
# mrs_bool/active = 1
# Links = 0
# mrs_bool/debug = 0
# Links = 0
# mrs_bool/mute = 0
# Links = 0
# mrs_bool/hasData = 0
# Links = 1
# /Series/playbacknet/SoundFileSource/src/mrs_bool/hasData
# mrs_bool/probe = 0
# Links = 0
# mrs_natural/inObservations = 1
# Links = 0
# mrs_natural/inSamples = 100
# Links = 0
# mrs_natural/loopPos = 0
# Links = 1
# /Series/playbacknet/SoundFileSource/src/mrs_natural/loopPos
# mrs_natural/nChannels = 1
# Links = 2
# /Series/playbacknet/SoundFileSource/src/mrs_natural/nChannels
# /Series/playbacknet/AudioSink/dest/mrs_natural/nChannels
# mrs_natural/onObservations = 1
# Links = 0
# mrs_natural/onSamples = 100
# Links = 0
# mrs_natural/pos = 661500
# Links = 1
# /Series/playbacknet/SoundFileSource/src/mrs_natural/pos
# mrs_real/israte = 22050
# Links = 1
# /Series/playbacknet/SoundFileSource/src/mrs_real/israte
# mrs_real/osrate = 22050
# Links = 0
# mrs_realvec/input0 = # MARSYAS mrs_realvec
# Size = 0

# type: matrix
# rows: 0
# columns: 0

# Size = 0
# MARSYAS mrs_realvec

# Links = 0
# mrs_realvec/input1 = # MARSYAS mrs_realvec
# Size = 0

# type: matrix
# rows: 0
# columns: 0

# Size = 0
# MARSYAS mrs_realvec

# Links = 0
# mrs_string/filename = /home/gtzan/data/sound/music_speech/music/guitar.au
# Links = 1
# /Series/playbacknet/SoundFileSource/src/mrs_string/filename
# mrs_string/inObsNames = audio,
# Links = 0
# mrs_string/onObsNames = audio,
# Links = 0

# nComponents = 3

# MarSystem
# Type = SoundFileSource
# Name = src

# MarControls = 27
# mrs_bool/active = 1
# Links = 0
# mrs_bool/advance = 0
# Links = 0
# mrs_bool/debug = 0
# Links = 0
# mrs_bool/mute = 0
# Links = 0
# mrs_bool/hasData = 0
# Links = 1
# /Series/playbacknet/mrs_bool/hasData
# mrs_bool/noteon = 0
# Links = 0
# mrs_bool/shuffle = 0
# Links = 0
# mrs_natural/cindex = 0
# Links = 0
# mrs_natural/inObservations = 1
# Links = 0
# mrs_natural/inSamples = 100
# Links = 0
# mrs_natural/loopPos = 0
# Links = 1
# /Series/playbacknet/mrs_natural/loopPos
# mrs_natural/nChannels = 1
# Links = 1
# /Series/playbacknet/mrs_natural/nChannels
# mrs_natural/numFiles = 1
# Links = 0
# mrs_natural/onObservations = 1
# Links = 0
# mrs_natural/onSamples = 100
# Links = 0
# mrs_natural/pos = 661500
# Links = 1
# /Series/playbacknet/mrs_natural/pos
# mrs_natural/size = 661500
# Links = 0
# mrs_real/duration = -1
# Links = 0
# mrs_real/frequency = 0
# Links = 0
# mrs_real/israte = 22050
# Links = 1
# /Series/playbacknet/mrs_real/israte
# mrs_real/osrate = 22050
# Links = 0
# mrs_real/repetitions = 1
# Links = 0
# mrs_string/allfilenames = ,
# Links = 0
# mrs_string/currentlyPlaying = daufile
# Links = 0
# mrs_string/filename = /home/gtzan/data/sound/music_speech/music/guitar.au
# Links = 1
# /Series/playbacknet/mrs_string/filename
# mrs_string/inObsNames = audio,
# Links = 0
# mrs_string/onObsNames = audio,
# Links = 0

# MarSystem
# Type = Gain
# Name = gt

# MarControls = 15
# mrs_bool/RMScalc = 0
# Links = 0
# mrs_bool/active = 1
# Links = 0
# mrs_bool/debug = 0
# Links = 0
# mrs_bool/mute = 0
# Links = 0
# mrs_natural/inObservations = 1
# Links = 0
# mrs_natural/inSamples = 100
# Links = 0
# mrs_natural/onObservations = 1
# Links = 0
# mrs_natural/onSamples = 100
# Links = 0
# mrs_real/gain = 1
# Links = 0
# mrs_real/israte = 22050
# Links = 0
# mrs_real/osrate = 22050
# Links = 0
# mrs_realvec/inRMS = # MARSYAS mrs_realvec
# Size = 0

# type: matrix
# rows: 0
# columns: 0

# Size = 0
# MARSYAS mrs_realvec

# Links = 0
# mrs_realvec/outRMS = # MARSYAS mrs_realvec
# Size = 0

# type: matrix
# rows: 0
# columns: 0

# Size = 0
# MARSYAS mrs_realvec

# Links = 0
# mrs_string/inObsNames = audio,
# Links = 0
# mrs_string/onObsNames = audio,
# Links = 0

# MarSystem
# Type = AudioSink
# Name = dest

# MarControls = 13
# mrs_bool/active = 1
# Links = 0
# mrs_bool/debug = 0
# Links = 0
# mrs_bool/mute = 0
# Links = 0
# mrs_natural/bufferSize = 256
# Links = 0
# mrs_natural/inObservations = 1
# Links = 0
# mrs_natural/inSamples = 100
# Links = 0
# mrs_natural/nChannels = 1
# Links = 1
# /Series/playbacknet/mrs_natural/nChannels
# mrs_natural/onObservations = 1
# Links = 0
# mrs_natural/onSamples = 100
# Links = 0
# mrs_real/israte = 22050
# Links = 0
# mrs_real/osrate = 22050
# Links = 0
# mrs_string/inObsNames = audio,
# Links = 0
# mrs_string/onObsNames = audio,
# Links = 0

max_stars_repo_name: jaouahbi/VampPlugins

max_issues_repo_name: jaouahbi/VampPlugins

max_forks_repo_name: jaouahbi/VampPlugins


text:
(*
 Copyright (C) 2017 M.A.L. Marques

 This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0. If a copy of the MPL was not distributed with this
 file, You can obtain one at http://mozilla.org/MPL/2.0/.
*)

(* type: mgga_exc *)
(* prefix:
  mgga_c_revtpss_params *params;

  assert(p->params != NULL);
  params = (mgga_c_revtpss_params * )(p->params);
*)

$include "gga_c_regtpss.mpl"
$include "tpss_c.mpl"

f := (rs, z, xt, xs0, xs1, us0, us1, ts0, ts1) ->
  + tpss_f(f_pbe, rs, z, xt, xs0, xs1, ts0, ts1):


text:
flavor 1
srclang 3
id 65535
numfuncs 2
import "triangle.mplt"
import "/home/bravewtz/Desktop/openarkcompiler/libjava-core/libjava-core.mplt"
entryfunc &Ltriangle_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V
fileinfo {
  @INFO_filename "triangle.jar"}
srcfileinfo {
  1 "triangle.java"}
type $__class_meta__ <struct {
  @shadow <* void> final,
  @monitor i32 final,
  @classloader u16 final,
  @objsize u16 final,
  @itab <* void> final,
  @vtab <* void> final,
  @gctib <* void> final,
  @classinforo <* void> final,
  @clinitbridge <* void> final}>
type $__class_meta_ro__ <struct {
  @classname <* void> final,
  @ifields <* void> final,
  @methods <* void> final,
  @superclass_or_componentclass <* void> final,
  @numoffields u16 final,
  @numofmethods u16 final,
  @flag u16 final,
  @numofsuperclasses u16 final,
  @padding u32 final,
  @mod i32 final,
  @annotation i32 final,
  @clinitAddr i32 final}>
type $__method_info__ <struct {
  @method_in_vtab_index i64 final,
  @declaringclass i64 final,
  @addr i64 final,
  @mod i32 final,
  @methodname i32 final,
  @signaturename i32 final,
  @annotationvalue i32 final,
  @flag u16 final,
  @argsize u16 final,
  @padding u32 final}>
type $__method_info_compact__ <struct {
  @method_in_vtab_index i32 final,
  @addr i32 final,
  @lebPadding0 u8 final}>
type $__field_info__ <struct {
  @offset u64 final,
  @mod u32 final,
  @flag u16 final,
  @index u16 final,
  @typeName i64 final,
  @fieldname u32 final,
  @annotation u32 final,
  @declaringclass <* void> final}>
type $__field_info_compact__ <struct {
  @offset u32 final,
  @lebPadding0 u8 final}>
type $__superclass_meta__ <struct {
  @superclassinfo <* void> final}>
type $MUIDFuncDefTabEntry <struct {
  @funcUnifiedAddr u64}>
type $MUIDFuncInfTabEntry <struct {
  @funcSize u32,
  @funcName u32}>
type $MUIDFuncDefMuidTabEntry <struct {
  @muidLow u64,
  @muidHigh u64}>
type $MUIDDataDefTabEntry <struct {
  @dataUnifiedAddr u64}>
type $MUIDDataDefMuidTabEntry <struct {
  @muidLow u64,
  @muidHigh u64}>
type $MUIDUnifiedUndefTabEntry <struct {
  @globalAddress u64}>
type $MUIDUnifiedUndefMuidTabEntry <struct {
  @muidLow u64,
  @muidHigh u64}>
type $MUIDRangeTabEntry <struct {
  @tabBegin <* void>,
  @tabEnd <* void>}>
javaclass $Ltriangle_3B <$Ltriangle_3B> public
var $_C_STR_2000 fstatic <[3] u64> readonly = [0, 0x300000000, 0x2000000020]
var $Ljava_2Flang_2FSystem_3B_7Cout extern <* <$Ljava_2Fio_2FPrintStream_3B>> final public static
var $__cinf_Ljava_2Flang_2FString_3B <$__class_meta__>
func &MCC_GetOrInsertLiteral () <* <$Ljava_2Flang_2FString_3B>>
var $__vtb_Ltriangle_3B fstatic <[11] <* void>> = [16, 28, 36, 40, 8, 4, 52, 12, 24, 48, 32]
var $__cinf_Ltriangle_3B <$__class_meta__> public
var $__methods_info__Ltriangle_3B fstatic <[2] <$__method_info__>> public = [[1= 0xfff6, 2= addrof ptr $__cinf_Ltriangle_3B, 3= addroffunc ptr &Ltriangle_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V, 4= 9, 5= 48, 6= 68, 7= 160, 8= 0xa201, 9= 1, 10= 0], [1= 0xfff6, 2= addrof ptr $__cinf_Ltriangle_3B, 3= addroffunc ptr &Ltriangle_3B_7C_3Cinit_3E_7C_28_29V, 4= 0x10001, 5= 176, 6= 204, 7= 160, 8= 0xad81, 9= 1, 10= 0]]
var $__cinf_Ljava_2Flang_2FObject_3B extern <$__class_meta__> public
var $__superclasses__Ltriangle_3B fstatic <[1] <$__superclass_meta__>> public = [[1= 0x4000000000000000]]
var $__classinforo__Ltriangle_3B fstatic <$__class_meta_ro__> public = [1= 4, 2= 0, 3= addrof ptr $__methods_info__Ltriangle_3B, 4= addrof ptr $__superclasses__Ltriangle_3B, 5= 0, 6= 2, 7= 0, 8= 1, 9= 0, 10= 33, 11= 160, 12= 0]
var $MCC_GCTIB__Ltriangle_3B fstatic <* void> public
var $classStateInitialized u64
var $__cinf_Ltriangle_3B <$__class_meta__> public = [1= 0x2d5ea50972d3c6a3, 2= 0, 3= 0xffff, 4= 0, 5= 0, 6= addrof ptr $__vtb_Ltriangle_3B, 7= addrof ptr $MCC_GCTIB__Ltriangle_3B, 8= addrof ptr $__classinforo__Ltriangle_3B, 9= addrof ptr $classStateInitialized]
var $__muid_classmetadata_bucket$$triangle_jar <[1] <* void>> public = [addrof ptr $__cinf_Ltriangle_3B]
func &MCC_Reflect_ThrowCastException nosideeffect () void
func &MCC_Reflect_Check_Casting_NoArray nosideeffect () void
func &MCC_Reflect_Check_Casting_Array nosideeffect () void
func &MCC_CheckThrowPendingException nosideeffect () void
func &MCC_PreNativeCall (var %caller ref) <* void>
func &MCC_PostNativeCall (var %env <* void>) void
func &MCC_DecodeReference nosideeffect (var %obj ref) ref
func &MCC_CallFastNative (var %func <* void>) <* void>
func &MCC_CallSlowNative0 (var %func <* void>) <* void>
func &MCC_CallSlowNative1 (var %func <* void>) <* void>
func &MCC_CallSlowNative2 (var %func <* void>) <* void>
func &MCC_CallSlowNative3 (var %func <* void>) <* void>
func &MCC_CallSlowNative4 (var %func <* void>) <* void>
func &MCC_CallSlowNative5 (var %func <* void>) <* void>
func &MCC_CallSlowNative6 (var %func <* void>) <* void>
func &MCC_CallSlowNative7 (var %func <* void>) <* void>
func &MCC_CallSlowNative8 (var %func <* void>) <* void>
func &MCC_CallFastNativeExt (var %func <* void>) <* void>
func &MCC_CallSlowNativeExt (var %func <* void>) <* void>
func &MCC_SetReliableUnwindContext nosideeffect () void
var $__reg_jni_func_tab$$triangle_jar <[0] <* void>>
var $__cinf_Ljava_2Flang_2FSystem_3B extern <$__class_meta__>
func &MCC_getFuncPtrFromItabSecondHash64 nosideeffect () ptr
var $__cinf_Ljava_2Flang_2FStringBuilder_3B extern ptr
var $__muid_func_def_tab$$triangle_jar fstatic <[2] <$MUIDFuncDefTabEntry>> = [[1= addroffunc ptr &Ltriangle_3B_7C_3Cinit_3E_7C_28_29V], [1= addroffunc ptr &Ltriangle_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V]]
var $__muid_func_inf_tab$$triangle_jar fstatic <[2] <$MUIDFuncInfTabEntry>> = [[1= addroffunc ptr &Ltriangle_3B_7C_3Cinit_3E_7C_28_29V, 2= addroffunc ptr &Ltriangle_3B_7C_3Cinit_3E_7C_28_29V], [1= addroffunc ptr &Ltriangle_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V, 2= addroffunc ptr &Ltriangle_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V]]
var $__muid_func_def_muid_tab$$triangle_jar fstatic <[2] <$MUIDFuncDefMuidTabEntry>> = [[1= -7771374696027735678, 2= -2331404492394030025], [1= -4846290012835284211, 2= -1374826168571557693]]
var $__muid_func_muid_idx_tab$$triangle_jar fstatic <[2] u32> = [0, 1]
var $__muid_data_def_tab$$triangle_jar fstatic <[1] <$MUIDDataDefTabEntry>> = [[1= addrof ptr $__cinf_Ltriangle_3B]]
var $__muid_data_def_muid_tab$$triangle_jar fstatic <[1] <$MUIDDataDefMuidTabEntry>> = [[1= -7133127083694108201, 2= -2324429630329342824]]
var $__muid_func_undef_tab$$triangle_jar fstatic <[13] <$MUIDUnifiedUndefTabEntry>> = [[1= 0], [1= 0], [1= 0], [1= 0], [1= 0], [1= 0], [1= 0], [1= 0], [1= 0], [1= 0], [1= 0], [1= 0], [1= 0]]
var $__muid_func_undef_muid_tab$$triangle_jar fstatic <[13] <$MUIDUnifiedUndefMuidTabEntry>> = [[1= 0x3e32352aee789835, 2= -3887705395317205813], [1= -4187412136968710015, 2= -3800091941095621250], [1= 0x6742c234127e0a27, 2= -3762262047879347071], [1= 0x7230554331c55d92, 2= -3676689525926909155], [1= 0x68ac654ba12897fd, 2= -3286408426690925789], [1= -715372855679083712, 2= -2647497990906227723], [1= -7464356948810446352, 2= -2259485500590180091], [1= 0x783627f2afd1cbde, 2= -2046851302095768916], [1= -2701934576591406938, 2= -1693831364093527548], [1= 0x126777a7fe39e1fb, 2= -1314856249532362766], [1= 0xbf40578f3343f7a, 2= -1198421541845410999], [1= 0x7ca2bdf69a6c7c94, 2= -801329978528900548], [1= 0x477aafa4d7dd102b, 2= -442561182569419835]]
var $__muid_data_undef_tab$$triangle_jar fstatic <[4] <$MUIDUnifiedUndefTabEntry>> = [[1= addrof ptr $__cinf_Ljava_2Flang_2FObject_3B], [1= addrof ptr $__cinf_Ljava_2Flang_2FStringBuilder_3B], [1= addrof ptr $Ljava_2Flang_2FSystem_3B_7Cout], [1= addrof ptr $__cinf_Ljava_2Flang_2FSystem_3B]]
var $__muid_data_undef_muid_tab$$triangle_jar fstatic <[4] <$MUIDUnifiedUndefMuidTabEntry>> = [[1= -567417612161374449, 2= -3298852447504547670], [1= -4416616377677153579, 2= -1692279531030365896], [1= 0x191283ac418c4bb9, 2= -1676204161023949463], [1= -5921653145571052587, 2= -171150348656858163]]
var $__muid_range_tab$$triangle_jar fstatic <[29] <$MUIDRangeTabEntry>> = [[1= 0x3db399ea2932af51, 2= -2547182005447951574], [1= 0xee7dc7c30acb205, 2= -3555984142825002936], [1= 2, 2= 2], [1= 3, 2= 3], [1= 4, 2= 4], [1= 5, 2= 5], [1= 6, 2= 6], [1= 7, 2= 7], [1= 8, 2= 8], [1= 9, 2= 9], [1= 0, 2= 0], [1= 11, 2= 11], [1= 12, 2= 12], [1= 13, 2= 13], [1= 14, 2= 14], [1= 15, 2= 15], [1= addrof ptr $__muid_func_def_tab$$triangle_jar, 2= addrof ptr $__muid_func_def_tab$$triangle_jar], [1= 0, 2= 0], [1= addrof ptr $__muid_func_inf_tab$$triangle_jar, 2= addrof ptr $__muid_func_inf_tab$$triangle_jar], [1= addrof ptr $__muid_func_undef_tab$$triangle_jar, 2= addrof ptr $__muid_func_undef_tab$$triangle_jar], [1= addrof ptr $__muid_data_def_tab$$triangle_jar, 2= addrof ptr $__muid_data_def_tab$$triangle_jar], [1= 0, 2= 0], [1= addrof ptr $__muid_data_undef_tab$$triangle_jar, 2= addrof ptr $__muid_data_undef_tab$$triangle_jar], [1= addrof ptr $__muid_func_def_muid_tab$$triangle_jar, 2= addrof ptr $__muid_func_def_muid_tab$$triangle_jar], [1= addrof ptr $__muid_func_undef_muid_tab$$triangle_jar, 2= addrof ptr $__muid_func_undef_muid_tab$$triangle_jar], [1= addrof ptr $__muid_data_def_muid_tab$$triangle_jar, 2= addrof ptr $__muid_data_def_muid_tab$$triangle_jar], [1= addrof ptr $__muid_data_undef_muid_tab$$triangle_jar, 2= addrof ptr $__muid_data_undef_muid_tab$$triangle_jar], [1= addrof ptr $__muid_func_muid_idx_tab$$triangle_jar, 2= addrof ptr $__muid_func_muid_idx_tab$$triangle_jar], [1= 0, 2= 0]]
var $__reflection_strtab$$triangle_jar fstatic <[55] u8> = [0, 76, 116, 114, 105, 97, 110, 103, 108, 101, 59, 0, 109, 97, 105, 110, 0, 40, 91, 76, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 83, 116, 114, 105, 110, 103, 59, 41, 86, 0, 48, 33, 48, 0, 60, 105, 110, 105, 116, 62, 0, 40, 41, 86, 0]
var $__compilerVersionNum$$triangle_jar <[0] <* void>> = [1, 0]
func &Ltriangle_3B_7C_3Cinit_3E_7C_28_29V public constructor (var %_this <* <$Ltriangle_3B>>) void {
  funcid 48153
  var %Reg1_R43694 <* <$Ltriangle_3B>> localrefvar
  var %Reg1_R57 <* <$Ljava_2Flang_2FObject_3B>> localrefvar
  var %__muid_symptr <* void>

  intrinsiccall MCCIncRef (dread ref %_this)
  intrinsiccall MCCDecRef (dread ref %Reg1_R43694)
  dassign %Reg1_R43694 0 (dread ref %_this)
  #INSTIDX : 0||0000:  aload_0
  #INSTIDX : 1||0001:  invokespecial
  regassign ptr %1 (dread ref %Reg1_R57)
  dassign %Reg1_R57 0 (retype ref <* <$Ljava_2Flang_2FObject_3B>> (dread ref %Reg1_R43694))
  intrinsiccall MCCIncRef (dread ref %Reg1_R57)
  intrinsiccall MCCDecRef (regread ptr %1)
  #Call function:Ljava_2Flang_2FObject_3B_7C_3Cinit_3E_7C_28_29V
  dassign %__muid_symptr 0 (iread ptr <* <$MUIDUnifiedUndefTabEntry>> 1 (array 0 ptr <* <[13] <$MUIDUnifiedUndefTabEntry>>> (addrof ptr $__muid_func_undef_tab$$triangle_jar, constval i64 10)))
  icallassigned (dread ptr %__muid_symptr, dread ref %Reg1_R57) {}
  #INSTIDX : 4||0004:  return
  intrinsiccall MPL_CLEANUP_LOCALREFVARS (dread ref %Reg1_R43694, dread ref %Reg1_R57)
  return ()
}
func &Ltriangle_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V public static (var %Reg10_R743 <* <[] <* <$Ljava_2Flang_2FString_3B>>>>) void {
  funcid 48154
  var %Reg0_I i32
  var %Reg6_I i32
  var %Reg0_R9160 <* <[] <* <[] i32>>>> localrefvar
  var %Reg7_R12 ref
  var %Reg8_I i32
  var %Reg9_I i32
  var %Reg7_R9160 <* <[] <* <[] i32>>>> localrefvar
  var %Reg0_R12 ref
  var %Reg1_I i32
  var %Reg1_R12 ref
  var %Reg2_I i32
  var %Reg2_R12 ref
  var %Reg0_R562 <* <$Ljava_2Fio_2FPrintStream_3B>> localrefvar
  var %Reg1_R43 <* <$Ljava_2Flang_2FString_3B>> localrefvar
  var %L_STR_15536 <* <$Ljava_2Flang_2FString_3B>>
  var %Reg1_R1112 <* <$Ljava_2Flang_2FStringBuilder_3B>> localrefvar
  var %Reg3_I i32
  var %Reg2_R43 <* <$Ljava_2Flang_2FString_3B>> localrefvar
  var %__muid_symptr <* void>

  #INSTIDX : 0||0000:  bipush
  dassign %Reg0_I 0 (constval i32 10)
  #INSTIDX : 2||0002:  istore_1
  dassign %Reg6_I 0 (dread i32 %Reg0_I)
  #INSTIDX : 3||0003:  iload_1
  #INSTIDX : 4||0004:  iload_1
  #INSTIDX : 5||0005:  multianewarray
  dassign %Reg6_I 0 (cvt i32 i32 (dread i32 %Reg6_I))
  dassign %Reg6_I 0 (cvt i32 i32 (dread i32 %Reg6_I))
  #INSTIDX : 9||0009:  astore_2
  dassign %Reg7_R12 0 (dread ref %Reg0_R9160)
  #INSTIDX : 10||000a:  iconst_0
  dassign %Reg0_I 0 (constval i32 0)
  #INSTIDX : 11||000b:  istore_3
  dassign %Reg8_I 0 (dread i32 %Reg0_I)
  dassign %Reg8_I 0 (cvt i32 i32 (dread i32 %Reg8_I))
@label0   #INSTIDX : 12||000c:  iload_3
  #INSTIDX : 13||000d:  iload_1
  #INSTIDX : 14||000e:  if_icmpge
  brtrue @label6 (ge i32 i32 (dread i32 %Reg8_I, dread i32 %Reg6_I))
  #INSTIDX : 17||0011:  iconst_0
  dassign %Reg0_I 0 (constval i32 0)
  #INSTIDX : 18||0012:  istore 4
  dassign %Reg9_I 0 (dread i32 %Reg0_I)
  dassign %Reg9_I 0 (cvt i32 i32 (dread i32 %Reg9_I))
@label1   #INSTIDX : 20||0014:  iload 4
  #INSTIDX : 22||0016:  iload_3
  #INSTIDX : 23||0017:  if_icmpgt
  brtrue @label5 (gt i32 i32 (dread i32 %Reg9_I, dread i32 %Reg8_I))
  #INSTIDX : 26||001a:  iload 4
  #INSTIDX : 28||001c:  ifeq
  brtrue @label2 (eq i32 i32 (dread i32 %Reg9_I, constval i32 0))
  #INSTIDX : 31||001f:  iload_3
  #INSTIDX : 32||0020:  iload 4
  #INSTIDX : 34||0022:  if_icmpne
  brfalse @label2 (ne i32 i32 (dread i32 %Reg8_I, dread i32 %Reg9_I))
@label3   #INSTIDX : 47||002f:  aload_2
  #INSTIDX : 48||0030:  iload_3
  #INSTIDX : 49||0031:  aaload
  regassign ptr %2 (dread ref %Reg7_R9160)
  dassign %Reg7_R9160 0 (retype ref <* <[] <* <[] i32>>>> (dread ref %Reg7_R12))
  intrinsiccall MCCIncRef (dread ref %Reg7_R9160)
  intrinsiccall MCCDecRef (regread ptr %2)
  dassign %Reg0_R12 0 (iread ref <* ref> 0 (array 1 ptr <* <[] ref>> (dread ref %Reg7_R9160, dread i32 %Reg8_I)))
  #INSTIDX : 50||0032:  iload 4
  #INSTIDX : 52||0034:  aload_2
  #INSTIDX : 53||0035:  iload_3
  #INSTIDX : 54||0036:  iconst_1
  dassign %Reg1_I 0 (constval i32 1)
  #INSTIDX : 55||0037:  isub
  dassign %Reg1_I 0 (sub i32 (dread i32 %Reg8_I, dread i32 %Reg1_I))
  #INSTIDX : 56||0038:  aaload
  regassign ptr %3 (dread ref %Reg7_R9160)
  dassign %Reg7_R9160 0 (retype ref <* <[] <* <[] i32>>>> (dread ref %Reg7_R12))
  intrinsiccall MCCIncRef (dread ref %Reg7_R9160)
  intrinsiccall MCCDecRef (regread ptr %3)
  dassign %Reg1_R12 0 (iread ref <* ref> 0 (array 1 ptr <* <[] ref>> (dread ref %Reg7_R9160, dread i32 %Reg1_I)))
  #INSTIDX : 57||0039:  iload 4
  #INSTIDX : 59||003b:  iconst_1
  dassign %Reg2_I 0 (constval i32 1)
  #INSTIDX : 60||003c:  isub
  dassign %Reg2_I 0 (sub i32 (dread i32 %Reg9_I, dread i32 %Reg2_I))
  #INSTIDX : 61||003d:  iaload
  dassign %Reg1_I 0 (iread i32 <* i32> 0 (array 1 ptr <* <[] i32>> (dread ref %Reg1_R12, dread i32 %Reg2_I)))
  #INSTIDX : 62||003e:  aload_2
  #INSTIDX : 63||003f:  iload_3
  #INSTIDX : 64||0040:  iconst_1
  dassign %Reg2_I 0 (constval i32 1)
  #INSTIDX : 65||0041:  isub
  dassign %Reg2_I 0 (sub i32 (dread i32 %Reg8_I, dread i32 %Reg2_I))
  #INSTIDX : 66||0042:  aaload
  regassign ptr %4 (dread ref %Reg7_R9160)
  dassign %Reg7_R9160 0 (retype ref <* <[] <* <[] i32>>>> (dread ref %Reg7_R12))
  intrinsiccall MCCIncRef (dread ref %Reg7_R9160)
  intrinsiccall MCCDecRef (regread ptr %4)
  dassign %Reg2_R12 0 (iread ref <* ref> 0 (array 1 ptr <* <[] ref>> (dread ref %Reg7_R9160, dread i32 %Reg2_I)))
  #INSTIDX : 67||0043:  iload 4
  #INSTIDX : 69||0045:  iaload
  dassign %Reg2_I 0 (iread i32 <* i32> 0 (array 1 ptr <* <[] i32>> (dread ref %Reg2_R12, dread i32 %Reg9_I)))
  #INSTIDX : 70||0046:  iadd
  dassign %Reg1_I 0 (add i32 (dread i32 %Reg1_I, dread i32 %Reg2_I))
  #INSTIDX : 71||0047:  iastore
  iassign <* i32> 0 (
    array 1 ptr <* <[] i32>> (dread ref %Reg0_R12, dread i32 %Reg9_I),
    dread i32 %Reg1_I)
  goto @label4
@label2   #INSTIDX : 37||0025:  aload_2
  #INSTIDX : 38||0026:  iload_3
  #INSTIDX : 39||0027:  aaload
  regassign ptr %1 (dread ref %Reg7_R9160)
  dassign %Reg7_R9160 0 (retype ref <* <[] <* <[] i32>>>> (dread ref %Reg7_R12))
  intrinsiccall MCCIncRef (dread ref %Reg7_R9160)
  intrinsiccall MCCDecRef (regread ptr %1)
  dassign %Reg0_R12 0 (iread ref <* ref> 0 (array 1 ptr <* <[] ref>> (dread ref %Reg7_R9160, dread i32 %Reg8_I)))
  #INSTIDX : 40||0028:  iload 4
  #INSTIDX : 42||002a:  iconst_1
  dassign %Reg1_I 0 (constval i32 1)
  #INSTIDX : 43||002b:  iastore
  iassign <* i32> 0 (
    array 1 ptr <* <[] i32>> (dread ref %Reg0_R12, dread i32 %Reg9_I),
    dread i32 %Reg1_I)
  #INSTIDX : 44||002c:  goto
  goto @label4
@label4   #INSTIDX : 72||0048:  iinc
  dassign %Reg9_I 0 (add i32 (dread i32 %Reg9_I, constval i32 1))
  dassign %Reg9_I 0 (cvt i32 i32 (dread i32 %Reg9_I))
  #INSTIDX : 75||004b:  goto
  goto @label1
@label5   #INSTIDX : 78||004e:  iinc
  dassign %Reg8_I 0 (add i32 (dread i32 %Reg8_I, constval i32 1))
  dassign %Reg8_I 0 (cvt i32 i32 (dread i32 %Reg8_I))
  #INSTIDX : 81||0051:  goto
  goto @label0
@label6   #INSTIDX : 84||0054:  iconst_0
  dassign %Reg0_I 0 (constval i32 0)
  #INSTIDX : 85||0055:  istore_3
  dassign %Reg8_I 0 (dread i32 %Reg0_I)
  dassign %Reg8_I 0 (cvt i32 i32 (dread i32 %Reg8_I))
@label7   #INSTIDX : 86||0056:  iload_3
  #INSTIDX : 87||0057:  iload_1
  #INSTIDX : 88||0058:  if_icmpge
  brtrue @label12 (ge i32 i32 (dread i32 %Reg8_I, dread i32 %Reg6_I))
  #INSTIDX : 91||005b:  iload_3
  #INSTIDX : 92||005c:  istore 4
  dassign %Reg9_I 0 (dread i32 %Reg8_I)
@label8   #INSTIDX : 94||005e:  iload 4
  #INSTIDX : 96||0060:  iload_1
  #INSTIDX : 97||0061:  if_icmpge
  brtrue @label9 (ge i32 i32 (dread i32 %Reg9_I, dread i32 %Reg6_I))
  #INSTIDX : 100||0064:  getstatic
  intrinsiccall MPL_CLINIT_CHECK (addrof ptr $__cinf_Ljava_2Flang_2FSystem_3B)
  regassign ptr %5 (dread ref %Reg0_R562)
  #Read from: Ljava_2Flang_2FSystem_3B_7Cout
  dassign %Reg0_R562 0 (iread ref <* <* <$Ljava_2Fio_2FPrintStream_3B>>> 0 (iread ptr <* <$MUIDUnifiedUndefTabEntry>> 1 (array 0 ptr <* <[4] <$MUIDUnifiedUndefTabEntry>>> (addrof ptr $__muid_data_undef_tab$$triangle_jar, constval i64 2))))
  intrinsiccall MCCIncRef (dread ref %Reg0_R562)
  intrinsiccall MCCDecRef (regread ptr %5)
  #INSTIDX : 103||0067:  ldc
  callassigned &MCC_GetOrInsertLiteral (addrof ptr $_C_STR_2000) { dassign %L_STR_15536 0 }
  intrinsiccall MCCIncRef (dread ptr %L_STR_15536)
  intrinsiccall MCCDecRef (dread ref %Reg1_R43)
  dassign %Reg1_R43 0 (dread ptr %L_STR_15536)
  #INSTIDX : 105||0069:  invokevirtual
  icallassigned (
    iread u64 <* u64> 0 (add ptr (
      iread ptr <* <$__class_meta__>> 6 (iread ref <* <$Ljava_2Flang_2FObject_3B>> 1 (dread ref %Reg0_R562)),
      constval u32 232)),
    dread ref %Reg0_R562,
    dread ref %Reg1_R43) {}
  #INSTIDX : 108||006c:  iinc
  dassign %Reg9_I 0 (add i32 (dread i32 %Reg9_I, constval i32 1))
  #INSTIDX : 111||006f:  goto
  goto @label8
@label9   #INSTIDX : 114||0072:  iload_1
  #INSTIDX : 115||0073:  iload_3
  #INSTIDX : 116||0074:  isub
  dassign %Reg6_I 0 (cvt i32 i32 (dread i32 %Reg6_I))
  dassign %Reg0_I 0 (sub i32 (dread i32 %Reg6_I, dread i32 %Reg8_I))
  #INSTIDX : 117||0075:  istore 4
  dassign %Reg9_I 0 (dread i32 %Reg0_I)
  dassign %Reg9_I 0 (cvt i32 i32 (dread i32 %Reg9_I))
@label10   #INSTIDX : 119||0077:  iload 4
  #INSTIDX : 121||0079:  iload_1
  #INSTIDX : 122||007a:  if_icmpgt
  brtrue @label11 (gt i32 i32 (dread i32 %Reg9_I, dread i32 %Reg6_I))
  #INSTIDX : 125||007d:  getstatic
  intrinsiccall MPL_CLINIT_CHECK (addrof ptr $__cinf_Ljava_2Flang_2FSystem_3B)
  regassign ptr %6 (dread ref %Reg0_R562)
  #Read from: Ljava_2Flang_2FSystem_3B_7Cout
  dassign %Reg0_R562 0 (iread ref <* <* <$Ljava_2Fio_2FPrintStream_3B>>> 0 (iread ptr <* <$MUIDUnifiedUndefTabEntry>> 1 (array 0 ptr <* <[4] <$MUIDUnifiedUndefTabEntry>>> (addrof ptr $__muid_data_undef_tab$$triangle_jar, constval i64 2))))
  intrinsiccall MCCIncRef (dread ref %Reg0_R562)
  intrinsiccall MCCDecRef (regread ptr %6)
  #INSTIDX : 128||0080:  new
  regassign ptr %7 (dread ref %Reg1_R1112)
  dassign %Reg1_R1112 0 (gcmalloc ref <$Ljava_2Flang_2FStringBuilder_3B>)
  intrinsiccall MCCDecRef (regread ptr %7)
  #INSTIDX : 131||0083:  dup
  #INSTIDX : 132||0084:  invokespecial
  #Call function:Ljava_2Flang_2FStringBuilder_3B_7C_3Cinit_3E_7C_28_29V
  dassign %__muid_symptr 0 (iread ptr <* <$MUIDUnifiedUndefTabEntry>> 1 (array 0 ptr <* <[13] <$MUIDUnifiedUndefTabEntry>>> (addrof ptr $__muid_func_undef_tab$$triangle_jar, constval i64 4)))
  icallassigned (dread ptr %__muid_symptr, dread ref %Reg1_R1112) {}
  #INSTIDX : 135||0087:  aload_2
  #INSTIDX : 136||0088:  iload_3
  #INSTIDX : 137||0089:  aaload
  regassign ptr %8 (dread ref %Reg7_R9160)
  dassign %Reg7_R9160 0 (retype ref <* <[] <* <[] i32>>>> (dread ref %Reg7_R12))
  intrinsiccall MCCIncRef (dread ref %Reg7_R9160)
  intrinsiccall MCCDecRef (regread ptr %8)
  dassign %Reg2_R12 0 (iread ref <* ref> 0 (array 1 ptr <* <[] ref>> (dread ref %Reg7_R9160, dread i32 %Reg8_I)))
  #INSTIDX : 138||008a:  iload_1
  #INSTIDX : 139||008b:  iload 4
  #INSTIDX : 141||008d:  isub
  dassign %Reg6_I 0 (cvt i32 i32 (dread i32 %Reg6_I))
  dassign %Reg3_I 0 (sub i32 (dread i32 %Reg6_I, dread i32 %Reg9_I))
  #INSTIDX : 142||008e:  iaload
  dassign %Reg2_I 0 (iread i32 <* i32> 0 (array 1 ptr <* <[] i32>> (dread ref %Reg2_R12, dread i32 %Reg3_I)))
  #INSTIDX : 143||008f:  invokevirtual
  icallassigned (
    iread u64 <* u64> 0 (add ptr (
      iread ptr <* <$__class_meta__>> 6 (iread ref <* <$Ljava_2Flang_2FObject_3B>> 1 (dread ref %Reg1_R1112)),
      constval u32 624)),
    dread ref %Reg1_R1112,
    dread i32 %Reg2_I) { regassign ptr %10}
  regassign ptr %9 (dread ref %Reg1_R1112)
  dassign %Reg1_R1112 0 (regread ptr %10)
  intrinsiccall MCCDecRef (regread ptr %9)
  #INSTIDX : 146||0092:  ldc
  callassigned &MCC_GetOrInsertLiteral (addrof ptr $_C_STR_2000) { dassign %L_STR_15536 0 }
  intrinsiccall MCCIncRef (dread ptr %L_STR_15536)
  intrinsiccall MCCDecRef (dread ref %Reg2_R43)
  dassign %Reg2_R43 0 (dread ptr %L_STR_15536)
  #INSTIDX : 148||0094:  invokevirtual
  icallassigned (
    iread u64 <* u64> 0 (add ptr (
      iread ptr <* <$__class_meta__>> 6 (iread ref <* <$Ljava_2Flang_2FObject_3B>> 1 (dread ref %Reg1_R1112)),
      constval u32 560)),
    dread ref %Reg1_R1112,
    dread ref %Reg2_R43) { regassign ptr %12}
  regassign ptr %11 (dread ref %Reg1_R1112)
  dassign %Reg1_R1112 0 (regread ptr %12)
  intrinsiccall MCCDecRef (regread ptr %11)
  #INSTIDX : 151||0097:  invokevirtual
  icallassigned (
    iread u64 <* u64> 0 (add ptr (
      iread ptr <* <$__class_meta__>> 6 (iread ref <* <$Ljava_2Flang_2FObject_3B>> 1 (dread ref %Reg1_R1112)),
      constval u32 32)),
    dread ref %Reg1_R1112) { regassign ptr %14}
  regassign ptr %13 (dread ref %Reg1_R43)
  dassign %Reg1_R43 0 (regread ptr %14)
  intrinsiccall MCCDecRef (regread ptr %13)
  #INSTIDX : 154||009a:  invokevirtual
  icallassigned (
    iread u64 <* u64> 0 (add ptr (
      iread ptr <* <$__class_meta__>> 6 (iread ref <* <$Ljava_2Flang_2FObject_3B>> 1 (dread ref %Reg0_R562)),
      constval u32 232)),
    dread ref %Reg0_R562,
    dread ref %Reg1_R43) {}
  #INSTIDX : 157||009d:  iinc
  dassign %Reg9_I 0 (add i32 (dread i32 %Reg9_I, constval i32 1))
  dassign %Reg9_I 0 (cvt i32 i32 (dread i32 %Reg9_I))
  #INSTIDX : 160||00a0:  goto
  goto @label10
@label11   #INSTIDX : 163||00a3:  getstatic
  intrinsiccall MPL_CLINIT_CHECK (addrof ptr $__cinf_Ljava_2Flang_2FSystem_3B)
  regassign ptr %15 (dread ref %Reg0_R562)
  #Read from: Ljava_2Flang_2FSystem_3B_7Cout
  dassign %Reg0_R562 0 (iread ref <* <* <$Ljava_2Fio_2FPrintStream_3B>>> 0 (iread ptr <* <$MUIDUnifiedUndefTabEntry>> 1 (array 0 ptr <* <[4] <$MUIDUnifiedUndefTabEntry>>> (addrof ptr $__muid_data_undef_tab$$triangle_jar, constval i64 2))))
  intrinsiccall MCCIncRef (dread ref %Reg0_R562)
  intrinsiccall MCCDecRef (regread ptr %15)
  #INSTIDX : 166||00a6:  invokevirtual
  icallassigned (
    iread u64 <* u64> 0 (add ptr (
      iread ptr <* <$__class_meta__>> 6 (iread ref <* <$Ljava_2Flang_2FObject_3B>> 1 (dread ref %Reg0_R562)),
      constval u32 248)),
    dread ref %Reg0_R562) {}
  #INSTIDX : 169||00a9:  iinc
  dassign %Reg8_I 0 (add i32 (dread i32 %Reg8_I, constval i32 1))
  dassign %Reg8_I 0 (cvt i32 i32 (dread i32 %Reg8_I))
  #INSTIDX : 172||00ac:  goto
  goto @label7
@label12   #INSTIDX : 175||00af:  return
  intrinsiccall MPL_CLEANUP_LOCALREFVARS (dread ref %Reg7_R9160, dread ref %Reg0_R562, dread ref %Reg1_R43, dread ref %Reg1_R1112, dread ref %Reg2_R43)
  return ()
}

max_stars_repo_name: Bravewtz/OpenArkCompiler

max_issues_repo_name: Bravewtz/OpenArkCompiler

max_forks_repo_name: Bravewtz/OpenArkCompiler


text:
f1:=proc() return 1; end proc:
f2:=proc() return 2; end proc:
f3:=proc() return 3; end proc:
f4:=proc() return 4; end proc:
fun:=proc(f1)
    global f2,f3,f4;
    print(f1(),f2(),f3(),f4());
end proc:
coverArgs:={},{}:
Grid:-Launch(fun,coverArgs,eval(f1),
             imports=['f2',"f3",':-f4'=eval(f4)]);


text:
# Inverse Dynamics for Parallel Robot Platform
# Einleitung
# Berechnung der inversen Dynamik der Roboter-Plattform
#
# Dateiname:
# robot -> Berechnung für allgemeinen Roboter
# para -> Berechnung für eine parallelen Roboter
# plattform -> Bezogen auf Plattform der PKM
# rotmat -> Kinematik wird mit Rotationsmatrizen berechnet
# dynamics -> Berechnung der Dynamik
# Autor
# Tim Job (Studienarbeit bei Moritz Schappler), 2018-12
# Moritz Schappler, moritz.schappler@imes.uni-hannover.de
# (C) Institut für Mechatronische Systeme, Universität Hannover
# Sources
# [Abdellatif2007] Modellierung, Identifikation und robuste Regelung von Robotern mit parallelkinematischen Strukturen
# Initialization
interface(warnlevel=0): # Unterdrücke die folgende Warnung.
restart: # Gibt eine Warnung, wenn über Terminal-Maple mit read gestartet wird.
interface(warnlevel=3):
with(LinearAlgebra):
with(codegen):
with(CodeGeneration):
with(StringTools):
with(VectorCalculus):
# Einstellungen für Code-Export: Optimierungsgrad (2=höchster) und Aktivierung jedes Terms.
codegen_dynpar := 1:
codegen_opt := 2:
codeexport_invdyn := false:
codeexport_grav := false:
codeexport_corvec := false:
codeexport_inertia := false:
read "../helper/proc_MatlabExport":
read "../helper/proc_vec2skew":
read "../robot_codegen_definitions/robot_env_par":
read sprintf("../codeexport/%s/tmp/tree_floatb_definitions", leg_name):
# Definitionen für parallelen Roboter laden
read "../robot_codegen_definitions/robot_env_par":
read sprintf("../codeexport/%s/tmp/para_definitions", robot_name):
r_P_sP_P := -r_P_sP:
s_P_P_sP := s_P_sP:

# Lade "robotics_repo_path"-File mit Link zum "imes-robotics-matlab"-Repo
read("../robotics_repo_path"):
# Lade die Funktionen aus dem "imes-robotics-matlab"-Repo
read(sprintf("%s/transformation/maple/proc_eul%s2r", robotics_repo_path, angleConv)):
read(sprintf("%s/transformation/maple/proc_eul%sjac", robotics_repo_path, angleConv)):

# Additional Kinematics
# Berechnung der Rotationsmatrizen

R_0_0_E_t := parse(sprintf("eul%s2r",angleConv))(xE_t(4..6)):
R_0_0_E_s := parse(sprintf("eul%s2r",angleConv))(xE_s(4..6)):
RPYjac_0_t := parse(sprintf("eul%sjac",angleConv))(xE_t(4..6)):
RPYjac_0_s := parse(sprintf("eul%sjac",angleConv))(xE_s(4..6)):
r_0_sP_P := R_0_0_E_s.r_P_sP_P:
if codegen_dynpar = 1 then
  J_P_P := J_SP + mE*Multiply(Transpose(vec2skew(r_P_sP_P)),vec2skew(r_P_sP_P)):
else
  J_P_P := J_P_P:
end if:
J_0_P := R_0_0_E_s.J_P_P.Transpose(R_0_0_E_s):

r_0_sP_P := R_0_0_E_t.r_P_sP_P:
rD_0_sP_P := diff~(r_0_sP_P,t):
s_0_P_sP := R_0_0_E_t.s_P_P_sP:
sD_0_P_sP := diff~(s_0_P_sP,t):
for i to 3 do
   for j to 6 do
      rD_0_sP_P(i) := subs({xED_t(j)=xED_s(j),xE_t(j)=xE_s(j)},rD_0_sP_P(i)):
      sD_0_P_sP(i) := subs({xED_t(j)=xED_s(j),xE_t(j)=xE_s(j)},sD_0_P_sP(i)):
   end do:
end do:
s_0_P_sP := R_0_0_E_s.s_P_P_sP:
r_0_sP_P := R_0_0_E_s.r_P_sP_P:

# Berechnung der H-Matrix und deren Ableitung nach Abdellatif2007 S.20
#
RPYjac_E_t := simplify(Multiply(Transpose(R_0_0_E_t),RPYjac_0_t)):
RPYjac_E_s := simplify(Multiply(Transpose(R_0_0_E_s),RPYjac_0_s)):
w_E_0_E_s := RPYjac_E_s.xED_s(4..6,1):
w_0_0_E_s := RPYjac_0_s.xED_s(4..6,1):
w_E_0_E_t := RPYjac_E_t.xED_t(4..6,1):
dRPYjac_E_t := diff~(RPYjac_E_t,t):
dRPYjac_0_t := diff~(RPYjac_0_t,t):
dRPYjac_E_s := Copy(dRPYjac_E_t):
dRPYjac_0_s := Copy(dRPYjac_0_t):
# Substituiere die zeitabhängigen Koordinaten in der H-Matrix mit zeitunabhängigen Koordinaten
for i to 3 do
  for j to 3 do
    for k from 4 to 6 do
      dRPYjac_E_s(i,j) := subs({xEDD_t(k)=xEDD_s(k),xED_t(k)=xED_s(k),xE_t(k)=xE_s(k)},dRPYjac_E_s(i,j)):
      dRPYjac_0_s(i,j) := subs({xEDD_t(k)=xEDD_s(k),xED_t(k)=xED_s(k),xE_t(k)=xE_s(k)},dRPYjac_0_s(i,j)):
    end do:
  end do:
end do:

wD_E_0_E_s := simplify(dRPYjac_E_s.xED_s(4..6,1)+RPYjac_E_s.xEDD_s(4..6,1)):
wD_0_0_E_s := simplify(dRPYjac_0_s.xED_s(4..6,1)+RPYjac_0_s.xEDD_s(4..6,1)):

# Abdellatif2007 S.20 (2.19)

H := <IdentityMatrix(3,3),ZeroMatrix(3);
      ZeroMatrix(3),RPYjac_0_s>:
Hinv := MatrixInverse(H):
dH := <ZeroMatrix(3),ZeroMatrix(3);
      ZeroMatrix(3),dRPYjac_0_s>:

# Gravitational-Vector gE of the platform
# Berechnung des Gravitationsvektors
# Abdellatif2007 S.34 (3.20)
xAll := <x;y;z;an;bn;cn>:
if codegen_dynpar = 1 then
  gE_z := xE_s(1..3,1) - r_0_sP_P:
else
  gE_z := mE*xE_s(1..3,1) + s_0_P_sP:
end if:
for j to 3 do
  for i from 1 to 6 do
    gE_z(j) := subs(xE_s(i)=xAll(i),gE_z(j)):
  end do:
end do:
dgEdz_final := Matrix(6,1):
dgEdz := Matrix(3,1):

for j to 6 do
  for i to 3 do
     dgEdz(i) := diff(gE_z(i),xAll(j)):
  end do:
  if codegen_dynpar = 1 then
    dgEdz_final(j) := mE*Transpose(g_world(..,1)).dgEdz(..,1):
  else
    dgEdz_final(j) := Transpose(g_world(..,1)).dgEdz(..,1):
  end if:
end do:
for j to 6 do
  for i from 1 to 6 do
    dgEdz_final(j) := subs(xAll(i)=xE_s(i),dgEdz_final(j)):
  end do:
end do:
gE := simplify(Transpose(Hinv).dgEdz_final):

if codeexport_grav then
  MatlabExport(gE, sprintf("../codeexport/%s/tmp/gravload_platform_eul%s_matlab.m", robot_name, angleConv), codegen_opt):
end if:

# Mass-Matrix ME of the platform
# Berechnung Massenmatrix für die EE-Plattform und die Winkelgeschwindigkeit
# Abdellatif2007 S.39 (3.30)

if codegen_dynpar = 1 then
  ME := simplify(<mE*Matrix(3,shape=identity),mE*vec2skew(r_0_sP_P);
         mE*Transpose(vec2skew(r_0_sP_P)),J_0_P>):
else
  ME := simplify(<mE*Matrix(3,shape=identity),vec2skew(-s_0_P_sP);
         Transpose(vec2skew(-s_0_P_sP)),J_0_P>):
end if:

if codeexport_inertia then
  MatlabExport(ME, sprintf("../codeexport/%s/tmp/inertia_platform_eul%s_matlab.m", robot_name, angleConv), codegen_opt):
end if:

# Coriolis-Vector cE of the platform
# Coriolis-Matrix
# Abdellatif2007 S.39 (3.31)

if codegen_dynpar = 1 then
  cE := simplify(<ZeroMatrix(3,3),mE*vec2skew(rD_0_sP_P);
         ZeroMatrix(3,3),Multiply(vec2skew(w_0_0_E_s),J_0_P)>):
else
  cE := simplify(<ZeroMatrix(3,3),vec2skew(-sD_0_P_sP);
         ZeroMatrix(3,3),Multiply(vec2skew(w_0_0_E_s),J_0_P)>):
end if:

if codeexport_corvec then
  # Der Term ist nicht der Coriolis-Vektor, sondern eine Matrix, die dazu führt. Daher kein Export.
  # MatlabExport(cE, sprintf("../codeexport/%s/tmp/coriolisvec_platform_eul%s_matlab.m", robot_name, angleConv), codegen_opt):
end if:

# Torque at the platform
# Inverse Dynamik der Plattform
# Abdellatif2007 S.39 (3.29)

MME := ME.H:
cvecE := Multiply(ME.dH+cE.H,xED_s):
tauE := Multiply(MME,xEDD_s) + cvecE - gE:
# Maple-Export
save MME, cvecE , gE, tauE, H, dH, sprintf("../codeexport/%s/tmp/floatb_platform_dynamic_maple.m", robot_name):
# Matlab Code Export
if codeexport_invdyn then
  MatlabExport(tauE, sprintf("../codeexport/%s/tmp/invdyn_platform_eul%s_matlab.m", robot_name, angleConv), codegen_opt):
end if:
#

max_stars_repo_name: SchapplM/robsynth-modelgen

max_issues_repo_name: SchapplM/robsynth-modelgen

max_forks_repo_name: SchapplM/robsynth-modelgen


text:
var x : int := 2 * (10 / (2 + 5 - 2)) * 2 + 10;
print x;
print "\n";
assert(x=48);

max_stars_repo_name: nicohi/mini-pl-interpreter

max_issues_repo_name: nicohi/mini-pl-interpreter

max_forks_repo_name: nicohi/mini-pl-interpreter


text:
# Energy Calculation for the Robot links based on MDH frames
# Introduction
# Berechnung von kinetischer Energie für den Roboter.
#
# Dateiname:
# robot -> Berechnung für allgemeinen Roboter
# tree -> Berechnung für eine beliebige Baumstruktur (ohne Schleifen)
# floatb -> floating base wird durch base twist (Geschwindigkeit der Basis) oder vollständige Orientierung (Euler-Winkel) berücksichtigt
# rotmat -> Kinematik wird mit Rotationsmatrizen berechnet
# energy -> Berechnung der Energie
# linkframe -> Berechnung der Geschwindigkeit im Körper-KS (KSi)
# par2 -> Parametersatz 2 (erstes Moment anstelle von Schwerpunkt als Parameter)
# Authors
# Moritz Schappler, schappler@irt.uni-hannover.de, 2016-03
# (C) Institut fuer Regelungstechnik, Leibniz Universitaet Hannover
# Sources
# [GautierKhalil1988] A direct determination of minimum inertial parameters of robots
# [GautierKhalil1990] Direct Calculation of Minimum Set of Inertial Parameters of Serial Robots
# [KhalilDombre2002] Modeling, Identification and Control of Robots
# [Craig] Introduction to Robotics, Modeling and Control (3rd Edition)
# [Ortmaier2014] Vorlesungsskript Robotik I
# Initialization
interface(warnlevel=0): # Unterdrücke die folgende Warnung.
restart: # Gibt eine Warnung, wenn über Terminal-Maple mit read gestartet wird.
interface(warnlevel=3):
with(LinearAlgebra):
with(ArrayTools):
with(codegen):
with(CodeGeneration):
with(StringTools):
codegen_act := true:
codegen_opt := 2:
read "../helper/proc_convert_s_t":
read "../helper/proc_convert_t_s":
read "../helper/proc_MatlabExport":
read "../helper/proc_simplify2":
read "../transformation/proc_rotx":
read "../transformation/proc_roty":
read "../transformation/proc_rotz":
read "../transformation/proc_trotx":
read "../transformation/proc_troty":
read "../transformation/proc_trotz":
read "../transformation/proc_transl":
read "../transformation/proc_trafo_mdh":
read "../robot_codegen_definitions/robot_env":
read sprintf("../codeexport/%s/tmp/tree_floatb_definitions", robot_name, base_method_name):
read sprintf("../codeexport/%s/tmp/kinematic_constraints_maple_inert.m", robot_name):
kin_constraints_exist := kin_constraints_exist: # Laden zur Einstellung der Term-Vereinfachung
;
# Einstellungen für Term-Vereinfachungen: 0=keine, 2=E_kin (einzelne), 3=auch E_kin (komplett)
if not assigned(simplify_options) or simplify_options(6)=-1 then
  # Die Vereinfachung ist ein Kompromiss aus Laufzeit des Programms und Güte der Ergebnisse
  # Bei zu komplizierten Termen stürzt Maple bei der Vereinfachung unvorhersehbar ab.
  # Die folgenden Regeln sind konservative Einstellungen, damit die Code-Generierung nicht zu lange dauert.
  if not kin_constraints_exist then # ohne Zwangsbedingungen. Annahme: Bringt dann sowieso nicht so viel
    use_simplify := 0: # Keine Vereinfachungen
  else # für Systeme mit Zwangsbedingungen
    if NJ <= 7 then
      use_simplify := 3: # standardmäßig bei einfachen Systemen alle simplify-Befehle anwenden
    else
      use_simplify := 0: # Sonst keine. Optimierung der einzelnen kinetischen Energien bringt sowieso nichts.
    end if:
  end if:
else
  use_simplify := simplify_options(6): # sechster Eintrag ist für Energie
end if:

# Ergebnisse der Kinematik laden
read sprintf("../codeexport/%s/tmp/kinematics_floatb_%s_rotmat_maple.m", robot_name, base_method_name):
Trf_c := Trf_c:
read sprintf("../codeexport/%s/tmp/velocity_linkframe_floatb_%s_maple.m", robot_name, base_method_name):
omega_i_i := omega_i_i:
rD_i_i := rD_i_i:

# Calculate Energy
# Use velocities in link frame and MX,MY,MZ as a parameter
# Kinetic Energy
# [GautierKhalil1988], equ.6
# Hier wird der Trägheitstensor um den Koordinatenursprung gewählt, und nicht um den Schwerpunkt!
T_b := Matrix(NL, 1):
T := 0:
for i to NL do
  I_i_i_tensor := Matrix([[I_i_i[1, i], I_i_i[2, i], I_i_i[3, i]], [I_i_i[2, i], I_i_i[4, i], I_i_i[5, i]], [I_i_i[3, i], I_i_i[5, i], I_i_i[6, i]]]):
  T_b_rot := (1/2)*Multiply(Transpose(omega_i_i(1 .. 3, i)), Multiply(I_i_i_tensor, omega_i_i(1 .. 3, i))):
  T_b_trans := (1/2)*M[i, 1]*Multiply(Transpose(rD_i_i(1 .. 3, i)), rD_i_i(1 .. 3, i))+Multiply(Transpose(rD_i_i(1 .. 3, i)), CrossProduct(omega_i_i(1 .. 3, i), mr_i_i_Si(1 .. 3, i))):
  T_b[i, 1] := T_b_rot+T_b_trans:
  printf("%s. Kinetische Energie für Körper %d berechnet (im Körper-KS, mit Parametersatz 2).\n", \
    FormatTime("%Y-%m-%d %H:%M:%S"), i-1):#0=Basis
  # Terme vereinfachen (nur einzelne Energien und nicht die Summe).
  # Annahme: Zusammenfassung verschiedener Körper nicht zielführend
  if use_simplify>=2 then
    tmp_t1:=time(): tmp_l1 := length(T_b[i,1]):
    printf("%s. Beginne Vereinfachung für kinetische Energie (Param. 2; Körper %d). Länge: %d.\n", \
      FormatTime("%Y-%m-%d %H:%M:%S"), i-1, tmp_l1):
    T_b[i,1] := simplify2(T_b[i,1]):
    tmp_t2:=time(): tmp_l2 := length(T_b[i,1]):
    printf("%s. Terme für kinetische Energie (Param. 2) vereinfacht (Körper %d). Länge: %d->%d. Rechenzeit %1.1fs.\n", \
      FormatTime("%Y-%m-%d %H:%M:%S"), i-1, tmp_l1, tmp_l2, tmp_t2-tmp_t1):
  end if:
  T := T+T_b[i, 1]:

  # Terme vereinfachen (optional, Standardmäßig nur kinetische Energie einzelner Körper optimieren)
  # Für komplizierte Systeme hängt sich Maple hier auf.
  if use_simplify>=3 then
    tmp_t1:=time(): tmp_l1 := length(T):
    printf("%s. Beginne Vereinfachung für kinetische Energie (Param. 2; Summe bis Körper %d). Länge: %d.\n", \
      FormatTime("%Y-%m-%d %H:%M:%S"), i-1, tmp_l1):
    T := simplify2(T):
    tmp_t2:=time(): tmp_l2 := length(T):
    printf("%s. Terme für kinetische Energie (Param. 2) vereinfacht (Körper %d). Länge: %d->%d. Rechenzeit %1.1fs.\n", \
      FormatTime("%Y-%m-%d %H:%M:%S"), i-1, tmp_l1, tmp_l2, tmp_t2-tmp_t1):
  end if:
end do:
# Maple Export
save T, sprintf("../codeexport/%s/tmp/energy_kinetic_floatb_%s_linkframe_par2_maple.m", robot_name, base_method_name):
# Potential Energy
# Berechnung in Welt-KS ist bereits erfolgreich. Wird hier nicht nochmal durchgeführt.
# siehe robot_tree_floatb_twist_rotmat_energy_worldframe_par2.mw
# Export
printf("%s: Kinetische Energie (Param. 2) berechnet und gespeichert. Beginne Matlab-Export.\n", \
      FormatTime("%Y-%m-%d %H:%M:%S")):
# Matlab Export
# Floating Base
# Eliminiere die Basis-Position (nicht: Orientierung). Die kinetische Energie kann nicht davon abhängen.
# Falls die Ausdrücke doch vorkommen, liegt es daran, dass Maple diese nicht wegoptimieren konnte.
T_s:=convert_t_s(T):
for i from 1 to 3 do
  T_s := subs({X_base_s[i,1]=0},T_s):
end do:
if codegen_act then
  MatlabExport(T_s, sprintf("../codeexport/%s/tmp/energy_kinetic_floatb_%s_linkframe_par2_matlab.m", robot_name, base_method_name), codegen_opt):
end if:
# Fixed Base
T_s_fixb:=T_s:
for i from 1 to NQB do
  T_s_fixb := subs({X_base_s[i,1]=0},T_s_fixb):
end do:
for i from 1 to 6 do
  T_s_fixb := subs({V_base_s[i,1]=0},T_s_fixb):
end do:
if codegen_act then
  MatlabExport(T_s_fixb, sprintf("../codeexport/%s/tmp/energy_kinetic_fixb_linkframe_par2_matlab.m", robot_name), codegen_opt):
end if:


text:
(*
 Copyright (C) 2017 M.A.L. Marques

 This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0. If a copy of the MPL was not distributed with this
 file, You can obtain one at http://mozilla.org/MPL/2.0/.
*)

k  := 6.5124: (* PBEsol transformation *)
xi := p -> 2*p/(k + p) - 1:
xj := a -> - (1 - a^2)^3/(1 + a^3*(1 + a^3)):

with(orthopoly):

mgga_mbeef := (x, t) -> add(add(
  + coefs_mbeef[i][j]
  * P(j-1, xi(X2S^2*x^2))
  * P(i-1, xj((t - x^2/8)/K_FACTOR_C)),
i=1..n_mbeef), j=1..n_mbeef):

max_stars_repo_name: rdietric/lsms

max_issues_repo_name: rdietric/lsms

max_forks_repo_name: rdietric/lsms


text:
N := 3;
A := {1,2,3,4,5,6,7,8};
B := {10,20,30,40};
C := {11,22,33};

check_operad("comm",[],A,B,C);

check_operad("ord",[],A,B,C);

check_operad("nonempty_subsets",[],A,B,C);

check_operad("partitions",[],A,B,C);

check_operad("trees",[],A,B,C);

check_operad("full_trees",[],A,B,C);

check_operad("simplex",[],A,B,C);

check_operad("simplex_interior",[],A,B,C);

check_operad("ord_simplex_interior",[],A,B,C);

check_operad("prime_simplex",[],A,B,C);

check_operad("cubes",[[N]],A,B,C);

check_operad("one_cubes_prime",[],A,B,C);

check_operad("stasheff_trees",[],A,B,C);

check_operad("stasheff_star",[],A,B,C);

# Deferred, because we have not defined `random_element/height_functions`
#check_operad("height_functions",[],A,B,C);
#check_operad("Fbar",[[N]],A,B,C);


text:
# Vierachsroboter KUKA KR700PA implizit
# Initialisierung
# Import (Library)
interface(warnlevel=0): 		# Unterdrücke die folgende Warnung.
restart: 				# Gibt eine Warnung, wenn über Terminal-Maple mit read gestartet wird.
interface(warnlevel=3):
kin_constraints_exist := true:		# Für Speicherung
;
with(StringTools): 			# Für Zeitausgabe
with(LinearAlgebra):
with(codegen):
with(CodeGeneration):
codegen_act := true:
codegen_opt := 1: 			# Geringerer Optimierungsgrad. Sonst zu lange.
codegen_debug := 0:		        # Zur Code-Generierung auch für Nicht-Inert-Ausdrücke
;
# Import (Hybriddyn)
read "../helper/proc_MatlabExport":
read "../transformation/proc_rotx":
read "../transformation/proc_roty":
read "../transformation/proc_rotz":
read "../transformation/proc_trotz":
read "../transformation/proc_transl":
read "../helper/proc_convert_s_t":
read "../helper/proc_convert_t_s":
read "../robot_codegen_constraints/proc_subs_kintmp_exp":
read "../helper/proc_intersect_circle":
with(RealDomain): # Schränkt alle Funktionen auf den reellen Bereich ein. Muss nach Definition von MatlabExport kommen. Sonst geht dieses nicht.
;
read "../robot_codegen_definitions/robot_env_IC":			#aktuelle Roboter, MDH-Tabelle
;
read sprintf("../codeexport/%s/tmp/tree_floatb_definitions", robot_name_OL):
# Ergebnisse der Kinematik laden
read sprintf("../codeexport/%s/tmp/kinematics_floatb_%s_rotmat_maple.m", robot_name_OL, base_method_name);
read "../robot_codegen_definitions/robot_env_IC":
Trf := Trf:
Trf_c := Trf_c:
Trf:
# VGK Gelb 1-6-11-9-7-2-1
# Schleife (1-6)-(6-11)
T_1_11 := combine( Matrix(Trf(1..4,1..4, 6)) . Matrix(Trf(1..4,1..4,11))):
# Schleife (1-2)(2-7)(7-9)
T_1_9 := combine(Matrix(Trf(1..4,1..4, 2)) . Matrix(Trf(1..4,1..4,7)) . Matrix(Trf(1..4, 1..4, 9))):
h1t := T_1_11(1..3,4) - T_1_9(1..3,4);
tmp := Transpose( Matrix(T_1_11(1..3,1..3)) ) . Matrix(T_1_9(1..3,1..3)): #nur anzeigen lassen für h1r
;
combine(tmp);# nur anzeigen lassen für h1r
;
h1r := -(-qJ6(t)+qJ2(t)+qJ7(t)+phi79+qJ9(t)) + Pi;
# VGK GRÜN 2-3-4-10-12-8-7-2
# Schleife (2-3)-(3-4)-(4-10)
T_2_10 := combine( Matrix(Trf(1..4,1..4, 3)) . Matrix(Trf(1..4,1..4,4)) . Matrix(Trf(1..4,1..4,10))):
# Schleife (2-7)-(7-8)-(8-12)
T_2_12:= combine( Matrix(Trf(1..4,1..4, 7)) . Matrix(Trf(1..4,1..4,8)).Matrix(Trf(1..4,1..4,12)) ):
h2t := T_2_10(1..3,4) - T_2_12(1..3,4);
tmp := Transpose( Matrix(T_2_10(1..3,1..3)) )  .  Matrix(T_2_12(1..3,1..3)):  #nur anzeigen lassen für h2r
;
combine(tmp);  #nur anzeigen lassen für h2r
;
h2r := (qJ3(t)+qJ4(t)+phi410+qJ10(t)-qJ7(t)+phi78-qJ8(t))+Pi;
# Zusammenstellen aller Zwangsbedingungen
implconstr_t := <h1t([1, 3],1);h2t([1, 2],1); h1r; h2r>; # TODO: In h1r, h2r muss das richtige drinstehen.
implconstr_s := convert_t_s(implconstr_t);
# Exportiere Code für folgende Skripte
kin_constraints_exist:=true:
save implconstr_t, implconstr_s, kin_constraints_exist, sprintf("../codeexport/%s/tmp/kinematic_constraints_implicit_maple.m", robot_name):
# Exportieren des vollständigen Ausdruckes
if codegen_act then
  MatlabExport(implconstr_s, sprintf("../codeexport/%s/tmp/kinconstr_impl_matlab.m", robot_name), 2):
end if:
# Liste mit abhängigen konstanten Kinematikparametern erstellen (wichtig für Matlab-Funktionsgenerierung)
read "../helper/proc_list_constant_expressions";
kc_symbols := Matrix(list_constant_expressions( implconstr_s )):
save kc_symbols, sprintf("../codeexport/%s/tmp/kinematic_implicit_constraints_symbols_list_maple", robot_name):
MatlabExport(Transpose(kc_symbols), sprintf("../codeexport/%s/tmp/kinematic_implicit_constraints_symbols_list_matlab.m", robot_name), 2):

max_stars_repo_name: SchapplM/robsynth-serhybroblib

max_issues_repo_name: SchapplM/robsynth-serhybroblib

max_forks_repo_name: SchapplM/robsynth-serhybroblib


text:
# Metric for planer symmetry
Ndim_ := 4:
x1_ := t:
x2_ := x:
x3_ := theta:
x4_ := phi:
complex_ := {}:
g11_ := -alpha(t,x)^2+a1(t,x)^2*beta(t,x)^2:
g12_ := a1(t,x)^2*beta(t,x):
g22_ := a1(t,x)^2:
g33_ := b1(t,x)^2*x^2:
g44_ := b1(t,x)^2*x^2*(sin(theta))^2:


text:
######################################################################

# General framework for operads freely generated by a strongly
# reduced Sigma-module.

`is_element/Phi/generic` := (gen_name,el_test) -> (A::set) ->
proc(TTm)
 local pn,TT,m,TT1,C,T;
 global reason;

 pn := cat("is_element/Phi/",gen_name);

 if not(type(TTm,list) and nops(TTm) = 2) then
  reason := [pn,"TTm is not a list of length two"];
  return false;
 fi;

 TT,m := op(TTm);

 if not(`is_element/full_trees`(A)(TT)) then
  reason := [pn,"TT is not a full tree on A",TT,A];
  return false;
 fi;

 if not type(m,table) then
  reason := [pn,"m is not a table"];
  return false;
 fi;

 if map(nops,{indices(m)}) <> {1} then
  reason := [pn,"m is not a unidimensional table"];
  return false;
 fi;

 TT1 := map(op,[indices(m)]);

 if {op(TT1)} <> select(T -> nops(T) > 1,TT) then
  reason := [pn,"m is not indexed by the big sets in TT",TT1,TT];
  return false;
 fi;

 C := children_map(A)(TT);

 for T in TT1 do
  if not(el_test(C[T])(m[T])) then
   reason := [pn,"m[T] is not in M(C[T])",m[T],T,C[T]];
   return false;
  fi;
 od;

 return true;
end;

######################################################################

`is_equal/Phi/generic` :=  (gen_name,eq_test) -> (A::set) ->
proc(TTm,UUn)
 local pn,TT,m,UU,n,C,TT1,T;
 global reason;

 pn := cat("is_element/realisation/",poset_name);

 TT,m := op(TTm);
 UU,n := op(UUn);

 if not(`is_equal/full_trees`(A)(TT,UU)) then
  reason := [pn,"TT <> UU",TT,UU];
  return false;
 fi;

 C := children_map(A)(TT);
 TT1 := select(T -> nops(T) > 1,TT);

 for T in TT1 do
  if not(eq_test(C[T])(m[T],n[T])) then
   reason := [pn,"m[T] <> n[T]",T,C[T],m[T],n[T]];
   return false;
  fi;
 od;

 return true;
end;

######################################################################

`eta/Phi/generic` := (gen_name) -> (A::set) -> `if`(nops(A) = 1,[{A},table()],FAIL);

######################################################################

`gamma/Phi/generic` := (gen_name,action) -> (A::set,B::set) -> (p) -> proc(UUn,TTm)
 local F,FF,UU,UU1,CU,CV,CT,U,U0,Ui,CU0,CU1,TT,T,VV,f,b,m,n,o;

 F := fibres(A,B)(p);
 UU,n := op(UUn);
 CU := children_map(B)(UU);
 FF := table();
 for U in UU do
  FF[U] := `union`(seq(F[b],b in U));
 od;

 TT := table();
 CT := table();
 m := table();

 for b in B do
  TT[b],m[b] := op(TTm[b]);
  CT[b] := children_map(F[b])(TT[b]);
 od;

 VV := `gamma/trees`(A,B)(p)(UU,TT);
 CV := children_map(A)(VV);

 o := table();
 UU1 := select(U -> nops(U) > 1,UU);
 for U in UU do
  Ui := FF[U];
  CU0 := CU[U];
  CU1 := CV[Ui];
  f := table();
  for U0 in CU0 do f[U0] := FF[U0]; od;
  o[Ui] := action(CU0,CU1)(f)(n[U]);
 od;

 for b in B do
  for T in TT[b] do
   if nops(T) > 1 then
    o[T] := m[b](T);
   fi;
  od;
 od;

 return(eval([VV,o]));
end:

######################################################################

`zeta/Phi/generic` := (gen_name,action) -> (A::set) -> proc(m)
 local TT,n,f,A1,a;

 if nops(A) = 1 then return(`eta/Phi/generic`(gen_name)(A)); fi;

 TT := corolla(A);
 n := table();
 f := table();
 A1 := {seq({a},a in A)};
 for a in A do f[a] := {a}; od;
 n[A] := action(A,A1)(f)(m);
 return eval([TT,n]);
end:

######################################################################

`epsilon/Phi/generic` := (gen_name,eta,gamma) -> (A::set) -> proc(TTm)
 local TT,m;

 TT,m := op(TTm);
 return `theta/Xi/generic`(gen_name,eta,gamma)(A)(TT,corolla(A))(m);
end;


text:
(*
 Copyright (C) 2017 M.A.L. Marques

 This Source Code Form is subject to the terms of the Mozilla Public
 License, v. 2.0. If a copy of the MPL was not distributed with this
 file, You can obtain one at http://mozilla.org/MPL/2.0/.
*)

(* type: mgga_exc *)

$define gga_c_pbe_params
$include "gga_c_pbe.mpl"

pkzb_c := 0.53:

pkzb_perp := (rs, z, xt, xs0, xs1, ts0, ts1) ->
  + (1 + pkzb_c*(t_total(z, xs0^2, xs1^2)/(8*t_total(z, ts0, ts1)))^2)
  * f_pbe(rs, z, xt, xs0, xs1):

pkzb_par  := (rs, z, xt, xs0, xs1, ts0, ts1) ->
  - (1 + pkzb_c)*(
    + (xs0^2/(8*ts0))^2*gga_stoll_par(f_pbe, rs,  z, xs0,  1)
    + (xs1^2/(8*ts1))^2*gga_stoll_par(f_pbe, rs, -z, xs1, -1)
):

pkzb_f := (rs, z, xt, xs0, xs1, ts0, ts1) ->
  pkzb_perp(rs, z, xt, xs0, xs1, ts0, ts1) + pkzb_par(rs, z, xt, xs0, xs1, ts0, ts1):

f := (rs, z, xt, xs0, xs1, us0, us1, ts0, ts1) ->
  pkzb_f(rs, z, xt, xs0, xs1, ts0, ts1):