-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from afvillaverde/dev
Dev
- Loading branch information
Showing
35 changed files
with
1,326 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
STRIKE-GOLDD/functions/expand_lie.m → ...OLDD/functions/aux_AutoRepar/expand_lie.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
120 changes: 60 additions & 60 deletions
120
STRIKE-GOLDD/functions/simp.m → STRIKE-GOLDD/functions/aux_AutoRepar/simp.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,60 @@ | ||
function [sim_vec] = simp(allVar,vec,eps_var) | ||
%% FUNCTION SIMPLIFY | ||
% | ||
% Function to find some expressions that may have not been simplified | ||
% during the computation of new variables | ||
% | ||
% INPUT: allVar --> All variables | ||
% vec --> vector with final tranformations | ||
% eps_var --> value of exponential(epsilon) | ||
% | ||
% OUTPUT: | ||
% sim_vec --> simplified final transformations vector | ||
%% | ||
syms epsilon | ||
ch=children(vec); | ||
[~,ncol]=size(ch); | ||
if iscell(ch)==0 % For R2020b | ||
ch=num2cell(ch); | ||
end | ||
for i=1:ncol | ||
[~,ncol_2]=size(ch{1,i}); | ||
if iscell(ch{1,i})==1 %For R2020b | ||
aux_v=[ch{1,i}{:}]; | ||
else | ||
aux_v=[ch{1,i}(:)]; | ||
end | ||
for j=1:ncol_2 | ||
[n,d]=numden(aux_v(j)); | ||
if n==1 %% Only denominator | ||
[c,p]=coeffs(d,allVar); | ||
if (numel(unique(abs(p)))==1 && abs(c)~=1) % Some expression contains exp(ep) | ||
eq=simplify(log(c),'IgnoreAnalyticConstraints',true); | ||
[cc,~]=coeffs(eq,epsilon); | ||
vec(i)=subs(vec(i),exp(cc*epsilon),eps_var^(cc)); | ||
end | ||
elseif d==1 | ||
[c,p]=coeffs(n,allVar); | ||
if (numel(unique(abs(p)))==1 && abs(c)~=1) % Some expression contains exp(ep) | ||
eq=simplify(log(c),'IgnoreAnalyticConstraints',true); | ||
[cc,~]=coeffs(eq,epsilon); | ||
vec(i)=subs(vec(i),exp(cc*epsilon),eps_var^(cc)); | ||
end | ||
else | ||
[c_n,p_n]=coeffs(n,allVar); | ||
[c_d,p_d]=coeffs(d,allVar); | ||
if numel(unique(abs(p_n)))==1 && abs(c_n)~=1 % Some expression contains exp(ep) | ||
eq=simplify(log(c_n),'IgnoreAnalyticConstraints',true); | ||
[cc_n,~]=coeffs(eq,epsilon); | ||
vec(i)=subs(vec(i),exp(cc_n*epsilon),eps_var^(cc_n)); | ||
elseif numel(unique(abs(p_d)))==1 && abs(c_d)~=1 | ||
eq=simplify(log(c_d),'IgnoreAnalyticConstraints',true); | ||
[cc_d,~]=coeffs(eq,epsilon); | ||
vec(i)=subs(vec(i),exp(cc_d*epsilon),eps_var^(cc_d)); | ||
end | ||
end | ||
end | ||
end | ||
sim_vec=vec; | ||
end | ||
|
||
function [sim_vec] = simp(allVar,vec,eps_var) | ||
%% FUNCTION SIMPLIFY | ||
% | ||
% Function to find some expressions that may have not been simplified | ||
% during the computation of new variables | ||
% | ||
% INPUT: allVar --> All variables | ||
% vec --> vector with final tranformations | ||
% eps_var --> value of exponential(epsilon) | ||
% | ||
% OUTPUT: | ||
% sim_vec --> simplified final transformations vector | ||
%% | ||
syms epsilon | ||
ch=children(vec); | ||
[~,ncol]=size(ch); | ||
if iscell(ch)==0 % For R2020b | ||
ch=num2cell(ch); | ||
end | ||
for i=1:ncol | ||
[~,ncol_2]=size(ch{1,i}); | ||
if iscell(ch{1,i})==1 %For R2020b | ||
aux_v=[ch{1,i}{:}]; | ||
else | ||
aux_v=[ch{1,i}(:)]; | ||
end | ||
for j=1:ncol_2 | ||
[n,d]=numden(aux_v(j)); | ||
if n==1 %% Only denominator | ||
[c,p]=coeffs(d,allVar); | ||
if (numel(unique(abs(p)))==1 && abs(c)~=1) % Some expression contains exp(ep) | ||
eq=simplify(log(c),'IgnoreAnalyticConstraints',true); | ||
[cc,~]=coeffs(eq,epsilon); | ||
vec(i)=subs(vec(i),exp(cc*epsilon),eps_var^(cc)); | ||
end | ||
elseif d==1 | ||
[c,p]=coeffs(n,allVar); | ||
if (numel(unique(abs(p)))==1 && abs(c)~=1) % Some expression contains exp(ep) | ||
eq=simplify(log(c),'IgnoreAnalyticConstraints',true); | ||
[cc,~]=coeffs(eq,epsilon); | ||
vec(i)=subs(vec(i),exp(cc*epsilon),eps_var^(cc)); | ||
end | ||
else | ||
[c_n,p_n]=coeffs(n,allVar); | ||
[c_d,p_d]=coeffs(d,allVar); | ||
if numel(unique(abs(p_n)))==1 && abs(c_n)~=1 % Some expression contains exp(ep) | ||
eq=simplify(log(c_n),'IgnoreAnalyticConstraints',true); | ||
[cc_n,~]=coeffs(eq,epsilon); | ||
vec(i)=subs(vec(i),exp(cc_n*epsilon),eps_var^(cc_n)); | ||
elseif numel(unique(abs(p_d)))==1 && abs(c_d)~=1 | ||
eq=simplify(log(c_d),'IgnoreAnalyticConstraints',true); | ||
[cc_d,~]=coeffs(eq,epsilon); | ||
vec(i)=subs(vec(i),exp(cc_d*epsilon),eps_var^(cc_d)); | ||
end | ||
end | ||
end | ||
end | ||
sim_vec=vec; | ||
end | ||
|
File renamed without changes.
File renamed without changes.
41 changes: 41 additions & 0 deletions
41
STRIKE-GOLDD/functions/aux_Prob_Obs_Test/ExpMatrixSeries.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
% ------------------------------------------------------------------------- | ||
% computation using a newton operator | ||
%-------------------------------------------------------------------------- | ||
|
||
function [sol1,sol2]=ExpMatrixSeries(Mat,LocalOrder,Matsize,MyPrime) | ||
|
||
if LocalOrder==1 | ||
sol1=zeros(1,Matsize*Matsize); | ||
sol1((1:Matsize:Matsize*Matsize)+(0:Matsize-1))=1; | ||
sol2=zeros(1,Matsize*Matsize); | ||
sol2((1:Matsize:Matsize*Matsize)+(0:Matsize-1))=1; | ||
else | ||
NewOrder=2^ceil(log2(LocalOrder)-1); | ||
aux=trunpoly(Mat,LocalOrder); | ||
[aux1,aux2]=ExpMatrixSeries(aux,NewOrder,Matsize,MyPrime); | ||
|
||
aux1=trunpoly(aux1,LocalOrder); | ||
aux2=trunpoly(aux2,LocalOrder); | ||
|
||
sol2=multmatpolytrun(-aux1,aux2,NewOrder,Matsize); | ||
sol2=mod(sol2,MyPrime); | ||
sol2(end,(1:Matsize:Matsize*Matsize)+(0:Matsize-1))= ... | ||
sol2(end,(1:Matsize:Matsize*Matsize)+(0:Matsize-1))+2; | ||
sol2=multmatpolytrun(aux2,sol2,NewOrder,Matsize); | ||
sol2=mod(sol2,MyPrime); | ||
|
||
|
||
Matder=dermatpoly(Mat,LocalOrder); | ||
aux1der=dermatpoly(aux1,LocalOrder); | ||
sol1=mod(trunpoly( ... | ||
multmatpolytrun(Matder,aux1,LocalOrder,Matsize)-aux1der ... | ||
,LocalOrder),MyPrime); | ||
sol1=mod(multmatpolytrun(sol2,sol1,LocalOrder,Matsize),MyPrime); | ||
sol1=intmatpoly(sol1,LocalOrder); | ||
sol1=ratmod(sol1,MyPrime); | ||
sol1(end,(1:Matsize:Matsize*Matsize)+(0:Matsize-1))= ... | ||
sol1(end,(1:Matsize:Matsize*Matsize)+(0:Matsize-1))+1; | ||
sol1=mod(multmatpolytrun(aux1,sol1,LocalOrder,Matsize),MyPrime); | ||
|
||
|
||
end |
27 changes: 27 additions & 0 deletions
27
STRIKE-GOLDD/functions/aux_Prob_Obs_Test/InverseMatrixSeries.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
%-------------------------------------------------------------------------- | ||
% use of newton operator for computation of InvHomSolInvA | ||
%-------------------------------------------------------------------------- | ||
|
||
function sol=InverseMatrixSeries(Mat,LocalOrder,MatSize,MyPrime) | ||
|
||
if LocalOrder==1 | ||
sol=Mat(end,:); | ||
aux=zeros(MatSize,MatSize); | ||
for i=1:MatSize | ||
aux(i,:)=sol((i-1)*MatSize+1:i*MatSize); | ||
end | ||
aux=inv(aux); | ||
for i=1:MatSize | ||
sol((i-1)*MatSize+1:i*MatSize)=aux(i,:); | ||
end | ||
else | ||
NewOrder = 2^ceil(log2(LocalOrder)-1); | ||
aux=trunpoly(Mat,NewOrder); | ||
aux=InverseMatrixSeries(aux,NewOrder,MatSize,MyPrime); | ||
aux=trunpoly(aux,LocalOrder); | ||
|
||
sol=mod(multmatpolytrun(-aux,Mat,LocalOrder,MatSize),MyPrime); | ||
sol(end,(1:MatSize:MatSize*MatSize)+(0:MatSize-1))= ... | ||
sol(end,(1:MatSize:MatSize*MatSize)+(0:MatSize-1))+2; | ||
sol=mod(multmatpolytrun(sol,aux,LocalOrder,MatSize),MyPrime); | ||
end |
Oops, something went wrong.