For four days, starting on Friday April 15th, about half a dozen souls gathered in the hive01 headquarters in Stuttgart. The goal of this very first ownCloud sprint was to discuss, plan and of course hack on the web services project.

To kickoff we had a brainstorming session and discussion of the topics that were to be dealt with over the following days. We extensively debated fundamental things concerning the future directions of ownCloud.

Discussing the navigation structure Discussing the navigation structure

Releasing ownCloud 1.2

OwnCloud 1.2 is the next maintenance version of the ownCloud 1.x series. It includes several bugfixes; if you are a user of ownCloud 1.1 you should upgrade to ownCloud 1.2. Since the team decided on a new code-base at this sprint, ownCloud 1.2 will also be the final release before ownCloud 2.0 enters the wild.

Refactoring, Facelift and Possibilities

Probably the most important work was done on refactoring ownCloud's initial concept and work by Jakob Sack. These changes will help to make the codebase clearer, easier to maintain and a lot more flexible. ownCloud will be easy to extend with additional applications and plugins. In the very near future ownCloud's web-based storage system will be capable of being enriched by extensions like Music Streamers, Photo Galleries or PIM functionality – basically anything a PHP application can do.

In order to make the installation of extensions straightforward we have created ownCloud Apps: an online application sharing platform which will easily be accessible via the Open Collaboration Services (OCS) API, that e.g. acts also as the backend for GetHotNewStuff you know from KDE applications. There will also be an interface for knowledge-base articles which will be accessible from within ownCloud. So instead of writing the user documentation the ownCloud users can easily excange questions and answers directly from within ownCloud itself.

Since ease of use is one of our main goals for ownCloud we are very happy to have Jan-Christoph Borchardt with us, who brought a lot of expertise in creating and optimizing user interfaces. Based on the great mockups from François we heavily worked on not only improving ownCloud's UI but also simplifying processes like the installation.

Refurbished interface (click to enlarge) Refurbished interface (click to enlarge)

Doing the deed

Typically, we quickly turned new ideas into code, resulting in us staying in the office until Sunday afternoon (with small breaks to sleep) and supported by the ultimate power of pizza deliveries. Though we intented to put a foot on the street, everyone needed five more minutes to commit a change, which practically ended in an infinite loop of development. On Sunday afternoon and evening we managed to have our "sightseeing" activities, and visited a Turkish fast food restaurant and an Irish pub (everything else was closed anyway).

The foundations laid on this sprint will be the base for the next release, which will be ownCloud 2.0. Seeing the good and fast results during the last days we want to get ownCloud into shape with all the basic functionality and release it as soon as possible, probably before this summer.

And still more on ownCloud's heap

We covered even more topics, that currently still need a bit more consideration. For example, translation. There are a few obstacles in translating web applications, which differs from desktop programs you usually compile. Nevertheless we want to hook up into KDE's translation system, of course, and use the synergy effects.

We are also looking into Plasma Active integration and are confident that ownCloud will work well as a web widget on a wide variety of devices, because making ownCloud usable from different kinds of devices, including Smartphones, Tablets, and Netbooks, has been considered throughout the design of the user interface. Nevertheless everybody is welcome to work on QML widgets that access or interact with ownCloud.

Participants hacking: Frank Karlitschek, Jakob Sack, Robin Appelman, Jan-Christoph Borchardt, Arthur Schiwon (from left to right) Participants hacking: Frank Karlitschek, Jakob Sack, Robin Appelman, Jan-Christoph Borchardt, Arthur Schiwon (from left to right)

Join ownCloud

We have made huge steps forward, but still need new people to join in ownCloud development and help to make the cloud a better place. If you want start to code away, check out the the current source code and implement a feature that you'd love to see in ownCloud, like a photo gallery, access over additional protocols (webdav is supported only at the moment) or Amarok integration to list a few examples.

Last but not least

We warmly thank KDE e.V. for sponsoring the sprint! We have had a lot of fun, agreed on plenty of topics, and hacked on countless features and techniques, making the ownCloud sprint a full success.

Just 5 more minutes to world domination.


using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

// TODO this should be fully commented; however it's not part of the main public API

#pragma warning disable 1591
#pragma warning disable 1570

namespace CsQuery.EquationParser.Implementation
{
    public static class Utils
    {
        public static bool IsIntegralType<T>()
        {
            return IsIntegralType(typeof(T));
        }
        public static bool IsIntegralType(IConvertible value)
        {
            return IsIntegralType(value.GetType());
        }
        public static bool IsIntegralType(Type type)
        {
            return type == typeof(Int16) ||
                type == typeof(Int32) ||
                type == typeof(Int64) ||
                type == typeof(UInt16) ||
                type == typeof(UInt32) ||
                type == typeof(UInt64) ||
                type == typeof(char) ||
                type == typeof(byte) ||
                type == typeof(bool);
        }
        public static bool IsIntegralValue(IConvertible value)
        {
            bool result = false;
            if (IsIntegralType(value))
            {
                result=true;
            } else {
                try
                {
                    double dblVal = (double)Convert.ChangeType(value, typeof(double));
                    double intVal = Math.Floor(dblVal);
                    return intVal == dblVal;
                }
                catch
                {
                    result = false;
                }
            }
            return result;

        }
        public static bool IsNumericType<T>()
        {
            return IsNumericType(typeof(T));
        }
        public static bool IsNumericType(object obj)
        {
            Type t = GetUnderlyingType(obj.GetType());
            return IsNumericType(t);
        }

        /// <summary>
        /// Test if the type is a numeric primitive type, e.g. all except string, char & bool.
        /// </summary>
        ///
        /// <param name="type">
        /// The type to test.
        /// </param>
        ///
        /// <returns>
        /// true if numeric type, false if not.
        /// </returns>

        public static bool IsNumericType(Type type)
        {
            return type.IsPrimitive && !(type == typeof(string) || type == typeof(char) || type == typeof(bool));
        }

        /// <summary>
        /// Any primitive type that can be converted to a number, e.g. all except string. This just
        /// returns any primitive type that is not IEnumerable.
        /// </summary>
        ///
        /// <param name="type">
        /// The type to test.
        /// </param>
        ///
        /// <returns>
        /// true if numeric convertible, false if not.
        /// </returns>

        public static bool IsNumericConvertible(Type type)
        {
            return type.IsPrimitive && !(type  == typeof(string));
        }

        /// <summary>
        /// Test if the value is a string or char type
        /// </summary>
        ///
        /// <param name="value">
        /// The value to test
        /// </param>
        ///
        /// <returns>
        /// true if text or char, false if not.
        /// </returns>

        public static bool IsText(object value)
        {
            Type t  = value.GetType();
            return t == typeof(string) || t == typeof(char);
        }

        /// <summary>
        /// Factory to return a function object based on a name
        /// </summary>
        ///
        /// <exception cref="ArgumentException">
        /// Thrown when the named function is not known.
        /// </exception>
        ///
        /// <typeparam name="T">
        /// The return type of the function
        /// </typeparam>
        /// <param name="functionName">
        /// Name of the function.
        /// </param>
        ///
        /// <returns>
        /// The function< t>
        /// </returns>

        public static IFunction GetFunction<T>(string functionName)
        {
            bool IsTyped = typeof(T) == typeof(IConvertible);
            switch (functionName)
            {
                case "abs":
                    return new Functions.Abs();
                default:
                    throw new ArgumentException("Undefined function '" + functionName + "'");

            }
        }
        /// <summary>
        /// If the value is an operand, returns it, otherwise creates the right kind of operand
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static IOperand EnsureOperand(IConvertible value)
        {
            if (value is IOperand)
            {
                return (IOperand)value;
            }
            else if (value is string)
            {
                //TODO: parse quotes and return a string liteeral if need be
                return Equations.CreateVariable((string)value);
            }
            else
            {
                return Equations.CreateLiteral(value);
            }
        }

        /// <summary>
        /// Return the proper type for an object (ignoring nullability)
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static Type GetUnderlyingType(Type type)
        {

            if (type != typeof(string) && IsNullableType(type))
            {
                return Nullable.GetUnderlyingType(type);
            }
            else
            {
                return type;
            }

        }

        /// <summary>
        /// Returns true of the type is a generic nullable type OR string
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static bool IsNullableType(Type type)
        {
            return type == typeof(string) ||
                (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>));
        }

        public static IEnumerable<T> EmptyEnumerable<T>()
        {
            yield break;
        }
    }
}


Q:

Count the number of records in group_by clause

I have the following categories grouped together
@categories = Category.all.group_by { |c| c.name }

In my view I am displaying the category names like so
<% @categories.each do |c, v| %>

<%= link_to c, blog_path(:name => c) %>

<% end %>

Which gives this for example
Ruby
Ruby On Rails
CSS

What i want to achieve is next to each category name have the total number of posts with that category name, so
Ruby(2)
Ruby On Rails(10)

So i have tried
@categories = Category.joins(:posts).all.group_by { |c| c.name }

Which results in only the categories with a post object being displayed (previously all categories would display, regardless of whether they had a post object) and in my view i tried
<% @categories.each do |c, v| %>

<%= link_to c, blog_path(:name => c) %><%= c.count %>

<% end %>

Which is outputting nothing. I thought i would ask how to approach this before i confuse the matter, if someone could explain the answer aswell that would be greatly appreciated
Many Thanks

A:

It's confusing to call the grouped categories @categories because that makes it sound like a collection of Category objects, when it's actually a Hash.  Using descriptive names, including in your loop, makes your code much clearer.
Try this:
@category_groups = Category.includes(:posts).all.group_by { |c| c.name }

and the view
<% @category_groups.each do |name, categories| %>

<%= link_to name, blog_path(:name => name) %> (<%= categories.map{|category| category.posts.size}.sum %> posts)

<% end %>


open SharedTypes;
open Reprocessing;

let style = font => {
  ...WelcomeScreen2.buttonStyle(font),
  fixedWidth: Some(150),
  margin: 20
};

let root = (env, ctx) => UIManager.{
  el: VBox([
    Button("Resume", `Resume, style(ctx.textFont)),
    Button("Home", `Quit, style(ctx.textFont)),
  ], 10, Center),
  pos: (Env.width(env) / 2, Env.height(env) / 2),
  align: Center,
  valign: Middle
};

let draw = (ctx, env) => {
  Draw.fill(Utils.color(~r=50, ~g=50 ,~b=80, ~a=150), env);
  Draw.rect(~pos=(0, 0), ~width=Env.width(env), ~height=Env.height(env), env);

  UIManager.draw(env, root(env, ctx));
};

let mouseDown = (ctx, env) => {
  UIManager.act(env, root(env, ctx))
};


Q:

html5 validation on apex:inputsecret

html5 validation fires on all fields except apex:inputsecret field.Any reason behind this ?
<apex:page id="Registration" showHeader="false" controller="SiteRegisterController" title="{!$Label.site.register}" docType="html-5.0">

                  <apex:outputText> Self Registration</apex:outputText>
                      <apex:form id="theForm" forceSSL="true">
                        <apex:pageMessages id="error"/>
                        <apex:panelGrid columns="2" style="margin-top:1em;">
                          <apex:outputLabel value="{!$Label.site.username}" for="username"/>
                          <apex:inputText required="true" id="username" value="{!username}" />
                          <apex:outputLabel value="{!$Label.site.community_nickname}" for="communityNickname"/>
                          <apex:inputText required="true" id="communityNickname" value="{!communityNickname}" />
                          <apex:outputLabel value="{!$Label.site.email}" for="email" />
                          <apex:inputText required="true" id="email" value="{!email}" />
                          <apex:outputLabel value="{!$Label.site.password}" for="password"/>
                          <apex:inputSecret id="password" value="{!password}" required="true"/>
                          <apex:outputLabel value="{!$Label.site.confirm_password}" for="confirmPassword"/>
                          <apex:inputSecret id="confirmPassword" value="{!confirmPassword}" required="true"/>
                          <apex:outputText value=""/>
                          <apex:commandButton action="{!registerUser}" value="{!$Label.site.submit}" id="submit"/>
                        </apex:panelGrid>
                        </apex:form>

    </apex:page>

A:

The required attribute on the <apex:inputSecret> does not appear to be passed through to the DOM. Maybe it is used for server side validation only from what I can tell.
the output of the <apex:inputSecret> is as follows:
<input id="j_id0:j_id1:abc" type="password" name="j_id0:j_id1:abc" value=""/>

The markup from the VF page was:
<apex:inputSecret required="true" id="abc"/>

The only way I was able to allow HTML5 validation was to add JS or jQuery to the document onReady to add the required attribute to all password inputs:
$('input[type="password"]').prop('required','true');

Once I did that the HTML5 validation worked as expected.


The purpose of this study is to examine the effects of the administration of a new compound called Celecoxib (SC 58,635) on the body "flu" like response and prostaglandin formation that follows endotoxin injection. We plan to measure these compounds at regular time intervals, in urine and blood, before and after endotoxin infection. We also wish to define the analgestic properties of this medication.


Q:

I can not access dataframe

With the following code, I am reading multiple csv files into dataframes.
setwd("/path/to/files")

filenames <- gsub("\\.csv$","", list.files(pattern="\\.csv$"))

for(i in filenames){
  assign(i, read.csv(paste(i, ".csv", sep="")))
}

When I try to access them in the following code
for (i in filenames) {
    imanDavenportTest(i)
}

I get the following error
Error in apply(data, MARGIN = 1, FUN = f) :
  dim(X) must have a positive length

can someone help me?

A:

Edward's answer is correct. But I wanted to add a note as you are going about this in a quite complicated way and not taking full advantage of R.
There's no reason to use assign here. You can read in all your data in one go and have the results stored as a single object (a list) rather than having N objects polluting your workspace. For example:
# read files in your directory
file_ls <- list.files('.', pattern=".csv$")

# use lapply to read each file and create a list of data frames
data_ls <- lapply(file_ls, read.csv)

# perform the test on each element of the list
lapply(data_ls, imanDavenportTest)

