text:
(*
 Copyright (C) 2020 Susi Lehtola

 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: gga_exc *)
(* prefix:
  gga_k_lgap_params *params;

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

(* Equation (20) *)
lgap_f0 := s -> 1 + params_a_kappa*(1-exp(-add(params_a_mu[i]*s^(i), i=1..3))):
lgap_f := x -> lgap_f0(X2S*x):

f := (rs, z, xt, xs0, xs1) ->
  gga_kinetic(lgap_f, rs, z, xs0, xs1):


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: gga_exc *)
(* prefix:
  gga_x_vmt84_params *params;

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

$include "gga_x_vmt.mpl"

vmt84_f0 := s -> (1 - exp(-params_a_alpha*s^4))/s^2 - 1 + exp(-params_a_alpha*s^4):
vmt84_f  := x -> vmt_f(x) + vmt84_f0(X2S*x):

f := (rs, zeta, xt, xs0, xs1) -> gga_exchange(vmt84_f, rs, zeta, xs0, xs1):

ext: mpl


text: /* abcde

max_stars_repo_name: Hiroya-W/lang-processing

max_issues_repo_name: Hiroya-W/lang-processing

max_forks_repo_name: Hiroya-W/lang-processing


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: gga_exc *)

wc_mu    := 0.2195149727645171:
wc_c     := (146/2025)*(4/9) - (73/405)*(2/3) + (wc_mu - MU_GE):
wc_kappa := KAPPA_PBE:

wc_f0_aux := s -> wc_kappa + MU_GE * s^2 + (wc_mu - MU_GE) * s^2 * exp(-s^2) + log(1 + wc_c * s^4):
wc_f0  := s -> 1 + wc_kappa*(1 - wc_kappa/wc_f0_aux(s)):
wc_f   := x -> wc_f0(X2S*x):

f := (rs, z, xt, xs0, xs1) -> gga_exchange(wc_f, rs, z, xs0, xs1):


text:
(*
 Copyright (C) 2019 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_task_params *params;

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

task_alpha := (x, t) -> (t/K_FACTOR_C) * m_max(1 - x^2/(8*t), 1e-10):

task_gx0 := x -> 1 - exp(-params_a_task_c*x^(-1/4)):
task_gx := x -> my_piecewise3(x > 0, task_gx0(m_max(x, 0)), 0):

task_hx1 := r -> simplify(add(params_a_task_anu[i+1]*ChebyshevT(i, (r - 1)/(r + 1)), i=0..2)):

task_fx  := r -> simplify(add(params_a_task_bnu[i+1]*ChebyshevT(i, (r - 1)/(r + 1)), i=0..4)):

task_f0 := (s, a) -> params_a_task_h0x*task_gx(s^2) +
  (1.0 - task_fx(a))*(task_hx1(s^2) - params_a_task_h0x)*task_gx(s^2)^params_a_task_d:

task_f := (x, u, t) -> task_f0(X2S*x, task_alpha(x, t)):

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


text:
macro(Multiply=LinearAlgebra[Multiply]):
macro(Copy=LinearAlgebra[Copy]):
macro(mInverse=LinearAlgebra[Modular][Inverse]):

# DoublePlusOneLift : Computes a sparse inverse expansion of the matrix A by using Double Plus One Lifting
#
# Input :
#		A : Integer matrix n x n
#		X : Integer which must be relatively prime with the determinant of A and >= max(10000, 3.61 * n^2 * ||A||)
#		n : Dimension of A
#		k : Determines the number of the times to lift and the precision of the inverse, i.e. X^(2^(k+1)-1)
#
# Precondition : gcd(X, det(A)) = 1 and X >= max(10000, 3.61 * n^2 * ||A||)
#
# Output:
#		A_0 : It is the inverse of A modulo X (Initialisation of the inverse)
#		R : A table from 0 to k needed for the sparse inverse expansion
#		M : A table from 0 to k - 1 needed for the sparse inverse expansion
#
# All together it will be : (...(A_0(I + R_0 * X_0) + M_0 * X_0^2) * (I + R_1 * X_1) + M_1 * X_1^2)...) = A^(-1) mod X^(2^(k+1)-1
#
DoublePlusOneLift := proc(A, X, n, k)
	A_0 := mInverse(X, A):
	R[0] := map(iquo, 1 - Multiply(A, A_0), X):
	for i from 0 to (k - 1) do
		R_bar := Multiply(R[i], R[i]):
		M[i] := map(modp , Multiply(A_0, R_bar), X):
		R[i+1] := map(iquo, R_bar - Multiply(A, M[i]), X):
	od:
	return A_0, eval(R), eval(M):
end proc:

# XadicRepresentationMatrixCreate : Computes the X-adic representation of a matrix and stores it compactly in a new larger one
#
# Input :
#		A : Input integer matrix n x m
#		X : Integer for the X-adic representation
#		n, m : Dimensions of A
#		p : Length of the X-adic representation to output
#
# Output :
#		A_xadic : Integer matrix n x (m*p) where every vertical slice contains one term from the X-adic representation of A
#
XadicRepresentationMatrixCreate := proc(A, X, n, m, p)
	A_xadic := Matrix(n, m*p):
	for i to n do
		for j to m do
			temp := convert(A[i, j], 'base', X):
			for k to min(p, nops(temp)) do
				A_xadic[i, j + m * (k - 1)] := temp[k]:
			od:
		od:
	od:
	return A_xadic:
end proc:

# XadicRepresentationMatrixCollapse : Computes the actual matrix from its X-adic representation
#
# Input :
#		A_xadic : Input integer matrix n x (m*p) containing the X-adic representation of A
#		X : Integer for the X-adic representation
#		n, m : Dimensions of A to output
#		p : Length of the input X-adic representation
#
# Output :
#		A : Integer matrix n x m collapsed from its X-adic representation
#
XadicRepresentationMatrixCollapse := proc(A_xadic, X, n, m, p)
	A := Matrix(n, m):
	for i to n do
		for j to m do
			sum := 0:
			for k to p do
				sum := sum + A_xadic[i, j + m * (k - 1)] * X^(k - 1)
			od:
			A[i, j] := sum:
		od:
	od:
	return A:
end proc:

# SwiftRightXadic : Multiplies an X-adic representation by X^swift, i.e.,
#	slides the vertical slices of the matrix swift times at the right
#
# Input :
#		A : Input integer matrix n x (m*p) containing an X-adic representation
#		swift : Exponent of X, i.e., A will be multiplied by X^swift
#		n, m : Dimensions of each slice in A
#		p : Length of the X-adic representation, i.e., number of slices
#
# Output :
#		A_slided : Integer matrix n x (m*p) containing the input X-adic representation multiplied by X^swift
#
SwiftRightXadic := proc(A, swift, n, m, p)
	A_slided := Matrix(n, m*p):
	if swift < p then
		A_slided[1..n, swift*m+1..m*p] := A[1..n, 1..m*(p-swift)]:
	fi:
	return A_slided:
end proc:

# SwiftRightAndMultiply : Computes the product of 2 matrices A, B, multiplied by X^swift
#
# Input :
#		A : Integer matrix n x n
#		B : Integer matrix n x (m*p) containing an X-adic representation
#		swift : Exponent of X, i.e., A*B will be multiplied by X^swift
#		n: Dimension of A, and the number of rows in B
#		m : Number of collumns of each slice in B
#		p : Length of the X-adic representation in B, i.e., number of slices
#
# Output :
#		C : Integer matrix n x (m*p) containing the X-adic representation of A * B * X^swift
#
SwiftRightAndMultiply := proc(A, B, swift, n, m, p)
	C := Matrix(n, m*p):
	if swift < p then
		C[1..n, swift*m+1..m*p] := Multiply(A, B[1..n, 1..m*(p-swift)]):
	fi:
	return C:
end proc:

# CleanUpXadic : Cleans up an X-adic representation, i.e.,
#	scans the matrix, looking for overflowed elements which will reduce mod X, and it will forward the carry to the next slice
#
# Input :
#		A : Input integer matrix n x (m*p) containing an X-adic representation to be cleaned up
#		X : Integer for the X-adic representation
#		n, m : Dimensions of each slice in A
#		p : Length of the X-adic representation, i.e., number of slices
#
# Output :
#		A : Integer matrix n x (m*p) containing the input X-adic representation that has been cleaned up
#
CleanUpXadic := proc(A, X, n, m, p)
	for k to p-1 do
#		A[1..n, 1+m*k..m*(k+1)] := A[1..n, 1+m*k..m*(k+1)] + map(iquo, A[1..n, 1+m*(k-1)..m*k], X):
#		A[1..n, 1+m*(k-1)..m*k] := map(modp, A[1..n, 1+m*(k-1)..m*k], X):
		for i to n do
			for j to m do
				entry := A[i, j + m * (k - 1)]:
				if entry >= X then
					A[i, j + m * (k - 1)] := modp(entry, X):
					A[i, j + m * k] := A[i, j + m * k] + iquo(entry, X):
				fi:
			od:
		od:
	od:
	# Take care of the last slice as well
#	A[1..n, 1+m*(p-1)..m*p] := map(modp, A[1..n, 1+m*(p-1)..m*p], X):
	for i to n do
		for j to m do
			A[i, j + m * (p - 1)] := modp(A[i, j + m * (p - 1)], X):
		od:
	od:
	return A:
end proc:

# ApplyDPOL : Applies the Double Plus One Lifting formula to a matrix B
#
# Input :
#		A_0, R, M : The output from the DoublePlusOneLift procedure, i.e., matrices that form the expansion of the inverse of a matrix A
#		B : Integer matrix n x (m*p) containing an X-adic representation on which the Double Plus One Lifting formula will be applied
#		X : Integer for the X-adic representation
#		n: Dimension of A_0, R[i], M[i], and the number of rows in B
#		m : Number of collumns of each slice in B
#		p : Length of the X-adic representation in B, i.e., number of slices
#		k : Length of the lists R and M
#
# Precondition : p <= 2^(k+1) - 1
#
# Output :
#		Expansion : Integer matrix n x (m*p) containg the X-adic representation of A^(-1) * B, where A is represented by its sparse inverese expansion here
#
ApplyDPOL := proc(A_0, R, M, B, X, n, m, p, k)
	Expansion := Matrix(n, m*p):
	Factor := Copy(B):
	for i from k-1 by -1 to 0 do
		Expansion := CleanUpXadic(Expansion + SwiftRightAndMultiply(M[i], Factor, 2^(i + 2) - 2, n, m, p), X, n, m, p):
		Factor := CleanUpXadic(Factor + SwiftRightAndMultiply(R[i], Factor, 2^(i + 1) - 1, n, m, p), X, n, m, p):
	od:
	Expansion := CleanUpXadic(Expansion + Multiply(A_0, Factor), X, n, m, p):
	return Expansion:
end proc:

# SolveLinearSystem : Solves a linear system A*x=B <=> x=A^(-1)*B over the integers
#
# Input :
#		A : Integer matrix n x n
#		B : Integer matrix n x m
#		n: Dimension of A, and the number of rows in B
#		m : Number of collumns in B
#
# Output :
#		Solution : Integer matrix n x m containg the solution x of the linear system A*x=B
#
SolveLinearSystem := proc(A, B, n, m)

	X := 10007:
	k := 5:
	p := 2^(k+1)-1:

	A_0, R, M := DoublePlusOneLift(A, X, n, k):

	B_xadic := XadicRepresentationMatrixCreate(B, X, n, m, p):

	Solution_xadic := ApplyDPOL(A_0, R, M, B_xadic, X, n, m, p, k):

	Solution := XadicRepresentationMatrixCollapse(Solution_xadic, X, n, m, p):

	return Solution:

end proc:


text:
Primes:=[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59]:
L:=1000;
S:=[1,7,11,13,17,19,23,29,31,37,41,43,47,49,53,59];
W:=[seq(i,i=1..ceil(L/60)-1)]:

for w in W do
	for s in S do
		n:=60*w+s;
		a:=0;

 		########3.1
		if modp(s,4)=1 then
			for x from 1 to ceil(sqrt(n)/2) do
				for y from 1 to ceil(sqrt(n)) do
					if 4*x^2+y^2=n then a:=1-a;end if;
				end do;
			end do;
		end if;

		########3.2
		if modp(s,6)=1 and modp(s,4)<>1 then
			for x from 1 to ceil(sqrt(n/3)) do
				for y from 1 to ceil(sqrt(n)) do
					if 3*x^2+y^2=n then a:=1-a;end if;
				end do;
			end do;
		end if;

		########3.3
		if modp(s,12)=11 and modp(s,6)<>1 and modp(s,4)<>1 then
			for x from 2 to n do
				for y from 1 to x-1 do
					if 3*x^2-y^2=n then a:=1-a;end if;
				end do;
			end do;
		 end if;

		##### squares
		if a=1 then
			for q in Primes while q^2<=n and a=1 do if irem(n,q^2)=0 then a:=0;fi;end do;
		end if;

		if a=1 then Primes:=[op(Primes),n]; end if;
		end do;
end do;

max_stars_repo_name: fylux/SieveOfAtkin

max_issues_repo_name: fylux/SieveOfAtkin

max_forks_repo_name: fylux/SieveOfAtkin


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: work_gga_c *)

$include "gga_c_pw91.mpl"

c1 := 1.1015:
c2 := 0.6625:

f  := (rs, z, xt, xs0, xs1) ->
  + c1*f_pw91(rs, z, xt, xs0, xs1) + (c2 - c1)*(
  +    f_pw91(rs*(2*(1 + z))^(1/3),  1, xs0, xs0, 0)
  +    f_pw91(rs*(2*(1 - z))^(1/3), -1, xs1, 0, xs1)
):

max_stars_repo_name: rdietric/lsms

max_issues_repo_name: rdietric/lsms

max_forks_repo_name: rdietric/lsms


text:
N:=kernelopts(numcpus):
x:=Array(1..N):
fun:=proc()
    uses Grid;
    global x;
    local node,i,id,v;
    node:=MyNode();
    if node<>0 then
        Send(0,node,node^2);
    else
        for i from 1 to NumNodes()-1 do
            id,v:=Receive();
            x[id+1]:=v;
        end do;
        x[1]:=0;
    end if;
    return NULL;
end proc:
Grid:-Launch(fun,imports=["x"],exports=["x"]);
print(convert(x,list));


text:
with(Groebner):
with(PolynomialIdeals):

J := PolynomialIdeal({x1*x2*x11 + x1*x11 + x2*x3*x11 + x3*x4*x11 + x4*x5*x11 + x5*x6*x11 + x6*x7*x11 + x7*x8*x11 + x8*x9*x11 + x9*x10*x11 - 1, x1*x3*x11 + x2*x4*x11 + x2*x11 + x3*x5*x11 + x4*x6*x11 + x5*x7*x11 + x6*x8*x11 + x7*x9*x11 + x8*x10*x11 - 2, x1*x4*x11 + x2*x5*x11 + x3*x6*x11 + x3*x11 + x4*x7*x11 + x5*x8*x11 + x6*x9*x11 + x7*x10*x11 - 3, x1*x5*x11 + x2*x6*x11 + x3*x7*x11 + x4*x8*x11 + x4*x11 + x5*x9*x11 + x6*x10*x11 - 4, x1*x6*x11 + x2*x7*x11 + x3*x8*x11 + x4*x9*x11 + x5*x10*x11 + x5*x11 - 5, x1*x7*x11 + x2*x8*x11 + x3*x9*x11 + x4*x10*x11 + x6*x11 - 6, x1*x8*x11 + x2*x9*x11 + x3*x10*x11 + x7*x11 - 7, x1*x9*x11 + x2*x10*x11 + x8*x11 - 8, x1*x10*x11 + x9*x11 - 9, x10*x11 - 10, x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + 1}):
st := time[real]():
Basis(J, tdeg(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11), characteristic=2^31-1):
time[real]() - st;

J := PolynomialIdeal({x1*x2*x12 + x1*x12 + x2*x3*x12 + x3*x4*x12 + x4*x5*x12 + x5*x6*x12 + x6*x7*x12 + x7*x8*x12 + x8*x9*x12 + x9*x10*x12 + x10*x11*x12 - 1,
x1*x3*x12 + x2*x4*x12 + x2*x12 + x3*x5*x12 + x4*x6*x12 + x5*x7*x12 + x6*x8*x12 + x7*x9*x12 + x8*x10*x12 + x9*x11*x12 - 2,
x1*x4*x12 + x2*x5*x12 + x3*x6*x12 + x3*x12 + x4*x7*x12 + x5*x8*x12 + x6*x9*x12 + x7*x10*x12 + x8*x11*x12 - 3,
x1*x5*x12 + x2*x6*x12 + x3*x7*x12 + x4*x8*x12 + x4*x12 + x5*x9*x12 + x6*x10*x12 + x7*x11*x12 - 4,
x1*x6*x12 + x2*x7*x12 + x3*x8*x12 + x4*x9*x12 + x5*x10*x12 + x5*x12 + x6*x11*x12 - 5,
x1*x7*x12 + x2*x8*x12 + x3*x9*x12 + x4*x10*x12 + x5*x11*x12 + x6*x12 - 6,
x1*x8*x12 + x2*x9*x12 + x3*x10*x12 + x4*x11*x12 + x7*x12 - 7,
x1*x9*x12 + x2*x10*x12 + x3*x11*x12 + x8*x12 - 8,
x1*x10*x12 + x2*x11*x12 + x9*x12 - 9, x1*x11*x12 + x10*x12 - 10,
x11*x12 - 11,
x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + 1}):
st := time[real]():
Basis(J, tdeg(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12), characteristic=2^31-1):
time[real]() - st;

J := PolynomialIdeal({x1*x2*x13 + x1*x13 + x2*x3*x13 + x3*x4*x13 + x4*x5*x13 + x5*x6*x13 + x6*x7*x13 + x7*x8*x13 + x8*x9*x13 + x9*x10*x13 + x10*x11*x13 + x11*x12*x13 - 1,
x1*x3*x13 + x2*x4*x13 + x2*x13 + x3*x5*x13 + x4*x6*x13 + x5*x7*x13 + x6*x8*x13 + x7*x9*x13 + x8*x10*x13 + x9*x11*x13 + x10*x12*x13 - 2,
x1*x4*x13 + x2*x5*x13 + x3*x6*x13 + x3*x13 + x4*x7*x13 + x5*x8*x13 + x6*x9*x13 + x7*x10*x13 + x8*x11*x13 + x9*x12*x13 - 3,
x1*x5*x13 + x2*x6*x13 + x3*x7*x13 + x4*x8*x13 + x4*x13 + x5*x9*x13 + x6*x10*x13 + x7*x11*x13 + x8*x12*x13 - 4,
x1*x6*x13 + x2*x7*x13 + x3*x8*x13 + x4*x9*x13 + x5*x10*x13 + x5*x13 + x6*x11*x13 + x7*x12*x13 - 5,
x1*x7*x13 + x2*x8*x13 + x3*x9*x13 + x4*x10*x13 + x5*x11*x13 + x6*x12*x13 + x6*x13 - 6,
x1*x8*x13 + x2*x9*x13 + x3*x10*x13 + x4*x11*x13 + x5*x12*x13 + x7*x13 - 7, x1*x9*x13 + x2*x10*x13 + x3*x11*x13 + x4*x12*x13 + x8*x13 - 8,
x1*x10*x13 + x2*x11*x13 + x3*x12*x13 + x9*x13 - 9,
x1*x11*x13 + x2*x12*x13 + x10*x13 - 10,
x1*x12*x13 + x11*x13 - 11, x12*x13 - 12,
x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 + 1}):
st := time[real]():
Basis(J, tdeg(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13), characteristic=2^31-1):
time[real]() - st;


text:
#===============================================================================
IdentifiabilityODE := proc(system_ODEs, params_to_assess, p, output_targets, count_solutions, char)#{p := 0.99, infolevel := 1, method := 2, num_nodes := 6})
#===============================================================================
 local i, j, k, n, m, s, all_params, all_vars, eqs, Q, X, Y, poly, d0, D1,
        sample, all_subs,alpha, beta, Et, x_theta_vars, prolongation_possible,
        eqs_i, JacX, vars, vars_to_add, ord_var, var_index, deg_variety, D2,
        y_hat, u_hat, theta_hat, Et_hat, Q_hat, theta_l, theta_g, gb, v, X_eq, Y_eq,
        poly_d, separant, leader, x_functions, y_functions, u_functions,
        all_symbols_rhs, mu, x_vars, y_vars, u_vars, theta, subst_first_order,
        subst_zero_order, x_eqs, y_eqs, param, other_params, to_add, at_node,
        prime, max_rank, R, tr, e, p_local, xy_ders, polys_to_process, new_to_process, method, start, finish, infolevel,
        num_nodes ,Et_x_vars, out_sian, var, G, P, solutions_table, check:

  #----------------------------------------------
  # 0. Extract inputs, outputs, states, and parameters from the system
  #----------------------------------------------
  method := 2:

  if SearchText(".", convert(system_ODEs, string)) <> 0 then
    LogText(sprintf("WARNING: It looks like your system involves floating-point numbers. This may result into a non-meaninful result, please convert them to rationals (e.g., 0.2 -> 1/5)"), "LogAreaSIAN"):
    WARNING("WARNING: It looks like your system involves floating-point numbers. This may result into a non-meaninful result, please convert them to rationals (e.g., 0.2 -> 1/5)"):
  end if:

  if not (indets(system_ODEs, name) subset indets(system_ODEs)) then
    LogText(sprintf(cat("ERROR: you are using reserved maple symbols: ", convert(indets(system_ODEs, name) minus indets(system_ODEs), string))), output_targets[log]):
    DocumentTools:-SetProperty("GlobalParams1", expression, Error(BadName)):
    DocumentTools:-SetProperty("LocalParams1", expression,  Error(BadName)):
    DocumentTools:-SetProperty("NoIDParams1", expression,  Error(BadName)):
    error (cat("ERROR: you are using reserved maple symbols: ", convert(indets(system_ODEs, name) minus indets(system_ODEs), string))):
    return;
  end if:

  randomize():
  infolevel:=1:
  num_nodes:=1:
  if infolevel > 0 then
    PrintHeader("0. Extracting states, inputs, outputs, and parameters from the system"):
  end if:
  x_functions := map(f -> int(f, t), select( f -> type(int(f, t), function(name)), map(lhs, system_ODEs) )):
  y_functions := select( f -> not type(int(f, t), function(name)), map(lhs, system_ODEs) ):
  all_symbols_rhs := foldl(`union`, op( map(e -> indets(rhs(e)), system_ODEs) )) minus {t}:
  xy_ders := {op(x_functions), op(y_functions), op(select(f -> (f in all_symbols_rhs), map(lhs, system_ODEs)))}:
  u_functions := select( f -> type(f, function), convert(all_symbols_rhs minus xy_ders, list)):
  mu := convert(all_symbols_rhs minus {op(xy_ders), op(u_functions)}, list):

  x_vars := map(FunctionToVariable, x_functions):
  y_vars := map(FunctionToVariable, y_functions):
  u_vars := map(FunctionToVariable, u_functions):
  theta := map(ParamToInner, params_to_assess):
  subst_first_order := {seq(diff(x_functions[i], t) = MakeDerivative(x_vars[i], 1), i = 1 .. nops(x_vars))}:
  subst_zero_order := {
    seq(x_functions[i] = MakeDerivative(x_vars[i], 0), i = 1 .. nops(x_vars)),
    seq(y_functions[i] = MakeDerivative(y_vars[i], 0), i = 1 .. nops(y_vars)),
    seq(u_functions[i] = MakeDerivative(u_vars[i], 0), i = 1 .. nops(u_vars))
  }:
  x_eqs := subs(subst_zero_order, subs(subst_first_order, select(e -> type(int(lhs(e), t), function(name)), system_ODEs))):
  y_eqs := subs(subst_zero_order, select(e -> not type(int(lhs(e), t), function(name)), system_ODEs)):

  # taking into account that fact that Groebner[Basis] is Monte Carlo with probability of error
  # at most 10^(-18) (for Maple 2017)
  p_local := p + nops(params_to_assess) * 10^(-18):
  if p_local >= 1 then
    LogTextSIAN("The probability of success cannot exceed 1 - #params_to_assess 10^{-18}. We reset it to 0.99");
    p_local := 0.99:
  end if:

  if infolevel > 0 then
    LogText(sprintf("\n===== Input info =====\n"), output_targets[log]):
    LogText(sprintf("%s %a\n", `State variables:         `, x_functions), output_targets[log]):
    LogText(sprintf("%s %a\n", `Output variables:        `, y_functions), output_targets[log]):
    LogText(sprintf("%s %a\n", `Input variables:         `, u_functions), output_targets[log]):
    LogText(sprintf("%s %a\n", `Parameters in equations: `, mu), output_targets[log]):
    LogText(sprintf("===================\n\n"), output_targets[log]):
  end if:

  #----------------------------------------------
  # 1. Construct the maximal system.
  #----------------------------------------------

  if infolevel > 0 then
    PrintHeader("1. Constructing the maximal polynomial system"):
  end if:

  # (a) ---------------
  n := nops(x_vars):
  m := nops(y_vars):
  s := nops(mu) + n:
  all_params := [op(mu), op(map(x -> MakeDerivative(x, 0), x_vars ))]:
  all_vars := [ op(x_vars), op(y_vars), op(u_vars) ]:
  eqs := [op(x_eqs), op(y_eqs)]:
  Q := foldl( (f, g) -> lcm(f, g), op( map(f -> denom(rhs(f)), eqs) )):

  # (b,c) ---------------
  X := []:
  X_eq := []:
  for i from 1 to n do
    X := [op(X), []]:
    poly := numer(lhs(x_eqs[i]) - rhs(x_eqs[i])):
    for j from 0 to s + 1 do
      poly_d := Differentiate(poly, all_vars, j):
      leader := MakeDerivative(x_vars[i], j + 1):
      separant := diff(poly_d, leader):
      X[i] := [op(X[i]), poly_d]:
      X_eq := [op(X_eq), leader = -(poly_d - separant * leader) / separant]:
    end do:
  end do:
  # LogExpression(X[1]);

  # (d,e) ---------------
  Y := []:
  Y_eq := []:
  for i from 1 to m do
    Y := [op(Y), []]:
    poly := numer(lhs(y_eqs[i]) - rhs(y_eqs[i])):
    for j from 0 to s + 1 do
      poly_d := Differentiate(poly, all_vars, j):
      leader := MakeDerivative(y_vars[i], j):
      separant := diff(poly_d, leader):
      Y[i] := [op(Y[i]), poly_d]:
      Y_eq := [op(Y_eq), leader = -(poly_d - separant * leader) / separant]:
    end do:
  end do:

  #----------------------------------------------
  # 2. Truncate.
  #----------------------------------------------

  if infolevel > 0 then
    PrintHeader("2. Truncating the polynomial system based on the Jacobian condition"):
  end if:

  # (a) ---------------
  d0 := max(op( map(f -> degree( simplify(Q * rhs(f)) ), eqs) ), degree(Q)):

  # (b) ---------------
  # extra factor nops(theta) + 1 compared to the formula in the paper is to
  # provide probability gaurantee to the local identifiability test
  D1 := floor( (nops(theta) + 1) * 2 * d0 * s * (n + 1) * (1 + 2 * d0 * s) / (1 - p_local) ):
  # prime := nextprime(D1):
  if infolevel > 1 then
    LogText(sprintf("%s %a\n", `Bound D_1 for testing the rank of the Jacobian probabilistically: `, D1), output_targets[log]);
  end if:

  # (c, d) ---------------
  sample := SamplePoint(D1, x_vars, y_vars, u_vars, mu, X_eq, Y_eq, Q):
  all_subs := sample[4]:
  u_hat := sample[2]:
  y_hat := sample[1]:

  # (e) ------------------
  alpha := [seq(1, i = 1..n)]:
  beta := [seq(0, i = 1..m)]:
  Et := [];
  # TODO: improve for arbitrary derivatives
  x_theta_vars := all_params:
  prolongation_possible := [seq(1, i = 1..m)]:

  # (f) ------------------
  while add(prolongation_possible) > 0 do
    for i from 1 to m do
      if prolongation_possible[i] = 1 then
        eqs_i := [op(Et), Y[i][beta[i] + 1]]:
        JacX := VectorCalculus[Jacobian](subs({op(u_hat), op(y_hat)}, eqs_i), x_theta_vars = subs(all_subs, x_theta_vars)):
        if LinearAlgebra[Rank](JacX) = nops(eqs_i) then
          Et := [op(Et), Y[i][beta[i] + 1]]:
          beta[i] := beta[i] + 1:
          # adding necessary X-equations
          polys_to_process := [op(Et), seq(Y[k][beta[k] + 1], k=1..m)]:
          while nops(polys_to_process) <> 0 do
            new_to_process := []:
            vars := {};
            for poly in polys_to_process do
              vars := vars union { op(GetVars(poly, x_vars)) }:
            end do:
            vars_to_add := { op(remove(v -> evalb(v in x_theta_vars), vars)) };
            for v in vars_to_add do
              x_theta_vars := [op(x_theta_vars), v];
              ord_var := GetOrderVar(v);
              var_index := ListTools[Search](ord_var[1], x_vars):
              poly := X[ var_index ][ ord_var[2] ]:
              Et := [op(Et), poly]:
              new_to_process := [op(new_to_process), poly]:
              alpha[ var_index ] := max(alpha[ var_index ], ord_var[2] + 1):
            end do:
            polys_to_process := new_to_process:
          end do:
        else
          prolongation_possible[i] := 0;
        end if:
      end if:
    end do:
  end do:
  # is used for assessing local identifiabilty
  max_rank := nops(Et):

  # (g) --------------
  for i from 1 to m do
    for j from beta[i] + 1 to nops(Y[i]) do
      to_add := true:
      for v in GetVars(Y[i][j], x_vars) do
        if not (v in x_theta_vars) then
          to_add := false:
        end if:
      end do:
      if to_add = true then
        beta[i] := beta[i] + 1:
        Et := [op(Et), Y[i][j]]:
      end if:
    end do:
  end do:

  if infolevel > 1 then
    LogText(sprintf("%s %a\n", `Orders of prolongations of the outputs (beta) = `, beta), output_targets[log]):
    LogText(sprintf("%s %a\n", `Orders of prolongations of the state variables (alpha) = `, alpha), output_targets[log]):
  end if:
  ##############################

  if infolevel > 0 then
    PrintHeader("3. Assessing local identifiability"):
  end if:

  theta_l := []:
  for param in theta do
    other_params := subs(param = NULL, x_theta_vars):
    JacX := VectorCalculus[Jacobian](
        subs( { op(u_hat), param = subs(all_subs, param), op(y_hat) }, Et),
        other_params = subs(all_subs, other_params)
    ):
    if LinearAlgebra[Rank](JacX) <> max_rank then
      theta_l := [op(theta_l), param]:
    end if:
  end do:
  DocumentTools:-SetProperty("LocalLabel" , caption, "Locally Identifiable Paramters");
  if infolevel > 1 then
    LogText(sprintf("%s %a\n", `Locally identifiable paramters: `, map(x -> ParamToOuter(x, all_vars), theta_l)), output_targets[log]);
    LogText(sprintf("%s %a\n", `Nonidentifiable parameter: `, map(x -> ParamToOuter(x, all_vars), [op({op(theta)} minus {op(theta_l)})])), output_targets[log]);
  end if:

  DocumentTools:-SetProperty(output_targets[localparams], expression, map(x -> ParamToOuter(x, all_vars), theta_l), 'refresh'): # local
  DocumentTools:-SetProperty(output_targets[noidparams], expression, map(x -> ParamToOuter(x, all_vars), [op({op(theta)} minus {op(theta_l)})]), 'refresh'): # no id

  #----------------------------------------------
  # 3. Randomize.
  #----------------------------------------------

  if infolevel > 0 then
    PrintHeader("4. Randomizing the truncated system"):
  end if:

  # (a) ------------
  deg_variety := foldl(`*`, op( map(e -> degree(e), Et) )):
  D2 := floor( 6 * nops(theta_l) * deg_variety * (1 + 2 * d0 * max(op(beta))) / (1 - p_local) ):
  if infolevel > 1 then
    LogText(sprintf("%s %a\n", `Bound D_2 for assessing global identifiability: `, D2), output_targets[log]):
  end if:

  # (b, c) ---------
  sample := SamplePoint(D2, x_vars, y_vars, u_vars, mu, X_eq, Y_eq, Q):
  y_hat := sample[1]:
  u_hat := sample[2]:
  theta_hat := sample[3]:
  if infolevel > 1 then
    LogText(sprintf("%s %a\n", `Random sample for the outputs and inputs is generated from `, theta_hat), output_targets[log]):
  end if:

  # (d) ------------
  Et_hat := map(e -> subs([op(y_hat), op(u_hat)], e), Et):
  Et_x_vars := {}:
  for poly in Et_hat do
    Et_x_vars := Et_x_vars union { op(GetVars(poly, x_vars)) }:
  end do:
  if infolevel > 1 then
    LogText(sprintf("%s %a %s %a %s\n", "The polynomial system contains", nops(Et_hat), "equations in ", nops(Et_x_vars) + nops(mu), " variables"), output_targets[log]);
  end if:
  Q_hat := subs(u_hat, Q):

  vars := [
    op(sort([op(Et_x_vars)], (a, b) -> CompareDiffVar(a, b, x_vars))),
    z_aux, w_aux,
    op(sort(mu))
  ]:
  if infolevel > 1 then
    LogText(sprintf("Variable ordering to be used for Groebner basis computation %a\n", vars), output_targets[log]);
  end if:

  #----------------------------------------------
  # 4. Determine.
  #----------------------------------------------

  if infolevel > 0 then
    PrintHeader("5. Assessing global identifiability"):
  end if:
  theta_g := []:
  if method = 1 then
    at_node := proc(var, args_node)
      local gb_loc, fname;
      gb_loc := Groebner[Basis](op(args_node)):
      gb_loc;
    end proc:

    if nops(theta_l) > 1 and num_nodes > 1 then
      Grid[Setup]("local", numnodes = num_nodes):
      Grid[Set](at_node):
      gb := Grid[Seq](
        at_node(theta_l[i], [
          [op(Et_hat), z_aux * Q_hat - 1, (theta_l[i] - subs(theta_hat, theta_l[i])) * w_aux - 1],
          tdeg(vars)
        ]),
        i = 1..nops(theta_l)
      ):
    else
      gb := []:
      for i from 1 to nops(theta_l) do
        gb := [
          op(gb),
          at_node(
            theta_l[i],
            [[op(Et_hat), z_aux * Q_hat - 1, (theta_l[i] - subs(theta_hat, theta_l[i])) * w_aux - 1], tdeg(op(vars))]
           )
        ]:
      end do:
    end if:
    for i from 1 to nops(theta_l) do
      if gb[i] = [1] then
        theta_g := [op(theta_g), theta_l[i]]:
      else
        if infolevel > 1 then
          LogText(sprintf("%s %a %s %a\n", `Groebner basis corresponding to the parameter `, theta_l[i], ` is `, gb[i]), output_targets[log]):
        end if:
      end if:
    end do:
  elif method = 2 then
     LogText(sprintf("%s %a\n", `Computing Groebner Basis with characteristic`, char), output_targets[log]):
    	gb := Groebner[Basis]([op(Et_hat), z_aux * Q_hat - 1], tdeg(op(vars)), characteristic=char);
     for i from 1 to nops(theta_l) do
       if char>0 then
       	check := subs(theta_hat, theta_l[i]) mod char:
       else
       	check := subs(theta_hat, theta_l[i]):
       end if:
       if Groebner[NormalForm](theta_l[i], gb, tdeg(op(vars)), characteristic=char) = check then
         theta_g := [ op(theta_g), theta_l[i] ]:
       end if:
     end do:

    if count_solutions then
     LogParameters("",output_targets[parameters]):
    	for var in theta_g do
 		LogText(sprintf("%s %a, %s %a\n",`The number of solutions for`, var, `is`, 1), output_targets[log]):
		LogParameters(sprintf("%s %a, %s %a\n",`Parameter`, ParamToOuter(var, all_vars), `number of solutions:`, 1), output_targets[parameters]):
		solutions_table[var]:=1:
    	end do:

    	for var in select(p -> not p in theta_g, theta_l) do
		G := Groebner[Walk](gb, tdeg(op(vars)), lexdeg([op({op(vars)} minus {var})], [var]), characteristic=char):
		P := select(x->evalb(indets(x)={var}), G):
		solutions_table[var]:=degree(P[1], [op(indets(P))]):
		LogText(sprintf("%s %a, %s %a\n",`The number of solutions for`, var, `is`, degree(P[1], [op(indets(P))])), output_targets[log]):
		LogParameters(sprintf("%s %a, %s %a\n",`Parameter`, ParamToOuter(var, all_vars), `number of solutions:`, degree(P[1], [op(indets(P))])),  output_targets[parameters])
    	end do:
     fi:
    	DocumentTools:-SetProperty(output_targets[globalparams], value,  [op(map(x -> ParamToOuter(x, all_vars), theta_g))], 'refresh'): # global
    	DocumentTools:-SetProperty(output_targets[localparams], value,  [op(map(x -> ParamToOuter(x, all_vars), select(p -> not p in theta_g, theta_l)))], 'refresh'): # global
  else
    LogText(sprintf(`No such method`), output_targets[log]):
    LogText(sprintf("%q\n", "Provided method: %d, allowed methods: 1, 2", method), output_targets[log]):
  end if:

  if infolevel > 0 then
    LogText(sprintf("\n=== Summary ===\n"), output_targets[log]):
    LogText(sprintf("%s %a\n", `Globally identifiable parameters:                 `, map(x -> ParamToOuter(x, all_vars), theta_g)), output_targets[log]):
    LogText(sprintf("%s %a\n", `Locally but not globally identifiable parameters: `, map(x -> ParamToOuter(x, all_vars), select(p -> not p in theta_g, theta_l))), output_targets[log]):
    LogText(sprintf("%s %a\n", `Not identifiable parameters:                      `, map(x -> ParamToOuter(x, all_vars), select(p -> not p in theta_l, theta))), output_targets[log]):
    LogText(sprintf("===============\n\n"), output_targets[log]):
  end if:
   DocumentTools:-SetProperty("LocalLabel" , caption, "Locally but not Globally Identifiable Paramters");
  out_sian := table([
    globally = [op(map(x -> ParamToOuter(x, all_vars), theta_g))],
    locally_not_globally = {op(map(x -> ParamToOuter(x, all_vars), select(p -> not p in theta_g, theta_l)))},
    non_identifiable = {op(map(x -> ParamToOuter(x, all_vars), select(p -> not p in theta_l, theta)))},
    parameters = mu,
    basis=gb,
    varordering=tdeg(op(vars)),
    allvars=vars,
    for_outer=all_vars
  ]):
  PrintHeader("WARNING: The result of solution counting is guaranteed with high probability, however it NOT the same probability 'p' as provided in the input."):
  out_sian[num_solutions] := solutions_table:
  return out_sian;
end proc:

#===============================================================================
PrintHeader := proc(text):
#===============================================================================
  LogText(sprintf("\n=======================================================\n"), "LogAreaSIAN"):
  LogText(sprintf(text), "LogAreaSIAN"):
  LogText(sprintf("\n=======================================================\n"), "LogAreaSIAN"):
end proc:

#===============================================================================
GetParameters := proc(system_ODEs, initial_conditions) local initial_values, all_symbols_rhs, mu:
#===============================================================================
  initial_values := map(f -> subs({t = 0}, int(f, t)), select( f -> type(int(f, t), function(name)), map(lhs, system_ODEs) )):
  all_symbols_rhs := foldl(`union`, op( map(e -> indets(rhs(e)), system_ODEs) )) minus {t}:
  mu := select(s -> not type(s, function), all_symbols_rhs):
  if initial_conditions then
    return [op(mu), op(initial_values)]:
  else
    return [op(mu)]:
  end if:
end proc:

#===============================================================================
FunctionToVariable := proc(f):
#===============================================================================
  convert(cat(convert(f, string)[1..-4], "_"), symbol):
end proc:

#===============================================================================
ParamToInner := proc(p) local s:
#===============================================================================
  s := convert(p, string):
  if length(s) > 3 and s[-3..-1] = "(0)" then
    MakeDerivative(FunctionToVariable(p), 0):
  else
    p:
  end if:
end proc:

#===============================================================================
ParamToOuter := proc(p, varnames) local s:
#===============================================================================
  s := convert(p, string):
  if length(s) > 2 and s[-2..-1] = "_0" and parse(s[1..-2] )in varnames then
    parse(cat(s[1..-3], "(0)")):
  else
    p:
  end if:
end proc:

#===============================================================================
MakeDerivative := proc(var_name, der_order):
#===============================================================================
  cat(var_name, der_order):
end proc:

#===============================================================================
DifferentiateOnce := proc(diff_poly, var_list)
#===============================================================================
  local result, aux, v, h, diff_v:
  result := 0:
  for diff_v in indets(diff_poly) do
    aux := GetOrderVar(diff_v):
    # seems that Maple does not have unpacking
    v := aux[1]:
    h := aux[2]:
    if v in var_list then
      result := result + diff(diff_poly, MakeDerivative(v, h)) * MakeDerivative(v, h + 1):
    end if:
  end do:
  simplify(result):
end proc:

#===============================================================================
Differentiate := proc(diff_poly, var_list, ord := 1)
#===============================================================================
  local result, i;
  result := diff_poly:
  for i from 1 to ord do
    result := DifferentiateOnce(result, var_list):
  end do:
  result:
end proc:

#===============================================================================
GetVars := proc(diff_poly, var_list)
#===============================================================================
  local result;
  result := select(v -> evalb(GetOrderVar(v)[1] in var_list), indets(diff_poly)):
  return result:
end proc:

#===============================================================================
GetOrderVar := proc(diff_var)
#===============================================================================
  local s, v, h;
  if not StringTools[RegMatch]("^(.*_)([0-9]+)$", diff_var, s, v, h) then
    return ["", ""]:
  end if:
  return [parse(v), parse(h)]:
end proc:

#===============================================================================
SamplePoint := proc(bound, x_vars, y_vars, u_vars, mu, X_eq, Y_eq, Q)
#===============================================================================
  local n, m, s, all_params, all_vars, theta_hat, u_variables,
        u_hat, x_hat, y_hat, eq, eq_num, eq_denom,
        v, poly, i, j, all_subs, roll, to_compute;
  n := nops(x_vars):
  m := nops(y_vars):
  s := nops(mu) + n:
  all_params := [op(mu), op(map(x -> MakeDerivative(x, 0), x_vars ))]:
  all_vars := [ op(x_vars), op(y_vars), op(u_vars) ]:

  roll := rand(0 .. bound):
  while true do
    theta_hat := map(p -> p = roll(), all_params):
    u_variables := [];
    for i from 1 to nops(u_vars) do
      u_variables := [ op(u_variables), seq(MakeDerivative(u_vars[i], j), j = 0..s + 1) ]:
    end do:
    u_hat := map(p -> p = roll(), u_variables) :

    all_subs := [op(theta_hat), op(u_hat)]:
    if subs(all_subs, Q) = 0 then
      next
    end if:
    to_compute := [op(X_eq), op(Y_eq)]:
    while nops(to_compute) <> 0 do
      to_compute := map(e -> lhs(e) = subs(all_subs, rhs(e)), to_compute);
      all_subs := [ op(all_subs), op(select(e -> type(rhs(e), numeric), to_compute)) ]:
      to_compute := remove(e -> type(rhs(e), numeric), to_compute):
    end do:
    y_hat := map(e -> lhs(e) = subs(all_subs, rhs(e)), Y_eq):
    x_hat := map(e -> lhs(e) = subs(all_subs, rhs(e)), X_eq):
    break:
  end do:

  return [y_hat, u_hat, theta_hat, all_subs];
end proc:

#===============================================================================
GenerateReplica := proc(equations, r)
#===============================================================================
  # generates a system of equations corresponding to r independent trajectories of
  # the original system. Time-dependent variabes are replicated, parameters are not
  local all_functions, zero_order, first_order, funcs, without_t, result, i, subst:
  all_functions := select(f -> type(f, function), foldl(`union`, op( map(indets, equations) ))):
  zero_order := select(f -> not type(int(f, t), function(name)), all_functions):
  first_order := map(f -> int(f, t), select(f -> type(int(f, t), function(name)), all_functions)):
  funcs := {op(zero_order), op(first_order)}:
  without_t := map(f -> convert(convert(f, string)[1..-4], symbol), funcs):
  result := []:
  for i from 1 to r do
    subst := map(f -> f = convert(cat(convert(f, string), "_r", i), symbol), without_t):
    result := [op(result), op(map(e -> subs(subst, e), equations))]:
  end do:
  return result:
end proc:

#===============================================================================
CompareDiffVar := proc(dvl, dvr, var_list)
#===============================================================================
  local vl, vr, hl, hr;
  vl, hl := op(GetOrderVar(dvl, var_list)):
  vr, hr := op(GetOrderVar(dvr, var_list)):
  if evalb(hl <> hr) then
    return evalb(hl > hr):
  end if:
  if evalb(length(vl) <> length(vr)) then
    return evalb(length(vl) > length(vr)):
  end if:
  return StringTools[Compare](vr, vl):
end proc:

max_stars_repo_name: iliailmer/sian-web-app

max_issues_repo_name: iliailmer/sian-web-app

max_forks_repo_name: iliailmer/sian-web-app


text:
flavor 1
srclang 3
id 65535
numfuncs 4
import "IteratorAndTemplateTest.mplt"
import "/home/bravewtz/Desktop/openarkcompiler/libjava-core/libjava-core.mplt"
entryfunc &LIteratorAndTemplateTest_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V
fileinfo {
  @INFO_filename "IteratorAndTemplateTest.jar"}
srcfileinfo {
  1 "IteratorAndTemplateTest.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 $LIteratorAndTemplateTest_3B <$LIteratorAndTemplateTest_3B> public
var $_C_STR_480065006c006c006f00 fstatic <[4] u64> readonly = [0, 0xb00000000, 0x6c6c6548042628b2, 111]
var $_C_STR_200057006f0072006c006400 fstatic <[4] u64> readonly = [0, 0xd00000000, 0x726f57203b993f52, 0x646c]
var $Ljava_2Flang_2FSystem_3B_7Cout extern <* <$Ljava_2Fio_2FPrintStream_3B>> final public static
var $__cinf_Ljava_2Flang_2FString_3B extern <$__class_meta__>
func &MCC_GetOrInsertLiteral () <* <$Ljava_2Flang_2FString_3B>>
var $__vtb_LIteratorAndTemplateTest_3B fstatic <[11] <* void>> = [16, 28, 40, 44, 8, 4, 60, 12, 24, 56, 32]
var $__cinf_LIteratorAndTemplateTest_3B <$__class_meta__> public
var $__methods_info__LIteratorAndTemplateTest_3B fstatic <[4] <$__method_info__>> public = [[1= 0xfff6, 2= addrof ptr $__cinf_LIteratorAndTemplateTest_3B, 3= addroffunc ptr &LIteratorAndTemplateTest_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V, 4= 9, 5= 108, 6= 128, 7= 220, 8= 0xa201, 9= 1, 10= 0], [1= 0xfff6, 2= addrof ptr $__cinf_LIteratorAndTemplateTest_3B, 3= addroffunc ptr &LIteratorAndTemplateTest_3B_7CtestIterator_7C_28_29V, 4= 9, 5= 236, 6= 288, 7= 220, 8= 0xab81, 9= 0, 10= 0], [1= 0xfff6, 2= addrof ptr $__cinf_LIteratorAndTemplateTest_3B, 3= addroffunc ptr &LIteratorAndTemplateTest_3B_7C_3Cinit_3E_7C_28_29V, 4= 0x10001, 5= 304, 6= 288, 7= 220, 8= 0xad81, 9= 1, 10= 0], [1= 0xfff6, 2= addrof ptr $__cinf_LIteratorAndTemplateTest_3B, 3= addroffunc ptr &LIteratorAndTemplateTest_3B_7CtestTemplate_7C_28_29V, 4= 9, 5= 332, 6= 288, 7= 220, 8= 0xdf01, 9= 0, 10= 0]]
var $__cinf_Ljava_2Flang_2FObject_3B extern <$__class_meta__> public
var $__superclasses__LIteratorAndTemplateTest_3B fstatic <[1] <$__superclass_meta__>> public = [[1= 0x4000000000000002]]
var $__classinforo__LIteratorAndTemplateTest_3B fstatic <$__class_meta_ro__> public = [1= 4, 2= 0, 3= addrof ptr $__methods_info__LIteratorAndTemplateTest_3B, 4= addrof ptr $__superclasses__LIteratorAndTemplateTest_3B, 5= 0, 6= 4, 7= 0, 8= 1, 9= 0, 10= 33, 11= 220, 12= 0]
var $MCC_GCTIB__LIteratorAndTemplateTest_3B fstatic <* void> public
var $classStateInitialized u64
var $__cinf_LIteratorAndTemplateTest_3B <$__class_meta__> public = [1= -8009400170058319410, 2= 0, 3= 0xffff, 4= 0, 5= 0, 6= addrof ptr $__vtb_LIteratorAndTemplateTest_3B, 7= addrof ptr $MCC_GCTIB__LIteratorAndTemplateTest_3B, 8= addrof ptr $__classinforo__LIteratorAndTemplateTest_3B, 9= addrof ptr $classStateInitialized]
var $__muid_classmetadata_bucket$$IteratorAndTemplateTest_jar <[1] <* void>> public = [addrof ptr $__cinf_LIteratorAndTemplateTest_3B]
func &MCC_Reflect_ThrowCastException nosideeffect () void
func &MCC_Reflect_Check_Casting_NoArray nosideeffect () void
func &MCC_Reflect_Check_Casting_Array nosideeffect () void
var $__cinf_Ljava_2Flang_2FInteger_3B extern ptr
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$$IteratorAndTemplateTest_jar <[0] <* void>>
var $__cinf_Ljava_2Futil_2FArrayList_3B extern <$__class_meta__>
var $__cinf_Ljava_2Flang_2FSystem_3B extern <$__class_meta__>
func &MCC_getFuncPtrFromItabSecondHash64 nosideeffect () ptr
var $__muid_func_def_tab$$IteratorAndTemplateTest_jar fstatic <[4] <$MUIDFuncDefTabEntry>> = [[1= addroffunc ptr &LIteratorAndTemplateTest_3B_7C_3Cinit_3E_7C_28_29V], [1= addroffunc ptr &LIteratorAndTemplateTest_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V], [1= addroffunc ptr &LIteratorAndTemplateTest_3B_7CtestIterator_7C_28_29V], [1= addroffunc ptr &LIteratorAndTemplateTest_3B_7CtestTemplate_7C_28_29V]]
var $__muid_func_inf_tab$$IteratorAndTemplateTest_jar fstatic <[4] <$MUIDFuncInfTabEntry>> = [[1= addroffunc ptr &LIteratorAndTemplateTest_3B_7C_3Cinit_3E_7C_28_29V, 2= addroffunc ptr &LIteratorAndTemplateTest_3B_7C_3Cinit_3E_7C_28_29V], [1= addroffunc ptr &LIteratorAndTemplateTest_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V, 2= addroffunc ptr &LIteratorAndTemplateTest_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V], [1= addroffunc ptr &LIteratorAndTemplateTest_3B_7CtestIterator_7C_28_29V, 2= addroffunc ptr &LIteratorAndTemplateTest_3B_7CtestIterator_7C_28_29V], [1= addroffunc ptr &LIteratorAndTemplateTest_3B_7CtestTemplate_7C_28_29V, 2= addroffunc ptr &LIteratorAndTemplateTest_3B_7CtestTemplate_7C_28_29V]]
var $__muid_func_def_muid_tab$$IteratorAndTemplateTest_jar fstatic <[4] <$MUIDFuncDefMuidTabEntry>> = [[1= -2709223879446397126, 2= -2806363862027557932], [1= 0x13f9008bb09e1306, 2= -146397749925616634], [1= -5928877165053927253, 2= -3742278727938525349], [1= 0x14f02b4d4c9c9cba, 2= -1298857141290561523]]
var $__muid_func_muid_idx_tab$$IteratorAndTemplateTest_jar fstatic <[4] u32> = [2, 0, 3, 1]
var $__muid_data_def_tab$$IteratorAndTemplateTest_jar fstatic <[1] <$MUIDDataDefTabEntry>> = [[1= addrof ptr $__cinf_LIteratorAndTemplateTest_3B]]
var $__muid_data_def_muid_tab$$IteratorAndTemplateTest_jar fstatic <[1] <$MUIDDataDefMuidTabEntry>> = [[1= -3870653282003606309, 2= -437735801171473029]]
var $__muid_func_undef_tab$$IteratorAndTemplateTest_jar fstatic <[15] <$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], [1= 0], [1= 0]]
var $__muid_func_undef_muid_tab$$IteratorAndTemplateTest_jar fstatic <[15] <$MUIDUnifiedUndefMuidTabEntry>> = [[1= 0x3e32352aee789835, 2= -3887705395317205813], [1= -4187412136968710015, 2= -3800091941095621250], [1= 0x6742c234127e0a27, 2= -3762262047879347071], [1= 0x7230554331c55d92, 2= -3676689525926909155], [1= 0x47734862a5f53540, 2= -3299719386741049273], [1= -715372855679083712, 2= -2647497990906227723], [1= -7464356948810446352, 2= -2259485500590180091], [1= 0x783627f2afd1cbde, 2= -2046851302095768916], [1= 0x5fd964249afcfd5a, 2= -1976922851284708166], [1= -2701934576591406938, 2= -1693831364093527548], [1= 0x126777a7fe39e1fb, 2= -1314856249532362766], [1= 0xbf40578f3343f7a, 2= -1198421541845410999], [1= -5560302915447892813, 2= -834808010082911755], [1= 0x7ca2bdf69a6c7c94, 2= -801329978528900548], [1= 0x477aafa4d7dd102b, 2= -442561182569419835]]
var $__muid_data_undef_tab$$IteratorAndTemplateTest_jar fstatic <[6] <$MUIDUnifiedUndefTabEntry>> = [[1= addrof ptr $__cinf_Ljava_2Flang_2FString_3B], [1= addrof ptr $__cinf_Ljava_2Futil_2FArrayList_3B], [1= addrof ptr $__cinf_Ljava_2Flang_2FObject_3B], [1= addrof ptr $__cinf_Ljava_2Flang_2FInteger_3B], [1= addrof ptr $Ljava_2Flang_2FSystem_3B_7Cout], [1= addrof ptr $__cinf_Ljava_2Flang_2FSystem_3B]]
var $__muid_data_undef_muid_tab$$IteratorAndTemplateTest_jar fstatic <[6] <$MUIDUnifiedUndefMuidTabEntry>> = [[1= 0x49d5bdf2b885a664, 2= -3917762785765844292], [1= 0x456b724b58b1374a, 2= -3443613183998313218], [1= -567417612161374449, 2= -3298852447504547670], [1= 0x6b904c5ebfbed6ec, 2= -1758530639733455790], [1= 0x191283ac418c4bb9, 2= -1676204161023949463], [1= -5921653145571052587, 2= -171150348656858163]]
var $__muid_range_tab$$IteratorAndTemplateTest_jar fstatic <[29] <$MUIDRangeTabEntry>> = [[1= 0x6d34586474009ca9, 2= -3364713755890618780], [1= -3695450366366920492, 2= -511067741139025509], [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$$IteratorAndTemplateTest_jar, 2= addrof ptr $__muid_func_def_tab$$IteratorAndTemplateTest_jar], [1= 0, 2= 0], [1= addrof ptr $__muid_func_inf_tab$$IteratorAndTemplateTest_jar, 2= addrof ptr $__muid_func_inf_tab$$IteratorAndTemplateTest_jar], [1= addrof ptr $__muid_func_undef_tab$$IteratorAndTemplateTest_jar, 2= addrof ptr $__muid_func_undef_tab$$IteratorAndTemplateTest_jar], [1= addrof ptr $__muid_data_def_tab$$IteratorAndTemplateTest_jar, 2= addrof ptr $__muid_data_def_tab$$IteratorAndTemplateTest_jar], [1= 0, 2= 0], [1= addrof ptr $__muid_data_undef_tab$$IteratorAndTemplateTest_jar, 2= addrof ptr $__muid_data_undef_tab$$IteratorAndTemplateTest_jar], [1= addrof ptr $__muid_func_def_muid_tab$$IteratorAndTemplateTest_jar, 2= addrof ptr $__muid_func_def_muid_tab$$IteratorAndTemplateTest_jar], [1= addrof ptr $__muid_func_undef_muid_tab$$IteratorAndTemplateTest_jar, 2= addrof ptr $__muid_func_undef_muid_tab$$IteratorAndTemplateTest_jar], [1= addrof ptr $__muid_data_def_muid_tab$$IteratorAndTemplateTest_jar, 2= addrof ptr $__muid_data_def_muid_tab$$IteratorAndTemplateTest_jar], [1= addrof ptr $__muid_data_undef_muid_tab$$IteratorAndTemplateTest_jar, 2= addrof ptr $__muid_data_undef_muid_tab$$IteratorAndTemplateTest_jar], [1= addrof ptr $__muid_func_muid_idx_tab$$IteratorAndTemplateTest_jar, 2= addrof ptr $__muid_func_muid_idx_tab$$IteratorAndTemplateTest_jar], [1= 0, 2= 0]]
var $__reflection_strtab$$IteratorAndTemplateTest_jar fstatic <[96] u8> = [0, 76, 73, 116, 101, 114, 97, 116, 111, 114, 65, 110, 100, 84, 101, 109, 112, 108, 97, 116, 101, 84, 101, 115, 116, 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, 116, 101, 115, 116, 73, 116, 101, 114, 97, 116, 111, 114, 0, 40, 41, 86, 0, 60, 105, 110, 105, 116, 62, 0, 116, 101, 115, 116, 84, 101, 109, 112, 108, 97, 116, 101, 0]
var $__compilerVersionNum$$IteratorAndTemplateTest_jar <[0] <* void>> = [1, 0]
func &LIteratorAndTemplateTest_3B_7C_3Cinit_3E_7C_28_29V public constructor (var %_this <* <$LIteratorAndTemplateTest_3B>>) void {
  funcid 48153
  var %Reg1_R43694 <* <$LIteratorAndTemplateTest_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 <* <[15] <$MUIDUnifiedUndefTabEntry>>> (addrof ptr $__muid_func_undef_tab$$IteratorAndTemplateTest_jar, constval i64 11)))
  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 &LIteratorAndTemplateTest_3B_7Cmain_7C_28ALjava_2Flang_2FString_3B_29V public static (var %Reg0_R743 <* <[] <* <$Ljava_2Flang_2FString_3B>>>>) void {
  funcid 48154
  var %__muid_symptr <* void>

  #INSTIDX : 0||0000:  invokestatic
  #Call function:LIteratorAndTemplateTest_3B_7CtestIterator_7C_28_29V
  dassign %__muid_symptr 0 (iread ptr <* <$MUIDFuncDefTabEntry>> 1 (array 0 ptr <* <[4] <$MUIDFuncDefTabEntry>>> (addrof ptr $__muid_func_def_tab$$IteratorAndTemplateTest_jar, constval i64 2)))
  icallassigned (dread ptr %__muid_symptr) {}
  #INSTIDX : 3||0003:  invokestatic
  #Call function:LIteratorAndTemplateTest_3B_7CtestTemplate_7C_28_29V
  dassign %__muid_symptr 0 (iread ptr <* <$MUIDFuncDefTabEntry>> 1 (array 0 ptr <* <[4] <$MUIDFuncDefTabEntry>>> (addrof ptr $__muid_func_def_tab$$IteratorAndTemplateTest_jar, constval i64 3)))
  icallassigned (dread ptr %__muid_symptr) {}
  #INSTIDX : 6||0006:  return
  intrinsiccall MPL_CLEANUP_LOCALREFVARS ()
  return ()
}
func &LIteratorAndTemplateTest_3B_7CtestIterator_7C_28_29V public static () void {
  funcid 48155
  var %Reg0_R2958 <* <$Ljava_2Futil_2FArrayList_3B>> localrefvar
  var %Reg4_R2958 <* <$Ljava_2Futil_2FArrayList_3B>> localrefvar
  var %Reg0_R43 <* <$Ljava_2Flang_2FString_3B>> localrefvar
  var %Reg1_R43 <* <$Ljava_2Flang_2FString_3B>> localrefvar
  var %L_STR_161343 <* <$Ljava_2Flang_2FString_3B>>
  var %Reg4_R3006 <* <$Ljava_2Futil_2FAbstractCollection_3B>> localrefvar
  var %Reg0_R57 <* <$Ljava_2Flang_2FObject_3B>> localrefvar
  var %Reg0_Z u1
  var %L_STR_161344 <* <$Ljava_2Flang_2FString_3B>>
  var %Reg0_R562 <* <$Ljava_2Fio_2FPrintStream_3B>> localrefvar
  var %Reg1_I i32
  var %__muid_symptr <* void>

  #INSTIDX : 0||0000:  new
  intrinsiccall MPL_CLINIT_CHECK (addrof ptr $__cinf_Ljava_2Futil_2FArrayList_3B)
  regassign ptr %1 (dread ref %Reg0_R2958)
  dassign %Reg0_R2958 0 (gcmalloc ref <$Ljava_2Futil_2FArrayList_3B>)
  intrinsiccall MCCDecRef (regread ptr %1)
  #INSTIDX : 3||0003:  dup
  #INSTIDX : 4||0004:  invokespecial
  #Call function:Ljava_2Futil_2FArrayList_3B_7C_3Cinit_3E_7C_28_29V
  dassign %__muid_symptr 0 (iread ptr <* <$MUIDUnifiedUndefTabEntry>> 1 (array 0 ptr <* <[15] <$MUIDUnifiedUndefTabEntry>>> (addrof ptr $__muid_func_undef_tab$$IteratorAndTemplateTest_jar, constval i64 4)))
  icallassigned (dread ptr %__muid_symptr, dread ref %Reg0_R2958) {}
  #INSTIDX : 7||0007:  astore_0
  intrinsiccall MCCIncRef (dread ref %Reg0_R2958)
  intrinsiccall MCCDecRef (dread ref %Reg4_R2958)
  dassign %Reg4_R2958 0 (dread ref %Reg0_R2958)
  #INSTIDX : 8||0008:  aload_0
  #INSTIDX : 9||0009:  new
  intrinsiccall MPL_CLINIT_CHECK (addrof ptr $__cinf_Ljava_2Flang_2FString_3B)
  regassign ptr %2 (dread ref %Reg0_R43)
  dassign %Reg0_R43 0 (gcmalloc ref <$Ljava_2Flang_2FString_3B>)
  intrinsiccall MCCDecRef (regread ptr %2)
  #INSTIDX : 12||000c:  dup
  #INSTIDX : 13||000d:  ldc
  callassigned &MCC_GetOrInsertLiteral (addrof ptr $_C_STR_480065006c006c006f00) { dassign %L_STR_161343 0 }
  intrinsiccall MCCIncRef (dread ptr %L_STR_161343)
  intrinsiccall MCCDecRef (dread ref %Reg1_R43)
  dassign %Reg1_R43 0 (dread ptr %L_STR_161343)
  #INSTIDX : 15||000f:  invokespecial
  #Call function:Ljava_2Flang_2FString_3B_7C_3Cinit_3E_7C_28Ljava_2Flang_2FString_3B_29V
  dassign %__muid_symptr 0 (iread ptr <* <$MUIDUnifiedUndefTabEntry>> 1 (array 0 ptr <* <[15] <$MUIDUnifiedUndefTabEntry>>> (addrof ptr $__muid_func_undef_tab$$IteratorAndTemplateTest_jar, constval i64 8)))
  icallassigned (dread ptr %__muid_symptr, dread ref %Reg0_R43, dread ref %Reg1_R43) {}
  #INSTIDX : 18||0012:  invokevirtual
  regassign ptr %3 (dread ref %Reg4_R3006)
  dassign %Reg4_R3006 0 (retype ref <* <$Ljava_2Futil_2FAbstractCollection_3B>> (dread ref %Reg4_R2958))
  intrinsiccall MCCIncRef (dread ref %Reg4_R3006)
  intrinsiccall MCCDecRef (regread ptr %3)
  regassign ptr %4 (dread ref %Reg0_R57)
  dassign %Reg0_R57 0 (retype ref <* <$Ljava_2Flang_2FObject_3B>> (dread ref %Reg0_R43))
  intrinsiccall MCCIncRef (dread ref %Reg0_R57)
  intrinsiccall MCCDecRef (regread ptr %4)
  icallassigned (
    iread u64 <* u64> 0 (add ptr (
      iread ptr <* <$__class_meta__>> 6 (iread ref <* <$Ljava_2Flang_2FObject_3B>> 1 (dread ref %Reg4_R3006)),
      constval u32 152)),
    dread ref %Reg4_R3006,
    dread ref %Reg0_R57) { dassign %Reg0_Z 0 }
  #INSTIDX : 21||0015:  pop
  #INSTIDX : 22||0016:  aload_0
  #INSTIDX : 23||0017:  new
  intrinsiccall MPL_CLINIT_CHECK (addrof ptr $__cinf_Ljava_2Flang_2FString_3B)
  regassign ptr %5 (dread ref %Reg0_R43)
  dassign %Reg0_R43 0 (gcmalloc ref <$Ljava_2Flang_2FString_3B>)
  intrinsiccall MCCDecRef (regread ptr %5)
  #INSTIDX : 26||001a:  dup
  #INSTIDX : 27||001b:  ldc
  callassigned &MCC_GetOrInsertLiteral (addrof ptr $_C_STR_200057006f0072006c006400) { dassign %L_STR_161344 0 }
  intrinsiccall MCCIncRef (dread ptr %L_STR_161344)
  intrinsiccall MCCDecRef (dread ref %Reg1_R43)
  dassign %Reg1_R43 0 (dread ptr %L_STR_161344)
  #INSTIDX : 29||001d:  invokespecial
  #Call function:Ljava_2Flang_2FString_3B_7C_3Cinit_3E_7C_28Ljava_2Flang_2FString_3B_29V
  dassign %__muid_symptr 0 (iread ptr <* <$MUIDUnifiedUndefTabEntry>> 1 (array 0 ptr <* <[15] <$MUIDUnifiedUndefTabEntry>>> (addrof ptr $__muid_func_undef_tab$$IteratorAndTemplateTest_jar, constval i64 8)))
  icallassigned (dread ptr %__muid_symptr, dread ref %Reg0_R43, dread ref %Reg1_R43) {}
  #INSTIDX : 32||0020:  invokevirtual
  regassign ptr %6 (dread ref %Reg4_R3006)
  dassign %Reg4_R3006 0 (retype ref <* <$Ljava_2Futil_2FAbstractCollection_3B>> (dread ref %Reg4_R2958))
  intrinsiccall MCCIncRef (dread ref %Reg4_R3006)
  intrinsiccall MCCDecRef (regread ptr %6)
  regassign ptr %7 (dread ref %Reg0_R57)
  dassign %Reg0_R57 0 (retype ref <* <$Ljava_2Flang_2FObject_3B>> (dread ref %Reg0_R43))
  intrinsiccall MCCIncRef (dread ref %Reg0_R57)
  intrinsiccall MCCDecRef (regread ptr %7)
  icallassigned (
    iread u64 <* u64> 0 (add ptr (
      iread ptr <* <$__class_meta__>> 6 (iread ref <* <$Ljava_2Flang_2FObject_3B>> 1 (dread ref %Reg4_R3006)),
      constval u32 152)),
    dread ref %Reg4_R3006,
    dread ref %Reg0_R57) { dassign %Reg0_Z 0 }
  #INSTIDX : 35||0023:  pop
  #INSTIDX : 36||0024:  getstatic
  intrinsiccall MPL_CLINIT_CHECK (addrof ptr $__cinf_Ljava_2Flang_2FSystem_3B)
  regassign ptr %8 (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 <* <[6] <$MUIDUnifiedUndefTabEntry>>> (addrof ptr $__muid_data_undef_tab$$IteratorAndTemplateTest_jar, constval i64 4))))
  intrinsiccall MCCIncRef (dread ref %Reg0_R562)
  intrinsiccall MCCDecRef (regread ptr %8)
  #INSTIDX : 39||0027:  aload_0
  #INSTIDX : 40||0028:  invokevirtual
  regassign ptr %9 (dread ref %Reg4_R3006)
  dassign %Reg4_R3006 0 (retype ref <* <$Ljava_2Futil_2FAbstractCollection_3B>> (dread ref %Reg4_R2958))
  intrinsiccall MCCIncRef (dread ref %Reg4_R3006)
  intrinsiccall MCCDecRef (regread ptr %9)
  icallassigned (
    iread u64 <* u64> 0 (add ptr (
      iread ptr <* <$__class_meta__>> 6 (iread ref <* <$Ljava_2Flang_2FObject_3B>> 1 (dread ref %Reg4_R3006)),
      constval u32 112)),
    dread ref %Reg4_R3006) { dassign %Reg1_I 0 }
  #INSTIDX : 43||002b:  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 272)),
    dread ref %Reg0_R562,
    dread i32 %Reg1_I) {}
  #INSTIDX : 46||002e:  getstatic
  intrinsiccall MPL_CLINIT_CHECK (addrof ptr $__cinf_Ljava_2Flang_2FSystem_3B)
  regassign ptr %10 (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 <* <[6] <$MUIDUnifiedUndefTabEntry>>> (addrof ptr $__muid_data_undef_tab$$IteratorAndTemplateTest_jar, constval i64 4))))
  intrinsiccall MCCIncRef (dread ref %Reg0_R562)
  intrinsiccall MCCDecRef (regread ptr %10)
  #INSTIDX : 49||0031:  aload_0
  #INSTIDX : 50||0032:  invokevirtual
  regassign ptr %11 (dread ref %Reg4_R3006)
  dassign %Reg4_R3006 0 (retype ref <* <$Ljava_2Futil_2FAbstractCollection_3B>> (dread ref %Reg4_R2958))
  intrinsiccall MCCIncRef (dread ref %Reg4_R3006)
  intrinsiccall MCCDecRef (regread ptr %11)
  icallassigned (
    iread u64 <* u64> 0 (add ptr (
      iread ptr <* <$__class_meta__>> 6 (iread ref <* <$Ljava_2Flang_2FObject_3B>> 1 (dread ref %Reg4_R3006)),
      constval u32 32)),
    dread ref %Reg4_R3006) { regassign ptr %13}
  regassign ptr %12 (dread ref %Reg1_R43)
  dassign %Reg1_R43 0 (regread ptr %13)
  intrinsiccall MCCDecRef (regread ptr %12)
  #INSTIDX : 53||0035:  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 312)),
    dread ref %Reg0_R562,
    dread ref %Reg1_R43) {}
  #INSTIDX : 56||0038:  return
  intrinsiccall MPL_CLEANUP_LOCALREFVARS (dread ref %Reg0_R2958, dread ref %Reg4_R2958, dread ref %Reg0_R43, dread ref %Reg1_R43, dread ref %Reg4_R3006, dread ref %Reg0_R57, dread ref %Reg0_R562)
  return ()
}
func &LIteratorAndTemplateTest_3B_7CtestTemplate_7C_28_29V public static () void {
  funcid 48156
  var %Reg0_R2958 <* <$Ljava_2Futil_2FArrayList_3B>> localrefvar
  var %Reg2_R2958 <* <$Ljava_2Futil_2FArrayList_3B>> localrefvar
  var %Reg0_I i32
  var %Reg0_R5353 <* <$Ljava_2Flang_2FInteger_3B>> localrefvar
  var %Reg2_R521 <* <$Ljava_2Futil_2FList_3B>> localrefvar
  var %Reg0_R57 <* <$Ljava_2Flang_2FObject_3B>> localrefvar
  var %Reg0_Z u1
  var %Reg0_R77 <* <$Ljava_2Futil_2FIterator_3B>> localrefvar
  var %Reg3_R77 <* <$Ljava_2Futil_2FIterator_3B>> localrefvar
  var %Reg4_R5353 <* <$Ljava_2Flang_2FInteger_3B>> localrefvar
  var %Reg0_R562 <* <$Ljava_2Fio_2FPrintStream_3B>> localrefvar
  var %Reg4_R57 <* <$Ljava_2Flang_2FObject_3B>> localrefvar
  var %_retst <* void>
  var %__muid_symptr <* void>

  #INSTIDX : 0||0000:  new
  intrinsiccall MPL_CLINIT_CHECK (addrof ptr $__cinf_Ljava_2Futil_2FArrayList_3B)
  regassign ptr %1 (dread ref %Reg0_R2958)
  dassign %Reg0_R2958 0 (gcmalloc ref <$Ljava_2Futil_2FArrayList_3B>)
  intrinsiccall MCCDecRef (regread ptr %1)
  #INSTIDX : 3||0003:  dup
  #INSTIDX : 4||0004:  invokespecial
  #Call function:Ljava_2Futil_2FArrayList_3B_7C_3Cinit_3E_7C_28_29V
  dassign %__muid_symptr 0 (iread ptr <* <$MUIDUnifiedUndefTabEntry>> 1 (array 0 ptr <* <[15] <$MUIDUnifiedUndefTabEntry>>> (addrof ptr $__muid_func_undef_tab$$IteratorAndTemplateTest_jar, constval i64 4)))
  icallassigned (dread ptr %__muid_symptr, dread ref %Reg0_R2958) {}
  #INSTIDX : 7||0007:  astore_0
  intrinsiccall MCCIncRef (dread ref %Reg0_R2958)
  intrinsiccall MCCDecRef (dread ref %Reg2_R2958)
  dassign %Reg2_R2958 0 (dread ref %Reg0_R2958)
  #INSTIDX : 8||0008:  aload_0
  #INSTIDX : 9||0009:  iconst_1
  dassign %Reg0_I 0 (constval i32 1)
  #INSTIDX : 10||000a:  invokestatic
  intrinsiccall MPL_CLINIT_CHECK (addrof ptr $__cinf_Ljava_2Flang_2FInteger_3B)
  #Call function:Ljava_2Flang_2FInteger_3B_7CvalueOf_7C_28I_29Ljava_2Flang_2FInteger_3B
  dassign %__muid_symptr 0 (iread ptr <* <$MUIDUnifiedUndefTabEntry>> 1 (array 0 ptr <* <[15] <$MUIDUnifiedUndefTabEntry>>> (addrof ptr $__muid_func_undef_tab$$IteratorAndTemplateTest_jar, constval i64 12)))
  icallassigned (dread ptr %__muid_symptr, dread i32 %Reg0_I) { regassign ptr %3}
  regassign ptr %2 (dread ref %Reg0_R5353)
  dassign %Reg0_R5353 0 (regread ptr %3)
  intrinsiccall MCCDecRef (regread ptr %2)
  #INSTIDX : 13||000d:  invokeinterface
  regassign ptr %4 (dread ref %Reg2_R521)
  dassign %Reg2_R521 0 (retype ref <* <$Ljava_2Futil_2FList_3B>> (dread ref %Reg2_R2958))
  intrinsiccall MCCIncRef (dread ref %Reg2_R521)
  intrinsiccall MCCDecRef (regread ptr %4)
  regassign ptr %5 (dread ref %Reg0_R57)
  dassign %Reg0_R57 0 (retype ref <* <$Ljava_2Flang_2FObject_3B>> (dread ref %Reg0_R5353))
  intrinsiccall MCCIncRef (dread ref %Reg0_R57)
  intrinsiccall MCCDecRef (regread ptr %5)
  regassign ptr %17 (iread ptr <* <$__class_meta__>> 5 (iread ref <* <$Ljava_2Flang_2FObject_3B>> 1 (dread ref %Reg2_R521)))
  regassign u64 %18 (iread u64 <* u64> 0 (add ptr (regread ptr %17, constval u32 112)))
  if (eq u1 u64 (regread u64 %18, constval u64 0)) {
    callassigned &MCC_getFuncPtrFromItabSecondHash64 (regread ptr %17, constval u64 0x681, conststr ptr "add|(Ljava/lang/Object;)Z") { regassign u64 %18}
  }
  icallassigned (regread u64 %18, dread ref %Reg2_R521, dread ref %Reg0_R57) { dassign %Reg0_Z 0 }
  #INSTIDX : 18||0012:  pop
  #INSTIDX : 19||0013:  aload_0
  #INSTIDX : 20||0014:  iconst_2
  dassign %Reg0_I 0 (constval i32 2)
  #INSTIDX : 21||0015:  invokestatic
  intrinsiccall MPL_CLINIT_CHECK (addrof ptr $__cinf_Ljava_2Flang_2FInteger_3B)
  #Call function:Ljava_2Flang_2FInteger_3B_7CvalueOf_7C_28I_29Ljava_2Flang_2FInteger_3B
  dassign %__muid_symptr 0 (iread ptr <* <$MUIDUnifiedUndefTabEntry>> 1 (array 0 ptr <* <[15] <$MUIDUnifiedUndefTabEntry>>> (addrof ptr $__muid_func_undef_tab$$IteratorAndTemplateTest_jar, constval i64 12)))
  icallassigned (dread ptr %__muid_symptr, dread i32 %Reg0_I) { regassign ptr %7}
  regassign ptr %6 (dread ref %Reg0_R5353)
  dassign %Reg0_R5353 0 (regread ptr %7)
  intrinsiccall MCCDecRef (regread ptr %6)
  #INSTIDX : 24||0018:  invokeinterface
  regassign ptr %8 (dread ref %Reg2_R521)
  dassign %Reg2_R521 0 (retype ref <* <$Ljava_2Futil_2FList_3B>> (dread ref %Reg2_R2958))
  intrinsiccall MCCIncRef (dread ref %Reg2_R521)
  intrinsiccall MCCDecRef (regread ptr %8)
  regassign ptr %9 (dread ref %Reg0_R57)
  dassign %Reg0_R57 0 (retype ref <* <$Ljava_2Flang_2FObject_3B>> (dread ref %Reg0_R5353))
  intrinsiccall MCCIncRef (dread ref %Reg0_R57)
  intrinsiccall MCCDecRef (regread ptr %9)
  regassign ptr %19 (iread ptr <* <$__class_meta__>> 5 (iread ref <* <$Ljava_2Flang_2FObject_3B>> 1 (dread ref %Reg2_R521)))
  regassign u64 %20 (iread u64 <* u64> 0 (add ptr (regread ptr %19, constval u32 112)))
  if (eq u1 u64 (regread u64 %20, constval u64 0)) {
    callassigned &MCC_getFuncPtrFromItabSecondHash64 (regread ptr %19, constval u64 0x681, conststr ptr "add|(Ljava/lang/Object;)Z") { regassign u64 %20}
  }
  icallassigned (regread u64 %20, dread ref %Reg2_R521, dread ref %Reg0_R57) { dassign %Reg0_Z 0 }
  #INSTIDX : 29||001d:  pop
  #INSTIDX : 30||001e:  aload_0
  #INSTIDX : 31||001f:  invokeinterface
  regassign ptr %10 (dread ref %Reg2_R521)
  dassign %Reg2_R521 0 (retype ref <* <$Ljava_2Futil_2FList_3B>> (dread ref %Reg2_R2958))
  intrinsiccall MCCIncRef (dread ref %Reg2_R521)
  intrinsiccall MCCDecRef (regread ptr %10)
  regassign ptr %21 (iread ptr <* <$__class_meta__>> 5 (iread ref <* <$Ljava_2Flang_2FObject_3B>> 1 (dread ref %Reg2_R521)))
  regassign u64 %22 (iread u64 <* u64> 0 (add ptr (regread ptr %21, constval u32 0)))
  if (eq u1 u64 (regread u64 %22, constval u64 0)) {
    callassigned &MCC_getFuncPtrFromItabSecondHash64 (regread ptr %21, constval u64 0xd01, conststr ptr "iterator|()Ljava/util/Iterator;") { regassign u64 %22}
  }
  icallassigned (regread u64 %22, dread ref %Reg2_R521) { regassign ptr %12}
  regassign ptr %11 (dread ref %Reg0_R77)
  dassign %Reg0_R77 0 (regread ptr %12)
  intrinsiccall MCCDecRef (regread ptr %11)
  #INSTIDX : 36||0024:  astore_1
  intrinsiccall MCCIncRef (dread ref %Reg0_R77)
  intrinsiccall MCCDecRef (dread ref %Reg3_R77)
  dassign %Reg3_R77 0 (dread ref %Reg0_R77)
@label0   #INSTIDX : 37||0025:  aload_1
  #INSTIDX : 38||0026:  invokeinterface
  regassign ptr %23 (iread ptr <* <$__class_meta__>> 5 (iread ref <* <$Ljava_2Flang_2FObject_3B>> 1 (dread ref %Reg3_R77)))
  regassign u64 %24 (iread u64 <* u64> 0 (add ptr (regread ptr %23, constval u32 48)))
  if (eq u1 u64 (regread u64 %24, constval u64 0)) {
    callassigned &MCC_getFuncPtrFromItabSecondHash64 (regread ptr %23, constval u64 0x15f9, conststr ptr "hasNext|()Z") { regassign u64 %24}
  }
  icallassigned (regread u64 %24, dread ref %Reg3_R77) { dassign %Reg0_Z 0 }
  #INSTIDX : 43||002b:  ifeq
  brtrue @label1 (eq i32 i32 (dread u1 %Reg0_Z, constval i32 0))
  #INSTIDX : 46||002e:  aload_1
  #INSTIDX : 47||002f:  invokeinterface
  regassign ptr %25 (iread ptr <* <$__class_meta__>> 5 (iread ref <* <$Ljava_2Flang_2FObject_3B>> 1 (dread ref %Reg3_R77)))
  regassign u64 %26 (iread u64 <* u64> 0 (add ptr (regread ptr %25, constval u32 152)))
  if (eq u1 u64 (regread u64 %26, constval u64 0)) {
    callassigned &MCC_getFuncPtrFromItabSecondHash64 (regread ptr %25, constval u64 0x19a6, conststr ptr "next|()Ljava/lang/Object;") { regassign u64 %26}
  }
  icallassigned (regread u64 %26, dread ref %Reg3_R77) { regassign ptr %14}
  regassign ptr %13 (dread ref %Reg0_R57)
  dassign %Reg0_R57 0 (regread ptr %14)
  intrinsiccall MCCDecRef (regread ptr %13)
  #INSTIDX : 52||0034:  checkcast
  brfalse @@4 (ne u1 ptr (dread ref %Reg0_R57, constval ptr 0))
  dassign %_retst 0 (iread ptr <* <$Ljava_2Flang_2FObject_3B>> 1 (dread ref %Reg0_R57))
  brfalse @@4 (ne u1 ptr (addrof ptr $__cinf_Ljava_2Flang_2FInteger_3B, dread ptr %_retst))
  call &MCC_Reflect_Check_Casting_NoArray (addrof ptr $__cinf_Ljava_2Flang_2FInteger_3B, dread ref %Reg0_R57)
  goto @@4
@@4   intrinsiccall MCCIncRef (dread ref %Reg0_R57)
  intrinsiccall MCCDecRef (dread ref %Reg0_R5353)
  dassign %Reg0_R5353 0 (dread ref %Reg0_R57)
  #INSTIDX : 55||0037:  astore_2
  intrinsiccall MCCIncRef (dread ref %Reg0_R5353)
  intrinsiccall MCCDecRef (dread ref %Reg4_R5353)
  dassign %Reg4_R5353 0 (dread ref %Reg0_R5353)
  #INSTIDX : 56||0038:  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 <* <[6] <$MUIDUnifiedUndefTabEntry>>> (addrof ptr $__muid_data_undef_tab$$IteratorAndTemplateTest_jar, constval i64 4))))
  intrinsiccall MCCIncRef (dread ref %Reg0_R562)
  intrinsiccall MCCDecRef (regread ptr %15)
  #INSTIDX : 59||003b:  aload_2
  #INSTIDX : 60||003c:  invokevirtual
  regassign ptr %16 (dread ref %Reg4_R57)
  dassign %Reg4_R57 0 (retype ref <* <$Ljava_2Flang_2FObject_3B>> (dread ref %Reg4_R5353))
  intrinsiccall MCCIncRef (dread ref %Reg4_R57)
  intrinsiccall MCCDecRef (regread ptr %16)
  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 320)),
    dread ref %Reg0_R562,
    dread ref %Reg4_R57) {}
  #INSTIDX : 63||003f:  goto
  goto @label0
@label1   #INSTIDX : 66||0042:  return
  intrinsiccall MPL_CLEANUP_LOCALREFVARS (dread ref %Reg0_R2958, dread ref %Reg2_R2958, dread ref %Reg0_R5353, dread ref %Reg2_R521, dread ref %Reg0_R57, dread ref %Reg0_R77, dread ref %Reg3_R77, dread ref %Reg4_R5353, dread ref %Reg0_R562, dread ref %Reg4_R57)
  return ()
}

max_stars_repo_name: Bravewtz/OpenArkCompiler

max_issues_repo_name: Bravewtz/OpenArkCompiler

max_forks_repo_name: Bravewtz/OpenArkCompiler


text:
# This is from the original version of Gemma Halliwell's thesis.
# It is probably not useful.

`build/standard_levelled_planar_tree` := proc(n::posint,num_levels::posint,u::list(posint))
 local u1,V,E,i,i1,h;

 if nops(u) <> n-1 then
  error "u should have length n-1";
 fi;

 if not(max(op(u)) < num_levels) then
  error "entries in u should be < num_levels";
 fi;

 u1 := [op(u),num_levels];
 V := {seq(seq([i,j],j=0..u1[i]-1),i=1..n)};
 E := {seq(seq([[i,j+1],[i,j]],j=0..u1[i]-2),i=1..n)};
 for i from 1 to n-1 do
  h := u1[i];
  i1 := i+1;
  while i1 < n and u1[i1] <= h do i1 := i1 + 1; od;
  E := {op(E),[[i1,h],[i,h-1]]};
 od;
 return [V,E];
end:


text:
#@ Not autoload
# This is mostly superseded by alternating_five.mpl but some stuff at the end has not been transferred

with(group):

# Generators

x2 := [[1,2],[3,4]];
y2 := [[1,3],[2,4]];
z2 := [[2,3],[4,5]];
x3 := [[1,2,3]];
x5 := [[1,3,4,2,5]];
y5 := [[1,2,3,4,5]];

A5 := permgroup(5,{y2,x5});

# Subgroups, named according to their order

H[1 ] := permgroup(5,{}):
H[2 ] := permgroup(5,{x2}):
H[3 ] := permgroup(5,{x3}):
H[4 ] := permgroup(5,{x2,y2}):
H[5 ] := permgroup(5,{x5}):
H[6 ] := permgroup(5,{z2,x3}):
H[10] := permgroup(5,{x2,x5}):
H[12] := permgroup(5,{x2,x3}):
H[60] := A5:

mp := proc()
 if nargs = 0 then
  return [];
 elif nargs = 1 then
  return args[1];
 elif nargs = 2 then
  return mulperms(args);
 else
  return mulperms(args[1],mp(args[2..-1]));
 fi;
end:

ip := invperm:
pp := proc(sigma,n)
 local rho,tau,m;
 if (n >= 0) then
  tau := sigma; m := n;
 else
  tau := invperm(sigma);
  m := abs(n);
 fi;
 rho := [];
 while m > 0 do
  rho := mulperms(tau,rho);
  m := m-1;
 od;
 return(rho);
end:

ccl := proc(x) map(g->mulperms(mulperms(g,x),invperm(g)),elements(A5)); end:

# Conjugacy classes

C[1] := {[]}:
C[2] := ccl(x2):
C[3] := ccl(x3):
C[4] := ccl(mulperms(x5,x5)):
C[5] := ccl(x5):

tau := (1+sqrt(5))/2;

# Dodecahedron representation

Rx1 := Matrix([[ 1,0,0],[0, 1,0],[0,0, 1]]):
Rx2 := Matrix([[ 1,0,0],[0,-1,0],[0,0,-1]]):
Ry2 := Matrix([[-1,0,0],[0,-1,0],[0,0, 1]]):
Rz2 := map(rationalize,Matrix([[1/tau,-tau,-1],[-tau,-1,1/tau],[-1,1/tau,-tau]])/2):
Rx3 := Matrix([[0,1,0],[0,0,1],[1,0,0]]):
Rx5 := map(rationalize,Matrix([[1/tau,tau,-1],[-tau,1,1/tau],[1,1/tau,tau]])/2):
Ry5 := map(rationalize,Matrix([[tau,-1,-1/tau],[1,1/tau,tau],[-1/tau,-tau,1]])/2):

prels := {
 pp(x2,2),
 pp(y2,2),
 pp(z2,2),
 pp(x3,3),
 pp(x5,5),
 pp(mp(x2,y2),2),
 pp(mp(x2,mp(y2,z2)),3),
 pp(mp(mp(z2,x2),mp(z2,y2)),3),
 pp(mp(x2,z2),5),
 pp(mp(y2,z2),5),
 mp(ip(x3),mp(y2,mp(z2,mp(x2,mp(z2,mp(y2,z2)))))),
 mp(ip(x5),mp(y2,mp(z2,mp(x2,y2)))),
 mp(ip(y5),mp(y2,mp(z2,mp(x2,mp(z2,x2)))))
};

mrels := [
 Rx2^2 - Rx1,
 Ry2^2 - Rx1,
 Rz2^2 - Rx1,
 Rx3^3 - Rx1,
 Rx5^5 - Rx1,
 (Rx2 . Ry2)^2 - Rx1,
 (Rx2 . Ry2 . Rz2)^3 - Rx1,
 (Rz2 . Rx2 . Rz2 . Ry2)^3 - Rx1,
 (Rx2 . Rz2)^5 - 1,
 (Ry2 . Rz2)^5 - 1,
 Rx3 - Ry2 . Rz2 . Rx2 . Rz2 . Ry2 . Rz2,
 Rx5 - Ry2 . Rz2 . Rx2 . Ry2,
 Ry5 - Ry2 . Rz2 . Rx2 . Rz2 . Rx2
]:

mrels := map(M -> map(expand,M),mrels):
rels := {op(map(expand,map(op,map(op,map(convert,mrels,listlist)))))};

ords := [1,2,4,3,6,12,5,10,60];

for n in ords do X[n] := [op(cosets(A5,H[n]))]: od:

is_fixed1 := (g,x,H) -> groupmember(mulperms(mulperms(x,g),invperm(x)),H):

is_fixed := proc(K,x,H)
 local gens,g;
 gens := op(2,K);
 for g in gens do
  if not(is_fixed1(g,x,H)) then return(false); end;
 od;
 return(true);
end:

phi := proc(i,j)
 local m,K,L,Y,y;
 K := H[i];
 L := H[j];
 Y := X[j];
 m := 0;
 for y in Y do
  if is_fixed(K,y,L) then
   m := m+1;
  fi;
 od;
 return(m);
end:

# Matrix of |(G/H_i)^{H_j}|

M := Matrix(9,9,[seq(seq(phi(ords[i],ords[j]),j=1..9),i=1..9)]);

# Cycle types of products of 5-cycles
P := matrix(12,12,[0$144]):
for i from 1 to 12 do
 for j from 1 to 12 do
  g := mulperms(C[5][i],invperm(C[5][j])):
  P[i,j] := map(nops,g):
 od:
od:

# Edges and faces of the icosahedron
E := []:
F := []:
for i from 1 to 12 do
 for j from i+1 to 12 do
  if (P[i,j] = [3]) then
   E := [op(E),[i,j]]:
   for k from j+1 to 12 do
    if (P[i,k] = [3] and P[j,k] = [3]) then
     F := [op(F),[i,j,k]]:
    fi:
   od:
  fi:
 od:
od:
E;
F;

# Words for all elements of A5
w[ 1] := []:
w[ 2] := [X2]:
w[ 3] := [Y2]:
w[ 4] := [Z2]:
w[ 5] := [X2,Y2]:
w[ 6] := [X2,Z2]:
w[ 7] := [Y2,Z2]:
w[ 8] := [Z2,X2]:
w[ 9] := [Z2,Y2]:
w[10] := [X2,Y2,Z2]:
w[11] := [X2,Z2,X2]:
w[12] := [X2,Z2,Y2]:
w[13] := [Y2,Z2,X2]:
w[14] := [Y2,Z2,Y2]:
w[15] := [Z2,X2,Y2]:
w[16] := [Z2,X2,Z2]:
w[17] := [Z2,Y2,Z2]:
w[18] := [X2,Y2,Z2,X2]:
w[19] := [X2,Y2,Z2,Y2]:
w[20] := [X2,Z2,X2,Y2]:
w[21] := [X2,Z2,X2,Z2]:
w[22] := [X2,Z2,Y2,Z2]:
w[23] := [Y2,Z2,X2,Y2]:
w[24] := [Y2,Z2,X2,Z2]:
w[25] := [Y2,Z2,Y2,Z2]:
w[26] := [Z2,X2,Y2,Z2]:
w[27] := [Z2,X2,Z2,X2]:
w[28] := [Z2,X2,Z2,Y2]:
w[29] := [Z2,Y2,Z2,X2]:
w[30] := [Z2,Y2,Z2,Y2]:
w[31] := [X2,Y2,Z2,X2,Z2]:
w[32] := [X2,Y2,Z2,Y2,Z2]:
w[33] := [X2,Z2,X2,Z2,X2]:
w[34] := [X2,Z2,X2,Z2,Y2]:
w[35] := [X2,Z2,Y2,Z2,X2]:
w[36] := [X2,Z2,Y2,Z2,Y2]:
w[37] := [Y2,Z2,X2,Z2,X2]:
w[38] := [Y2,Z2,X2,Z2,Y2]:
w[39] := [Y2,Z2,Y2,Z2,X2]:
w[40] := [Y2,Z2,Y2,Z2,Y2]:
w[41] := [Z2,X2,Z2,X2,Y2]:
w[42] := [Z2,X2,Z2,Y2,Z2]:
w[43] := [Z2,Y2,Z2,X2,Y2]:
w[44] := [Z2,Y2,Z2,X2,Z2]:
w[45] := [X2,Y2,Z2,X2,Z2,X2]:
w[46] := [X2,Y2,Z2,X2,Z2,Y2]:
w[47] := [X2,Y2,Z2,Y2,Z2,X2]:
w[48] := [X2,Y2,Z2,Y2,Z2,Y2]:
w[49] := [X2,Z2,X2,Z2,X2,Y2]:
w[50] := [X2,Z2,X2,Z2,Y2,Z2]:
w[51] := [X2,Z2,Y2,Z2,X2,Y2]:
w[52] := [X2,Z2,Y2,Z2,X2,Z2]:
w[53] := [Y2,Z2,X2,Z2,Y2,Z2]:
w[54] := [Y2,Z2,Y2,Z2,X2,Y2]:
w[55] := [Y2,Z2,Y2,Z2,X2,Z2]:
w[56] := [Z2,X2,Z2,Y2,Z2,Y2]:
w[57] := [Z2,Y2,Z2,X2,Z2,X2]:
w[58] := [X2,Y2,Z2,Y2,Z2,X2,Y2]:
w[59] := [Z2,Y2,Z2,Y2,Z2,X2,Z2]:
w[60] := [X2,Z2,Y2,Z2,Y2,Z2,X2,Z2]:

# Rotations for all elements
Rw[1] := IdentityMatrix(3):
for i from 2 to 60 do
 Rw[i] := map(expand,`.`(op(subs({X2=Rx2,Y2=Ry2,Z2=Rz2},w[i]))));
od:

# Permutations for all elements
Sw[1] := []:
for i from 2 to 60 do
 Sw[i] := mp(op(subs({X2=x2,Y2=y2,Z2=z2},w[i])));
od:

# Vertices of the icosahedron

V[ 1] := <   0,   1, tau>:
V[ 2] := <   0,  -1, tau>:
V[ 3] := <   0,   1,-tau>:
V[ 4] := <   0,  -1,-tau>:
V[ 5] := <   1, tau,   0>:
V[ 6] := <  -1, tau,   0>:
V[ 7] := <   1,-tau,   0>:
V[ 8] := <  -1,-tau,   0>:
V[ 9] := < tau,   0,   1>:
V[10] := < tau,   0,  -1>:
V[11] := <-tau,   0,   1>:
V[12] := <-tau,   0,  -1>:

for i from 1 to 12 do
 U := V[i];
 VV[U[1],U[2],U[3]] := i;
od:

Vix := proc(T)
 local T1;
 T1 := map(expand,T);
 return(VV[T1[1],T1[2],T1[3]]);
end:

# Permutation action on vertices

Px2 := convert([seq(Vix(Rx2 . V[i]),i=1..12)],disjcyc);
Py2 := convert([seq(Vix(Ry2 . V[i]),i=1..12)],disjcyc);
Pz2 := convert([seq(Vix(Rz2 . V[i]),i=1..12)],disjcyc);
Px3 := convert([seq(Vix(Rx3 . V[i]),i=1..12)],disjcyc);
Px5 := convert([seq(Vix(Rx5 . V[i]),i=1..12)],disjcyc);


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: gga_exc *)

$define gga_x_pbe_sol_params
$include "gga_x_pbe.mpl"

q2d_cc := 100:
q2d_c1 := 0.5217:

q2d_f1 := s -> pbe_f0(s)*(q2d_cc - s^4) + q2d_c1*s^3.5*(1 + s^2):
q2d_f2 := s -> q2d_cc + s^6:
q2d_f  := x -> q2d_f1(X2S*x)/q2d_f2(X2S*x):

f := (rs, zeta, xt, xs0, xs1) -> gga_exchange(q2d_f, rs, zeta, xs0, xs1):


text:
(*
 Copyright (C) 2020 Susi Lehtola

 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: gga_exc *)
(* prefix:
  gga_k_pg_params *params;

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

pg_f0 := s -> 5/3*s^2 + exp(-params_a_pg_mu * s^2):
pg_f := x -> pg_f0(X2S*x):

f := (rs, z, xt, xs0, xs1) -> gga_kinetic(pg_f, rs, z, xs0, xs1):


text:
# Let E be the surjection operad, as explained by Berger and Fresse
# following McClure.  We represent a basis element of E(A) by
# expressions S(...), where the arguments are elements of A,
# each element appears at least once, and no two adjacent elements
# are the same.

`is_element/surjections` := (A::set) -> proc(x)
 global reason;
 local i,y,z;

 if x = 0 then return true; fi;

 if type(x,`+`) then
  return `and`(op(map(`is_element/surjections`(A),[op(x)])));
 fi;

 if type(x,`*`) then
  y,z := selectremove(type,[op(x)],integer);
  return (nops(z) = 1 and `is_element/surjections`(A)(z[1]));
 fi;

 if not type(x,specfunc(S)) then return false; fi;
 if {op(x)} <> A then return false; fi;

 for i from 1 to nops(x) - 1 do
  if x[i] = x[i+1] then return false; fi;
 od;

 return true;
end:

`is_equal/surjections` := (A::set) -> (x0,x1) -> evalb(expand(x0 - x1) = 0);

`is_equal_unsigned/surjections` := (A::set) -> (x0,x1) -> evalb(modp(expand(x0 - x1),2) = 0);

`random_basis_element/surjections` := (A) -> proc(m_)
 local n,m,i,x,ok;

 n := nops(A);

 if n = 0 then return FAIL; fi;

 if n = 1 then
  if nargs = 0 or m_ = 1 then
   return S(op(A));
  else
   return FAIL;
  fi;
 fi;

 if nargs > 0 then
  m := m_;
 else
  m := rand(0..5)();
 end:

 ok := false;
 while not(ok) do
  x := [op(A),seq(random_element_of(A),i=1..m)];
  x := combinat[randperm](x);
  ok := true;
  for i from 1 to n + m - 1 do
   if x[i] = x[i+1] then
    ok := false;
    break;
   fi;
  od;
 od;
 x := S(op(x));
 return x;
end:

`random_element/surjections` := (A) -> proc(coeff_range_,num_terms_)
 local coeff_range,num_terms;

 coeff_range := -3..3;
 num_terms := 5;
 if nargs > 0 then coeff_range := args[1]; fi;
 if nargs > 1 then num_terms := args[2]; fi;

 add(rand(coeff_range)() * `random_basis_element/surjections`(A)(),i=1..num_terms);
end:

# Let u be a basis element of E(A), of length n say.  A gap means
# a pair (i,i+1) with 1 <= i < i+1 <= n.  The gap is bound if
# u[i] = u[j] for some j > i.  Here we represent a bound gap
# (i,i+1) by its initial index i.  The following function
# returns the ordered list of bound gaps.

`bound_gaps/surjections` := (A) -> proc(u)
 local G,N,M,a;
 G := NULL;
 N := [seq(i,i=1..nops(u))];
 for a in A do
  M := select(i -> op(i,u) = a,N);
  G := G,op(1..-2,M);
 od:
 G := sort([G]);
 return(G);
end:

# Auxiliary function feeding into `diff/surjections`

`diff0/surjections` := (A::set) -> proc(x)
 local i,j,m,y,z,s,ss,t,l,r;

 i := [op(x)];
 m := nops(i);

 y := 0;
 s := 1;
 ss := table();

 for j from 1 to m do
  l := [op(1..j-1,i)];
  r := [op(j+1..m,i)];
  if member(i[j],r) then
   t := s;
   ss[i[j]] := t;
   s := -s;
  elif member(i[j],l) then
   t := -ss[i[j]];
   ss[i[j]] := t;
  else
   t := 0;
  fi;
  if 1 < j and j < m and op(j-1,i) = op(j + 1,i) then
   t := 0;
  fi;
  y := y + t * S(op(1..j-1,i),op(j+1..m,i));
 od:
end:

# Differential on the surjection chain complex

`diff/surjections` := (A::set) -> apply_linear(`diff0/surjections`(A));

# Auxilary function feeding into `deg/surjections`
`deg0/surjections` := (A) -> (u) -> nops(u) - nops(A);

# Degree function for the surjection chain complex.
`deg/surjections` := (A) -> apply_deg(`deg0/surjections`(A));

`reflect/surjections` := (A) -> proc(u)
 local c,v;

 if type(u,`+`) then
  return map(`reflect/surjections`(A),u);
 fi;

 c,v := op(coeff_split(u));

 if not(type(v,specfunc(S))) then return FAIL; fi;

 return (-1)^(nops(v) - nops(A)) * u;
end:

# This is the circle product for the operad structure.
# It is assumed that B is a subset of A and u is in E(A/B) and v is in E(B),
# where A/B is implemented as A \ B u {B}.

`o0/surjections` := (A,B) -> proc(u,v)
 local AB,nu,nv,Nu,Nv,M,l,m,JJ,w,J,k,p,i,j,s;

 AB := A minus B union {B};

 nu := nops(u);
 nv := nops(v);
 Nu := [seq(i,i=1..nu)];
 Nv := [seq(i,i=1..nv)];
 M := select(i -> op(i,u) = B,Nu);
 m := nops(M);
 JJ := combinat[choose]([seq(i,i=2..nv+m-1)],m-1);
 JJ := map(J -> [1,seq(J[i]-i,i=1..m-1),nv],JJ);

 w := 0;
 for J in JJ do
  k := NULL;
  l := NULL;
  p := 1;
  for i from 1 to nu do
   if op(i,u) = B then
    k := k,seq(op(j,v),j=J[p]..J[p+1]);
    l := l,seq([i,j],j=J[p]..J[p+1]);
    p := p+1;
   else
    k := k,op(i,u);
    l := l,[i,0];
   fi;
  od;
  l := [l];
  s := NULL;
  for i in `bound_gaps/surjections`(AB)(u) do
   j := nops(l);
   while j > 1 and l[j][1] <> i do j := j - 1; od;
   s := s,j;
  od;
  for i in `bound_gaps/surjections`(B)(v) do
   j := nops(l);
   while j > 1 and l[j][2] <> i do j := j - 1; od;
   s := s,j;
  od;
  w := w + sgn([s]) * S(k);
 od:

 return w;
end:

`o/surjections` := (A,B) -> apply_bilinear(`o0/surjections`(A,B));

`gamma0/surjections` := (A::set,B::set) -> (p) -> proc(y,x)
 local F,J,I0,J0,b,L,m,n,S0,s;

 F := fibres(A,B)(p);
 J := [seq(i,i=0..nops(y)-1)];
 I0 := table():
 J0 := table():
 for b in B do
  I0[b] := [seq(i,i=0..nops(x[b])-1)];
  J0[b] := select(j -> op(j+1,y) = b,J);
 od:
 L := [[]];

 for b in B do
  m := nops(J0[b]) - 1;
  n := nops(I0[b]) - 1;
  S0 := map(`to_grid_path/shuffles`(m,n),`list_elements/shuffles`(m,n));
  S0 := map(s -> [seq(s[i],i=0..n+m)],S0);
  S0 := map(s -> map(ji -> [J0[b][ji[1]+1],ji[2]],s),S0);
  L := [seq(seq([op(l),op(s)],s in S0),l in L)];
 od:
 L := map(sort,L);
 L := map(l -> S(op(map(ji -> op(ji[2]+1,x[op(ji[1]+1,y)]),l))),L);
 return `+`(op(L));
end:

`gamma/surjections` := eval(extend_gamma_linear(`gamma0/surjections`)):

# We now have various functions related to an interesting filtration
# of the surjections operad.

`flip_count/surjections` := (A::set) -> proc(u,s_)
 local r,m,a,b,c,u0,i;
 if nargs > 1 then
  r := `rank_table/ord`(A)(s_);
 else
  r := NULL;
 fi;

 m := table():
 for a in A do
  for b in A do
   m[a,b] := 0;
   u0 := select(p -> p = a or p = b,[op(u)]);
   for i from 1 to nops(u0) - 1 do
    if u0[i+1] <> u0[i] then m[a,b] := m[a,b] + 1; fi;
   od;

   if m[a,b] > 0 and r <> NULL then
    c := `if`(r[a] < r[b],a,b);
    if u0[-1] = c then m[a,b] := m[a,b] + 1; fi;
   fi;
  od;
 od;

 return eval(m);
end:

`flip_count_matrix/surjections` := (A::set) -> proc(u,s_)
 local m;
 m := `flip_count/surjections`(A)(args);
 return Matrix([seq([seq(m[a,b],b in A)],a in A)]);
end:

`max_flip_count/surjections` := (A::set) -> proc(u)
 local m,mm,a,b;

 m := `flip_count/surjections`(A)(u);

 mm := 0;
 for a in A do
  for b in A do
   mm := max(mm,m[a,b]);
  od;
 od;

 return mm;
end:

`is_cell_member/surjections` := (A::set) -> (ms) -> proc(u)
 local m0,m1,s,r,i,j,a,b,c,u0,k,l,y,z;

 if x = 0 then return true; fi;
 if type(x,`+`) then
  return `and`(seq(`is_cell_member/surjections`(A)(ms)(y),y in x));
 fi;
 if type(x,`*`) then
  y,z := selectremove(type,[op(x)],integer);
  if nops(z) = 1 then
   return `is_cell_member/surjections`(A)(ms)(z[1]);
  else
   return false;
  fi;
 fi;

 m0,s := op(ms);
 m1 := `flip_count/surjections`(A)(u,s);

 for a in A do
  for b in A do
   if m1[a,b] > m0[a,b] then return false; fi;
  od;
 od;

 return true;
end:

`filtration0/surjections` := (A::set) -> proc(u)
 local m,m_max,s,rr,k,i,r0,r1,a,b;

 if type(u,integer) then return 0; fi;

 return 1 + `max_flip_count/surjections`(A)(u);
end:

`filtration/surjections` := (A::set) ->
 apply_max_deg(`filtration0/surjections`(A));

`rho0/barratt_eccles/surjections` := (A::set) -> proc(x)
 local rr,d,R,r,y,z,z0,ok,i,m;

 rr := nops(A);
 d := nops(x) - 1;
 R := combinat[choose]([seq(i,i=1..d+rr-1)],d);
 R := map(r -> [0,op(r),d+rr],R);
 R := map(r -> [seq(r[i+1]-r[i],i=1..d+1)],R);
 y := 0;
 for r in R do
  z := NULL;
  z0 := NULL;
  ok := true;
  for i from 1 to d+1 do
   m := select(j -> not(member(j,[z0])),op(i,x));
   if nops(m) >= r[i] and ([z] = [] or [z][-1] <> m[1]) then
    z := z,op(1..r[i],m);
    z0 := z0,op(1..r[i]-1,m);
   else
    ok := false;
    break;
   fi;
  od;
  if ok then y := y + S(z); fi;
 od;
 return y;
end:

`rho/barratt_eccles/surjections` := (A::set) ->
 apply_linear(`rho0/barratt_eccles/surjections`(A));

# We now define a map from the surjections operad to the
# Barratt-Eccles operad.  This is not an operad morphism,
# but it is a section of the map in the opposite direction.

`sigma0/surjections/barratt_eccles` := (A::set) -> proc(x)
 local i,j,k,l,r,t,p,m,d,w,ww;

 i := [op(x)];
 m := nops(i);
 d := m - nops(A);

 ww := NULL;

 for k from 0 to d do
  w := NULL;

  p := 0;

  for j from 1 to m do
   l := [op(1..j-1,i)];
   r := [op(j+1..m,i)];
   if member(i[j],r) then
    t := false;
    p := p + 1;
   else
    t := true;
   fi;

   if not(member(i[j],[w])) then
    if t or (p > k) then
     w := w,i[j];
    fi;
   fi;
  od:
  w := [w];
  ww := ww,w;
 od;

 return T(ww);
end:

`sigma/surjections/barratt_eccles` := (A::set) ->
 apply_linear(`sigma0/surjections/barratt_eccles`(A));

# The cut operation construction gives a morphism from the surjection
# operad to the Eilenberg-Zilber operad.  Unfortunately the EZ operad
# cannot be represented properly in our framework because each set
# EZ(A) is an infinite product over the natural numbers.  To deal with
# this we insert natural number indices in various places.

`cut_operation0/surjections` := (n::nonnegint) -> (A::set) -> proc(x)
 local A0,m,d,N,J,p,q,r,j,c,t,a,is_degen;

 A0 := sort([op(A)]);
 m := nops(A);
 d := nops(x) - m;
 N := [seq(i,i=0..n)];
 J := [[0]];
 for p from 1 to m + d - 1 do
  J := [seq(seq([op(j),q],q=j[-1]..n),j in J)];
 od:
 J := map(j -> [op(j),n],J);

 c := 0;

 for j in J do
  t := table():
  for a in A0 do t[a] := []: od:
  for p from 1 to m+d do
   a := op(p,x);
   t[a] := [op(t[a]),seq(r,r=j[p]..j[p+1])];
  od:

  is_degen := false;

  for a in A0 do
   if nops(t[a]) > nops({op(t[a])}) then
    is_degen := true;
    break;
   fi;
  od:

  if not(is_degen) then
   c := c + `detranspose/eilenberg_zilber`(A)(t);
  fi;
 od:

 return c;
end:

`cut_operation1/surjections` := (n::nonnegint) -> (A::set) -> proc(x)
 add(`cut_operation0/surjections`(k)(A)(x),k=0..n);
end:

`cut_operation/surjections` := (n::nonnegint) -> (A::set) ->
 apply_linear(`cut_operation1/surjections`(n)(A));

`multiplicity_table/surjections` := (A::set) -> proc(x)
 local t,a;

 t := table():
 for a in A do t[a] := 0; od:
 for a in [op(x)] do
  t[a] := t[a] + 1;
 od:
 return eval(t);
end:
`max_multiplicity/surjections` := (A::set) -> proc(x)
 local t,m,a;
 t := `multiplicity_table/surjections`(A)(x);
 m := 0;
 for a in A do m := max(m,t[a]); od;
 return m;
end:
`is_biased/surjections` := (A::set) -> proc(x,a0_)
 local a,a0,t;

 a0 := NULL;
 if nargs > 1 then a0 := a0_; fi;

 t := `multiplicity_table/surjections`(A)(x);

 for a in A do
  if t[a] > 1 then
   if a0 = NULL then
    a0 := a;
   else
    if a0 <> a then
     return false;
    fi;
   fi;
  fi;
 od:

 return true;
end:
`is_strongly_biased/surjections` := (A::set) -> proc(x,a0_)
 local a,a0,t;

 a0 := NULL;
 if nargs > 1 then a0 := a0_; fi;

 t := `multiplicity_table/surjections`(A)(x);

 for a in A do
  if t[a] > 1 then
   if a0 = NULL then
    a0 := a;
   else
    if a0 <> a then
     return false;
    fi;
   fi;
  fi;
 od:

 if a0 = NULL or t[a0] <= 1 then return false; fi;

 return true;
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 *)

$include "mgga_c_scan.mpl"

(* Override definition of beta *)
mbeta := (rs, t) -> 0.066725:

rmggac_gamma1 := 0.08:
rmggac_gamma2 := 0.3:
rmggac_g := (alpha, s) ->
  (1 + rmggac_gamma1)*alpha/(rmggac_gamma1 + alpha + rmggac_gamma2*s^2):

rmggac_f2 := (alpha, s) ->
  3*rmggac_g(alpha, s)^3/(1 + rmggac_g(alpha, s)^3 + rmggac_g(alpha, s)^6):
rmggac_f1 := (alpha, s) ->
  1 - rmggac_f2(alpha, s):

rmggac_gamma := 0.031091:
(* from mmga_c_r2scan *)
rmggac_w1 := (rs, z) -> exp(-f_pw(rs, z)/(rmggac_gamma*mphi(z)^3)) - 1:
rmggac_H1 := (rs, z, t) -> rmggac_gamma*mphi(z)^3*log(1 + rmggac_w1(rs, z) * (1 - scan_e0_g(rs, z, t))):

rmggac_eps1 := (rs, z, t) ->
  (f_pw(rs, z) +  rmggac_H1(rs, z, t)):

rmggac_alpha := (z, xt, ts0, ts1) ->
  (t_total(z, ts0, ts1) - xt^2/4)/(2**(1/3)*K_FACTOR_C):

rmggac_f := (rs, z, xt, xs0, xs1, ts0, ts1) ->
  + scan_e0(rs, z, X2S*2^(1/3)*xt)
      * rmggac_f1(rmggac_alpha(z, xt, ts0, ts1), X2S*2^(1/3)*xt)
  + rmggac_eps1(rs, z, tp(rs, z, xt))
      * rmggac_f2(rmggac_alpha(z, xt, ts0, ts1), X2S*2^(1/3)*xt):

(* the functional is written for the other convention for tau *)
f := (rs, z, xt, xs0, xs1, us0, us1, ts0, ts1) ->
  rmggac_f(rs, z, xt, xs0, xs1, 2*ts0, 2*ts1):


text:
with(ListTools):
with(combinat):
with(Physics):
with(Threads):
with(GroupTheory):
interface(labelling=false):

Setup(mathematicalnotation=true, anticommutativecolor=olive):
Setup(anticommutativeprefix={phi,theta,tau,eta,psi,rho}):

#Protecting variable names to avoid non-omniscient program user errors.
protect(a);
protect(m);
protect(n);
protect(p);
protect(h);
protect(e);
protect(s);
protect(sbar);
protect(sEt);
protect(sbarEt);
protect(beta);
protect(alpha);
protect(box):
protect(circle):

read "./lib/sparts.mpl";
read "./lib/types.mpl";
read "./lib/operators.mpl";
read "./lib/basis.mpl";
read "./lib/CMS.mpl";
read "./lib/visual.mpl";
read "./lib/sBern_1.mpl";
read "./lib/bernsteinLAV.mpl";
####################################################################################################
#interface(screenwidth=100);


text:
type $SS <struct {
        @real f32,
        @imag f32}>
var $sconst1 <struct {
        @f11 i32,
        @f22 <$SS>,
        @f33 i32,
        @f44 i32,
        @f55 f32,
        @f66 f32}> = [ 6=1007.0f, 2= [1=11.11f, 2=22.22f], 3=-273, 4=75, 1=1425926, 5=6023.0f ]
func $printf (var %p1 <* i8>)void
func $main ( ) i32 {
   call &printf (addrof a32 $sconst1)
   return (constval i32 0) }

 # EXEC: %irbuild Main.mpl
 # EXEC: %irbuild Main.irb.mpl
 # EXEC: %cmp Main.irb.mpl Main.irb.irb.mpl

max_stars_repo_name: openmaple/MapleCompiler

max_issues_repo_name: venshine/OpenArkCompiler

max_forks_repo_name: venshine/OpenArkCompiler