maxsep.m

来自「该算法是用于量子运算的matlab程序」· M 代码 · 共 65 行

M
65
字号
% maxsep   Maximum for multi-qubit separable states. %   Uses simple numerical search for which parameters can %   be set in the beginning of the maxsep.m file. %   Slower than maxsymsep.function m=maxsep(op)[sx,sy]=size(op);N=log2(sx);% Parameters for the simulationDelta=0.005;Nit1=10000;Nit2=20000;rmax=-Inf;% Dimensionsd=2;fa=zeros(d,N);famax=fa;for n=1:Nit1     if mod(n,100)==0,  randn('state',sum(100*clock));  end %if     f=(rand(d,1)-0.5)+i*(rand(d,1)-0.5);     fa(:,1)=f;     for n=1:N-1        f2=(rand(d,1)-0.5)+i*(rand(d,1)-0.5);	fa(:,n+1)=f2;        f=kron(f,f2);     end %for     r=real(trace(op*f*f')/(f'*f));     if r>rmax,         rmax=r;	 famax=fa;     end %ifend %forfa0=famax;r0=rmax;% Second phase of the searchfor n=1:Nit2     if mod(n,100)==0,  randn('state',sum(100*clock));  end %if     f=(rand(d,1)-0.5)+i*(rand(d,1)-0.5);     f=fa0(:,1)+Delta*f;     fa(:,1)=f;     for n=1:N-1        f2=(rand(d,1)-0.5)+i*(rand(d,1)-0.5);	f2=fa0(:,n+1)+Delta*f2;	fa(:,n+1)=f2;        f=kron(f,f2);     end %for     r=real(trace(op*f*f')/(f'*f));     if r>r0,         r0=r;         fa0=fa;             end %ifend %for m=r0;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?