⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prodop.m

📁 The goal of SPID is to provide the user with tools capable to simulate, preprocess, process and clas
💻 M
字号:
function output=prodop(spin_num,xyz,spin);
    
    %calculate spin operators
    ident=eye(spin_num);

    %product operators
    halfunity=sparse([1/2 0 ; 0 1/2]);
    Ix=sparse([0 1/2 ; 1/2 0]);
    Iy=sparse([0 -1/2*i ; 1/2*i 0]);
    Iz=sparse([1/2 0 ; 0 -1/2]);
  
    if xyz=='x'
        for n=1:spin_num
            if n==1
                if ident(n,spin)==0
                    temp=halfunity;
                else
                    temp=Ix; 
                end
            else
                if ident(n,spin)==0
                    temp=kron(temp,halfunity);
                else
                    temp=kron(temp,Ix); 
                end
            end
        end
    end
    
    if xyz=='y'
        for n=1:spin_num
            if n==1
                if ident(n,spin)==0
                    temp=halfunity;
                else
                    temp=Iy; 
                end
            else
                if ident(n,spin)==0
                    temp=kron(temp,halfunity);
                else
                    temp=kron(temp,Iy); 
                end
            end
        end
    end

    if xyz=='z'
        for n=1:spin_num
            if n==1
                if ident(n,spin)==0
                    temp=halfunity;
                else
                    temp=Iz; 
                end
            else
                if ident(n,spin)==0
                    temp=kron(temp,halfunity);
                else
                    temp=kron(temp,Iz); 
                end
            end
        end
    end
    output=temp;
    output=output*2^(spin_num-1);
end

⌨️ 快捷键说明

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