assign is often adopted by people that are coming from languages that have global variables but it doesn't take advantage of R's object-orientated functional programming. IMHO, using assign in this manner creates code that is hard to read and fragile to maintain.


---
abstract: 'One of the typical features of Majorana zero mode (MZM) at the end of topological superconductor is a zero-bias peak in the tunneling spectroscopy of the normal lead-superconductor junction. In this paper we study on a model with one phonon mode coupling to the superconductor lead of the normal lead-superconductor junction, which can be viewed as an electron-lead/phonon-coupled-MZM/hole-lead structure. The phonon-coupled MZM acts as a series of channels in which electron can turn into hole by absorbing and emitting phonons. These channels present in the local density of states (LDOS) as a series of stripes, generating the corresponding peaks in the tunneling spectroscopy. In LDOS, the electron-phonon interaction narrows and redistributes the weight among stripes. In the tunneling spectroscopy, the heights of peaks present a feature of the multi-phonon process. With these investigations, our work illuminates the mechanism of phonon-assisted Andreev reflection at a Majorana zero mode.'
author:
- Ning Dai
- 'Qing-Feng Sun'
title: 'Phonon-Assisted Andreev Reflection at Majorana Zero Mode'
---

introduction
============

Majorana fermion, a fermion which is its own antiparticle, can be achieved in condensed matter as a quasiparticle of electrons and holes.[@MF1; @MF2; @MF4; @MF5; @MFadd] For example, Majorana fermion appears in spinless p wave superconductor at the transition between strong and weak pairing phases.[@ps1; @ps2; @ps3; @ps4] In practice, the Majorana zero mode (MZM) can be achieved at the end of a quantum wire which is in proximity to a s-wave superconductor and in a Zeeman field.[@MZM1; @MZM2] An efficient method to check the existence of MZM is to construct a normal lead-superconductor junction and measure the tunneling spectroscopy. With a MZM residing in the junction, the tunneling spectroscopy presents a zero-bias peak[@ZBP1; @ZBP2; @YSZheng1; @WP2] which is resulted from the Majorana induced resonance Andreev reflection.[@MIRAR] Up to now, the zero-bias peak has been observed in many experiments,[@ZBPep9; @ZBPep5; @ZBPep2; @ZBPep4; @ZBPep6; @ZBPep7; @ZBPep8] but the height of the peak usually is much lower than the perfect value $2 e^2/h$, because of the soft gap,[@soft] thermal effect,[@thermal1; @thermal2] or the electron-phonon interaction (EPI). Very recent, an experiment work has successfully achieved the zero-bias peak with the peak height $ 2e^2/h$ in an indium antimonide semiconductor nanowire covered a superconducting shell,[@ZBPep10] which gives a strong evidence of the existence of the MZM.

The phonon plays an important role in electron transport.[@PA1; @PA3; @PA4; @PA5; @SunPhonon1; @SJT1] While short wave phonon participates in the superconducting pairing,[@psc1; @psc2] it is also worth to consider the influence of long wave optical phonon in the Majorana induced Andreev reflection. Some reports have shown the spectroscopy of phonon-assisted Andreev reflection, where a series of peaks appear with the equal peak interval $\frac{\omega_p}{2}$ with $\omega_p$ being the frequency of the phonon.[@PAAR2; @Gramich1; @FTF6; @add1; @add2] However, the Majorana induced Andreev reflection is a kind of special Andreev reflection which is more like resonance tunneling. The normal lead plays a role of both electron lead and hole lead, and the MZM acts as a quantum dot with a single zero energy level.[@MIRAR] In phonon-assisted resonance tunneling, the local density of states (LDOS) of the quantum dot and the differential conductance present a series of peaks at $n\omega_p$ with the integer $n$ and are sensitive to the average Fermi energy of the two leads,[@PART1; @PART2] which is exactly zero for electron and hole leads in the case of Majorana induced Andreev reflection and aligns to the MZM. Moreover, very recent, Song and Das Sarma have studied the relaxation time of the Majorana qubit with the coupling of phonons, and show that the relaxation rate can be manipulated by the accompanied phonon energy which can be tuned by the voltage bias.[@addSong] So far, the mechanism of phonon-assisted Majorana induced Andreev reflection has not been investigated, which is exactly the subject of the present work.

In order to look into the influence of phonon on Majorana induced Andreev reflection, we investigate a simplified model with one phonon mode coupling to the superconductor of a normal lead-superconductor junction in this paper. An non-equilibrium Green’s function formalism is developed to numerically solve the LDOS and conductance of this normal lead-superconductor junction. With the phonon mode coupling, MZM generates a series of channels in which electron can turn into hole by absorbing and emitting phonons. These channels present in the LDOS as a series of stripes which have the same width in energy, the same shape in real space but different scales. The stripes are reduced to peaks in energy distribution at a fixed position. The coupling strength of the normal lead and superconductor has a broadening effect on the peaks, but has no influence on the weight of each peak. On the other hand, the EPI strength restrains the broadening and elevates the weight of non-zeroth phonon sidebands. The heights of peaks grow with the EPI strength moderately at zero temperature but intensively at nonzero temperature. However, the soar of peaks in LDOS with temperature is wiped out in conductance by thermal broadening effect. At zero temperature, the width of peaks in conductance are exactly equal to their counterpart in LDOS, and the height of the $n$th conductance peak presents a feature of $n$-phonons process.

The rest of this paper is organized as follows: In Sec.\[sec2\] we introduce the normal lead-superconductor model and the non-equilibrium Green’s function, of which the detailed deduction is developed in the Appendix. The results are presented in Sec.\[result\]. Specifically, we first give a picture of phonon assisted Andreev reflection at MZM in Sec.\[sec31\], then numerically study the LDOS in Sec.\[spfu\] and differential conductance in Sec.\[cond\], respectively. In the end, we summary the work in Sec.\[sec4\].

\[sec2\]model and method
========================

The phonon-coupled normal lead-superconductor device is shown in Fig.\[device\](a). With the help of Zeeman field and proximity to s-wave superconductor, an 1D quantum wire changes into a spinless p-wave superconductor or a Kitaev chain[@Kitaev] of which a MZM resides at the end. In this paper, a single phonon mode is coupled to this superconductor to simulate the effect of long wave optical phonon, of which the frequency is $\omega_p$ and the momentum can be omitted. The experimental realization of such a model can be achieved with the help of some material with special phonon spectrum and the spin-orbit coupling, e.g. a nanowire with spin-orbit coupling and the vibration phonon mode. In fact, it has been experimentally found that phonon modes exist in various systems, such as nanowires, nanotubes, quantum dots and so on. For example, if the 1D quantum wire is made of carbon nanotube, there exists a radial breathing mode corresponding to the global radial vibration.[@RBM1; @RBM2; @RBM3] In addition, the intrinsic vibration phonon mode can exist in nanowires, nanotubes, quantum dots and some molecules.[@Gramich1; @addphn1; @addphn2; @addphn3]

The phonon-coupled superconducting wire is connected to a normal lead, forming a normal lead-superconductor junction \[Fig.\[device\](a)\]. The superconducting lead is grounded and a bias $V$ is added on the normal lead. The EPI strength is $\lambda$, and in this paper we also use the dimensionless quantity $g=\lambda^2/\omega_p^2$ to denote the strength of EPI. The tunneling strength between the normal lead and superconductor is labeled by $1/\alpha$, which means a larger $\alpha$ represents a weaker tunneling. The parameter $\alpha$ is called reversed coupling strength in the rest of this paper. The Hamiltonian of this device is presented below: $$\begin{aligned}
H&=&H_L+H_R+H_T ,\label{1}\\
H_R&=&H_{R0}+\lambda(\hat{a}+\hat{a}^\dagger)\sum_k\hat{c}_k^\dagger\hat{c}_k
 +\omega_p\hat{a}^\dagger\hat{a}, \label{HR}\\
H_{R0}&=&\sum_k\varepsilon_k\hat{c}_k^\dagger\hat{c}_k+\Delta_k\hat{c}_{k}\hat{c}_{-k}
 +\Delta_k^*\hat{c}_{-k}^\dagger\hat{c}_k^\dagger, \label{HR0}\\
H_L&=&\sum_k\varepsilon'_k\hat{d}^\dagger_k\hat{d}_k, \label{HL} \\
H_T&=&\sum_{k,k'}(T_0/\alpha)\hat{d}^\dagger_k\hat{c}_{k'}+\mathrm{h.c.},\label{HT}\end{aligned}$$ where $H_L$ and $H_R$ represent the normal and superconductor lead, respectively, and $H_T$ describe the coupling term or the tunneling term between the normal lead and superconductor. In particular, $H_R$ consists of spinless p-wave superconductor term $H_{R0}$, EPI term $\lambda(\hat{a}+\hat{a}^\dagger)\hat{c}_k^\dagger\hat{c}_k$ and phonon term $\omega_p\hat{a}^\dagger\hat{a}$. The operators $\hat{a}(\hat{a}^\dagger)$, $\hat{c}(\hat{c}^\dagger)$ and $\hat{d}(\hat{d}^\dagger)$ annihilate (create) a phonon, an electron in normal lead and in superconducting lead, respectively. The energy spectrum $\varepsilon_k$ and $\varepsilon'_k$ are both parabolic, and the constant $T_0$ stand for the normal lead-superconductor coupling strength at $\alpha=1$.

![\[device\] (a) Andreev reflection in weak tunneling 1D normal lead-superconductor junction with a phonon mode coupled to the superconductor wire. A MZM exists at the end of the superconductor wire. The bias $V$ is added on the normal lead and the superconductor is grounded. (b) Regarding the normal wire as a hybrid of an electron lead and a hole lead, this normal lead-superconductor junction can be viewed as an electron-lead/phonon-coupled-MZM/hole-lead structure.](fig0.eps){width="\linewidth"}

The EPI term in Eq.(\[HR\]) complicates the solving of this system. A well developed canonical transformation method is widely used to solve problems in this kind.[@SunPhonon1; @PART1; @PAAR2; @po] Introducing the canonical transformation on any operator $\hat{O}$, that $\hat{\bar{O}}={\mathrm{e}}^S\hat{O}{\mathrm{e}}^{-S}$ with $$S=\sum_k\hat{c}_k^\dagger\hat{c}_k\frac{\lambda}{\omega_p}(\hat{a}^\dagger-\hat{a}).$$ The creation and annihilation operators under this transformation are: $$\begin{aligned}
    \hat{\bar{c}}_k&=&{\mathrm{e}}^S \hat{c}_k {\mathrm{e}}^{-S}=
\hat{c}_k{\mathrm{e}}^{-\frac{\lambda}{\omega_p}(\hat{a}^\dagger-\hat{a})},\label{fieldoperator1}\\
\hat{\bar{c}}^\dagger_k
&=&{\mathrm{e}}^S \hat{c}^\dagger_k {\mathrm{e}}^{-S}
=\hat{c}_k^\dagger{\mathrm{e}}^{\frac{\lambda}{\omega_p}(\hat{a}^\dagger-\hat{a})},\label{fieldoperator2}\\
    \hat{\bar{a}} &=&{\mathrm{e}}^S \hat{a} {\mathrm{e}}^{-S} =
\hat{a}-\frac{\lambda}{\omega_p}\sum_k\hat{c}_k^\dagger\hat{c}_k ,\label{fieldoperator3}\\
\hat{\bar{a}}^\dagger
&=&{\mathrm{e}}^S \hat{a}^\dagger {\mathrm{e}}^{-S}
=\hat{a}^\dagger-\frac{\lambda}{\omega_p}\sum_k\hat{c}_k^\dagger\hat{c}_k ,\label{fieldoperator4}\end{aligned}$$ and the operators $\hat{d}_k$ and $\hat{d}^{\dagger}_k$ remain unchange under this transformation.

Before applying this canonical transformation, we note that the superconducting pairing term in Eq.(\[HR0\]) originates from the attraction interaction $U_{k,k'}$ between electrons, that is, the original form of Hamiltonian $H_{R0}$ in Eq.(\[HR0\]) is $$H_{R0}=\sum_k\varepsilon_k\hat{c}_k^\dagger\hat{c}_k
+\sum_{k,k'}U_{k,k'}\hat{c}^\dagger_{k'}\hat{c}^\dagger_{-k'}\hat{c}_{-k}\hat{c}_{k} .\label{HR0'}$$ A mean-field approximation is applied on Eq.(\[HR0’\]) to arrive at the BCS Hamiltonian \[Eq.(\[HR0\])\], where $$\Delta_k\equiv\sum_{k'}U_{k,k'}\langle\hat{c}^\dagger_{-k'}\hat{c}^\dagger_{k'}\rangle.\label{superpair}$$ The canonical transformation should act on Eq.(\[HR0’\]) rather than Eq.(\[HR0\]). Under the canonical transformation, i.e. substituting Eqs.(\[fieldoperator1\]-\[fieldoperator4\]) to Eqs.(\[HR\],\[HL\],\[HT\],\[HR0’\]), the Hamiltonians $H_{R0}$ and $H_L$ remain unchange with $\bar{H}_L ={\mathrm{e}}^S H_L {\mathrm{e}}^{-S} = H_L$ and $\bar{H}_{R0}= {\mathrm{e}}^S H_{R0} {\mathrm{e}}^{-S} = H_{R0}$. On the other hand, the Hamiltonians $H_{R}$ and $H_T$ change into: $$\begin{aligned}
\bar{H}_R&=& \bar{H}_{R0}
-\frac{\lambda^2}{\omega_p}\sum_{k,k'}\hat{c}^\dagger_k\hat{c}^\dagger_{k'}\hat{c}_{k'}\hat{c}_k
-\frac{\lambda^2}{\omega_p}\sum_{k}\hat{c}^\dagger_k\hat{c}_k
+\omega_pa^\dagger a , \label{mean2}\\
\bar{H}_T&=&
\sum_{k,k'}(T_0/\alpha){\mathrm{e}}^{-\frac{\lambda}{\omega_p}(\hat{a}^\dagger-\hat{a})}\hat{d}^\dagger_k\hat{c}_{k'}
+\mathrm{h.c.}.\label{8}\end{aligned}$$ By using the mean-field approximation same to what we have used in arriving at BCS Hamiltonian, Eq.(\[mean2\]) is reduced to $$\bar{H}_R=\sum_k\bar{\varepsilon}_k\hat{c}^\dagger_k\hat{c}_k+\omega_pa^\dagger a+\sum_k\bar{\Delta}_k\hat{c}_k\hat{c}_{-k}+\mathrm{h.c.},\label{9}$$ where $$\begin{aligned}
\bar{\Delta}_k &=& \Delta_k
+\frac{\lambda^2}{\omega_p}\langle \hat{c}^\dagger_k\hat{c}^\dagger_{-k}\rangle,\\
\bar{\varepsilon}_k &=&\varepsilon_k- {\lambda^2}/{\omega_p}.\end{aligned}$$ So, the transformed Hamiltonian $\bar{H} ={\mathrm{e}}^S H{\mathrm{e}}^{-S} $ reads $$\bar{H}= H_L+\bar{H}_T+\bar{H}_R.$$ In $\bar{H}$, instead of the complicated EPI term $\lambda(\hat{a}+\hat{a}^\dagger)\hat{c}_k^\dagger\hat{c}_k$, EPI only exists in $\bar{H}_T$ and can be eliminated by a mean-field approximation[@SunPhonon1; @PART1; @PAAR2] $${\mathrm{e}}^{-\frac{\lambda}{\omega_p}(\hat{a}^\dagger-\hat{a})}=\langle{\mathrm{e}}^{-\frac{\lambda}{\omega_p}(\hat{a}^\dagger-\hat{a})}\rangle={\mathrm{e}}^{-g(N+1/2)},\label{appro}$$ where $g=\lambda^2/\omega_p^2$ and $$N=\frac{1}{{\mathrm{e}}^{\omega_p/k_B \mathcal{T}}-1}\label{N}$$ stands for the number of phonon with the temperature $\mathcal{T}$. The approximation in Eq.(\[appro\]) includes all the irreducible self-energy of single normal lead-superconductor coupling ones and single EPI ones, only omits the high order of irreducible Feynman diagram which contain both normal lead-superconductor coupling and EPI. Eq.(\[appro\]) is exact at $T_0/\alpha=0$ or $\lambda=0$, and it is reasonable while $T_0/\alpha$ or $\lambda$ is the smallest energy scales, i.e $T_0/\alpha \ll \min(\lambda,\Delta)$ or $\lambda \ll \min(T_0/\alpha,\Delta)$.[@SunPhonon1; @PART1; @PAAR2] In addition, at the low temperature, the phonon number $N$ is small and the effective EPI is weak. So this approximation is more valid at the low temperature than at high temperature.

The Hamiltonian $\bar{H}$ is discretized to adapt to numerical calculation. Let $\varepsilon'_k=\frac{\hbar^2 k^2}{2m}-\epsilon_L$, $\bar{\varepsilon}_k=\frac{\hbar^2 k^2}{2m}-\epsilon_R$, $T_0=\frac{-1}{2ma_0^2}$, and the order parameter for p wave pairing could be set to $\bar{\Delta}_k=\Delta k$. These terms with $k$ and $k^2$ can be discretized by the following relation: $$\begin{aligned}
\sum_kkc_k^\dagger c_k&=&\sum_x\frac{-{\mathrm{i}}}{2a_0}[c^\dagger_xc_{x+1}-c^\dagger_xc_{x-1}],\label{de1}
\\
\sum_kk^2c_k^\dagger c_k&=&\sum_x\frac{-1}{a_0^2}[c^\dagger_xc_{x+1}-2c^\dagger_xc_x+c^\dagger_xc_{x-1}].\label{de2}\end{aligned}$$ In addition, by using the inverse Fourier transformation $\hat{d}_x=\sum_{k}{\mathrm{e}}^{-{\mathrm{i}}kx}\hat{d}_k$ and $\hat{c}_x=\sum_{k}{\mathrm{e}}^{-{\mathrm{i}}kx}\hat{c}_k$, we have $\hat{d}_0=\sum_{k} \hat{d}_k$ and $\hat{c}_0=\sum_{k}\hat{c}_k$. To combine Eqs.(\[de1\],\[de2\]) with the inverse Fourier transformation, the $\bar{H}$ can be discretized into the following form: $$\begin{aligned}
H_L&=&(\frac{1}{ma_0^2}-\epsilon_L)\hat{d}^\dagger_x\hat{d}_x-\frac{1}{2ma_0^2}\hat{d}^\dagger_{x+1}\hat{d}_x+\mathrm{h.c.}\nonumber\\
&&\hspace{6cm}x\leq0\label{dis1}\\
\bar{H}_R&=&(\frac{1}{ma_0^2}-\epsilon_R)\hat{c}^\dagger_x\hat{c}_x-\frac{1}{2ma_0^2}\hat{c}^\dagger_{x+1}\hat{c}_x+\frac{\Delta}{2a_0}\hat{c}_{x+1}\hat{c}_x+\mathrm{h.c.}\nonumber\\
&&\hspace{6cm}x\geq0\label{dis2}\\
\bar{H}_T&=&-\frac{1}{\alpha}\frac{1}{2 ma_0^2}{\mathrm{e}}^{-g(N+1/2)}\hat{c}^\dagger_0\hat{d}_0+\mathrm{h.c.}.\label{dis3}\end{aligned}$$ Here $a_0$ denotes the discretization length. The normal lead-superconductor interface is located at $x=0$.

![\[add\] The LDOS of finite p-wave superconductor of different length, coupling with normal conductor leads in both ends. The superconductor is discretized into 200 lattices in both panels (a) and (b), but the lattice lengths are different in (a) shorter system with $a_0=0.05$ and (b) longer system with $a_0=0.07$. ](figadd.eps){width="\linewidth"}

With Eq.(\[dis1\]-\[dis3\]) we can easily acquire the transformed Green’s function $\bar{\mathcal{G}}(x,x')$.[@Datta; @ZhangYT1; @YFZ] With the help of $\bar{\mathcal{G}}(x,x')$, we are able to achieve the LDOS $\rho(x,E)$ of phonon-coupled MZM as well as the tunneling spectroscopy $G(V)$. The explicit formulation is developed in the Appendix of this paper. The numerical investigations in LDOS and transporting property are detailed in Sec.\[result\], which are at the parameters of $m=0.025$, $a_0=0.05$, $\epsilon_R=15$, $\Delta=20$, $\epsilon_L=2000$, where the natural unit is adopted and the phonon frequency $\omega_p=1$ as the energy unit. At this group of parameters the superconducting gap is $E_\mathrm{gap}=28$.

Eqs.(\[dis1\]-\[dis3\]) describe the semi-infinite p-wave superconducting wire coupled with a normal conductor lead, which has topological edge states in the interface of the superconductor and normal conductor. If for a finite p-wave superconducting wire (or a finite p-wave superconducting wire coupled with two normal conductor leads, i.e. the normal conductor/finite p-wave superconducting wire/normal conductor system), there exist the Majorana zero modes in both end of the wire. Fig.\[add\] shows the LDOS of finite p-wave superconducting wire coupled with two normal conductors for the different length. In a short superconducting wire, the MZMs in both ends of the wire couple with each other, splitting in energy spectrum \[see Fig.\[add\](a)\]. On the other hand, for the long superconducting wire, the coupling between both ends vanishes, leaving an isolated MZM in each end of the wire \[see Fig.\[add\](b)\]. This clearly indicates the existence of the MZM in the interface of the superconductor and normal conductor.

\[result\]result
================

\[sec31\]mechanism
------------------

![\[model\] (a-c) Diagrams of Andreev reflections concerning with 0, 1, 2 phonons, respectively. The wavy line represents the phonon propagator, and the blue and red lines represent electrons and holes respectively. (d) The MZM is expanded in energy by normal lead-superconductor coupling and plays a role of electron-hole exchange channel. There exist a series of subchannels which are integer number of phonon frequencies apart from the MZM. Electrons in subchannel can pass through the MZM channel by absorbing and emitting phonons. The transparency of each channel is expressed by the color.](fig00.eps){width="\linewidth"}

![\[fig1\] (a) The LDOS $\rho(x,E)$ presents several stripes, referring to the channels in Fig.\[model\](d). Logarithmic color bar is applied to exaggerate the existence of narrow stripes. (b) The space distribution of the stripes. The curve $A_n$ is extracted from (a) along the track of $E=n\omega_p$. The shape of $A_n$s are exactly the same but vary in scale. The normal lead-superconductor interface is at x=0.](fig1.eps){width="\linewidth"}

In condition of weak tunneling and small bias comparing to the superconducting gap, the normal current through the normal lead-superconductor junction is blocked, and the current flow is dominated by superconducting current which comes from Andreev reflection at the MZM. In this case the normal lead can be viewed as a combination of an electron lead and a hole lead and the normal lead-superconductor junction can be viewed as a two terminal system \[Fig.\[device\](b)\]. The superconductor lead is suspended and the remaining electron-lead/MZM/hole-lead structure constitutes a resonance tunneling system (i.e., the Majorana induced resonance Andreev reflection) in which the MZM plays the role of the quantum dot.[@QD1] The electron and hole leads are coupled to the MZM with the same tunneling strength, leading to a perfect tunneling at $V=0$, i.e., the zero-bias peak in the tunneling spectroscopy. Here the MZM acts as an electron-hole channel at zero energy. This e-h channel is broadened in energy by the coupling of the normal lead to MZM, which presents in the tunneling spectroscopy as the widening of the zero-bias peak. Figure.\[model\](a) gives the diagram of the Majorana induced resonance Andreev reflection. While $\omega_0=0$ is in the e-h channel of MZM, Fig.\[model\](a) has a non-vanishing contribution, leading to an Andreev reflection.

Electrons outside the MZM channel are unable to participate an Andreev reflection unless with the help of phonons. The single phonon process is presented in Fig.\[model\](b). If the energy of electron is $\omega_p$ away from $\omega_0=0$, this electron can also participate the process in Fig.\[model\](a) by emitting a phonon. The multi phonon processes are similar, that an electron whose energy is $n\omega_p$ away from $\omega_0$ can go through the process in Fig\[model\](a) by emitting $n$ phonons. Figure.\[model\](c) gives an example of $n=2$ case.

![image](fig2.eps){width="\textwidth"}

The no-phonon, single-phonon, and multi-phonon processes in Fig.\[model\](a-c) are summarized in Fig.\[model\](d), which gives a understandable picture of phonon-assisted Andreev reflection at MZM. The phonon-coupled MZM is a series of e-h channels, and the $n$th channel locates at $E=n\hbar\omega_p$. The 0th channel is just the broadened MZM which is perfectly transparent. The non-zeroth channels, on the other hand, are the copies of the 0th channel. An electron in the $n$th channel has a chance to take road of the 0th channel by emitting or absorbing $n$ phonons. For this reason all channels have the same width $W$ originating from the 0th channel. In the case of weak EPI, the multi phonon process is infrequent so that the high order channels are nearly blocked.

\[spfu\]Local Density of States
-------------------------------

The channels in Fig.\[model\](d) can be directly recognized in the LDOS $\rho(x,E)$, which is defined by Eq.(\[defA\]) in the Appendix A. The LDOS $\rho(x,E)$ gives the probability of the electron at position $x$ having the energy of $E$. In Fig.\[fig1\](a) we numerically solve the $\rho(x,E)$ with $g=0.6$, $\alpha=4$, $\mathcal{T}=0$ in units of $\rho_0=\frac{a_0\omega_p}{10000}$. The bias voltage $V$ which exists in Eq.(\[Aexp\]) in form of $\mu$ ($\mu=eV$) actually has no effect on $\rho$, because the average Fermi level of electron-lead and hole-lead is always 0 at every $V$ and exactly aligns to the MZM. Since the bulk gap $E_\mathrm{gap}\gg E$ in the concerned region and the tunneling is weak enough to suppress the influence of bulk states near the MZM, the electron-hole symmetry is conserved, and $\rho(x,E)$ presents a series of narrow stripes near the normal lead-superconductor interface. The $n$th stripe is at the position of $E=n\omega_p$, which is related to an n-phonons process at the MZM. The total integral of these stripes are $\frac{1}{2}$, which is corresponding to one Majorana fermion, and is equivalent to half a Fermion.[@Kitaev] Because of the negligible momentum, the long wave phonon splits MZM in energy spectrum but has little influence in the space distribution, i.e., the space distribution are the same for every stripes, which are shown in Fig.\[fig1\](b). The stripes have the same profile but decline in scale with the raise of $n$, because in the condition of weak EPI the multi phonon process is hard to achieve.

![\[fig3\] The height of the $n$th LDOS peak $h_n$ varies with the EPI strength $g$ at the temperature $\mathcal{T}=0$ (a) and $\mathcal{T}=1$ (b). At $g=0$ only $h_0$ is nonzero. For every $n$, $h_n$ increase with $g$, but the increasement at $\mathcal{T}=1$ is much intenser than $\mathcal{T}=0$. Moreover, the ratio $h_1/h_0$ and $h_2/h_0$ are larger at $\mathcal{T}=1$ than $\mathcal{T}=0$. (c) The width of MZM peak varies with temperature $\mathcal{T}$ at different $g$. These curves have similar profile with the phonon distribution \[Eq.(\[N\])\].](fig3.eps){width="\linewidth"}

![image](fig4.eps){width="\textwidth"}

The transport property is dependent on the energy distribution $\rho(E)$ near the normal lead-superconductor interface, which is shown in Fig.\[fig2\]. However, Fig.\[fig1\](b) indicates that $\rho(E)\equiv0$ at the exact $x=0$ position, so the average $\rho(E)$ over the small lattice $a_0$ next to the interface, $\rho(E) =\frac{1}{a_0} \int_0^{a_0} \rho(x,E)dx$, is shown in Fig.\[fig2\]. Since the space distributions for every stripe are in the same shape, Fig.\[fig2\] honestly reflects the energy distribution near the interface. The overall outline of $\rho(E)$ is shown in Fig.\[fig2\](a), in which the cross section of stripes in Fig.\[fig1\](a) are turned into peaks. The peaks in $\rho(E)$ represent the electron-hole channels by which electrons participate Andreev reflection and generate superconducting current. Figure.\[fig2\](b-d) zoom in on the 0th-2nd peaks. The LDOS is influenced by normal lead-superconductor coupling strength $1/\alpha$, EPI factor $g$ and temperature $\mathcal{T}$. The coupling strength $1/\alpha$ directly broadens the MZM in energy from a delta-type function to a Lorentzian curve, so it directly affects the width of each peak. The EPI factor $g$ and temperature $\mathcal{T}$ suppress the effective normal lead-superconductor coupling in $\bar{H}_T$ by a suppression factor ${\mathrm{e}}^{-g(N+1/2)}$ and narrow the peaks. However, the EPI also appears in the coefficient $L_n$\[Eq.(\[Ln\])\], which redistributes the weights of each phonon peak. So $g$ and $\mathcal{T}$ change the areas of each peak but $\alpha$ does not. With the decrease of EPI, the LDOS is centralizing in the main peak. When the EPI is absent, all phonon sidebands are absorbed in the central peak.

The influence of EPI on LDOS is studied in Fig.\[fig3\]. The height of LDOS peak $h_n\equiv \rho(n\omega_p)$ describes the possibility of electron at the energy of $n\omega_p$, corresponding to a $n$-phonon process. At $g=0$ where EPI is absent, $h_n=0$ for all nonzero $n$. From Fig.\[fig3\](a) and (b), we can see that all $h_n$s raise with the EPI strength $g$ for two different reasons: the suppression in effective coupling strength between the normal lead and superconductor (see $\bar{H}_T$) and the redistribution among the peaks. The increase of $h_0$ is because of the suppression of the effective coupling strength, which narrow the peaks. On the other hand for nonzero $n$, the raise of the peak height $h_n$ is due to not only the suppression of the effective coupling strength but also the inter peak redistribution. The increase of $h_n$ with $g$ is much intenser at the temperature $\mathcal{T}=1$ than $\mathcal{T}=0$. The primary reason for this difference is about the coupling strength suppression, because $h_0$ also soars at $\mathcal{T}=1$ which is irrelevant to the inter peak redistribution. The suppression factor ${\mathrm{e}}^{-g(N+1/2)}$ is much smaller at finite temperature since the phonon number $N$ is positive comparing to $N=0$ at zero temperature. However, the inter peak redistribution also differs between the temperature $\mathcal{T}=0$ and $\mathcal{T}=1$. It is obvious that the ratio $h_1/h_0$ and $h_2/h_0$ raise faster at $\mathcal{T}=1$ than $\mathcal{T}=0$, which mean the single-phonon and bi-phonon processes happen more frequently at the higher temperature. This is reasonable since at zero temperature electron can only emit phonons and transmit phonons to itself, while at finite temperature electron can also absorb phonons from the environment. While the height of peaks is under the co-effect of the suppression of effective coupling strength and inter peak redistribution, the width of peaks directly reflects the effective coupling strength \[see Fig.\[fig3\](c)\]. The widths vary slowly at the low temperature region and then begin to drop. These $W$-$\mathcal{T}$ curves have a similar profile with the Boson distribution of phonons \[Eq.(\[N\])\], because the influence of temperature on width just appears in the effective coupling strength at $\bar{H}_T$ in form of $N$.

\[cond\]conductance
-------------------

![\[fig5\] (a) Tunneling spectroscopy at different EPI strength $g$ with $\alpha=4$ and $\mathcal{T}=0$. (b) The heights of conductance peaks vary with $g$ at zero temperature. The height of $n$th conductance peak $h_n$ is proportional to $g^n$.](fig5.eps){width="\linewidth"}

In Fig.\[fig4\], we investigate the effects of the reversed coupling strength $\alpha$ and temperature $\mathcal{T}$ on the tunneling spectroscopy. The differential conductance $G(V)=\frac{{\mathop{}\!\mathrm{d}}I}{{\mathop{}\!\mathrm{d}}V}$ presents a series of peaks at $V=n\omega_p$ which just resembles the LDOS. The resemblance also exist in the effect of the reversed coupling strength $\alpha$, that the peaks narrow with the increase of $\alpha$. In fact, at zero temperature the width of peaks in $G(V)$ is exactly the same with its counterpart in $\rho(E)$, since the Fermi distribution for electrons is reduced to a step function $\theta(E-V)$. The energy distribution is uniform away from $E=V$, so that the electron number in a channel varies only if the bias $V$ is varying in this channel. On the other hand, peaks in $G(V)$ are severely broadened and the heights of peaks are strongly reduced at finite temperature, while the channel itself is slightly narrowed \[see Fig.\[fig2\]\]. This is because of the thermal broadening effect. The thermal broadening is much stronger than the EPI-induced channel narrowing, which leads to the different thermal behavior of $\rho(E)$ and $G(V)$.

Another difference between $\rho(E)$ and $G(V)$ is that the heights of peaks vary with the reversed coupling strength $\alpha$ in $\rho(E)$ but do not in $G(V)$. While normal lead-superconductor coupling strength $1/\alpha$ broadens the MZM, it has no effect on the height of zero-bias peak, because whatever the effective coupling strength in $\bar{H}_T$ is, it stands for the coupling term of both electron and hole leads, so the e-h tunneling is always resonance at $V=0$, which means a complete Andreev reflection and $G(0)=2e^2/h$. The middle of the 0th e-h channel, for this reason, is perfect transparent. In some experiments, the suppression of the height of the zero-bias peak happens.[@ZBPep9; @ZBPep5] Here we can exclude the influence of the phonons on the suppression. The behavior of the zero-bias peak is very different with the photon-assisted Majorana induced resonance Andreev reflection, in which the height of the $0$th peak of the conductance is reduced by the time-periodic potential.[@WP1] The transport in non-zeroth channel is achieved by absorbing and emitting phonons and taking the road of the 0th channel. So the transparency in the middle of the $n$th channel is only related to EPI but irrelevant to the normal lead-superconductor coupling strength $1/\alpha$. The influence of EPI on transport property is presented in Fig.\[fig5\]. When EPI is absent, there is only a zero-bias peak in the tunneling spectroscopy $G(V)$. With the increase of EPI strength $g$, non-zeroth peaks come out at $V=n\omega_p$ \[see Fig.\[fig5\](a)\]. The width of peaks in $G(V)$ narrows with the increase of $g$ for the EPI-induced channel narrowing. Meanwhile the heights of phonon sidebands $h_n=G(n\omega_p)$ rise with $g$, which is illustrated in Fig.\[fig5\](b). At zeros temperature and at the small EPI strength $g$, the height of $n$th peak $h_n$ obeys the rule of $$h_n\propto g^n.\label{Ghigh}$$ This relation can be accounted for the following explanation: In the condition of weak EPI, the probability of $n$-phonon process is proportional to $\lambda^n$. Take Fig.\[model\](b) as an example. This diagram stands for single phonon process and contains one wavy line corresponding to $\lambda^1$. The diagram represents the scattering coefficient $s_{eh}$, and the conductance $G\propto|s_{eh}|^2$. So the 1st conductance peak $h_1\propto\lambda^2\propto g^1$. Similarly, the $n$th conductance peak $h_n\propto\lambda^{2n}\propto g^{n}$. However, for the large EPI strength $g$, the conductance peaks $h_n$ will deviate from this proportional relationship ($h_n\propto g^{n}$), because the conductance can not exceed $2e^2/h$.

\[sec4\]conclusion
==================

In order to investigate the influence of electron-phonon interaction on the Majorana induced resonance Andreev reflection, a normal lead-superconductor junction is studied in this paper, of which a single long wave phonon mode is coupled to the superconductor. With the help of canonical transformation and mean-field approximation, a non-equilibrium Green’s function method is developed for numerical research on this junction. The Andreev reflection in the normal lead-superconductor junction can be viewed as resonance tunneling from electron lead to hole lead, where Majorana zero mode (MZM) plays the role of e-h channel. With the phonon mode coupling, a series of subchannels at $E=n\omega_p$ are derived from the MZM channel with the same width but different transparency. Electron in the subchannel can take the road of the MZM channel by emitting and absorbing phonons. These channels are presented in LDOS $\rho(x,E)$ as a series of stripes. The stripes are same in space distribution but different in scale. These stripes are reduced to peaks in energy distribution $\rho(E)$ near the normal lead-superconductor interface. The lead-superconductor coupling strength broadens these peaks, while electron-phonon interaction has two effects on these peaks. One is the suppression in effective coupling strength which narrows the width and raise the height. The other one is the inter peak redistribution which changes the weights of every peak. The tunneling spectroscopy presents conductance peaks similar to LDOS. At zero temperature the width of peaks are the same in tunneling spectroscopy and LDOS. At finite temperature, while the peaks in LDOS are slightly narrowed for the increase of phonon number, the conductance peaks are severely broadened and strongly reduced for thermal broadening effect. The height of the $n$th conductance peak is proportional to $g^n$ at zero temperature and weak electron-phonon interaction strength $g$, presenting a feature of multi phonon process.

acknowledgments {#acknowledgments .unnumbered}
===============

This work was financially supported by National Key R and D Program of China (Grant No. 2017YFA0303301), NBRP of China (Grant No. 2015CB921102), NSF-China (Grant No. 11574007), the Strategic Priority Research Program of Chinese Academy of Sciences (Grant No. XDB28000000), and Beijing Municipal Science & Technology Commission (Grant No.Z181100004218001).

spectral function
=================

In this Appendix A, we deduce the expression of the spectral function. Using $\langle\langle\cdots\rangle\rangle$ and $\overline{\langle\langle\cdots\rangle\rangle}$ to denote the Green’s function of $H$ and $\bar{H}$, respectively, their relation is presented below:[@Mahan; @FTF6; @PART1; @PAAR2] $$\begin{aligned}
\langle\langle \hat{c}_x|\hat{c}^\dagger_x\rangle\rangle^<(\omega)=\sum_nL_n\overline{\langle\langle \hat{c}_x|\hat{c}^\dagger_x\rangle\rangle^<}(\omega+n\omega_p)\label{<},\\
\langle\langle \hat{c}_x|\hat{c}^\dagger_x\rangle\rangle^>(\omega)=\sum_nL_n\overline{\langle\langle \hat{c}_x|\hat{c}^\dagger_x\rangle\rangle^>}(\omega-n\omega_p)\label{>}.\end{aligned}$$ The coefficient $L_n$ can be expressed by the $n$th modified Bessel function of first kind $I_n$:[@Mahan; @FTF6; @PART1; @PAAR2] $$L_n={\mathrm{e}}^{-g(2N+1)}{\mathrm{e}}^{n\omega_p\beta/2}I_n(2g\sqrt{N(N+1)}),\label{Ln}$$ with $\beta=1/k_B \mathcal{T}$.

The spectral function, i.e., the LDOS in the superconducting lead is defined as $$\rho(x,\omega)=\frac{{\mathrm{i}}}{2{\mathrm{\pi}}}[\langle\langle \hat{c}_x|\hat{c}^\dagger_x\rangle\rangle^>(\omega)-\langle\langle \hat{c}_x|\hat{c}^\dagger_x\rangle\rangle^<(\omega)],\label{defA}$$ which can be expressed by the transformed Green’s function $$\begin{aligned}
\rho(x,\omega)&=&\frac{{\mathrm{i}}}{2{\mathrm{\pi}}}\sum\limits_n L_n \left[\overline{\langle\langle \hat{c}_x|\hat{c}^\dagger_x\rangle\rangle}^>(\omega-n\omega_p) \right.\nonumber \\
&&\left.-\overline{\langle\langle \hat{c}_x|\hat{c}^\dagger_x\rangle\rangle}^<(\omega+n\omega_p)\right].\label{A0}\end{aligned}$$ Hereafter the parameter $\omega$ is omitted if it does not lead to confusion. Introduce the Nambu representation, and let[@SunAR3] $$\bar{\mathcal{G}}(x,x')\equiv\begin{pmatrix}
\overline{\langle\langle \hat{c}_x|\hat{c}^\dagger_{x'}\rangle\rangle}&\overline{\langle\langle \hat{c}_x|\hat{c}_{x'}\rangle\rangle}\\
\overline{\langle\langle \hat{c}^\dagger_x|\hat{c}^\dagger_{x'}\rangle\rangle}&\overline{\langle\langle \hat{c}^\dagger_x|\hat{c}_{x'}\rangle\rangle}
\end{pmatrix}\label{Nam}$$ to be the Green’s function of $\bar{H}$ in Nambu representation. With the help of Eq.(\[dis1\]-\[dis3\]), we can directly achieve the retarded and advanced Green’s function $\bar{\mathcal{G}}^{r/a}$. The relations between the greater/lesser Green’s function to the retarded/advanced one are Keldysh equation[@NEGF1] $$\begin{aligned}
\bar{\mathcal{G}}^<={\mathrm{i}}\bar{\mathcal{G}}^rf_L\bar{\Gamma}^L\bar{\mathcal{G}}^a\label{G<},\\
\bar{\mathcal{G}}^>=\bar{\mathcal{G}}^<-{\mathrm{i}}\bar{\mathcal{A}}\label{G>},\\
\bar{\mathcal{A}}\equiv{\mathrm{i}}[\bar{\mathcal{G}}^r-\bar{\mathcal{G}}^a].\label{A}\end{aligned}$$ Here $f_L$ represents the Fermi distribution in the normal lead $$f_L(\omega)=\begin{bmatrix}
f(\omega-\mu)& 0 \\
0& f(\omega+\mu),
\end{bmatrix}$$ where $f(\omega)\equiv {1}/\{ {\mathrm{e}}^{{\omega}/{k_B \mathcal{T}}}+1\}$ and the chemical potential $\mu$ is controlled by bias voltage $V$ that $$\mu\equiv eV/\hbar.$$ The transformed linewidth function is defined as $$\bar{\Gamma}^L=\begin{bmatrix}
{\mathrm{i}}|\bar{T}_t|^2(\langle\langle \hat{d}_0|\hat{d}^\dagger_0\rangle\rangle_0^r-\langle\langle \hat{d}_0|\hat{d}^\dagger_0\rangle\rangle_0^a) & 0 \\
\hspace{-2cm}0 & \hspace{-2cm}{\mathrm{i}}|\bar{T}_t|^2(\langle\langle \hat{d}^\dagger_0|\hat{d}_0\rangle\rangle_0^a-\langle\langle \hat{d}^\dagger_0|\hat{d}_0\rangle\rangle_0^r)\label{tgamma}
\end{bmatrix}$$ where $\langle\langle\cdots\rangle\rangle_0$ stands for the Green’s function of an isolated $H_L$. Here $\bar{T}_t=T_t{\mathrm{e}}^{-g(N+1/2)}$ and $T_t=\frac{1}{\alpha}\frac{1}{ma_0^2}$ which is the tunneling term in Eq.(\[dis3\]). The surface Green’s function $\langle\langle \hat{d}_0|\hat{d}^\dagger_0\rangle\rangle_0^{r/a}$ can be solved directly from Eq.(\[dis1\]), so are $\bar{\Gamma}^L$.

Substituting Eqs.(\[G<\],\[G>\]) into Eq.(\[A0\]), we have arrived at a numerical solvable expression of LDOS: $$\begin{aligned}
\rho(\omega)&=&\frac{1}{2{\mathrm{\pi}}}\sum\limits_{n}\left[L_n\bar{\mathcal{A}}(\omega_{-n})\right.\label{Aexp}\\
&+&\left.(L_{-n}-L_n)\mathcal{\bar{G}}^r(\omega_{-n})f_L(\omega_{-n})
\bar{\Gamma}^L(\omega_{-n})\mathcal{\bar{G}}^a(\omega_{-n})\right]_{11} \nonumber\end{aligned}$$ where $\omega_n =\omega+n\omega_p$ and the subscript “11" represents the “11" element of the matrix.

\[con\]conductance
==================

In the Appendix B, we deduce the formulation for the conductance. The electric current from the normal lead flowing into the superconductor is the time derivative of the electron number $N_L =\sum_{k} \hat{d}_k^{\dagger} \hat{d}_k$, that[@SunAR3; @NEGF2] $$I=-e\langle\dot{N}_L\rangle=-\frac{2e}{\hbar}\sum_{k,k'}\mathrm{Re}T_t\langle\langle \hat{d}_{k'}(t)|\hat{c}^\dagger_k(t)\rangle\rangle^<.\label{cur}$$ With the help of the motion equation, the Green’s function of interacting system $\langle\langle \hat{d}_{k'}|\hat{c}^\dagger_k\rangle\rangle^<(\omega)$ can be reduced to[@SunAR3; @NEGF2] $$\begin{aligned}
    \langle\langle \hat{d}_{k'}|\hat{c}^\dagger_k\rangle\rangle^<&=&\langle\langle \hat{d}_{k'}|\hat{d}^\dagger_{k'}\rangle\rangle_0^rT_t\sum_{k''}\langle\langle \hat{c}_{k''}|\hat{c}^\dagger_k\rangle\rangle^<\nonumber\\
    &+&\langle\langle \hat{d}_{k'}|\hat{d}^\dagger_{k'}\rangle\rangle_0^<T_t\sum_{k''}\langle\langle \hat{c}_{k''}|\hat{c}^\dagger_k\rangle\rangle^a.\label{motion}\end{aligned}$$ Substituting Eq.(\[motion\]) into Eq.(\[cur\]) and transforming to the discrete Hamiltonian in the real space, we arrive at $$\begin{aligned}
I&=&-\frac{2e}{h}\int{\mathop{}\!\mathrm{d}}\omega|T_t|^2\mathrm{Re}[\langle\langle \hat{d}_0|\hat{d}^\dagger_0\rangle\rangle_0^r\langle\langle \hat{c}_0|\hat{c}^\dagger_0\rangle\rangle^<\nonumber\\
&&+\langle\langle \hat{d}_0|\hat{d}^\dagger_0\rangle\rangle_0^<\langle\langle \hat{c}_0|\hat{c}^\dagger_0\rangle\rangle^a].\label{curr}\end{aligned}$$ Here $\hat{d}_0 (\hat{d}_0^{\dagger})$ and $\hat{c}_0 (\hat{c}_0^{\dagger})$ are the annihilation (creation) operators at the end of the normal lead and superconductor, respectively. Introducing the linewidth function corresponding to Eq.(\[tgamma\]) $$\Gamma^L=\begin{bmatrix}
{\mathrm{i}}|T_t|^2(\langle\langle \hat{d}_0|\hat{d}^\dagger_0\rangle\rangle_0^r-\langle\langle \hat{d}_0|\hat{d}^\dagger_0\rangle\rangle_0^a) & 0 \\
\hspace{-2cm}0 & \hspace{-2cm}{\mathrm{i}}|T_t|^2(\langle\langle \hat{d}^\dagger_0|\hat{d}_0\rangle\rangle_0^a-\langle\langle \hat{d}^\dagger_0|\hat{d}_0\rangle\rangle_0^r)
\end{bmatrix}$$ and applying the fluctuation-dispassion theorem on $\langle\langle \hat{d}_0|\hat{d}^\dagger_0\rangle\rangle_0^<$, combining with $$\langle\langle \hat{c}_0|\hat{c}^\dagger_0\rangle\rangle^r-\langle\langle \hat{c}_0|\hat{c}^\dagger_0\rangle\rangle^a=\langle\langle \hat{c}_0|\hat{c}^\dagger_0\rangle\rangle^>-\langle\langle \hat{c}_0|\hat{c}^\dagger_0\rangle\rangle^<,$$ and Eqs.(\[<\],\[>\],\[Nam\]), the Eq.(\[curr\]) is reduced to $$\begin{aligned}
I&=&\frac{{\mathrm{i}}e}{h}\sum_nL_n\int\{\Gamma^L[(1-f_L(\omega))\bar{\mathcal{G}}^<(\omega_n)\nonumber\\
&&+f_L(\omega)\bar{\mathcal{G}}^>(\omega_{-n})]\}_{11}{\mathop{}\!\mathrm{d}}\omega.\end{aligned}$$ Substituting Eqs.(\[G<\],\[G>\],\[A\]), we get a solvable expression of electric current:

$$\begin{aligned}
I&=&\frac{e}{h}\int{\mathop{}\!\mathrm{d}}\omega\sum_n
 \left\{L_{-n}\Gamma^L(\omega)f_L(\omega)\bar{\mathcal{A}}(\omega_n)
 -\Gamma^L(\omega)[L_n+(L_{-n}-L_n)f_L(\omega)]
  \mathcal{\bar{G}}^r(\omega_n)f_L(\omega_n)\bar{\Gamma}^L(\omega_n)
  \mathcal{\bar{G}}^a(\omega_n)\right\}_{11}\nonumber\\
&=&\frac{e}{h}\int{\mathop{}\!\mathrm{d}}\omega\sum_n \left\{L_{-n}\Gamma^L_{11}(\omega)f(\omega-\mu)
 \bar{\mathcal{A}}_{11}(\omega_n) \right.\nonumber\\
&-&\left.\Gamma^L_{11}(\omega)[L_n+(L_{-n}-L_n)f(\omega-\mu)]
\left[\mathcal{\bar{G}}_{11}^r(\omega_n)f(\omega_n-\mu)\bar{\Gamma}^L_{11}(\omega_n)
 \mathcal{\bar{G}}_{11}^a(\omega_n)
+\mathcal{\bar{G}}_{12}^r(\omega_n)f(\omega_n+\mu)\bar{\Gamma}^L_{22}(\omega_n)
 \mathcal{\bar{G}}_{21}^a(\omega_n)\right]\right\} . \label{fincur}\end{aligned}$$

Then, the differential conductance $G(V) \equiv {{\mathop{}\!\mathrm{d}}I}/{{\mathop{}\!\mathrm{d}}V} $ is $$\begin{aligned}
 G(V)&=&
 \frac{e^2}{h}\frac{1}{T}\int{\mathop{}\!\mathrm{d}}\omega\sum_n
 \left\{L_{-n}\Gamma^L(\omega)\sigma_z
  f_L(\omega)(1-f_L(\omega))\bar{\mathcal{A}}(\omega_n)\right.\nonumber\\
&-&\Gamma^L(\omega)[L_n+(L_{-n}-L_n)f_L(\omega)]\mathcal{\bar{G}}^r(\omega_n)\sigma_zf_L(\omega_n)
(1-f_L(\omega_n))\bar{\Gamma}^L(\omega_n)\mathcal{\bar{G}}^a(\omega_n)\\
&-&\left.\Gamma^L(\omega)(L_{-n}-L_n)\sigma_zf_L(\omega)(1-f_L(\omega))
 \mathcal{\bar{G}}^r(\omega_n)f_L(\omega_n)\bar{\Gamma}^L(\omega_n)\mathcal{\bar{G}}^a(\omega_n)
\right\}_{11}.\nonumber\end{aligned}$$ In particular, at zero temperature the differential conductance $G(V)$ reduces into: $$\begin{aligned}
G(V) &=&
 \frac{e^2}{h}\left\{\sum_nL_{-n}\Gamma^L_{11}(\mu)\bar{\mathcal{A}}_{11}(\mu_n)
-\sum_n\Gamma^L_{11}(\mu_{-n})L_n\mathcal{\bar{G}}_{11}^r(\mu)\bar{\Gamma}^L_{11}(\mu)\mathcal{\bar{G}}_{11}^a(\mu)
\right.\nonumber\\
&&-\sum_{n\leq0}\Gamma^L_{11}(\mu)(L_{-n}-L_n)\mathcal{\bar{G}}_{11}^r(\mu_n)\bar{\Gamma}^L_{11}(\mu_n)
  \mathcal{\bar{G}}_{11}^a(\mu_n)
-\sum_{n>0}\Gamma^L_{11}(\mu_{-n})(L_{-n}-L_n)\mathcal{\bar{G}}_{11}^r(\mu)\bar{\Gamma}^L_{11}(\mu)\mathcal{\bar{G}}_{11}^a(\mu)\nonumber\\
&&+\sum_n\Gamma^L_{11}(-\mu_n)L_n\mathcal{\bar{G}}_{12}^r(-\mu)\bar{\Gamma}^L_{22}(-\mu)\mathcal{\bar{G}}_{21}^a(-\mu)
-\sum_{n<n_0}\Gamma^L_{11}(\mu)(L_{-n}-L_n)\mathcal{\bar{G}}_{12}^r(\mu_n)\bar{\Gamma}^L_{22}(\mu_n)
 \mathcal{\bar{G}}_{21}^a(\mu_n)\nonumber\\
&&+\left.\sum_{n>n_0}\Gamma^L_{11}(-\mu_n)(L_{-n}-L_n)\mathcal{\bar{G}}_{12}^r(-\mu)\bar{\Gamma}^L_{22}(-\mu)\mathcal{\bar{G}}_{21}^a(-\mu)
\right\},\end{aligned}$$ where $\mu_n=\mu+n\omega_p$ and $n_0=-\frac{2\mu}{\omega_p}$.

[1]{} C. W. J. Beenakker, in Annual Review of Condensed Matter Physics, Vol 4, edited by J. S. Langer (Annual Reviews, Palo Alto, 2013), pp. 113.

M. Z. Hasan and C. L. Kane, Rev. Mod. Phys. **82**, 3045 (2010).

R. M. Lutchyn, J. D. Sau, and S. Das Sarma, Phys. Rev. Lett. **105**, 077001 (2010).

X.-L. Qi and S.-C. Zhang, Rev. Mod. Phys. **83** (2011).

R. Aguado, Riv. Nuovo Cimento 40, 523 (2017).

D. A. Ivanov, Phys. Rev. Lett. **86**, 268 (2001).

A. L. R. Manesco, G. Weber, and D. Rodrigues, Jr., IEEE Trans. Appl. Supercond. **28**, 1700105 (2018).

N. Read and D. Green, Phys. Rev. B **61**, 10267 (2000).

A. P. Schnyder, S. Ryu, A. Furusaki, and A. W. W. Ludwig, Phys. Rev. B **78**, 195125 (2008).

L. Fu and C. L. Kane, Phys. Rev. Lett. **100**, 096407 (2008).

Y. Oreg, G. Refael, and F. von Oppen, Phys. Rev. Lett. **105**, 177002 (2010).

A. R. Akhmerov, J. P. Dahlhaus, F. Hassler, M. Wimmer, and C. W. J. Beenakker, Phys. Rev. Lett. **106**, 057001 (2011).

L. Fu and C. L. Kane, Phys. Rev. Lett. **102**, 216403 (2009).

W.-J. Gong, S.-F. Zhang, Z.-C. Li, G. Yi, and Y.-S. Zheng, Phys. Rev. B **89**, 245413 (2014).

P. Wang, J. Liu, Q.-F. Sun, and X.C. Xie, Phys. Rev. B **91**, 224512 (2015).

K. T. Law, P. A. Lee, and T. K. Ng, Phys. Rev. Lett. **103**, 237001 (2009).

V. Mourik, K. Zuo, S. M. Frolov, S. R. Plissard, E. P. A. M. Bakkers, and L. P. Kouwenhoven, Science **336**, 1003 (2012).

M. T. Deng, C. L. Yu, G. Y. Huang, M. Larsson, P. Caroff, and H. Q. Xu, Nano. Lett. **12**, 6414 (2012).

H. O. H. Churchill, V. Fatemi, K. Grove-Rasmussen, M. T. Deng, P. Caroff, H. Q. Xu, and C. M. Marcus, Phys. Rev. B **87**, 241401 (2013).

M. T. Deng, S. Vaitiekenas, E. B. Hansen, J. Danon, M. Leijnse, K. Flensberg, J. Nygard, P. Krogstrup, and C. M. Marcus, Science **354**, 1557 (2016).

A. D. K. Finck, D. J. Van Harlingen, P. K. Mohseni, K. Jung, and X. Li, Phys. Rev. Lett. **110**, 126406 (2013).

O. Gul et al., Nat. Nanotech. **13**, 192 (2018).

R. M. Lutchyn, E. Bakkers, L. P. Kouwenhoven, P. Krogstrup, C. M. Marcus, and Y. Oreg, Nat. Rev. Mater. **3**, 17 (2018).

T. D. Stanescu, R. M. Lutchyn, and S. Das Sarma, Phys. Rev. B **90**, 085302 (2014).

J. Liu, A. C. Potter, K. T. Law, and P. A. Lee, Phys. Rev. Lett. **109**, 267002 (2012).

F. Setiawan, C.-X. Liu, J. D. Sau, and S. Das Sarma, Phys. Rev. B **96**, 184520 (2017).

H. Zhang, C. X. Liu, S. Gazibegovic, D. Xu, J. A. Logan, G. Z. Wang, N. van Loo, J. D. S. Bommer, M. W. A. de Moor, D. Car, Rlmoh Veld, P. J. van Veldhoven, S. Koelling, M. A. Verheijen, M. Pendharkar, D. J. Pennachio, B. Shojaei, J. S. Lee, C. J. Palmstrom, Epam Bakkers, S. Das Sarma, L. P. Kouwenhoven, Nature **556**, 74 (2018).

V. J. Goldman, D. C. Tsui, and J. E. Cunningham, Phys. Rev. B **36**, 7635 (1987).

L. Kleinman, Phys. Rev. **140**, A637 (1965).

S. Makram-Ebeid and M. Lannoo, Phys. Rev. B **25**, 6406 (1982).

N. S. Wingreen, K. W. Jacobsen, and J. W. Wilkins, Phys. Rev. Lett. **61**, 1396 (1988).

Q.-F. Sun and X.C. Xie, Phys. Rev. B **75**, 155306 (2007).

J. Song, Q.-F. Sun, J. Gao, and X.C. Xie, Phys. Rev. B **75**, 195320 (2007).

J. Bardeen, L. N. Cooper, and J. R. Schrieffer, Phys. Rev. **108**, 1175 (1957).

P. Morel and P. W. Anderson, Phys. Rev. **125**, 1263 (1962).

S.-N. Zhang, W. Pei, T.-F. Fang, and Q.-F. Sun, Phys. Rev. B **86**, 104513 (2012).

P. Stadler, W. Belzig, and G. Rastelli, Phys. Rev. Lett. **117**, 197202 (2016).

P. Stadler, W. Belzig, and G. Rastelli, Phys. Rev. B **96**, 045429 (2017).

J. Gramich, A. Baumgartner, and C. Sch$\ddot{o}$nenberger, Phys. Rev. Lett. **115**, 216801 (2015).

Z. Cao, T.-F. Fang, Q.-F. Sun, and H.-G. Luo, Phys. Rev. B **95**, 121110 (2017).

Z. Z. Chen, R. Lu, and B. F. Zhu, Phys. Rev. B **71**, 165324 (2005).

M. Galperin, A. Nitzan, and M. A. Ratner, Phys. Rev. B **73**, 13, 045314 (2006).

Y. Song and S. Das Sarma, Phys. Rev. B **98**, 075159 (2018).

A. Kitaev, Phys. Usp. **44**, 131 (2001).

X.-W. Lei, Q.-Q. Ni, J.-X. Shi, and T. Natsuki, Nanoscale Res. Lett. **6**, 492 (2011).

N. Sano, M. Chhowalla, D. Roy, and G. A. J. Amaratunga, Phys. Rev. B **66**, 113403 (2002).

X. Zhao, Y. Liu, S. Inoue, T. Suzuki, R. O. Jones, and Y. Ando, Phys. Rev. Lett. **92**, 125502 (2004).

S. Sapmaz, P. Jarillo-Herrero, Y.M. Blanter, C. Dekker, and H. S. J. van der Zant, Phys. Rev. Lett. **96**, 026801 (2006).

B.J. LeRoy, S.G. Lemay, J. Kong, and C. Dekker, Nature **432**, 371 (2004).

A. Benyamini, A. Hamo, S. V. Kusminskiy, F. von Oppen, and S. Ilani, Nat. Phys. **10**, 151 (2014).

J. M. Robin, Phys. Rev. B **56**, 13634 (1997).

S. Datta, *Electronic Transport in Mesoscopic Systems*, (Cambridge University Press, Cambridge, 1995).

Y.-T. Zhang, Z. Hou, X.C. Xie, and Q.-F. Sun, Phys. Rev. B **95**, 245433 (2017).

Y.-F. Zhou, Z. Hou, P. Lv, X.-C. Xie and Q.-F. Sun, Sci. China-Phys. Mech. Astron. **61**(12), 127811(2018).

S.M. Reimann and M. Manninen, Rev. Mod. Phys. **74**, 1283 (2002).

P. Wang, Q.-F. Sun, and X.C. Xie, Phys. Rev. B **90**, 155407 (2014).

G. D. Mahan, *Many-Particle Physics*, 3rd ed. (Plenum Press, New York, 2000).

Z. Y. Zeng, F. Claro, B. Li, arXiv:cond-mat/0110502

Q.-F. Sun, B.-G. Wang, J. Wang, and T.-H. Lin, Phys. Rev. B **61**, 4754 (2000).

A.-P. Jauho, N. S. Wingreen, and Y. Meir, Phys. Rev. B **50**, 5528 (1994).


Campus Overview

Preferred Senior Living of Ellsworth is located just minutes north of town near the scenic Ellsworth golf course. Our setting offers the tranquility of rural living with the convenience of nearby village shopping, medical clinics, and community activities.

Preferred Senior Living strives to provide seniors with an enriching lifestyle while offering excellent care and services by professional, friendly and compassionate staff 24 hours a day. Services will be tailored to individual needs, adjusting cares accordingly. Homey apartments offer the privacy and comfort of your own home while our beautiful building is designed to promote a sense of community and security.

Enjoy life to the fullest. Satisfy your appetite with a home cooked meal. Participate in stimulating activities. Relax in front of a cozy fireplace. Soak up the sun on the outdoor patio or share stories around an evening campfire. Tend to the raised gardens. Take a stroll on our walking paths taking in the fresh country air. Enjoy the company of new and old friends. All of this is right outside your door!

Preferred Senior Living of Ellsworth is here to provide a new option for senior living in your own hometown. Striving to provide our seniors with the highest quality of care and services within their own community.


1. Field of the Invention
The present invention relates to an electronic apparatus provided with a device of entering and calculating complex numbers, which apparatus is suitable for a function electronic calculator.
2. Description of the Related Art
FIG. 9 shows an example of the operation of entering complex numbers using a conventional electronic apparatus of this kind as well as a resulting display thereon. Referring to FIG. 9, a method for entering complex numbers enables an imaginary number unit i to be entered immediately after entering a value 2 without fail as seen in an example of 2i.
However, such conventional method for entering complex numbers does not allow entering directly mathematical expressions represented as i2. As seen in this case, the method suffers a drawback of complicating the input operation itself, because it demands operators to converting the input location of the imaginary number unit to a predetermined form so that the unit come after a real number.
Incidentally as related art of the present invention the Japanese Laid-Open Patent No. 83547/1978 discloses an electronic calculator provided with a device of calculating complex numbers, said calculator comprising a real number key designating a real number portion of the complex numbers and an imaginary number key designating an imaginary number portion thereof,
said real number key functioning to transcribe the contents of substituted registers onto an auxiliary register, whereas said imaginary number key functioning to impede the transmission of the contents of the substituted register and those of the auxiliary register.
The Japanese Laid-Open Patent No. 75459/1986 also discloses another electronic calculator provided with a device of calculating complex numbers comprising:
a first register for memorizing both a real number and an imaginary number portion of the complex numbers produced by a calculation; and
a second register for memorizing both imaginary number and real number portion of the complex numbers that are not memorized in the first register;
the contents of the first and the second register being exchanged in response to the operation of the changeover switch to selectively displaying either the real number or the imaginary number portion of the complex numbers determined in the above process.
The Japanese Laid-Open Patent No. 75460/1986 also discloses another electronic calculator provided with a device of calculating a complex number comprising a register housing both a real number portion and an imaginary number portion,
said calculator simultaneously displaying both the real number and imaginary number portion while distinguishing them to provide an immediate detection of calculation results without errors.


Q:

Why is my List.GetUserEffectivePermissions() method not working?

I'm developing a process in C# with the SharePoint 2013 Client Side Object Model. I need to retrieve the SharePoint List Permissions of a given user, that will be different than the user that is executing the code.
using SP = Microsoft.SharePoint.Client;

SP.ClientContext SpContext = new SP.ClientContext("SITEURL");
SP.Web SiteWeb = SpContext.Web;
SP.List Lst = SpContext.Web.Lists.GetByTitle("LIST");
var ClientUserEffPerms = Lst.GetUserEffectivePermissions(@"<domain>\<username>");

SpContext.Load(SiteWeb, S => S.EffectiveBasePermissions);
SpContext.Load(Lst, L => L.EffectiveBasePermissions);
SpContext.ExecuteQuery();

After this code executes, the ClientUserEffPerms.Value (BasePermissions) object does not represent the permissions of the given user correctly.  The object isn't null, but it represents the user as having no permissions.  The user has at minimum view and edit permissions and I can confirm this by viewing/editing List Items using the web browser as this user.
The code executing user has permission to enumerate permissions at both the Web and List level.  I've confirmed this with the code below, both booleans resolve to true.
bool SvcUserHasSiteEnumPermsPerm = SiteWeb.EffectiveBasePermissions.Has(SP.PermissionKind.EnumeratePermissions);
bool SvcUserHasListEnumPermsPerm = Lst.EffectiveBasePermissions.Has(SP.PermissionKind.EnumeratePermissions);

Can anyone help me determine what is wrong with my GetUserEffectivePermissions() method?

A:

When you call GetUserEffectivePermissions you need to pass in the full claims token version of the login name, which looks something like this:
i:0#.w|domain\user
You can get this by loading the LoginName property on a user object:
clientContext.Load(clientContext.Web.CurrentUser, i => i.LoginName);
clientContext.ExecuteQuery();

Of course, that's for the current user, so you'll need to acquire the user you actually want first.


The color you gave her eyes is a very nice color! It isn't common with small animal characters to have an eye color like she has.Her hat looks sweet on her, and great job with her tail and fur colors!


February 13, 2009

A new blog....

So once upon a time I had various blogs. All very specfic such as my knitting blog, outdoor adventures blog, and pink shirt daily blog. Then I realized it was just too much to keep everything in compartmentalized so now I am just throwing all together.

My first post is to share is this delicious Vegan Mousse recipe I found at Homespun Oasis. Yes, the main ingredient is Avocado and that's a little off putting at first but I made a batch last week and it's delicious. I used quite a bit of agave nectar in mine and ended up eating it right out of the bowl.

If you haven't had a chance check out Homespun Oasis. It's a treasure trove for anyone who loves handmade goods, fun stories, recipes, and lots of giveaways!


##############################################################################
# LuaJIT Makefile. Requires GNU Make.
#
# Please read doc/install.html before changing any variables!
#
# Suitable for POSIX platforms (Linux, *BSD, OSX etc.).
# Also works with MinGW and Cygwin on Windows.
# Please check msvcbuild.bat for building with MSVC on Windows.
#
# Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
##############################################################################

MAJVER=  2
MINVER=  1
RELVER=  0
ABIVER=  5.1
NODOTABIVER= 51

##############################################################################
#############################  COMPILER OPTIONS  #############################
##############################################################################
# These options mainly affect the speed of the JIT compiler itself, not the
# speed of the JIT-compiled code. Turn any of the optional settings on by
# removing the '#' in front of them. Make sure you force a full recompile
# with "make clean", followed by "make" if you change any options.
#
# LuaJIT builds as a native 32 or 64 bit binary by default.
CC= gcc
#
# Use this if you want to force a 32 bit build on a 64 bit multilib OS.
#CC= gcc -m32
#
# Since the assembler part does NOT maintain a frame pointer, it's pointless
# to slow down the C part by not omitting it. Debugging, tracebacks and
# unwinding are not affected -- the assembler part has frame unwind
# information and GCC emits it where needed (x64) or with -g (see CCDEBUG).
CCOPT= -O2 -fomit-frame-pointer
# Use this if you want to generate a smaller binary (but it's slower):
#CCOPT= -Os -fomit-frame-pointer
# Note: it's no longer recommended to use -O3 with GCC 4.x.
# The I-Cache bloat usually outweighs the benefits from aggressive inlining.
#
# Target-specific compiler options:
#
# x86/x64 only: For GCC 4.2 or higher and if you don't intend to distribute
# the binaries to a different machine you could also use: -march=native
#
CCOPT_x86= -march=i686 -msse -msse2 -mfpmath=sse
CCOPT_x64=
CCOPT_arm=
CCOPT_arm64=
CCOPT_ppc=
CCOPT_mips=
#
CCDEBUG=
# Uncomment the next line to generate debug information:
#CCDEBUG= -g
#
CCWARN= -Wall
# Uncomment the next line to enable more warnings:
#CCWARN+= -Wextra -Wdeclaration-after-statement -Wredundant-decls -Wshadow -Wpointer-arith
#
##############################################################################

##############################################################################
################################  BUILD MODE  ################################
##############################################################################
# The default build mode is mixed mode on POSIX. On Windows this is the same
# as dynamic mode.
#
# Mixed mode creates a static + dynamic library and a statically linked luajit.
BUILDMODE= mixed
#
# Static mode creates a static library and a statically linked luajit.
#BUILDMODE= static
#
# Dynamic mode creates a dynamic library and a dynamically linked luajit.
# Note: this executable will only run when the library is installed!
#BUILDMODE= dynamic
#
##############################################################################

##############################################################################
#################################  FEATURES  #################################
##############################################################################
# Enable/disable these features as needed, but make sure you force a full
# recompile with "make clean", followed by "make".
XCFLAGS=
#
# Permanently disable the FFI extension to reduce the size of the LuaJIT
# executable. But please consider that the FFI library is compiled-in,
# but NOT loaded by default. It only allocates any memory, if you actually
# make use of it.
#XCFLAGS+= -DLUAJIT_DISABLE_FFI
#
# Features from Lua 5.2 that are unlikely to break existing code are
# enabled by default. Some other features that *might* break some existing
# code (e.g. __pairs or os.execute() return values) can be enabled here.
# Note: this does not provide full compatibility with Lua 5.2 at this time.
#XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT
#
# Disable the JIT compiler, i.e. turn LuaJIT into a pure interpreter.
#XCFLAGS+= -DLUAJIT_DISABLE_JIT
#
# Some architectures (e.g. PPC) can use either single-number (1) or
# dual-number (2) mode. Uncomment one of these lines to override the
# default mode. Please see LJ_ARCH_NUMMODE in lj_arch.h for details.
#XCFLAGS+= -DLUAJIT_NUMMODE=1
#XCFLAGS+= -DLUAJIT_NUMMODE=2
#
##############################################################################

##############################################################################
############################  DEBUGGING SUPPORT  #############################
##############################################################################
# Enable these options as needed, but make sure you force a full recompile
# with "make clean", followed by "make".
# Note that most of these are NOT suitable for benchmarking or release mode!
#
# Use the system provided memory allocator (realloc) instead of the
# bundled memory allocator. This is slower, but sometimes helpful for
# debugging. This option cannot be enabled on x64, since realloc usually
# doesn't return addresses in the right address range.
# OTOH this option is mandatory for Valgrind's memcheck tool on x64 and
# the only way to get useful results from it for all other architectures.
#XCFLAGS+= -DLUAJIT_USE_SYSMALLOC
#
# This define is required to run LuaJIT under Valgrind. The Valgrind
# header files must be installed. You should enable debug information, too.
# Use --suppressions=lj.supp to avoid some false positives.
#XCFLAGS+= -DLUAJIT_USE_VALGRIND
#
# This is the client for the GDB JIT API. GDB 7.0 or higher is required
# to make use of it. See lj_gdbjit.c for details. Enabling this causes
# a non-negligible overhead, even when not running under GDB.
#XCFLAGS+= -DLUAJIT_USE_GDBJIT
#
# Turn on assertions for the Lua/C API to debug problems with lua_* calls.
# This is rather slow -- use only while developing C libraries/embeddings.
#XCFLAGS+= -DLUA_USE_APICHECK
#
# Turn on assertions for the whole LuaJIT VM. This significantly slows down
# everything. Use only if you suspect a problem with LuaJIT itself.
#XCFLAGS+= -DLUA_USE_ASSERT
#
##############################################################################
# You probably don't need to change anything below this line!
##############################################################################

##############################################################################
# Flags and options for host and target.
##############################################################################

# You can override the following variables at the make command line:
#   CC       HOST_CC       STATIC_CC       DYNAMIC_CC
#   CFLAGS   HOST_CFLAGS   TARGET_CFLAGS
#   LDFLAGS  HOST_LDFLAGS  TARGET_LDFLAGS  TARGET_SHLDFLAGS
#   LIBS     HOST_LIBS     TARGET_LIBS
#   CROSS    HOST_SYS      TARGET_SYS      TARGET_FLAGS
#
# Cross-compilation examples:
#   make HOST_CC="gcc -m32" CROSS=i586-mingw32msvc- TARGET_SYS=Windows
#   make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu-

ASOPTIONS= $(CCOPT) $(CCWARN) $(XCFLAGS) $(CFLAGS)
CCOPTIONS= $(CCDEBUG) $(ASOPTIONS)
LDOPTIONS= $(CCDEBUG) $(LDFLAGS)

HOST_CC= $(CC)
HOST_RM= rm -f
# If left blank, minilua is built and used. You can supply an installed
# copy of (plain) Lua 5.1 or 5.2, plus Lua BitOp. E.g. with: HOST_LUA=lua
HOST_LUA=

HOST_XCFLAGS= -I.
HOST_XLDFLAGS=
HOST_XLIBS=
HOST_ACFLAGS= $(CCOPTIONS) $(HOST_XCFLAGS) $(TARGET_ARCH) $(HOST_CFLAGS)
HOST_ALDFLAGS= $(LDOPTIONS) $(HOST_XLDFLAGS) $(HOST_LDFLAGS)
HOST_ALIBS= $(HOST_XLIBS) $(LIBS) $(HOST_LIBS)

STATIC_CC = $(CROSS)$(CC)
DYNAMIC_CC = $(CROSS)$(CC) -fPIC
TARGET_CC= $(STATIC_CC)
TARGET_STCC= $(STATIC_CC)
TARGET_DYNCC= $(DYNAMIC_CC)
TARGET_LD= $(CROSS)$(CC)
TARGET_AR= $(CROSS)ar rcus
TARGET_STRIP= $(CROSS)strip

TARGET_LIBPATH= $(or $(PREFIX),/usr/local)/$(or $(MULTILIB),lib)
TARGET_SONAME= libluajit-$(ABIVER).so.$(MAJVER)
TARGET_DYLIBNAME= libluajit-$(ABIVER).$(MAJVER).dylib
TARGET_DYLIBPATH= $(TARGET_LIBPATH)/$(TARGET_DYLIBNAME)
TARGET_DLLNAME= lua$(NODOTABIVER).dll
TARGET_XSHLDFLAGS= -shared -fPIC -Wl,-soname,$(TARGET_SONAME)
TARGET_DYNXLDOPTS=

TARGET_LFSFLAGS= -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
TARGET_XCFLAGS= $(TARGET_LFSFLAGS) -U_FORTIFY_SOURCE
TARGET_XLDFLAGS=
TARGET_XLIBS= -lm
TARGET_TCFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS)
TARGET_ACFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS)
TARGET_ASFLAGS= $(ASOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS)
TARGET_ALDFLAGS= $(LDOPTIONS) $(TARGET_XLDFLAGS) $(TARGET_FLAGS) $(TARGET_LDFLAGS)
TARGET_ASHLDFLAGS= $(LDOPTIONS) $(TARGET_XSHLDFLAGS) $(TARGET_FLAGS) $(TARGET_SHLDFLAGS)
TARGET_ALIBS= $(TARGET_XLIBS) $(LIBS) $(TARGET_LIBS)

TARGET_TESTARCH=$(shell $(TARGET_CC) $(TARGET_TCFLAGS) -E lj_arch.h -dM)
ifneq (,$(findstring LJ_TARGET_X64 ,$(TARGET_TESTARCH)))
  TARGET_LJARCH= x64
else
ifneq (,$(findstring LJ_TARGET_X86 ,$(TARGET_TESTARCH)))
  TARGET_LJARCH= x86
else
ifneq (,$(findstring LJ_TARGET_ARM ,$(TARGET_TESTARCH)))
  TARGET_LJARCH= arm
else
ifneq (,$(findstring LJ_TARGET_ARM64 ,$(TARGET_TESTARCH)))
  TARGET_LJARCH= arm64
else
ifneq (,$(findstring LJ_TARGET_PPC ,$(TARGET_TESTARCH)))
  ifneq (,$(findstring LJ_LE 1,$(TARGET_TESTARCH)))
    TARGET_ARCH= -DLJ_ARCH_ENDIAN=LUAJIT_LE
  else
    TARGET_ARCH= -DLJ_ARCH_ENDIAN=LUAJIT_BE
  endif
  TARGET_LJARCH= ppc
else
ifneq (,$(findstring LJ_TARGET_MIPS ,$(TARGET_TESTARCH)))
  ifneq (,$(findstring MIPSEL ,$(TARGET_TESTARCH)))
    TARGET_ARCH= -D__MIPSEL__=1
  endif
  TARGET_LJARCH= mips
else
  $(error Unsupported target architecture)
endif
endif
endif
endif
endif
endif

ifneq (,$(findstring LJ_TARGET_PS3 1,$(TARGET_TESTARCH)))
  TARGET_SYS= PS3
  TARGET_ARCH+= -D__CELLOS_LV2__
  TARGET_XCFLAGS+= -DLUAJIT_USE_SYSMALLOC
  TARGET_XLIBS+= -lpthread
endif

TARGET_XCFLAGS+= $(CCOPT_$(TARGET_LJARCH))
TARGET_ARCH+= $(patsubst %,-DLUAJIT_TARGET=LUAJIT_ARCH_%,$(TARGET_LJARCH))

ifneq (,$(PREFIX))
ifneq (/usr/local,$(PREFIX))
  TARGET_XCFLAGS+= -DLUA_ROOT=\"$(PREFIX)\"
  ifneq (/usr,$(PREFIX))
    TARGET_DYNXLDOPTS= -Wl,-rpath,$(TARGET_LIBPATH)
  endif
endif
endif
ifneq (,$(MULTILIB))
  TARGET_XCFLAGS+= -DLUA_MULTILIB=\"$(MULTILIB)\"
endif
ifneq (,$(LMULTILIB))
  TARGET_XCFLAGS+= -DLUA_LMULTILIB=\"$(LMULTILIB)\"
endif

##############################################################################
# System detection.
##############################################################################

ifeq (Windows,$(findstring Windows,$(OS))$(MSYSTEM)$(TERM))
  HOST_SYS= Windows
  HOST_RM= del
else
  HOST_SYS:= $(shell uname -s)
  ifneq (,$(findstring MINGW,$(HOST_SYS)))
    HOST_SYS= Windows
    HOST_MSYS= mingw
  endif
  ifneq (,$(findstring CYGWIN,$(HOST_SYS)))
    HOST_SYS= Windows
    HOST_MSYS= cygwin
  endif
endif

TARGET_SYS?= $(HOST_SYS)
ifeq (Windows,$(TARGET_SYS))
  TARGET_STRIP+= --strip-unneeded
  TARGET_XSHLDFLAGS= -shared
  TARGET_DYNXLDOPTS=
else
ifeq (,$(shell $(TARGET_CC) -o /dev/null -c -x c /dev/null -fno-stack-protector 2>/dev/null || echo 1))
  TARGET_XCFLAGS+= -fno-stack-protector
endif
ifeq (Darwin,$(TARGET_SYS))
  ifeq (,$(MACOSX_DEPLOYMENT_TARGET))
    export MACOSX_DEPLOYMENT_TARGET=10.4
  endif
  TARGET_STRIP+= -x
  TARGET_AR+= 2>/dev/null
  TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
  TARGET_DYNXLDOPTS=
  TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
  ifeq (x64,$(TARGET_LJARCH))
    TARGET_XLDFLAGS+= -pagezero_size 10000 -image_base 100000000
    TARGET_XSHLDFLAGS+= -image_base 7fff04c4a000
  endif
else
ifeq (iOS,$(TARGET_SYS))
  TARGET_STRIP+= -x
  TARGET_AR+= 2>/dev/null
  TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
  TARGET_DYNXLDOPTS=
  TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
  ifeq (arm64,$(TARGET_LJARCH))
    TARGET_XCFLAGS+= -fno-omit-frame-pointer
  endif
else
  ifneq (SunOS,$(TARGET_SYS))
    ifneq (PS3,$(TARGET_SYS))
      TARGET_XLDFLAGS+= -Wl,-E
    endif
  endif
  ifeq (Linux,$(TARGET_SYS))
    TARGET_XLIBS+= -ldl
  endif
  ifeq (GNU/kFreeBSD,$(TARGET_SYS))
    TARGET_XLIBS+= -ldl
  endif
endif
endif
endif

ifneq ($(HOST_SYS),$(TARGET_SYS))
  ifeq (Windows,$(TARGET_SYS))
    HOST_XCFLAGS+= -malign-double -DLUAJIT_OS=LUAJIT_OS_WINDOWS
  else
  ifeq (Linux,$(TARGET_SYS))
    HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_LINUX
  else
  ifeq (Darwin,$(TARGET_SYS))
    HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX
  else
  ifeq (iOS,$(TARGET_SYS))
    HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX
  else
    HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OTHER
  endif
  endif
  endif
  endif
endif

ifneq (,$(CCDEBUG))
  TARGET_STRIP= @:
endif

##############################################################################
# Files and pathnames.
##############################################################################

MINILUA_O= host/minilua.o
MINILUA_LIBS= -lm
MINILUA_T= host/minilua
MINILUA_X= $(MINILUA_T)

ifeq (,$(HOST_LUA))
  HOST_LUA= $(MINILUA_X)
  DASM_DEP= $(MINILUA_T)
endif

DASM_DIR= ../dynasm
DASM= $(HOST_LUA) $(DASM_DIR)/dynasm.lua
DASM_XFLAGS=
DASM_AFLAGS=
DASM_ARCH= $(TARGET_LJARCH)

ifneq (,$(findstring LJ_ARCH_BITS 64,$(TARGET_TESTARCH)))
  DASM_AFLAGS+= -D P64
endif
ifneq (,$(findstring LJ_HASJIT 1,$(TARGET_TESTARCH)))
  DASM_AFLAGS+= -D JIT
endif
ifneq (,$(findstring LJ_HASFFI 1,$(TARGET_TESTARCH)))
  DASM_AFLAGS+= -D FFI
endif
ifneq (,$(findstring LJ_DUALNUM 1,$(TARGET_TESTARCH)))
  DASM_AFLAGS+= -D DUALNUM
endif
ifneq (,$(findstring LJ_ARCH_HASFPU 1,$(TARGET_TESTARCH)))
  DASM_AFLAGS+= -D FPU
  TARGET_ARCH+= -DLJ_ARCH_HASFPU=1
else
  TARGET_ARCH+= -DLJ_ARCH_HASFPU=0
endif
ifeq (,$(findstring LJ_ABI_SOFTFP 1,$(TARGET_TESTARCH)))
  DASM_AFLAGS+= -D HFABI
  TARGET_ARCH+= -DLJ_ABI_SOFTFP=0
else
  TARGET_ARCH+= -DLJ_ABI_SOFTFP=1
endif
ifneq (,$(findstring LJ_NO_UNWIND 1,$(TARGET_TESTARCH)))
  DASM_AFLAGS+= -D NO_UNWIND
  TARGET_ARCH+= -DLUAJIT_NO_UNWIND
endif
DASM_AFLAGS+= -D VER=$(subst LJ_ARCH_VERSION_,,$(filter LJ_ARCH_VERSION_%,$(subst LJ_ARCH_VERSION ,LJ_ARCH_VERSION_,$(TARGET_TESTARCH))))
ifeq (Windows,$(TARGET_SYS))
  DASM_AFLAGS+= -D WIN
endif
ifeq (x64,$(TARGET_LJARCH))
  ifeq (,$(findstring LJ_FR2 1,$(TARGET_TESTARCH)))
    DASM_ARCH= x86
  endif
else
ifeq (arm,$(TARGET_LJARCH))
  ifeq (iOS,$(TARGET_SYS))
    DASM_AFLAGS+= -D IOS
  endif
else
ifeq (ppc,$(TARGET_LJARCH))
  ifneq (,$(findstring LJ_ARCH_SQRT 1,$(TARGET_TESTARCH)))
    DASM_AFLAGS+= -D SQRT
  endif
  ifneq (,$(findstring LJ_ARCH_ROUND 1,$(TARGET_TESTARCH)))
    DASM_AFLAGS+= -D ROUND
  endif
  ifneq (,$(findstring LJ_ARCH_PPC32ON64 1,$(TARGET_TESTARCH)))
    DASM_AFLAGS+= -D GPR64
  endif
  ifeq (PS3,$(TARGET_SYS))
    DASM_AFLAGS+= -D PPE -D TOC
  endif
  ifneq (,$(findstring LJ_ARCH_PPC64 ,$(TARGET_TESTARCH)))
    DASM_ARCH= ppc64
  endif
endif
endif
endif

DASM_FLAGS= $(DASM_XFLAGS) $(DASM_AFLAGS)
DASM_DASC= vm_$(DASM_ARCH).dasc

BUILDVM_O= host/buildvm.o host/buildvm_asm.o host/buildvm_peobj.o \
	   host/buildvm_lib.o host/buildvm_fold.o
BUILDVM_T= host/buildvm
BUILDVM_X= $(BUILDVM_T)

HOST_O= $(MINILUA_O) $(BUILDVM_O)
HOST_T= $(MINILUA_T) $(BUILDVM_T)

LJVM_S= lj_vm.S
LJVM_O= lj_vm.o
LJVM_BOUT= $(LJVM_S)
LJVM_MODE= elfasm

LJLIB_O= lib_base.o lib_math.o lib_bit.o lib_string.o lib_table.o \
	 lib_io.o lib_os.o lib_package.o lib_debug.o lib_jit.o lib_ffi.o
LJLIB_C= $(LJLIB_O:.o=.c)

LJCORE_O= lj_gc.o lj_err.o lj_char.o lj_bc.o lj_obj.o lj_buf.o \
	  lj_str.o lj_tab.o lj_func.o lj_udata.o lj_meta.o lj_debug.o \
	  lj_state.o lj_dispatch.o lj_vmevent.o lj_vmmath.o lj_strscan.o \
	  lj_strfmt.o lj_api.o lj_profile.o \
	  lj_lex.o lj_parse.o lj_bcread.o lj_bcwrite.o lj_load.o \
	  lj_ir.o lj_opt_mem.o lj_opt_fold.o lj_opt_narrow.o \
	  lj_opt_dce.o lj_opt_loop.o lj_opt_split.o lj_opt_sink.o \
	  lj_mcode.o lj_snap.o lj_record.o lj_crecord.o lj_ffrecord.o \
	  lj_asm.o lj_trace.o lj_gdbjit.o \
	  lj_ctype.o lj_cdata.o lj_cconv.o lj_ccall.o lj_ccallback.o \
	  lj_carith.o lj_clib.o lj_cparse.o \
	  lj_lib.o lj_alloc.o lib_aux.o \
	  $(LJLIB_O) lib_init.o

LJVMCORE_O= $(LJVM_O) $(LJCORE_O)
LJVMCORE_DYNO= $(LJVMCORE_O:.o=_dyn.o)

LIB_VMDEF= jit/vmdef.lua
LIB_VMDEFP= $(LIB_VMDEF)

LUAJIT_O= luajit.o
LUAJIT_A= libluajit.a
LUAJIT_SO= libluajit.so
LUAJIT_T= luajit

ALL_T= $(LUAJIT_T) $(LUAJIT_A) $(LUAJIT_SO) $(HOST_T)
ALL_HDRGEN= lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h \
	    host/buildvm_arch.h
ALL_GEN= $(LJVM_S) $(ALL_HDRGEN) $(LIB_VMDEFP)
WIN_RM= *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk
ALL_RM= $(ALL_T) $(ALL_GEN) *.o host/*.o $(WIN_RM)

##############################################################################
# Build mode handling.
##############################################################################

# Mixed mode defaults.
TARGET_O= $(LUAJIT_A)
TARGET_T= $(LUAJIT_T) $(LUAJIT_SO)
TARGET_DEP= $(LIB_VMDEF) $(LUAJIT_SO)

ifeq (Windows,$(TARGET_SYS))
  TARGET_DYNCC= $(STATIC_CC)
  LJVM_MODE= peobj
  LJVM_BOUT= $(LJVM_O)
  LUAJIT_T= luajit.exe
  ifeq (cygwin,$(HOST_MSYS))
    LUAJIT_SO= cyg$(TARGET_DLLNAME)
  else
    LUAJIT_SO= $(TARGET_DLLNAME)
  endif
  # Mixed mode is not supported on Windows. And static mode doesn't work well.
  # C modules cannot be loaded, because they bind to lua51.dll.
  ifneq (static,$(BUILDMODE))
    BUILDMODE= dynamic
    TARGET_XCFLAGS+= -DLUA_BUILD_AS_DLL
  endif
endif
ifeq (Darwin,$(TARGET_SYS))
  LJVM_MODE= machasm
endif
ifeq (iOS,$(TARGET_SYS))
  LJVM_MODE= machasm
endif
ifeq (SunOS,$(TARGET_SYS))
  BUILDMODE= static
endif
ifeq (PS3,$(TARGET_SYS))
  BUILDMODE= static
endif

ifeq (Windows,$(HOST_SYS))
  MINILUA_T= host/minilua.exe
  BUILDVM_T= host/buildvm.exe
  ifeq (,$(HOST_MSYS))
    MINILUA_X= host\minilua
    BUILDVM_X= host\buildvm
    ALL_RM:= $(subst /,\,$(ALL_RM))
  endif
endif

ifeq (static,$(BUILDMODE))
  TARGET_DYNCC= @:
  TARGET_T= $(LUAJIT_T)
  TARGET_DEP= $(LIB_VMDEF)
else
ifeq (dynamic,$(BUILDMODE))
  ifneq (Windows,$(TARGET_SYS))
    TARGET_CC= $(DYNAMIC_CC)
  endif
  TARGET_DYNCC= @:
  LJVMCORE_DYNO= $(LJVMCORE_O)
  TARGET_O= $(LUAJIT_SO)
  TARGET_XLDFLAGS+= $(TARGET_DYNXLDOPTS)
else
ifeq (Darwin,$(TARGET_SYS))
  TARGET_DYNCC= @:
  LJVMCORE_DYNO= $(LJVMCORE_O)
endif
ifeq (iOS,$(TARGET_SYS))
  TARGET_DYNCC= @:
  LJVMCORE_DYNO= $(LJVMCORE_O)
endif
endif
endif

Q= @
E= @echo
#Q=
#E= @:

##############################################################################
# Make targets.
##############################################################################

default all:	$(TARGET_T)

amalg:
	@grep "^[+|]" ljamalg.c
	$(MAKE) all "LJCORE_O=ljamalg.o"

clean:
	$(HOST_RM) $(ALL_RM)

libbc:
	./$(LUAJIT_T) host/genlibbc.lua -o host/buildvm_libbc.h $(LJLIB_C)
	$(MAKE) all

depend:
	@for file in $(ALL_HDRGEN); do \
	  test -f $$file || touch $$file; \
	  done
	@$(HOST_CC) $(HOST_ACFLAGS) -MM *.c host/*.c | \
	  sed -e "s| [^ ]*/dasm_\S*\.h||g" \
	      -e "s|^\([^l ]\)|host/\1|" \
	      -e "s| lj_target_\S*\.h| lj_target_*.h|g" \
	      -e "s| lj_emit_\S*\.h| lj_emit_*.h|g" \
	      -e "s| lj_asm_\S*\.h| lj_asm_*.h|g" >Makefile.dep
	@for file in $(ALL_HDRGEN); do \
	  test -s $$file || $(HOST_RM) $$file; \
	  done

.PHONY: default all amalg clean libbc depend

##############################################################################
# Rules for generated files.
##############################################################################

$(MINILUA_T): $(MINILUA_O)
	$(E) "HOSTLINK  $@"
	$(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(MINILUA_O) $(MINILUA_LIBS) $(HOST_ALIBS)

host/buildvm_arch.h: $(DASM_DASC) $(DASM_DEP)
	$(E) "DYNASM    $@"
	$(Q)$(DASM) $(DASM_FLAGS) -o $@ $(DASM_DASC)

host/buildvm.o: $(DASM_DIR)/dasm_*.h

$(BUILDVM_T): $(BUILDVM_O)
	$(E) "HOSTLINK  $@"
	$(Q)$(HOST_CC) $(HOST_ALDFLAGS) -o $@ $(BUILDVM_O) $(HOST_ALIBS)

$(LJVM_BOUT): $(BUILDVM_T)
	$(E) "BUILDVM   $@"
	$(Q)$(BUILDVM_X) -m $(LJVM_MODE) -o $@

lj_bcdef.h: $(BUILDVM_T) $(LJLIB_C)
	$(E) "BUILDVM   $@"
	$(Q)$(BUILDVM_X) -m bcdef -o $@ $(LJLIB_C)

lj_ffdef.h: $(BUILDVM_T) $(LJLIB_C)
	$(E) "BUILDVM   $@"
	$(Q)$(BUILDVM_X) -m ffdef -o $@ $(LJLIB_C)

lj_libdef.h: $(BUILDVM_T) $(LJLIB_C)
	$(E) "BUILDVM   $@"
	$(Q)$(BUILDVM_X) -m libdef -o $@ $(LJLIB_C)

lj_recdef.h: $(BUILDVM_T) $(LJLIB_C)
	$(E) "BUILDVM   $@"
	$(Q)$(BUILDVM_X) -m recdef -o $@ $(LJLIB_C)

$(LIB_VMDEF): $(BUILDVM_T) $(LJLIB_C)
	$(E) "BUILDVM   $@"
	$(Q)$(BUILDVM_X) -m vmdef -o $(LIB_VMDEFP) $(LJLIB_C)

lj_folddef.h: $(BUILDVM_T) lj_opt_fold.c
	$(E) "BUILDVM   $@"
	$(Q)$(BUILDVM_X) -m folddef -o $@ lj_opt_fold.c

##############################################################################
# Object file rules.
##############################################################################

%.o: %.c
	$(E) "CC        $@"
	$(Q)$(TARGET_DYNCC) $(TARGET_ACFLAGS) -c -o $(@:.o=_dyn.o) $<
	$(Q)$(TARGET_CC) $(TARGET_ACFLAGS) -c -o $@ $<

%.o: %.S
	$(E) "ASM       $@"
	$(Q)$(TARGET_DYNCC) $(TARGET_ASFLAGS) -c -o $(@:.o=_dyn.o) $<
	$(Q)$(TARGET_CC) $(TARGET_ASFLAGS) -c -o $@ $<

$(LUAJIT_O):
	$(E) "CC        $@"
	$(Q)$(TARGET_STCC) $(TARGET_ACFLAGS) -c -o $@ $<

$(HOST_O): %.o: %.c
	$(E) "HOSTCC    $@"
	$(Q)$(HOST_CC) $(HOST_ACFLAGS) -c -o $@ $<

include Makefile.dep

##############################################################################
# Target file rules.
##############################################################################

$(LUAJIT_A): $(LJVMCORE_O)
	$(E) "AR        $@"
	$(Q)$(TARGET_AR) $@ $(LJVMCORE_O)

# The dependency on _O, but linking with _DYNO is intentional.
$(LUAJIT_SO): $(LJVMCORE_O)
	$(E) "DYNLINK   $@"
	$(Q)$(TARGET_LD) $(TARGET_ASHLDFLAGS) -o $@ $(LJVMCORE_DYNO) $(TARGET_ALIBS)
	$(Q)$(TARGET_STRIP) $@

$(LUAJIT_T): $(TARGET_O) $(LUAJIT_O) $(TARGET_DEP)
	$(E) "LINK      $@"
	$(Q)$(TARGET_LD) $(TARGET_ALDFLAGS) -o $@ $(LUAJIT_O) $(TARGET_O) $(TARGET_ALIBS)
	$(Q)$(TARGET_STRIP) $@
	$(E) "OK        Successfully built LuaJIT"

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