<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>Yingzhou Li</title>
 <link href="/atom.xml" rel="self"/>
 <link href="/"/>
 <updated>2026-03-11T05:02:03+00:00</updated>
 <id></id>
 <author>
   <name>Yingzhou Li</name>
 </author>
 
 
   
   <entry>
     <title>Probability bound in factoring to order-finding</title>
     <link href="/posts/2022-06/probability-bound-in-factoring-order-finding.html"/>
     <updated>2022-06-09T00:00:00+00:00</updated>
     <id>/posts/2022-06/probability-bound-in-factoring-order-finding</id>
     <content type="html">&lt;p&gt;Given a positive integer $N$ and an integer $x$ ($1\leq x &amp;lt; N$) co-prime
to $N$. The order of $x$ modulo $N$ is the smallest positive integer $r$
such that $x^r \equiv 1 \pmod{N}$. Order-finding problem then aims to
solve $r$ given $N$ and $x$. A probalistic result, Theorem A4.13, is given
in Appendix 4.3 of (Nielsen and Chuang 2010)&lt;sup id=&quot;fnref:Nielsen2010&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:Nielsen2010&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;p&gt;As mentioned by Yihan Guo, the bound in (Nielsen and Chuang
2010)&lt;sup id=&quot;fnref:Nielsen2010:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:Nielsen2010&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; could be incorrect. After a detailed checking, I agree
with Yihan and a modified version of Theorem A4.13 should be as follows.&lt;/p&gt;

&lt;h2 id=&quot;probability-of-random-choosing-an-even-order-number&quot;&gt;Probability of Random Choosing an Even Order Number&lt;/h2&gt;

&lt;blockquote class=&quot;theorem&quot; id=&quot;unibound&quot;&gt;

  &lt;p&gt;&lt;strong&gt;Theorem&lt;/strong&gt;
Suppose $N = p_1^{\alpha_1} \cdots p_m^{\alpha_m}$ is the prime
factorization of an odd composite positive integer. Let $x$ be chosen
uniformly at random from $\mathbb{Z}_N^*$, and let $r$ be the order of
$x$, modulo $N$. Then&lt;/p&gt;

\[\mathbb{P} \left(r \text{ is even and } x^{r/2} \not\equiv -1 \pmod{N} \right) \geq
1 - \frac{1}{2^{m-1}}.\]

&lt;/blockquote&gt;

&lt;p&gt;In the above &lt;a href=&quot;#unibound&quot;&gt;Theorem&lt;/a&gt;, \(\mathbb{Z}_N^*\) is the set of all
elements in \(\mathbb{Z}_N\), which are co-prime to $N$. The size of
\(\mathbb{Z}_N^*\) is \(\varphi(N)\), which is known as Euler \(\varphi\)
function. The proof of &lt;a href=&quot;#unibound&quot;&gt;Theorem&lt;/a&gt; relies on the
&lt;a href=&quot;https://en.wikipedia.org/wiki/Chinese_remainder_theorem&quot; target=&quot;_blank&quot;&gt;Chinese remainder theorem&lt;/a&gt; and &lt;a href=&quot;#lem&quot;&gt;Lemma A4.12&lt;/a&gt; in
(Nielsen and Chuang 2010)&lt;sup id=&quot;fnref:Nielsen2010:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:Nielsen2010&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;. We cite the statement of
&lt;a href=&quot;#lem&quot;&gt;Lemma A4.12&lt;/a&gt; in this post.&lt;/p&gt;

&lt;blockquote class=&quot;theorem&quot; id=&quot;lem&quot;&gt;

  &lt;p&gt;&lt;strong&gt;Lemma A4.12&lt;/strong&gt;
Let $p$ be an odd prime. Let $2^D$ be the largest power of 2 dividing
$\varphi(p^\alpha)$. Then with probability exactly one-half $2^D$ divides
the order modulo $p^{\alpha}$ of a randomly chosen element of
$\mathbb{Z}_{p^\alpha}^*$.&lt;/p&gt;

&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Proof of &lt;a href=&quot;#unibound&quot;&gt;Theorem&lt;/a&gt;.&lt;/strong&gt;
We prove that
\(\begin{equation} \label{eq:ineq}
\mathbb{P} \left(r \text{ is odd or } x^{r/2} \equiv -1 \pmod{N} \right) \leq
\frac{1}{2^{m-1}}.
\end{equation}\)&lt;/p&gt;

&lt;p&gt;Given an integer $x \in \mathbb{Z}_N^*$ with $r$ being its order modulo
$N$. Since $p_i^{\alpha_i}$ is a factor of $N$, we have,&lt;/p&gt;

\[\begin{equation*}
x^r \equiv 1 \pmod{N} \Longrightarrow x^r \equiv 1 \pmod{p_i^{\alpha_i}} \quad
i = 1, 2, \dots, m.
\end{equation*}\]

&lt;p&gt;We define ${x_i}_{i=1}^m$ as,
\(\begin{equation} \label{eq:xieqx}
    x_i \equiv x \pmod{p_i^{\alpha_i}} \quad i = 1, 2, \dots, m,
\end{equation}\)
with $r_i$ being their orders modulo $p_i^{\alpha_i}$ respectively, i.e.,&lt;/p&gt;

\[\begin{equation*}
x_i^{r_i} \equiv 1 \pmod{p_i^{\alpha_i}}.
\end{equation*}\]

&lt;p&gt;We take to $r$-th power of \eqref{eq:xieqx} and obtain,
\(\begin{equation} \label{eq:mod1}
    x_i^r \equiv x^r \equiv 1 \pmod{p_i^{\alpha_i}}.
\end{equation}\)
Hence we conclude that $r_i$ divides $r$, i.e., $r_i \mid r$.&lt;/p&gt;

&lt;p&gt;We further denote $d$ and $d_i$ be the largest power of 2 divide $r$ and
$r_i$, respectively.&lt;/p&gt;

&lt;p&gt;Now we consider the cases in the probability statement \eqref{eq:ineq}: 1)
$r$ is odd; and 2) $r$ is even and $x^{r/2} \equiv -1 \pmod{N}$.&lt;/p&gt;

&lt;p&gt;When $r$ is odd, we have that all $r_i$ are odd. Hence we have $d = d_1 =
\cdots = d_m = 0$.&lt;/p&gt;

&lt;p&gt;When $r$ is even and $x^{r/2} \equiv -1 \pmod{N}$, we have similar modulo
congruence formula,
\(\begin{equation} \label{eq:modn1}
    x_i^{r/2} \equiv x^{r/2} \equiv -1 \pmod{p_i^{\alpha_i}}.
\end{equation}\)
Comparing \eqref{eq:mod1} and \eqref{eq:mod1}, we know that $r_i \nmid
\frac{r}{2}$. Together with $r_i \mid r$, we know that $r$ and $r_i$ have
the same power of 2 factor, i.e., $d_i = d$ for $i=1, 2, \dots, m$.&lt;/p&gt;

&lt;p&gt;Now we are ready to bound the probability \eqref{eq:ineq}.
By &lt;a href=&quot;https://en.wikipedia.org/wiki/Chinese_remainder_theorem&quot; target=&quot;_blank&quot;&gt;Chinese remainder theorem&lt;/a&gt;, uniform sampling from
\(\mathbb{Z}_N^*\) is equivalent to uniform sampling from
\(\mathbb{Z}_{p_i^{\alpha_i}}^*\) independetly. Further we denote the the
largest power of 2 dividing $\varphi(p_i^{\alpha_i})$ as $D_i$. By &lt;a href=&quot;#lem&quot;&gt;Lemma
A4.12&lt;/a&gt;, we know that&lt;/p&gt;

\[\begin{equation*}
\mathbb{P}\left(r_i = 2^{D_i}\{odd\}\right) = \frac{1}{2}.
\end{equation*}\]

&lt;p&gt;The above analysis on $r$ shows that the statement in the probability must
obeys that $d = d_1 = \cdots = d_m$. Hence we could rewrite
\eqref{eq:ineq} as,&lt;/p&gt;

\[\begin{equation*}
\begin{split}
    &amp;amp; \mathbb{P} \left(r \text{ is odd or } x^{r/2} \equiv -1 \pmod{N} \right) \\
    \leq &amp;amp; \sum_{d = 0}^{\min_i{D_i}}
    \prod_{i=1}^m \mathbb{P} \left(r_i = 2^{d}\{odd\}\right) \\
    \leq &amp;amp; \sum_{d = 0}^{\min_i{D_i}-1}
    \prod_{i=1}^m \mathbb{P} \left(r_i = 2^{d}\{odd\} \right) + \frac{1}{2^m}\\
    \leq &amp;amp; \prod_{i=1}^m \sum_{d = 0}^{\min_i{D_i}-1}
    \mathbb{P} \left(r_i = 2^{d}\{odd\} \right) + \frac{1}{2^m} \\
    \leq &amp;amp; \prod_{i=1}^m (1-\frac{1}{2}) + \frac{1}{2^m} \\
    = &amp;amp; \frac{1}{2^{m-1}}.
\end{split}
\end{equation*}\]

&lt;p&gt;Hence we proved &lt;a href=&quot;#unibound&quot;&gt;Theorem&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;revisit-the-bound&quot;&gt;Revisit the Bound&lt;/h2&gt;

&lt;p&gt;Through the above proof, we find that the original bound $1-\frac{1}{2^m}$
as in Theorem A4.13 in (Nielsen and Chuang 2010)&lt;sup id=&quot;fnref:Nielsen2010:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:Nielsen2010&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; could still
hold if we change the assumption in the statement. Hence we give the
following &lt;a href=&quot;#coro&quot;&gt;Corollar&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote class=&quot;theorem&quot; id=&quot;coro&quot;&gt;

  &lt;p&gt;&lt;strong&gt;Corollary&lt;/strong&gt;
Suppose $N = p_1^{\alpha_1} \cdots p_m^{\alpha_m}$ is the prime
factorization of an odd composite positive integer, and $D_i$ is the
largest power of 2 dividing $\varphi(p_i^{\alpha_i})$. Assume $D_i$ are not
all equal to each other. Let $x$ be chosen uniformly at random from
$\mathbb{Z}_N^*$, and let $r$ be the order of $x$, modulo $N$. Then&lt;/p&gt;

\[\mathbb{P} \left(r \text{ is even and } x^{r/2} \not\equiv -1 \pmod{N}\right) \geq
1 - \frac{1}{2^m}.\]

&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Proof of &lt;a href=&quot;#coro&quot;&gt;Corollary&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;All other parts of the proof remain the same as that of
&lt;a href=&quot;#unibound&quot;&gt;Theorem&lt;/a&gt;. We would rederive the bound on the probability.
Without loss of generality, we assume $D_1$ is greater than the minimum of
$D_i$, i.e., $D_1 &amp;gt; \min_i D_i$.
By &lt;a href=&quot;#lem&quot;&gt;Lemma A4.12&lt;/a&gt;, we have&lt;/p&gt;

\[\sum_{d=0}^{\min_i D_i} \mathbb{P} \left(r_1 = 2^d\{odd\} \right) \leq \frac{1}{2}.\]

&lt;p&gt;Then we could rewrite \eqref{eq:ineq} as,&lt;/p&gt;

\[\begin{equation*}
\begin{split}
    &amp;amp; \mathbb{P}\left(r \text{ is odd or } x^{r/2} \equiv -1 \pmod{N} \right) \\
    \leq &amp;amp; \sum_{d = 0}^{\min_i{D_i}}
    \prod_{i=1}^m \mathbb{P} \left(r_i = 2^{d}\{odd\} \right) \\
    \leq &amp;amp; \left( \sum_{d = 0}^{\min_i{D_i}} \mathbb{P}\left( r_1 = 2^{d}\{odd\} \right) \right)
    \prod_{i=2}^m \frac{1}{2}\\
    \leq &amp;amp; \frac{1}{2^m}.
\end{split}
\end{equation*}\]

&lt;p&gt;Hence we proved &lt;a href=&quot;#coro&quot;&gt;Corollary&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;example-1-n3&quot;&gt;Example 1 ($N=3$)&lt;/h2&gt;

&lt;p&gt;Through the proof of &lt;a href=&quot;#unibound&quot;&gt;Theorem&lt;/a&gt;, we find that the
&lt;a href=&quot;#unibound&quot;&gt;Theorem&lt;/a&gt; should also hold for odd prime numbers. We take $N =
3$ as an example (as provided by Yihan Guo).&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Number&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Order $r$&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;$x^{r/2}$ mod $N$&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Check&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:x:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;-1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:x:&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The probability is 0 and the bound is also 0, i.e.,&lt;/p&gt;

\[0 = \mathbb{P} \left(r \text{ is even and } x^{r/2} \not\equiv -1 \pmod{3}
\right) \geq
1 - \frac{1}{2^{1-1}} = 0.\]

&lt;h2 id=&quot;example-2-n15&quot;&gt;Example 2 ($N=15$)&lt;/h2&gt;

&lt;p&gt;We take $N = 15$ as another example.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Number&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Order $r$&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;$x^{r/2}$ mod $N$&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Check&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:x:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;4&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;4&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:heavy_check_mark:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;4&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;4&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:heavy_check_mark:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;7&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;4&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;4&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:heavy_check_mark:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;8&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;4&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;4&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:heavy_check_mark:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;11&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;11&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:heavy_check_mark:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;13&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;4&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;4&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:heavy_check_mark:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;14&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;-1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:x:&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The probability is $\frac{6}{8}$ and the bound is $\frac{1}{2}$, i.e.,&lt;/p&gt;

\[\frac{3}{4} = \mathbb{P} \left(r \text{ is even and } x^{r/2} \not\equiv -1
\pmod{3} \right) \geq 1 - \frac{1}{2^{2-1}} = \frac{1}{2}.\]

&lt;p&gt;In this case, the original Theorem A4.13 in (Nielsen and Chuang
2010)&lt;sup id=&quot;fnref:Nielsen2010:4&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:Nielsen2010&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; also holds. By the argument around &lt;a href=&quot;#coro&quot;&gt;Corollary&lt;/a&gt;,
we have $D_1 = 1$ and $D_2 = 2$, which are not equal to each other. Hence
&lt;a href=&quot;#coro&quot;&gt;Corollary&lt;/a&gt; holds and so is the bound in Theorem A4.13.&lt;/p&gt;

&lt;h2 id=&quot;example-3-n63&quot;&gt;Example 3 ($N=63$)&lt;/h2&gt;

&lt;p&gt;We take $N = 63 = 3^2 \cdot 7$ as the last example.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Number&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Order $r$&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;$x^{r/2}$ mod $N$&lt;/th&gt;
      &lt;th style=&quot;text-align: center&quot;&gt;Check&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:x:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;8&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:heavy_check_mark:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;4&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:x:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;5&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;-1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:x:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;8&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;8&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:heavy_check_mark:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;10&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;55&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:heavy_check_mark:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;11&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;8&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:heavy_check_mark:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;13&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;55&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:heavy_check_mark:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;16&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:x:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;17&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;-1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:x:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;19&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;55&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:heavy_check_mark:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;20&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;-1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:x:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;22&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:x:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;23&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;8&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:heavy_check_mark:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;25&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:x:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;26&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;-1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:x:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;29&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;8&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:heavy_check_mark:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;31&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;55&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:heavy_check_mark:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;32&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;8&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:heavy_check_mark:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;34&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;55&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:heavy_check_mark:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;37&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:x:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;38&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;-1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:x:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;40&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;55&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:heavy_check_mark:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;41&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;-1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:x:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;43&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:x:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;44&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;8&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:heavy_check_mark:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;46&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:x:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;47&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;-1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:x:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;50&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;8&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:heavy_check_mark:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;52&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;55&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:heavy_check_mark:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;53&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;8&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:heavy_check_mark:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;55&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;55&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:heavy_check_mark:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;58&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;3&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt; &lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:x:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;59&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;-1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:x:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;61&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;6&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;55&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:heavy_check_mark:&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;62&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;2&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;-1&lt;/td&gt;
      &lt;td style=&quot;text-align: center&quot;&gt;:x:&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The probability is $\frac{18}{36}$ and the bound is $\frac{1}{2}$, i.e.,&lt;/p&gt;

\[\frac{1}{2} = \mathbb{P} \left(r \text{ is even and } x^{r/2} \not\equiv -1
\pmod{3} \right) \geq 1 - \frac{1}{2^{2-1}} = \frac{1}{2}.\]

&lt;p&gt;In this case, the original Theorem A4.13 in (Nielsen and Chuang
2010)&lt;sup id=&quot;fnref:Nielsen2010:5&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:Nielsen2010&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; does not hold.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Yingzhou Li&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;Reference&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:Nielsen2010&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Nielsen, M. A., &amp;amp; Chuang, I. L. (2010). Quantum computation and quantum information (10th Anniversary Edition ed.). Cambridge University Press. &lt;a href=&quot;#fnref:Nielsen2010&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt; &lt;a href=&quot;#fnref:Nielsen2010:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;sup&gt;2&lt;/sup&gt;&lt;/a&gt; &lt;a href=&quot;#fnref:Nielsen2010:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;sup&gt;3&lt;/sup&gt;&lt;/a&gt; &lt;a href=&quot;#fnref:Nielsen2010:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;sup&gt;4&lt;/sup&gt;&lt;/a&gt; &lt;a href=&quot;#fnref:Nielsen2010:4&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;sup&gt;5&lt;/sup&gt;&lt;/a&gt; &lt;a href=&quot;#fnref:Nielsen2010:5&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;sup&gt;6&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</content>
   </entry>
   
 
   
   <entry>
     <title>Fudan Library Access Button</title>
     <link href="/posts/2021-01/fudan-library-access-button.html"/>
     <updated>2021-01-15T00:00:00+00:00</updated>
     <id>/posts/2021-01/fudan-library-access-button</id>
     <content type="html">&lt;p&gt;The content in this post is
inspired by Duke library access button as in
&lt;a href=&quot;https://library.duke.edu/research/library-access-button&quot; target=&quot;_blank&quot;&gt;link&lt;/a&gt;.
I wrote a bookmarklet to access Fudan library resources via &lt;a href=&quot;https://webvpn.fudan.edu.cn/&quot; target=&quot;_blank&quot;&gt;Fudan
WebVPN&lt;/a&gt;. Although
the final functionality is nearly identical to that of Duke, the
implementation is different.&lt;/p&gt;

&lt;p&gt;We will not discuss the actual implementation in this post. Instead,
we simply give the installation and usage instructions.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;javascript: (function() {
    a = document.createElement('script');
    a.src = 'https://webvpn.fudan.edu.cn/wengine-vpn/js/aes-js.js';
    a.async = false;
    document.body.appendChild(a);
    e = document.createElement('script');
    e.src = 'https://webvpn.fudan.edu.cn/wengine-vpn/js/js/portal.js';
    e.async = false;
    e.onload = function() {
        wrdvpnIV = 'wrdvpnisthebest!';
        wrdvpnKey = 'wrdvpnisthebest!';
        location.href = 'https://webvpn.fudan.edu.cn' + encrypUrl(parseProtocol(location.href), location.href);
    };
    document.body.appendChild(e);
})();
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;After installation of the access button, you will have a button on
your browser’s bookmark toolbar. You can gain access to web content
that requires Fudan VPN service through one-click of the button
(UIS login is still needed, at least for the first time).&lt;/p&gt;

&lt;h2 id=&quot;installation-instruction&quot;&gt;Installation Instruction&lt;/h2&gt;

&lt;h3 id=&quot;mozilla-firefox&quot;&gt;Mozilla Firefox&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;javascript:(function(){a=document.createElement('script');a.src='https://webvpn.fudan.edu.cn/wengine-vpn/js/aes-js.js';a.async=false;document.body.appendChild(a);e=document.createElement('script');e.src='https://webvpn.fudan.edu.cn/wengine-vpn/js/js/portal.js';e.async=false;e.onload=function(){wrdvpnIV='wrdvpnisthebest!';wrdvpnKey='wrdvpnisthebest!';location.href='https://webvpn.fudan.edu.cn'+encrypUrl(parseProtocol(location.href),location.href);};document.body.appendChild(e);})();&quot;&gt;Fudan Library Access Button&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Right click&lt;/strong&gt; on the above link to add the button to your
&lt;strong&gt;Bookmarks bar&lt;/strong&gt;. From the dropdown, select &lt;strong&gt;Bookmark this Link&lt;/strong&gt;
and choose your folder.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;google-chrome-edge-or-safari&quot;&gt;Google Chrome, Edge or Safari&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;javascript:(function(){a=document.createElement('script');a.src='https://webvpn.fudan.edu.cn/wengine-vpn/js/aes-js.js';a.async=false;document.body.appendChild(a);e=document.createElement('script');e.src='https://webvpn.fudan.edu.cn/wengine-vpn/js/js/portal.js';e.async=false;e.onload=function(){wrdvpnIV='wrdvpnisthebest!';wrdvpnKey='wrdvpnisthebest!';location.href='https://webvpn.fudan.edu.cn'+encrypUrl(parseProtocol(location.href),location.href);};document.body.appendChild(e);})();&quot;&gt;Fudan Library Access Button&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Drag&lt;/strong&gt; the above link to your &lt;strong&gt;Bookmarks Toolbar&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;internet-explorer&quot;&gt;Internet Explorer&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;javascript:(function(){a=document.createElement('script');a.src='https://webvpn.fudan.edu.cn/wengine-vpn/js/aes-js.js';a.async=false;document.body.appendChild(a);e=document.createElement('script');e.src='https://webvpn.fudan.edu.cn/wengine-vpn/js/js/portal.js';e.async=false;e.onload=function(){wrdvpnIV='wrdvpnisthebest!';wrdvpnKey='wrdvpnisthebest!';location.href='https://webvpn.fudan.edu.cn'+encrypUrl(parseProtocol(location.href),location.href);};document.body.appendChild(e);})();&quot;&gt;Fudan Library Access Button&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Right click&lt;/strong&gt; on the above link to add the button to your
&lt;strong&gt;Bookmarks bar&lt;/strong&gt;. From the dropdown, select &lt;strong&gt;Add to Favorites&lt;/strong&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Probably, there will be a safety warning. If you are not confident,
you can read through the detail of the link below.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;mobile-users&quot;&gt;Mobile Users&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;javascript:(function(){a=document.createElement('script');a.src='https://webvpn.fudan.edu.cn/wengine-vpn/js/aes-js.js';a.async=false;document.body.appendChild(a);e=document.createElement('script');e.src='https://webvpn.fudan.edu.cn/wengine-vpn/js/js/portal.js';e.async=false;e.onload=function(){wrdvpnIV='wrdvpnisthebest!';wrdvpnKey='wrdvpnisthebest!';location.href='https://webvpn.fudan.edu.cn'+encrypUrl(parseProtocol(location.href),location.href);};document.body.appendChild(e);})();
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;Copy&lt;/strong&gt; the single line text above.&lt;/li&gt;
  &lt;li&gt;Open the browser and create a new bookmark of any page. Then tap
&lt;strong&gt;Edit&lt;/strong&gt; and replace the name as &lt;strong&gt;Fudan Library Access Button&lt;/strong&gt;(you
can change the name as you like) and replace the bookmark link by the
copied text.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;usage-instruction&quot;&gt;Usage Instruction&lt;/h2&gt;

&lt;p&gt;Our usage instruction will be demonstrated through an example.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Go to a Fudan library resource link, for example,
&lt;a href=&quot;https://pubs.acs.org/doi/10.1021/acs.jctc.9b00138&quot; target=&quot;_blank&quot;&gt;link&lt;/a&gt;.
If you are not connected to Fudan VPN or other library VPNs,
you should not have access to the PDF file.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;After the webpage is fully loaded&lt;/strong&gt;, click the button. You will
be navigated to Fudan WebVPN homepage and asked to input your
UIS credentials.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Login your UIS account.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;You will be redirected back to the link you have opened. Try to open
the PDF file.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you encounter any issue, please leave a message below.&lt;/p&gt;

&lt;h2 id=&quot;known-issue&quot;&gt;Known Issue&lt;/h2&gt;

&lt;p&gt;Recently, Fudan WebVPN cannot redirect to the link after login. Temporary
alternative solution is to login WebVPN first and then use the button.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Yingzhou Li&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;hr /&gt;

</content>
   </entry>
   
 
   
   <entry>
     <title>Von Neumann's Trace Inequalities</title>
     <link href="/posts/2020-07/von-neumann-trace-inequalities.html"/>
     <updated>2020-07-18T00:00:00+00:00</updated>
     <id>/posts/2020-07/von-neumann-trace-inequalities</id>
     <content type="html">&lt;p&gt;Trace inequality is important for matrix analysis. In this post we
first discuss Von Neumann’s trace inequality and another related
one, which can be viewed as a slightly more detailed version of the
trace inequality &lt;a href=&quot;https://en.wikipedia.org/wiki/Trace_inequality#Von_Neumann's_trace_inequality_and_related_results&quot; target=&quot;_blank&quot;&gt;Wiki page&lt;/a&gt;. Then we prove
a related trace inequality for general Hermitian matrices.&lt;/p&gt;

&lt;h2 id=&quot;von-neumanns-trace-inequality-and-related-results&quot;&gt;Von Neumann’s trace inequality and related results&lt;/h2&gt;

&lt;p&gt;In 1937, Von Neumann proved the following trace inequality
&lt;sup id=&quot;fnref:VonNeumann1937&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:VonNeumann1937&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;, where the trace of the product of two general
matrices is upper bounded by the sum of product of their singular
values in order.&lt;/p&gt;

&lt;blockquote class=&quot;theorem&quot; id=&quot;vonneumann&quot;&gt;

  &lt;p&gt;&lt;strong&gt;Theorem&lt;/strong&gt; (Von Neumann’s trace inequality).
If $A, B$ are complex $n \times n$ matrices with singular values,&lt;/p&gt;

\[\alpha_1 \geq \cdots \geq \alpha_n, \quad
\beta_1 \geq \cdots \geq \beta_n,\]

  &lt;p&gt;respectively, then&lt;/p&gt;

\[\lvert \mathrm{tr}(AB) \rvert \leq \sum_{i=1}^n \alpha_i \beta_i.\]

&lt;/blockquote&gt;

&lt;p&gt;Later in 1970, Ruhe proved a related trace inequality for the product
of positive semidefinite matrices &lt;sup id=&quot;fnref:Ruhe1970&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:Ruhe1970&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;. Importantly, both
the upper and the lower bounds are provided. The original statement
is for $A^* A$ and $B^* B$ for general complex matrices $A \in
\mathbb{C}^{m\times n}$ and $B \in \mathbb{C}^{n\times p}$.  Here we
restate the lemma with positive semidefinite Hermitian matrices.&lt;/p&gt;

&lt;blockquote class=&quot;theorem&quot; id=&quot;ruhe&quot;&gt;

  &lt;p&gt;&lt;strong&gt;Lemma 1&lt;/strong&gt; (Ruhe’s trace inequality). If $A, B$ are $n \times n$
positive semidefinite Hermitian matrices with eigenvalues,&lt;/p&gt;

\[a_1 \geq \cdots \geq a_n \geq 0, \quad
b_1 \geq \cdots \geq b_n \geq 0,\]

  &lt;p&gt;respectively, then&lt;/p&gt;

\[\sum_{i=1}^n a_i b_{n-i+1} \leq \mathrm{tr}(AB)
\leq \sum_{i=1}^n a_i b_i.\]

&lt;/blockquote&gt;

&lt;p&gt;Generalized version of both &lt;a href=&quot;#vonneumann&quot;&gt;Theorem&lt;/a&gt; and &lt;a href=&quot;#ruhe&quot;&gt;Lemma 1&lt;/a&gt;
are proved by Marshall et al. &lt;sup id=&quot;fnref:Marshall2011&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:Marshall2011&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;.  In the following,
we use $\lambda_i(\cdot)$ and $\sigma_i(\cdot)$ to denote the $i$-th
eigenvalue and singular value of a matrix. Both are of descending
order.&lt;/p&gt;

&lt;blockquote class=&quot;theorem&quot; id=&quot;lemma2&quot;&gt;

  &lt;p&gt;&lt;strong&gt;Lemma 2&lt;/strong&gt;
If $A, B$ are complex $n \times n$ matrices, then for any $k = 1, \dots,
n$,&lt;/p&gt;

\[\sum_{i=1}^k \sigma_i(AB) \leq \sum_{i=1}^k \sigma_i(A) \sigma_i(B).\]

&lt;/blockquote&gt;

&lt;blockquote class=&quot;theorem&quot; id=&quot;lemma3&quot;&gt;

  &lt;p&gt;&lt;strong&gt;Lemma 3&lt;/strong&gt; If $A, B$ are $n \times n$ positive semidefinite Hermitian
matrices, then for any $k = 1, \dots, n$,&lt;/p&gt;

\[\sum_{i=1}^k \lambda_i(A) \lambda_{n-i+1}(B) \leq
\sum_{i=1}^k \lambda_i(AB)\]

&lt;/blockquote&gt;

&lt;p&gt;Although &lt;a href=&quot;#lemma3&quot;&gt;Lemma 3&lt;/a&gt; only generalizes lower bound part of
&lt;a href=&quot;#ruhe&quot;&gt;Lemma 1&lt;/a&gt;, the other inequality also holds under the same
generalization.&lt;/p&gt;

&lt;h2 id=&quot;lemma-1-for-general-hermitian-matrices&quot;&gt;&lt;a href=&quot;#ruhe&quot;&gt;Lemma 1&lt;/a&gt; for general Hermitian matrices&lt;/h2&gt;

&lt;p&gt;In (Marshall et al. 2011) &lt;sup id=&quot;fnref:Marshall2011:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:Marshall2011&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;, it is mentioned the upper
bound part of &lt;a href=&quot;#ruhe&quot;&gt;Lemma 1&lt;/a&gt; can be generalized to general Hermitian
matrices. Here we rigorously prove that the positive semidefinite
assumption can be removed and both inequalities in &lt;a href=&quot;#ruhe&quot;&gt;Lemma 1&lt;/a&gt;
still hold.&lt;/p&gt;

&lt;blockquote class=&quot;theorem&quot; id=&quot;gruhe&quot;&gt;

  &lt;p&gt;&lt;strong&gt;Lemma 4&lt;/strong&gt; (Generalized Ruhe’s trace inequality). If $A, B$ are
$n \times n$ Hermitian matrices, then&lt;/p&gt;

\[\sum_{i=1}^n \lambda_i(A) \lambda_{n-i+1}(B) \leq \mathrm{tr}(AB)
\leq \sum_{i=1}^n \lambda_i(A) \lambda_i(B).\]

&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Proof.&lt;/strong&gt; Since Hermitian matrices have unitary eigenvectors,
we denote the eigen-decomposition of $A$ as $A = Q \Lambda Q^\star$
where $Q$ is a unitary matrix. The trace of $AB$ is then,
\(\begin{equation}
    \mathrm{tr}(AB) = \mathrm{tr}(Q \Lambda Q^\star B) =
    \mathrm{tr}(\Lambda Q^\star BQ),
\end{equation}\)
where $Q^\star BQ$ and $B$ share the same eigenvalues.&lt;/p&gt;

&lt;p&gt;Therefore, without loss of generality, we can assume that $A$ is a
diagonal matrix with diagonal entries being eigenvalues, $\lambda_1(A),
\dots, \lambda_n(A)$. Then we have,&lt;/p&gt;

\[\begin{equation} \label{eq:trace}
    \mathrm{tr}(AB) = \sum_{i=1}^n \lambda_i(A) B_{ii}.
\end{equation}\]

&lt;p&gt;We use induction over $n$ to prove the lemma. For $n=1$, both
inequalities become equality and hold. Now we assume that both
inequalities are true for all $(n-1) \times (n-1)$ matrices.&lt;/p&gt;

&lt;p&gt;We reorganize the trace \eqref{eq:trace} as follows,&lt;/p&gt;

\[\begin{split}
\mathrm{tr}(AB) = &amp;amp; \sum_{i=1}^{n-1} (\lambda_i(A) - \lambda_n(A)) B_{ii}
+ \sum_{i=1}^n \lambda_n(A) B_{ii}\\
= &amp;amp; \mathrm{tr}(\tilde{\Lambda} \tilde{B})
+ \lambda_n(A) \mathrm{tr}(B)\\
\end{split}
,\]

&lt;p&gt;where $\tilde{\Lambda}$ is an $(n-1)\times (n-1)$ diagonal matrix with
diagonal entries being $\lambda_i(A) - \lambda_n(A)$, and $\tilde{B}$ is
the first $(n-1) \times (n-1)$ principal submatrix of $B$.&lt;/p&gt;

&lt;p&gt;By &lt;a href=&quot;https://en.wikipedia.org/wiki/Min-max_theorem#Cauchy_interlacing_theorem&quot; target=&quot;_blank&quot;&gt;Cauchy Interlacing
Theorem&lt;/a&gt;,
we have the following relations for eigenvalues of $B$ and $\tilde{B}$,&lt;/p&gt;

\[\begin{equation} \label{eq:interlacing}
    \lambda_{i+1}(B) \leq \lambda_i(\tilde{B}) \leq \lambda_i(B).
\end{equation}\]

&lt;p&gt;Applying the induction hypothesis on $\mathrm{tr}(\tilde{\Lambda}
\tilde{B})$, we first show the upper bound part,&lt;/p&gt;

\[\begin{split}
\mathrm{tr}(AB) \leq &amp;amp; \sum_{i=1}^{n-1} (\lambda_i(A) - \lambda_n(A))
\lambda_i(\tilde{B})
+ \lambda_n(A) \sum_{i=1}^n \lambda_i(B)\\
\leq &amp;amp; \sum_{i=1}^{n-1} (\lambda_i(A) - \lambda_n(A))
\lambda_i(B)
+ \lambda_n(A) \sum_{i=1}^n \lambda_i(B)\\
= &amp;amp; \sum_{i=1}^n \lambda_i(A) \lambda_i(B)
\end{split}
,\]

&lt;p&gt;where the second inequality adopts positivity of $\lambda_i(A) -
\lambda_n(A)$ and the interlacing theorem \eqref{eq:interlacing}.&lt;/p&gt;

&lt;p&gt;Similarly, we can show the lower bound part as,&lt;/p&gt;

\[\begin{split}
\mathrm{tr}(AB) \geq &amp;amp; \sum_{i=1}^{n-1} (\lambda_i(A) - \lambda_n(A))
\lambda_{n-i}(\tilde{B})
+ \lambda_n(A) \sum_{i=1}^{n} \lambda_{n-i+1}(B)\\
\geq &amp;amp; \sum_{i=1}^{n-1} (\lambda_i(A) - \lambda_n(A))
\lambda_{n-i+1}(B)
+ \lambda_n(A) \sum_{i=1}^{n} \lambda_{n-i+1}(B)\\
= &amp;amp; \sum_{i=1}^n \lambda_i(A) \lambda_{n-i+1}(B)
\end{split}
.\]

&lt;p&gt;Hence we proved the lemma.
\(\tag*{$\blacksquare$}\)&lt;/p&gt;

&lt;p&gt;The conditions for the equalities in &lt;a href=&quot;#gruhe&quot;&gt;Lemma 4&lt;/a&gt; are very
restrictive. First, $A$ and $B$ must commute so that they have
the same eigenvectors and the trace of product becomes the sum of
products of eigenvalues. In addition to the commutative property,
the ordering of eigenvalues also matters. When the eigenvalues of
$A$ are decreasingly ordered, the corresponding eigenvalues of $B$
must be also of decreasing order to satisfy the equality of the upper
bound part, and of increasing order to satisfy the equality of the
lower bound part.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Yingzhou Li&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;Reference&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:VonNeumann1937&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Von Neumann, J., Some matrix-inequalities and metrization of matrix-space, Tomsk Univ. Rev. 1, 286-300 (1937). Reprinted in Collected Works (Pergamon Press, 1962), iv, 205-219. &lt;a href=&quot;#fnref:VonNeumann1937&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:Ruhe1970&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Ruhe, A., Perturbation bounds for means of eigenvalues and invariant subspaces, Nordisk Tidskr. Informationsbehandling (BIT) 10, 343-354 (1970). &lt;a href=&quot;#fnref:Ruhe1970&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:Marshall2011&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Marshall, A. W.; Olkin, I.; Arnold, B., Inequalities: Theory of Majorization and Its Applications (2nd ed.). New York: Springer. p. 340-341 (2011). &lt;a href=&quot;#fnref:Marshall2011&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt; &lt;a href=&quot;#fnref:Marshall2011:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;sup&gt;2&lt;/sup&gt;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</content>
   </entry>
   
 
   
   <entry>
     <title>Setup mex with MSVC on Windows</title>
     <link href="/posts/2020-06/mex-msvc.html"/>
     <updated>2020-06-30T00:00:00+00:00</updated>
     <id>/posts/2020-06/mex-msvc</id>
     <content type="html">&lt;p&gt;Recently, while I was trying to support
&lt;a href=&quot;https://github.com/YingzhouLi/metismex&quot;&gt;metismex&lt;/a&gt; on Windows, the
mex setup on Windows confused me for a very long time when my MSVC
was installed through BuildTools. The direct setup in Matlab for mex,
i.e., &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mex -setup C&lt;/code&gt; fails to locate compiler path.  It turned out
that the Matlab search path only include ‘Community’, ‘Professional’,
and ‘Enterprise’ versions, while the ‘BuildTools’ version is left
out. However, ‘BuildTools’ version is much lighter in disk cost than
other versions and is more preferred if IDE is not needed.&lt;/p&gt;

&lt;p&gt;When I ran &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mex -setup&lt;/code&gt;, the following error message appeared,&lt;/p&gt;

&lt;div class=&quot;language-matlab highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;   &lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;mex&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;v&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;setup&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;Verbose&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;mode&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;

   &lt;span class=&quot;c1&quot;&gt;%&lt;/span&gt;
   &lt;span class=&quot;c1&quot;&gt;% many lines are removed&lt;/span&gt;
   &lt;span class=&quot;c1&quot;&gt;%&lt;/span&gt;

   &lt;span class=&quot;k&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;c&quot;&gt; Looking for compiler 'Microsoft Visual C++ 2019 (C)' ...&lt;/span&gt;
   &lt;span class=&quot;k&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;c&quot;&gt; Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').&lt;/span&gt;
   &lt;span class=&quot;k&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;c&quot;&gt; Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.&lt;/span&gt;
   &lt;span class=&quot;k&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;c&quot;&gt; Executing command '&quot;C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe&quot; -version &quot;[16.0,17.0)&quot; -products Microsoft.VisualStudio.Product.Enterprise -property installationPath -format value' ...No.&lt;/span&gt;
   &lt;span class=&quot;k&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;c&quot;&gt; Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').&lt;/span&gt;
   &lt;span class=&quot;k&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;c&quot;&gt; Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.&lt;/span&gt;
   &lt;span class=&quot;k&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;c&quot;&gt; Executing command '&quot;C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe&quot; -version &quot;[16.0,17.0)&quot; -products Microsoft.VisualStudio.Product.Professional -property installationPath -format value' ...No.&lt;/span&gt;
   &lt;span class=&quot;k&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;c&quot;&gt; Looking for environment variable 'ProgramFiles(x86)' ...Yes ('C:\Program Files (x86)').&lt;/span&gt;
   &lt;span class=&quot;k&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;c&quot;&gt; Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe' ...Yes.&lt;/span&gt;
   &lt;span class=&quot;k&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;c&quot;&gt; Executing command '&quot;C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe&quot; -version &quot;[16.0,17.0)&quot; -products Microsoft.VisualStudio.Product.Community -property installationPath -format value' ...No.&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;Did&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;find&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;installed&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;compiler&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'Microsoft Visual C++ 2019 (C)'&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;Error&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;using&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;mex&lt;/span&gt;
   &lt;span class=&quot;n&quot;&gt;No&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;supported&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;compiler&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;or&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;SDK&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;was&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;found&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;For&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;options&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;visit&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;http&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;://&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;www&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mathworks&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;com&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;support&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;compilers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;R2016a&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;maci64&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To be more precise, my MATLAB version is R2020a and MSVC version
is 2019. Although MATLAB with versions earlier than R2019b does not
support Visual Studio 2019 version 16, adding the following xml files
to folder &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;MATLABROOT/bin/win64/mexopts/&lt;/code&gt; could resolve the issue. If
any reader succeed, please let me know.&lt;/p&gt;

&lt;p&gt;Here, we list a few steps in the modification.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Change the editing permission of the following two &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xml&lt;/code&gt; files.&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MATLABROOT/bin/win64/mexopts/msvc2019.xml
MATLABROOT/bin/win64/mexopts/msvcpp2019.xml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Edit both &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xml&lt;/code&gt; files in the following way.&lt;/p&gt;

    &lt;ol&gt;
      &lt;li&gt;Find the block of lines as
        &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;and&amp;gt;
    &amp;lt;envVarExists name=&quot;ProgramFiles(x86)&quot; /&amp;gt;
    &amp;lt;fileExists name=&quot;$$\Microsoft Visual Studio\Installer\vswhere.exe&quot; /&amp;gt;
    &amp;lt;cmdReturns name=&quot;&amp;amp;quot;$$\\vswhere.exe&amp;amp;quot; -version &amp;amp;quot;[16.0,17.0)&amp;amp;quot; -products Microsoft.VisualStudio.Product.Community -property installationPath -format value&quot; /&amp;gt;
    &amp;lt;cmdReturns name=&quot;set &amp;amp;quot;vcroot=$$&amp;amp;quot;&amp;amp;amp;for /f &amp;amp;quot;delims= &amp;amp;quot; %a in ('type &amp;amp;quot;$$\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt&amp;amp;quot;') do @if exist &amp;amp;quot;$$\VC\Tools\MSVC\%a\bin\HostX64\x64\cl.exe&amp;amp;quot; call echo %vcroot%&quot; /&amp;gt;
&amp;lt;/and&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
        &lt;p&gt;and attach the following block right below it&lt;/p&gt;
        &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;and&amp;gt;
    &amp;lt;envVarExists name=&quot;ProgramFiles(x86)&quot; /&amp;gt;
    &amp;lt;fileExists name=&quot;$$\Microsoft Visual Studio\Installer\vswhere.exe&quot; /&amp;gt;
    &amp;lt;cmdReturns name=&quot;&amp;amp;quot;$$\\vswhere.exe&amp;amp;quot; -version &amp;amp;quot;[16.0,17.0)&amp;amp;quot; -products Microsoft.VisualStudio.Product.BuildTools -property installationPath -format value&quot; /&amp;gt;
    &amp;lt;cmdReturns name=&quot;set &amp;amp;quot;vcroot=$$&amp;amp;quot;&amp;amp;amp;for /f &amp;amp;quot;delims= &amp;amp;quot; %a in ('type &amp;amp;quot;$$\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt&amp;amp;quot;') do @if exist &amp;amp;quot;$$\VC\Tools\MSVC\%a\bin\HostX64\x64\cl.exe&amp;amp;quot; call echo %vcroot%&quot; /&amp;gt;
&amp;lt;/and&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
      &lt;/li&gt;
      &lt;li&gt;Find the block of lines as
        &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;and&amp;gt;
    &amp;lt;envVarExists name=&quot;ProgramFiles(x86)&quot; /&amp;gt;
    &amp;lt;fileExists name=&quot;$$\Microsoft Visual Studio\Installer\vswhere.exe&quot; /&amp;gt;
    &amp;lt;cmdReturns name=&quot;&amp;amp;quot;$$\\vswhere.exe&amp;amp;quot; -version &amp;amp;quot;[16.0,17.0)&amp;amp;quot; -products Microsoft.VisualStudio.Product.Community -property installationPath -format value&quot; /&amp;gt;
&amp;lt;/and&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
        &lt;p&gt;and attach the following block right below it&lt;/p&gt;
        &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;and&amp;gt;
    &amp;lt;envVarExists name=&quot;ProgramFiles(x86)&quot; /&amp;gt;
    &amp;lt;fileExists name=&quot;$$\Microsoft Visual Studio\Installer\vswhere.exe&quot; /&amp;gt;
    &amp;lt;cmdReturns name=&quot;&amp;amp;quot;$$\\vswhere.exe&amp;amp;quot; -version &amp;amp;quot;[16.0,17.0)&amp;amp;quot; -products Microsoft.VisualStudio.Product.BuildTools -property installationPath -format value&quot; /&amp;gt;
&amp;lt;/and&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
      &lt;/li&gt;
      &lt;li&gt;Find the block of lines as
        &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;and&amp;gt;
    &amp;lt;envVarExists name=&quot;ProgramFiles(x86)&quot; /&amp;gt;
    &amp;lt;fileExists name=&quot;$$\Microsoft Visual Studio\Installer\vswhere.exe&quot; /&amp;gt;
    &amp;lt;cmdReturns name=&quot;&amp;amp;quot;$$\\vswhere.exe&amp;amp;quot; -version &amp;amp;quot;[16.0,17.0)&amp;amp;quot; -products Microsoft.VisualStudio.Product.Community -property installationPath -format value&quot; /&amp;gt;
    &amp;lt;cmdReturns name=&quot;set &amp;amp;quot;vcroot=$$&amp;amp;quot;&amp;amp;amp;for /f &amp;amp;quot;delims= &amp;amp;quot; %a in ('type &amp;amp;quot;$$\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt&amp;amp;quot;') do @if exist &amp;amp;quot;$$\VC\Tools\MSVC\%a\bin\HostX64\x64\cl.exe&amp;amp;quot; call echo %vcroot%\VC\Tools\MSVC\%a&quot; /&amp;gt;
&amp;lt;/and&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
        &lt;p&gt;and attach the following block right below it&lt;/p&gt;
        &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;and&amp;gt;
    &amp;lt;envVarExists name=&quot;ProgramFiles(x86)&quot; /&amp;gt;
    &amp;lt;fileExists name=&quot;$$\Microsoft Visual Studio\Installer\vswhere.exe&quot; /&amp;gt;
    &amp;lt;cmdReturns name=&quot;&amp;amp;quot;$$\\vswhere.exe&amp;amp;quot; -version &amp;amp;quot;[16.0,17.0)&amp;amp;quot; -products Microsoft.VisualStudio.Product.BuildTools -property installationPath -format value&quot; /&amp;gt;
    &amp;lt;cmdReturns name=&quot;set &amp;amp;quot;vcroot=$$&amp;amp;quot;&amp;amp;amp;for /f &amp;amp;quot;delims= &amp;amp;quot; %a in ('type &amp;amp;quot;$$\VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt&amp;amp;quot;') do @if exist &amp;amp;quot;$$\VC\Tools\MSVC\%a\bin\HostX64\x64\cl.exe&amp;amp;quot; call echo %vcroot%\VC\Tools\MSVC\%a&quot; /&amp;gt;
&amp;lt;/and&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
      &lt;/li&gt;
      &lt;li&gt;Find the block of lines as
        &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;and&amp;gt;
    &amp;lt;envVarExists name=&quot;ProgramFiles(x86)&quot; /&amp;gt;
    &amp;lt;fileExists name=&quot;$$\Microsoft Visual Studio\Installer\vswhere.exe&quot; /&amp;gt;
    &amp;lt;cmdReturns name=&quot;&amp;amp;quot;$$\\vswhere.exe&amp;amp;quot; -version &amp;amp;quot;[16.0,17.0)&amp;amp;quot; -products Microsoft.VisualStudio.Product.Community -property installationPath -format value&quot; /&amp;gt;
    &amp;lt;fileExists name=&quot;$$\VC\Auxiliary\Build\vcvarsall.bat&quot; /&amp;gt;
    &amp;lt;dirExists name=&quot;$$&quot;/&amp;gt;
&amp;lt;/and&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
        &lt;p&gt;and attach the following block right below it&lt;/p&gt;
        &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;and&amp;gt;
    &amp;lt;envVarExists name=&quot;ProgramFiles(x86)&quot; /&amp;gt;
    &amp;lt;fileExists name=&quot;$$\Microsoft Visual Studio\Installer\vswhere.exe&quot; /&amp;gt;
    &amp;lt;cmdReturns name=&quot;&amp;amp;quot;$$\\vswhere.exe&amp;amp;quot; -version &amp;amp;quot;[16.0,17.0)&amp;amp;quot; -products Microsoft.VisualStudio.Product.BuildTools -property installationPath -format value&quot; /&amp;gt;
    &amp;lt;fileExists name=&quot;$$\VC\Auxiliary\Build\vcvarsall.bat&quot; /&amp;gt;
    &amp;lt;dirExists name=&quot;$$&quot;/&amp;gt;
&amp;lt;/and&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
      &lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For convenience, I list two updated &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;xml&lt;/code&gt; files for download:
&lt;a href=&quot;/download_file/File/msvc2019.xml&quot;&gt;msvc2019.xml&lt;/a&gt; and
&lt;a href=&quot;/download_file/File/msvcpp2019.xml&quot;&gt;msvcpp2019.xml&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The above updates should be valid across different Windows systems
and most MATLAB versions. If there is major difference, and you find
it impossible to update accordingly, please comment below or send me
an Email.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Yingzhou Li&lt;/p&gt;
</content>
   </entry>
   
 
   
   <entry>
     <title>Reducible Singular Value Decomposition</title>
     <link href="/posts/2018-07/reducible-svd.html"/>
     <updated>2018-07-04T00:00:00+00:00</updated>
     <id>/posts/2018-07/reducible-svd</id>
     <content type="html">&lt;p&gt;While reading the following review article on density-matrix
renormalization group (DMRG), I encountered a linear algebra excise based
on the last paragraph of page 125.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;U. Schollwöck, The density-matrix renormalization group in
the age of matrix product states, Annals of Physics 326, 96-192
(2011). [&lt;a href=&quot;https://www.sciencedirect.com/science/article/pii/S0003491610001752?via%3Dihub&quot;&gt;journal&lt;/a&gt;]&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The paper concludes the result of the excise in one sentence, “they are
reduced basis transformations to orthonormal subspaces, hence the largest
singular value must be less or equal to that of $S$”. However, I found
that the proof is beyond such a single sentence. Therefore, it worth
to post the excise together with the solution here.&lt;/p&gt;

&lt;h2 id=&quot;preliminary&quot;&gt;Preliminary&lt;/h2&gt;

&lt;p&gt;We first briefly introduce the singular value decomposition (SVD) and
another matrix decomposition called reducible SVD as preliminary for
the excise.&lt;/p&gt;

&lt;p&gt;Let $A \in \mathbb{R}^{n \times n}$ be a real $n$ by $n$ full rank
matrix. The SVD of $A$ is $A = U\Sigma V^\top$, where $U \in \mathbb{R}^{n
\times n}$ is a unitary matrix being the left singular vectors,
$\Sigma \in \mathbb{R}^{n \times n}$ is a diagonal matrix with $A$’s
singular values in decreasing order, and $V \in \mathbb{R}^{n \times
n}$ is another unitary matrix being the right singular vectors. It is
well-known that the SVD is unique up to a complex sign (if the singular
vectors are restricted to real matrices, complex sign is simply $\pm$).&lt;/p&gt;

&lt;p&gt;We now define another decomposition which has the same structure as the
SVD,&lt;/p&gt;

\[A = P S Q^\top\]

&lt;p&gt;where $P \in \mathbb{R}^{n \times m}$ satisfies $PP^\top = I$, $S \in
\mathbb{R}^{m \times m}$ is a diagonal matrix with positive diagonal in
decreasing order, $Q \in \mathbb{R}^{n \times m}$ satisfies $QQ^\top =
I$, and $I$ denotes the identity matrix. This is very different from the
usual case that $m$ denotes the numerical rank which is upper bounded
by $n$. In our excise, we have $m \geq n$. In this post, we call
such a decomposition reducible SVD.&lt;/p&gt;

&lt;p&gt;If $m$ is strictly larger than $n$, through a trivial example,&lt;/p&gt;

\[1 =
\begin{bmatrix} \frac{\sqrt{2}}{2} &amp;amp; \frac{\sqrt{2}}{2}
\end{bmatrix}
\cdot
\begin{bmatrix} 1 &amp;amp; \\ &amp;amp; 1 
\end{bmatrix}
\cdot
\begin{bmatrix} \frac{\sqrt{2}}{2} \\ \frac{\sqrt{2}}{2}
\end{bmatrix}
=
\begin{bmatrix} \frac{\sqrt{2}}{2} &amp;amp; \frac{\sqrt{2}}{2}
\end{bmatrix}
\cdot
\begin{bmatrix} 1.5 &amp;amp; \\ &amp;amp; 0.5
\end{bmatrix}
\cdot
\begin{bmatrix} \frac{\sqrt{2}}{2} \\ \frac{\sqrt{2}}{2}
\end{bmatrix},\]

&lt;p&gt;we are convinced that such a decomposition is not unique.&lt;/p&gt;

&lt;h2 id=&quot;excise&quot;&gt;Excise&lt;/h2&gt;

&lt;p&gt;With these definitions, the excise can be summarized as follows. Let $P
S Q^\top$ be any reducible SVD of $A$. The following statement holds,&lt;/p&gt;

\[\max_i \sigma_i \leq \max_i s_{i},\]

&lt;p&gt;where $\sigma_i$ denotes the $i$-th singular value of $A$ and $s_{i}$ is
the $i$-th diagonal entry of $S$. The statement is equivalent to say that
the largest singular value is smaller or equal to largest reducible
singular value.&lt;/p&gt;

&lt;h2 id=&quot;solution&quot;&gt;Solution&lt;/h2&gt;

&lt;p&gt;Now we will solve the excise. Since both SVD and reducible SVD are
decomposition of $A$, we have,&lt;/p&gt;

\[A = U \Sigma V^\top = P S Q^\top \Leftrightarrow \Sigma = U^\top P S
Q^\top V = G S H^\top,\]

&lt;p&gt;where $G = U^\top P$ satisfies $GG^\top = I$, and $H = V^\top Q$ satisfies
$HH^\top = I$. In terms of $G,S$, and $H$, the largest singular value of
$A$ can be written as,&lt;/p&gt;

\[\sigma_1 = \sum_i G_{1,i} s_i H_{1,i},\]

&lt;p&gt;where $G_{1,i}$ denotes the $(1,i)$-th entry of $G$, and $H_{1,i}$
is defined analogously. The conditions on $G$ and $H$ led to,&lt;/p&gt;

\[\sum_i G_{1,i}^2 = 1 \quad \text{and} \quad \sum_i H_{1,i}^2 = 1.\]

&lt;p&gt;Then we have,&lt;/p&gt;

\[\sigma_1^2 = \left( \sum_i G_{1,i} s_i H_{1,i} \right)^2
\leq \left( \sum_i G_{1,i}^2 \right)
\cdot \left( \sum_i s_i^2 H_{1,i}^2 \right)
\leq \left( \sum_i H_{1,i}^2 \right) \cdot \max_i s_i^2 = s_1^2,\]

&lt;p&gt;where the first inequality is due to Cauchy-Schwartz inequality and
the second inequality is due to Hölder’s inequality with $p=1$ and
$q=\infty$. Finally, since both $\sigma_1$ and $s_1$ are positive, we
conclude $\max_i \sigma_i = \sigma_1 \leq s_1 = \max_i s_i$.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Yingzhou Li&lt;/p&gt;

</content>
   </entry>
   
 
   
   <entry>
     <title>Setup mex with GFORTRAN on Mac</title>
     <link href="/posts/2017-05/mex-gfortran.html"/>
     <updated>2017-05-08T00:00:00+00:00</updated>
     <id>/posts/2017-05/mex-gfortran</id>
     <content type="html">&lt;p&gt;I was struggling with mex setup on Mac for a very long time since there was
error with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mex -setup C&lt;/code&gt; for Matlab on new MacOS. It turned out that the
Matlab search path did not include the newest Xcode SDK “MacOSX10.12.sdk” in
its search path. Once it was added, the problem with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mex -setup C&lt;/code&gt; was
resolved.&lt;/p&gt;

&lt;p&gt;However, today, I encountered another mex issue in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mex -setup FORTRAN&lt;/code&gt;.
When I ran &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mex -setup -v FORTRAN&lt;/code&gt;, the following error message appeared,&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;   &amp;gt;&amp;gt; mex -setup -v FORTRAN
   Verbose mode is on.
   ... Looking for compiler 'gfortran' ...
   ... Looking for environment variable 'DEVELOPER_DIR' ...No.
   ... Executing command 'which gfortran' ...Yes ('/usr/local/bin/gfortran').
   ... Looking for folder '/usr/local/bin' ...Yes.
   ... Executing command 'which gfortran' ...Yes ('/usr/local/bin/gfortran').
   ... Executing command '/usr/local/bin/gfortran -print-file-name=libgfortran.dylib' ...Yes ('/usr/local/Cellar/gcc/6.3.0_1/lib/gcc/6/libgfortran.dylib').
   ... Looking for folder '/usr/local/Cellar/gcc/6.3.0_1/lib/gcc/6' ...Yes.
   ... Executing command 'which gfortran' ...Yes ('/usr/local/bin/gfortran').
   ... Executing command '/usr/local/bin/gfortran -print-file-name=libgfortranbegin.a' ...Yes ('libgfortranbegin.a').
   ... Looking for folder 'libgfortranbegin.a' ...No.
   Did not find installed compiler 'gfortran'.
   ... Looking for compiler 'Intel Fortran' ...
   ... Looking for environment variable 'IFORT_COMPILER14' ...No.
   ... Looking for environment variable 'IFORT_COMPILER13' ...No.
   ... Executing command 'which ifort' ...Yes ('/usr/local/bin/ifort').
   ... Looking for folder '/usr/local/bin' ...Yes.
   ... Looking for environment variable 'IFORT_COMPILER14' ...No.
   ... Looking for environment variable 'IFORT_COMPILER13' ...No.
   ... Executing command 'which ifort' ...Yes ('/usr/local/bin/ifort').
   ... Looking for folder '/usr/compiler/lib' ...No.
   Did not find installed compiler 'Intel Fortran'.
   Error using mex
   No supported compiler or SDK was found. For options, visit http://www.mathworks.com/support/compilers/R2016a/maci64.html.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;To be more specific, my Fortran version is GFORTRAN (GCC 6.3.0_1) and my
MATLAB version is R2016a. The reason causing the error above is due to the
change of the Fortran library in the new GNU version. In recent versions,
GNU removed the library &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;libgfortranbegin.a&lt;/code&gt; and moved these piece of code
into &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;libgfortran.a&lt;/code&gt;. Therefore, if we need to link the mex with new
GFORTRAN version, the searching in MATLAB must be modified.&lt;/p&gt;

&lt;p&gt;Here, we list a few steps in the modification.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Copy a xml file to local start up folder.&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cp /Applications/MATLAB_R2016a.app/bin/maci64/mexopts/gfortran.xml ~/.matlab/R2016a/mex_FORTRAN_maci64.xml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Edit &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mex_FORTRAN_maci64.xml&lt;/code&gt; with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo&lt;/code&gt; permission.&lt;/p&gt;

    &lt;ol&gt;
      &lt;li&gt;Find the line with
        &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;LINKLIBS=&quot;-L&amp;amp;quot;$MATLABROOT/bin/maci64&amp;amp;quot; -lmx -lmex -lmat -L&amp;amp;quot;$GFORTRAN_LIBDIR&amp;amp;quot; -lgfortran -L&amp;amp;quot;$GFORTRANBEGIN_LIBDIR&amp;amp;quot; -lgfortranbegin&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
        &lt;p&gt;and change it to&lt;/p&gt;
        &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;LINKLIBS=&quot;-L&amp;amp;quot;$MATLABROOT/bin/maci64&amp;amp;quot; -lmx -lmex -lmat -L&amp;amp;quot;$GFORTRAN_LIBDIR&amp;amp;quot; -lgfortran -lgcc_s.1&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
      &lt;/li&gt;
      &lt;li&gt;Find the lines as
        &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;cmdReturns name=&quot;$$/gfortran -print-file-name=libgfortranbegin.a    &quot; /&amp;gt;
&amp;lt;dirExists name=&quot;$$&quot; /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
        &lt;p&gt;and change it to&lt;/p&gt;
        &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;cmdReturns name=&quot;$$/gfortran -print-file-name=libgfortranbegin.a    &quot; /&amp;gt;
&amp;lt;dirExists name=&quot;/&quot; /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
      &lt;/li&gt;
      &lt;li&gt;Find all lines with
        &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;dirExists name=&quot;$$/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk&quot; /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
        &lt;p&gt;and attach the following line below in every place&lt;/p&gt;
        &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;dirExists name=&quot;$$/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk&quot; /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
      &lt;/li&gt;
      &lt;li&gt;Find all lines with
        &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;cmdReturns name=&quot;find $$ -name MacOSX10.11.sdk&quot; /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
        &lt;p&gt;and attach the following line below in every place&lt;/p&gt;
        &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;cmdReturns name=&quot;find $$ -name MacOSX10.12.sdk&quot; /&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
      &lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If there is minor difference between your system and mine, please update the
corresponding path. If the difference is major, and you find it impossible
to update accordingly, please comment below or send me an Email.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Yingzhou Li&lt;/p&gt;
</content>
   </entry>
   
 
   
   <entry>
     <title>Paper Corrections for A multiscale butterfly algorithm for multidimensional Fourier integral operators</title>
     <link href="/posts/2017-04/correction-mba.html"/>
     <updated>2017-04-22T00:00:00+00:00</updated>
     <id>/posts/2017-04/correction-mba</id>
     <content type="html">&lt;p&gt;This post lists corrections for the following paper.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Y. Li, H. Yang, and L. Ying, A multiscale butterfly algorithm for
multidimensional Fourier integral operators, Multiscale Modeling and
Simulation 13:2, 614-631 (2015). [&lt;a href=&quot;/download_file/Paper/mba.pdf&quot;&gt;PDF&lt;/a&gt;, &lt;a href=&quot;http://epubs.siam.org/doi/abs/10.1137/140997658&quot;&gt;journal&lt;/a&gt;]&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So far, I have found the following mistakes or typos.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Page 629, Equation (36), “$\Phi(x,\xi) = x \cdot \xi +
c(x)\sqrt{\xi_1^2+\xi_2^2}$” should be “$\Phi(x,\xi) = x \cdot
\xi + c(x) \sqrt{\xi_1^2+\xi_2^2+\xi_3^2}$”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Yingzhou Li&lt;/p&gt;

</content>
   </entry>
   
 
   
   <entry>
     <title>Paper Corrections for Butterfly Factorization</title>
     <link href="/posts/2017-04/correction-bf.html"/>
     <updated>2017-04-22T00:00:00+00:00</updated>
     <id>/posts/2017-04/correction-bf</id>
     <content type="html">&lt;p&gt;This post lists corrections for the following paper.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Y. Li, H. Yang, E. Martin, K. Ho and L. Ying, Butterfly Factorization,
Multiscale Modeling and Simulation 13:2, 714-732 (2015). [&lt;a href=&quot;/download_file/Paper/bf.pdf&quot;&gt;PDF&lt;/a&gt;,
&lt;a href=&quot;http://epubs.siam.org/doi/abs/10.1137/15M1007173&quot;&gt;journal&lt;/a&gt;]&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So far, I have found the following mistakes or typos.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Page 719, Section 2.2, last sentence of the first paragraph “… hence
  requires only $O(r(m+n))$ operations and memory.” should be “… hence
  requires only $O(r^2(m+n))$ operations and $O(r(m+n))$ memory …”&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Page 718, Section 2.1, SVD via random matrix-vector multiplication. The
  formula for the middle matrix $ M = Q^\star_{col} Z Q_{row} $ in the
  third step should not be used in the middle level factorization
  directly, since the matrix Z could not be applied to basis $ Q_{row} $
  or $ Q_{col} $ again.  The actual way to implement is that $ M = \left(
  R^\star_{row}Q_{col} \right)^\dagger R^\star_{row} Z R_{col} \left(
  Q^\star_{row} R_{col} \right)^\dagger $. Such the case $ Z R_{col} $ can
  be reused and all the computations are in the local block.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Yingzhou Li&lt;/p&gt;

</content>
   </entry>
   
 
   
   <entry>
     <title>乔布斯传</title>
     <link href="/posts/2016-06/qiaobusizhuan.html"/>
     <updated>2016-06-18T00:00:00+00:00</updated>
     <id>/posts/2016-06/qiaobusizhuan</id>
     <content type="html">&lt;p&gt;这次花了比较长的时间才读完《乔布斯传》。全书基本上按照时间顺序讲述了乔布斯的一生，从一出生被领养，跳到大学时期，再详细的介绍了从创立苹果之后的点点滴滴。&lt;/p&gt;

&lt;p&gt;由于阅读的是中文译本，所以对于文笔不再做任何评论。但是对于人物传记而言，事件记录还算客观，作者对乔布斯的评价不能算客观，但是还是给读者留出了足够的客观事实，从而使得读者可以给出自己对乔布斯的评价。这里我们先零零散散的讲几处印象比较深刻的地方，最后再说说我个人对乔布斯的评价，以及对自身的反省。&lt;/p&gt;

&lt;p&gt;第一个给我留下深刻印象的是乔布斯服用致幻剂。任何一个在中国长大的人应该都无法直接接受服用致幻剂这样一个事实。但是全书中多次出现乔布斯强调服用致幻剂给他带来的积极影响，以及后来设计了一些类似于幻觉艺术的屏保。由此我们也可以联想到很多服用致幻剂的艺术家。或者往轻一点的方向说，李白斗酒诗百篇，酒醉的状态也是许多大家在艺术创作时的追求。这种状态或许就是理性推理和艺术创作之间的不那么鲜明的界限。&lt;/p&gt;

&lt;p&gt;第二个深刻的印象就是乔布斯的“扭曲现实力场”。作者或者乔布斯身边的人对此既爱又恨。一部分是因为扭曲现实力场让很多人做到了超越自己，而另外一方面就是扭曲现实力场也给人以绝望。这可能就是每天都需要面对绝境求生的挑战。每当完成一次挑战以后，其实每个人都会得到一个自身的提高以及对未来的自信。虽然乔布斯经常强调自己招募的都是一流人才，抵制二流人才，由此他的团队都是精英；而且他还强调精英也只会和精英合作。我承认后面一点，也就是精英只会和精英合作。不过与其说精英和精英合作，倒不如说精英和非精英在一起的时候，人的惰性就把他也变成了非精英。这也就是著名的短板效应。至于前面一点，我就不敢苟同了。虽然我并没有针对每个书中提到的员工做一番研究，但是显而易见的是那么大一个苹果公司，不可能所有的员工甚至说所有的核心员工都是一流人才。但是乔布斯的扭曲现实力场致使所有员工都超水平发挥，从而达到了一流的水平甚至超一流的水平。其实每个人对自己或多或少都有扭曲现实力场的作用，例如有很多人异想天开，很多人都有梦想。但是当面对周围的人的时候，人们往往都希望给别人留下美好的印象，而且不希望被人讥笑。由此对于任何扭曲现实的想法，也就胎死腹中了。乔布斯的与众不同之处就在于，他凭借着自己的任性，还能登顶人才金字塔。这往往是大多数人做不到的。在通往成功的路上，很多人都不愿意得罪周围的人，得罪金字塔顶端的人。乔布斯却杀出了一条血路，这或许也是一条不可复制的成功之路。&lt;/p&gt;

&lt;p&gt;再一个深刻的印象就是乔布斯的禅修经历。&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Yingzhou Li&lt;/p&gt;
</content>
   </entry>
   
 
   
   <entry>
     <title>艽野尘梦</title>
     <link href="/posts/2016-05/jiaoyechenmeng.html"/>
     <updated>2016-05-17T00:00:00+00:00</updated>
     <id>/posts/2016-05/jiaoyechenmeng</id>
     <content type="html">&lt;p&gt;第一次听说《艽野尘梦》是快读到大冰的《他们最幸福》最后的时候看到的。大冰提到了想去徒步行走羌塘无人区正是由于受到了艽野尘梦的影响，并且他也在书中简要的介绍了陈渠珍的这本著作。出于好奇，我也拿起了这本也是我第一本阅读的文言体的书。过去初高中时期因为苦读文言片段而积累的单薄的功底也发挥了一次远离考试的作用，余心甚慰。&lt;/p&gt;

&lt;p&gt;《艽(jiao)野尘梦》是民国时期陈渠珍所著的笔记。其中“艽野”一词出自《诗·小雅·小明》的“我征租西，至于艽野”，意思是“远荒之地”，而这里指的就是西藏。全书记录了陈渠珍在清末辛亥革命前后出入西藏的刻骨铭心的记忆。&lt;/p&gt;

&lt;p&gt;作者陈渠珍(1882-1952)是著名的“湘西王”，一生历经三朝官场。晚晴时他先毕业于湖南武备学堂，而后在新军任三营管带；民国时期他统一湘西，并经营湘西数十载；在新中国成立以后，1950年，他赴京参加了全国政协会议。在丰富的人生经历背后，他还是一个爱书之人。陈渠珍的书记，也是后来的著名作家沈从文先生回忆他时提到，“平时极爱读书，以曾国藩、王守仁自许，看书与治事时间几乎各占一半。在他的军部会议室里，放置了五个大楠木橱柜，柜里藏有百来幅自宋及明清绘画，几十件铜器古瓷，十来箱书籍，一大批碑帖，和一套《四部丛书》”。&lt;/p&gt;

&lt;p&gt;而《艽野尘梦》也曾于1940-1942年间在《康导月刊》连载。而后藏学家任乃强先生为其做注。于1982年和1999年分别由重庆出版社和西藏人民出版社出版。我阅读的版本是2011年由朝华出版社出的kindle版。&lt;/p&gt;

&lt;p&gt;介绍完此书及其作者的基本背景，再来聊聊我对此书的些许印象。《艽野尘梦》着墨于大量的切身相关的历史事件。从最初的入藏，到在西藏波密剿匪，而后哥老会夺权，以致陈渠珍寻思返乡，再误入羌塘无人区，最后抵达长安止。但是诸多描写中，出作者自身所见之历史事件和相关人物外并无刻意描写某一个人物角色。唯有其藏妻西原，经常不经意间提起，确让读者对她的品质印象极深。大量的后记，书评都对其称赞有加着重评论。我也不免俗的要对她称赞一番。西原原是藏地营官加瓜彭错的侄女。一日加瓜彭错宴请陈渠珍，并让西原及其他在宴会上表演骑马把杆。而西原连拔五竿引起了陈渠珍的注意。在觥筹交错中，加瓜彭错许诺讲西原许配给陈渠珍，而陈渠珍也是醉意朦胧中答应。几日后，加瓜彭错竟然真的将西原送至陈渠珍的府邸，陈渠珍非常惊讶，但是还是欣然接受了这桩婚事，其中原由不可深究。而后在平定波密的战事中，西原也是横刀立马，与将士一起出站，更解围困之危。至此我们见识到了西原的女将之风。随着内地革命，藏地的军队政权发生更迭，陈渠珍处于自身安危的考虑，让西原及100多人的小部队横跨羌塘返回内地。西原带着母亲给的红珊瑚饰品泪别母亲，追随陈渠珍前往死地。由于大雪隆冬，又没有GPS的定位，一个喇嘛向导带领着这支队伍向死亡前进。不出几日，粮尽，又几日，牲畜都吃完了。在没有下雪的日子里，大家就打野兔、野羊为食，但是遇到连续大雪天，没有野味，出现了吞食死去同伴的尸体。即使在这样的情况下，西原仍旧为陈渠珍省下自己的口粮，并称自己可以挨饿，但是陈渠珍必须要吃饱指挥队伍。为了避免同伴杀死随行藏童来吃，西原独自提枪出猎。&lt;/p&gt;

&lt;p&gt;在描述羌塘惨状时，有两个时刻分外精彩。一个是最后的几根火柴。另一个是截杀喇嘛团队。虽然这两个故事都与西原无关，但是却必须要在这里强行提到。&lt;/p&gt;

&lt;p&gt;在大家只剩最后20来根火柴的时候，就集中保管到了陈渠珍手上，由他来分配使用。每次使用的时候，大家都先立成人墙，有点像足球里的人墙，但是这里必须要密不透风，然后另一人在人强中用火柴点燃牲畜粪便，等到有一点烟的时候，再令人墙分开一道缝让微风把火堆吹旺。众人齐心协力，为了能成功的点燃每一次火。&lt;/p&gt;

&lt;p&gt;然而在后来遇到喇嘛团的时候，期初相安无事。喇嘛团也给了他们食物，还许诺要在分别时给他们再留一些食物。然而在分别前一天，陈渠珍发现了士兵有截杀喇嘛团的企图，但是他害怕士兵会集体谋害自己(也可能是他自己也是想的，却不想写在书中)，没有当众阻止。第二日，喇嘛团帮士兵们整理好食物，并且连同几批骆驼一起留给他们，在分别时，6个士兵却突然开枪相向，而喇嘛团发觉后也立马开枪回应。打死两三个喇嘛后，其余喇嘛骑着骆驼逃走了，而原来留给陈渠珍他们的骆驼受惊于枪声也背着食物逃走了。至于这六个士兵也是5死1重伤不能行。而余下的人却不愿携带重伤员前行，就把他遗弃在荒原等死。六个人虽无人性遭天谴，然而余下的人在人性上也未必比他们高级。&lt;/p&gt;

&lt;p&gt;再回到西原的爱情故事，最终连带西原和陈渠珍，仅有7人逃出无人区回到长安。上天不公，西原在长安时却染上天花，病逝在长安，而陈渠珍当时穷困的无法厚葬西原。全书以“述至此，肝肠寸断矣。余书亦从此辍笔矣”做结。我不喜陈渠珍的行为和心性，却深深的被西原感染。&lt;/p&gt;

&lt;p&gt;一个藏族女子，为其夫做到如此，感天动地。我并不确定是爱情的力量，或者是她的心性让西原如此。我更相信这是西原的心性。但是无论是什么，在死亡面前，任然处处为夫君考虑，愿意做一切，也愿意死在夫君之前，是值得赞叹的大女子。&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Yingzhou Li&lt;/p&gt;

</content>
   </entry>
   
 
   
   <entry>
     <title>写在书架边缘</title>
     <link href="/posts/2016-05/preface.html"/>
     <updated>2016-05-13T00:00:00+00:00</updated>
     <id>/posts/2016-05/preface</id>
     <content type="html">&lt;p&gt;这是一篇写在书架边缘的小文。&lt;/p&gt;

&lt;p&gt;由于搬家的缘故，我每天都要坐一小时的校车横跨旧金山湾去学校，这给我提供了大量的固定的时间。于是，在几个月前我买了Kindle聊以慰藉路途的空虚。不知不觉中，三天一小本，半月一大本的也读了不少闲书。对于这些书，我并不觉得自己理解的多么深刻，也不觉得提高了多少自身修养，却仍旧感到收获颇丰。&lt;/p&gt;

&lt;p&gt;俗话说，好记性不如烂笔头，更何况我这烂记性，可能连好笔头都救不回来。经常只记得自己读过哪本书，或记得书名，或记得作者，但是对于书中的内容，故事情节，主要人物等等都淡忘如书的简介，更甚者对应简介都无法回想。导致我经常要质问自己是否真的读过这本书。&lt;/p&gt;

&lt;p&gt;迫于学术研究的需要，我架设了英文版个人主页，为了方便自己看综艺节目，又增加了中文页面。这里仅仅能称之为中文页面，而不能叫做中文版本，除了姓名是翻译以外，其余一切都未曾转换成中文。这周早些时候下午回家路上，由于忘带Kindle，就看看跨湾大桥两侧的广袤滩涂和稀疏的水草荡。顺带着也回忆回忆最近读过的书。忽地发现，能记住梗概的也只能是最近的几本了。而数月前阅读的书，情节，脉络都淡忘了许多。于是突发奇想，为什么不给自己新阅读的每本书籍写一篇小文，既能总结概括一下书的内容，偶尔还能犯犯矫情。&lt;/p&gt;

&lt;p&gt;这就是个书架栏的诞生。&lt;/p&gt;

&lt;p&gt;然而，我自幼不是一个好读书写字的人。更多的时间花在了摆弄数字和电脑。不流畅的语言和混乱的逻辑关系，希望不幸读到这里的人原谅。或许随着不断的添加新的文字，未来的某一天，我也可以向苏先生等等老一辈学者看齐。在摆弄符号之余，也有一定的文字功底。但是根据目前的状况，我阅读过的书可能都还放不满一整个书架。所以姑且称为书架。待日后，阅读量增加，笔尖可以流出点墨水而不是苦水的时候，兴许可以改之为“书斋”。&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Yingzhou Li&lt;/p&gt;

</content>
   </entry>
   
 
   
   <entry>
     <title>Command Line Cheat Sheet</title>
     <link href="/posts/2016-01/commline-cheatsheet.html"/>
     <updated>2016-01-30T00:00:00+00:00</updated>
     <id>/posts/2016-01/commline-cheatsheet</id>
     <content type="html">&lt;p&gt;Recently, I was trying to auto-launch multiple terminals with one command
and got different terminals into different directories.
A typical output of the solution on Mac is like:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;/images/posts/Mac-Desktop.png&quot;&gt;&lt;img src=&quot;/images/posts/Mac-Desktop.png&quot; alt=&quot;mac-desktop&quot; title=&quot;Mac Desktop&quot; /&gt;&lt;/a&gt;
&lt;em&gt;Mac Desktop&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In the process of searching for solution, I found the following
command line cheat sheets useful for both Linux and Mac user.
Sharing them in my post is to keep a record for myself,
the credits go to the original authors,
&lt;a href=&quot;http://www.cheatography.com/davechild/cheat-sheets/linux-command-line/&quot;&gt;DavidChild&lt;/a&gt; and &lt;a href=&quot;https://github.com/0nn0/terminal-mac-cheatsheet/wiki/Terminal-Cheatsheet-for-Mac-(-basics-)&quot;&gt;Onno Schwanen&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you prefer to have a more complete list of basic commends, please
refer to &lt;a href=&quot;https://www.pcwdld.com/linux-commands-cheat-sheet&quot;&gt;PCWDLD&lt;/a&gt; page.&lt;/p&gt;

&lt;hr /&gt;

&lt;h3 id=&quot;bash-shortcuts&quot;&gt;Bash Shortcuts&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Mac                    &lt;/th&gt;
      &lt;th&gt;Linux                  &lt;/th&gt;
      &lt;th&gt;Description&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Ctrl + C&lt;/td&gt;
      &lt;td&gt;Ctrl + C&lt;/td&gt;
      &lt;td&gt;Kill current command&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Ctrl + Z&lt;/td&gt;
      &lt;td&gt;Ctrl + Z&lt;/td&gt;
      &lt;td&gt;Puts whatever you are running into a suspended background process. fg restores it.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Ctrl + A&lt;/td&gt;
      &lt;td&gt;Ctrl + A&lt;/td&gt;
      &lt;td&gt;Go to the beginning of the line you are currently typing on&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Ctrl + E&lt;/td&gt;
      &lt;td&gt;Ctrl + E&lt;/td&gt;
      &lt;td&gt;Go to the end of the line you are currently typing on&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Ctrl + U&lt;/td&gt;
      &lt;td&gt;Ctrl + U&lt;/td&gt;
      &lt;td&gt;Clears the line before the cursor position. If you are at the end of the line, clears the entire line.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Ctrl + K&lt;/td&gt;
      &lt;td&gt;Ctrl + K&lt;/td&gt;
      &lt;td&gt;Clear the line after the cursor&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Ctrl + L&lt;/td&gt;
      &lt;td&gt;Ctrl + L&lt;/td&gt;
      &lt;td&gt;Clears the Screen&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Command + K&lt;/td&gt;
      &lt;td&gt; &lt;/td&gt;
      &lt;td&gt;Reset the Terminal display&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Ctrl + H&lt;/td&gt;
      &lt;td&gt;Ctrl + H&lt;/td&gt;
      &lt;td&gt;Same as backspace&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Ctrl + R&lt;/td&gt;
      &lt;td&gt;Ctrl + R&lt;/td&gt;
      &lt;td&gt;Lets you search through previously used commands&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Ctrl + D&lt;/td&gt;
      &lt;td&gt;Ctrl + D&lt;/td&gt;
      &lt;td&gt;Exit the current shell&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Ctrl + W&lt;/td&gt;
      &lt;td&gt;Ctrl + W&lt;/td&gt;
      &lt;td&gt;Delete the word before the cursor&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Ctrl + T&lt;/td&gt;
      &lt;td&gt;Ctrl + T&lt;/td&gt;
      &lt;td&gt;Swap the last two characters before the cursor&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Ctrl + F&lt;/td&gt;
      &lt;td&gt;Ctrl + F&lt;/td&gt;
      &lt;td&gt;Move cursor one character forward&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Ctrl + B&lt;/td&gt;
      &lt;td&gt;Ctrl + B&lt;/td&gt;
      &lt;td&gt;Move cursor one character backward&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Esc + F&lt;/td&gt;
      &lt;td&gt;Esc + F&lt;/td&gt;
      &lt;td&gt;Move cursor one word forward&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Esc + B&lt;/td&gt;
      &lt;td&gt;Esc + B&lt;/td&gt;
      &lt;td&gt;Move cursor one word backward&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Esc + T&lt;/td&gt;
      &lt;td&gt;Esc + T&lt;/td&gt;
      &lt;td&gt;Swap the last two words before the cursor&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Tab&lt;/td&gt;
      &lt;td&gt;Tab&lt;/td&gt;
      &lt;td&gt;Auto-complete files and folder names&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h3 id=&quot;core-commands&quot;&gt;Core Commands&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Mac                    &lt;/th&gt;
      &lt;th&gt;Linux                  &lt;/th&gt;
      &lt;th&gt;Description&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;cd&lt;/td&gt;
      &lt;td&gt;cd&lt;/td&gt;
      &lt;td&gt;Home directory&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;cd [folder]&lt;/td&gt;
      &lt;td&gt;cd [folder]&lt;/td&gt;
      &lt;td&gt;Change directory&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;cd ~&lt;/td&gt;
      &lt;td&gt;cd ~&lt;/td&gt;
      &lt;td&gt;Home directory, e.g. ‘cd ~/folder/’&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;cd /&lt;/td&gt;
      &lt;td&gt;cd /&lt;/td&gt;
      &lt;td&gt;Root of drive&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;ls&lt;/td&gt;
      &lt;td&gt;ls&lt;/td&gt;
      &lt;td&gt;Short listing&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;ls -l&lt;/td&gt;
      &lt;td&gt;ls -l&lt;/td&gt;
      &lt;td&gt;Long listing&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;ls -a&lt;/td&gt;
      &lt;td&gt;ls -a&lt;/td&gt;
      &lt;td&gt;Listing all files&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;ls -lh&lt;/td&gt;
      &lt;td&gt;ls -lh&lt;/td&gt;
      &lt;td&gt;Long listing with Human readable file sizes&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;ls -R&lt;/td&gt;
      &lt;td&gt;ls -R&lt;/td&gt;
      &lt;td&gt;Entire content of folder recursively&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;sudo [cmd]&lt;/td&gt;
      &lt;td&gt;sudo [cmd]&lt;/td&gt;
      &lt;td&gt;Run command with the security privileges of the superuser (Super User DO)&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;open [file]&lt;/td&gt;
      &lt;td&gt;open [file]&lt;/td&gt;
      &lt;td&gt;Opens a file ( as if you double clicked it )&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;top&lt;/td&gt;
      &lt;td&gt;top&lt;/td&gt;
      &lt;td&gt;Displays active processes. Press q to quit&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;nano [file]&lt;/td&gt;
      &lt;td&gt;nano [file]&lt;/td&gt;
      &lt;td&gt;Opens the Terminal its editor&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;vi [file]&lt;/td&gt;
      &lt;td&gt;vi [file]&lt;/td&gt;
      &lt;td&gt;Opens the editor VIM&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;exit&lt;/td&gt;
      &lt;td&gt;exit&lt;/td&gt;
      &lt;td&gt;Exit&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;clear&lt;/td&gt;
      &lt;td&gt;clear&lt;/td&gt;
      &lt;td&gt;Clear screen&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;reset&lt;/td&gt;
      &lt;td&gt;reset&lt;/td&gt;
      &lt;td&gt;Reset the Terminal display&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h3 id=&quot;command-history&quot;&gt;Command History&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Mac                    &lt;/th&gt;
      &lt;th&gt;Linux                  &lt;/th&gt;
      &lt;th&gt;Description&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;history n&lt;/td&gt;
      &lt;td&gt;history n&lt;/td&gt;
      &lt;td&gt;Shows the stuff typed - add a number to limit the last n items&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;![value]&lt;/td&gt;
      &lt;td&gt;![value]&lt;/td&gt;
      &lt;td&gt;Execute the last command typed that starts with ‘value’&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;!!&lt;/td&gt;
      &lt;td&gt;!!&lt;/td&gt;
      &lt;td&gt;Execute the last command typed&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h3 id=&quot;file-management&quot;&gt;File Management&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Mac                    &lt;/th&gt;
      &lt;th&gt;Linux                  &lt;/th&gt;
      &lt;th&gt;Description&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;touch [file]&lt;/td&gt;
      &lt;td&gt;touch [file]&lt;/td&gt;
      &lt;td&gt;Create new file&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;cat&lt;/td&gt;
      &lt;td&gt;cat&lt;/td&gt;
      &lt;td&gt;Concatenate to screen&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;cat [file1] [file2]&lt;/td&gt;
      &lt;td&gt;cat [file1] [file2]&lt;/td&gt;
      &lt;td&gt;Concatenate files and output&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;less [file]&lt;/td&gt;
      &lt;td&gt;less [file]&lt;/td&gt;
      &lt;td&gt;View and paginate file&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;file [file]&lt;/td&gt;
      &lt;td&gt;file [file]&lt;/td&gt;
      &lt;td&gt;Get type of file&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;rm [file]&lt;/td&gt;
      &lt;td&gt;rm [file]&lt;/td&gt;
      &lt;td&gt;Remove a file&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;rm -i [file]&lt;/td&gt;
      &lt;td&gt;rm -i [file]&lt;/td&gt;
      &lt;td&gt;Remove with confirmation&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;rm -r [dir]&lt;/td&gt;
      &lt;td&gt;rm -r [dir]&lt;/td&gt;
      &lt;td&gt;Remove a directory and contents&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;rm -f [file]&lt;/td&gt;
      &lt;td&gt;rm -f [file]&lt;/td&gt;
      &lt;td&gt;Force removal without confirmation&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;cp [file1] [file2]&lt;/td&gt;
      &lt;td&gt;cp [file1] [file2]&lt;/td&gt;
      &lt;td&gt;Copy file1 to file2&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;cp [file] [dir]&lt;/td&gt;
      &lt;td&gt;cp [file] [dir]&lt;/td&gt;
      &lt;td&gt;Copy file to directory&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;mv [file1] [file2]&lt;/td&gt;
      &lt;td&gt;mv [file1] [file2]&lt;/td&gt;
      &lt;td&gt;Move/Rename file1 to file2&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;head [file]&lt;/td&gt;
      &lt;td&gt;head [file]&lt;/td&gt;
      &lt;td&gt;Show first 10 lines of file&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;tail [file]&lt;/td&gt;
      &lt;td&gt;tail [file]&lt;/td&gt;
      &lt;td&gt;Show last 10 lines of file&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;tail -F [file]&lt;/td&gt;
      &lt;td&gt;tail -F [file]&lt;/td&gt;
      &lt;td&gt;Show last lines of file as it changes&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h3 id=&quot;directory-management&quot;&gt;Directory Management&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Mac                    &lt;/th&gt;
      &lt;th&gt;Linux                  &lt;/th&gt;
      &lt;th&gt;Description&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;pwd&lt;/td&gt;
      &lt;td&gt;pwd&lt;/td&gt;
      &lt;td&gt;Full path to working directory&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;..&lt;/td&gt;
      &lt;td&gt;..&lt;/td&gt;
      &lt;td&gt;Parent/enclosing directory&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;.&lt;/td&gt;
      &lt;td&gt;.&lt;/td&gt;
      &lt;td&gt;Current folder&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;mkdir [dir]&lt;/td&gt;
      &lt;td&gt;mkdir [dir]&lt;/td&gt;
      &lt;td&gt;Create new directory&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;mkdir -p [dir]/[dir]&lt;/td&gt;
      &lt;td&gt;mkdir -p [dir]/[dir]&lt;/td&gt;
      &lt;td&gt;Create nested directories&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;rmdir [dir]&lt;/td&gt;
      &lt;td&gt;rmdir [dir]&lt;/td&gt;
      &lt;td&gt;Remove directory ( only operates on empty directories )&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;rm -R [dir]&lt;/td&gt;
      &lt;td&gt;rm -R [dir]&lt;/td&gt;
      &lt;td&gt;Remove directory and contents&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h3 id=&quot;pipes---allows-to-combine-multiple-commands-that-generate-output&quot;&gt;Pipes - Allows to combine multiple commands that generate output&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Mac                    &lt;/th&gt;
      &lt;th&gt;Linux                  &lt;/th&gt;
      &lt;th&gt;Description&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;more&lt;/td&gt;
      &lt;td&gt;more&lt;/td&gt;
      &lt;td&gt;Output content delivered in screensize chunks&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&amp;gt; [file]&lt;/td&gt;
      &lt;td&gt;&amp;gt; [file]&lt;/td&gt;
      &lt;td&gt;Push output to file, keep in mind it will get overwritten&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;» [file]&lt;/td&gt;
      &lt;td&gt;» [file]&lt;/td&gt;
      &lt;td&gt;Append output to existing file&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&amp;lt;&lt;/td&gt;
      &lt;td&gt;&amp;lt;&lt;/td&gt;
      &lt;td&gt;Tell command to read content from a file&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;h3 id=&quot;help&quot;&gt;Help&lt;/h3&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Mac                    &lt;/th&gt;
      &lt;th&gt;Linux                  &lt;/th&gt;
      &lt;th&gt;Description&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;[cmd] -h&lt;/td&gt;
      &lt;td&gt;[cmd] -h&lt;/td&gt;
      &lt;td&gt;Offers help&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;[cmd] –help&lt;/td&gt;
      &lt;td&gt;[cmd] –help&lt;/td&gt;
      &lt;td&gt;Offers help&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;[cmd] help&lt;/td&gt;
      &lt;td&gt;[cmd] help&lt;/td&gt;
      &lt;td&gt;Offers help&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;man [cmd]&lt;/td&gt;
      &lt;td&gt;man [cmd]&lt;/td&gt;
      &lt;td&gt;Show the help for ‘command’&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;whatis [cmd]&lt;/td&gt;
      &lt;td&gt;whatis [cmd]&lt;/td&gt;
      &lt;td&gt;Gives a one-line description of ‘command’&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Yingzhou Li&lt;/p&gt;

</content>
   </entry>
   
 
   
   <entry>
     <title>User compilers installation</title>
     <link href="/posts/2015-11/compiler-install.html"/>
     <updated>2015-11-19T00:00:00+00:00</updated>
     <id>/posts/2015-11/compiler-install</id>
     <content type="html">&lt;h2 id=&quot;installation-of-gnu-compilers&quot;&gt;Installation of GNU compilers&lt;/h2&gt;

&lt;p&gt;There are many ways to install &lt;a href=&quot;https://gcc.gnu.org/&quot;&gt;GNU&lt;/a&gt; compilers. 
And the following is found to be the most simple and straightforward way.
The following ingredients are the simplified version of
&lt;a href=&quot;http://advogato.org/person/redi/diary/253.html&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;First download and unpacked your desired version of gcc compiler.
Here an official gcc download address are provided
https://ftp.gnu.org/gnu/gcc . And we will take version 5.2.0 as an
example. If other versions are desired, please replace &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;5.2.0&lt;/code&gt; in all
following instructions by the version number,
e.g. replace &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gccver=5.2.0&lt;/code&gt; by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gccver=4.9.3&lt;/code&gt;.&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;gccver=5.2.0
mkdir ~/gcc-tmp
cd ~/gcc-tmp
wget https://ftp.gnu.org/gnu/gcc/gcc-${gccver}/gcc-${gccver}.tar.gz
tar -xzf gcc-${gccver}.tar.gz 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Download the prerequisite sources into the same gcc source directory.&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cd ~/gcc-tmp/gcc-${gccver}
./contrib/download_prerequisites
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Create a building directory and configure gcc.
&lt;strong&gt;One important thing here is
that the building directory must be different
from the source directory.&lt;/strong&gt;&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mkdir ~/gcc-tmp/build
cd ~/gcc-tmp/build
~/gcc-tmp/gcc-${gccver}/configure --prefix=/path/to/install/the/gcc/ --disable-multilib
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Build gcc.&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cd ~/gcc-tmp/build
make
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Install gcc.&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cd ~/gcc-tmp/build
make install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Clean all temporary folders and files.&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cd ~
rm -rf ~/gcc-tmp 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;installation-of-mpich&quot;&gt;Installation of MPICH&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;http://www.mpich.org/&quot;&gt;MPICH&lt;/a&gt; is a high performance and widely portable implementation 
of the Message Passing Interface (MPI) standard.
The following ingredients are the simplified version of
&lt;a href=&quot;http://www.mpich.org/static/downloads/3.1.3/mpich-3.1.3-installguide.pdf&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;First download and unpacked your desired version of mpich.
Here an official mpich download address are provided
http://www.mpich.org/static/downloads/. And we will take version 3.2 as an
example. If other versions are desired, please replace &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;3.2&lt;/code&gt; in all
following instructions by the version number,
e.g. replace &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mpichver=3.2&lt;/code&gt; by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mpichver=3.1.4&lt;/code&gt;.&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mpichver=3.2
mkdir ~/mpich-tmp
cd ~/mpich-tmp
wget http://www.mpich.org/static/downloads/${mpichver}/mpich-${mpichver}.tar.gz
tar -xzf mpich-${mpichver}.tar.gz 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Configure mpich.&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cd ~/mpich-tmp/mpich-${mpichver}
LD_LIBRARY_PATH=/path/to/installed/gcc/lib64 ./configure CC=/path/to/installed/gcc/bin/gcc CXX=/path/to/installed/gcc/bin/g++ F77=/path/to/installed/gcc/bin/gfortran FC=/path/to/installed/gcc/bin/gfortran --prefix=/path/to/install/the/mpich/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Install mpich.&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cd ~/mpich-tmp/mpich-${mpichver}
make install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Clean all temporary folders and files.&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cd ~
rm -rf ~/mpich-tmp 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;hr /&gt;

&lt;p&gt;Updating List:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;2015-11-19: Added the first version of the compilers
 installation instructions.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;2015-11-20: Added the installation instructions for mpich.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;hr /&gt;
&lt;p&gt;Please let me know if any of other compilers are useful to be installed
under local directory.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Yingzhou Li&lt;/p&gt;

</content>
   </entry>
   
 
   
   <entry>
     <title>ICME Related Seminar Calendar</title>
     <link href="/posts/2015-10/seminar-calendar.html"/>
     <updated>2015-10-06T00:00:00+00:00</updated>
     <id>/posts/2015-10/seminar-calendar</id>
     <content type="html">&lt;p&gt;Yesterday, I got the ICME weekly seminar digest from ICME office
and found it helpful to have all the speakers, titles and abstracts
listed in a single email. However, the date and time listed in the email
are not very convenient to follow. Verifying the seminar time slot in your
own calendar costs a lot of energy.&lt;/p&gt;

&lt;p&gt;Since then, I created my own seminar calendar for many ICME related seminars,
i.e., &lt;a href=&quot;https://icme.stanford.edu/events/seminars&quot;&gt;ICME Departmental Seminar&lt;/a&gt;,
&lt;a href=&quot;https://icme.stanford.edu/events/seminars&quot;&gt;ICME First Year Seminar&lt;/a&gt;,
&lt;a href=&quot;https://icme.stanford.edu/events/seminars&quot;&gt;Linear Algebra and Optimization Seminar&lt;/a&gt;,
&lt;a href=&quot;http://math.stanford.edu/~ryzhik/stanf_sem.html&quot;&gt;Applied Math Seminar&lt;/a&gt;,
&lt;a href=&quot;https://statistics.stanford.edu/events/statistics-seminar&quot;&gt;Probability Seminar&lt;/a&gt; and
&lt;a href=&quot;https://statistics.stanford.edu/events/statistics-seminar&quot;&gt;Statistics Department Seminar&lt;/a&gt;.
And there is no reason to keep it private. Hence, I published the calendar
and embedded it into my homepage in a &lt;a href=&quot;http://www.stanford.edu/people/yingzhouli/pages/seminar-calendar.html&quot;&gt;Seminar Calendar&lt;/a&gt;
page. 
Currently, the speaker, title and abstract are listed in description
as well.&lt;/p&gt;

&lt;p&gt;In the future, I will keep on adding more related seminar calendar
and more ICME academic events.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;The new seminar calendar for Winter 2016 is available online.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Yingzhou Li&lt;/p&gt;

</content>
   </entry>
   
 
   
   <entry>
     <title>Ubuntu installation list</title>
     <link href="/posts/2015-09/ubuntu-install.html"/>
     <updated>2015-09-23T00:00:00+00:00</updated>
     <id>/posts/2015-09/ubuntu-install</id>
     <content type="html">&lt;h2 id=&quot;installation-of-ubuntu&quot;&gt;Installation of Ubuntu&lt;/h2&gt;

&lt;p&gt;Readers are referred to the following links for the creation
of a bootable USB stick on different platform.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Ubuntu: &lt;a href=&quot;http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-ubuntu&quot;&gt;bootable usb&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Mac: &lt;a href=&quot;http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-mac-osx&quot;&gt;bootable usb&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Windows: &lt;a href=&quot;http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-windows&quot;&gt;bootable usb&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Installation instruction of Ubuntu is available &lt;a href=&quot;https://help.ubuntu.com/community/Installation/FromUSBStick&quot;&gt;here&lt;/a&gt;.
However, the installation is relatively easy
even without these instruction.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;ppa-list&quot;&gt;PPA List&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Chrome (double check if it is necessary)&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo sh -c 'echo &quot;deb http://dl.google.com/linux/chrome/deb/ stable main&quot; &amp;gt;&amp;gt; /etc/apt/sources.list.d/chrome.list'
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Thunderbird&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo add-apt-repository ppa:mozillateam/thunderbird-next
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;RStudio ( This repository currently does not support Ubuntu Vivid.
Please ignore this line if you are using Ubuntu 15.04. )&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo add-apt-repository ppa:opencpu/rstudio
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Julia&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo add-apt-repository ppa:staticfloat/juliareleases
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;At the end of adding these repository, we need the following commands
to update the package list and upgrade installed packages.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It is also suggested to run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo apt-get autoremove&lt;/code&gt; to remove
unnecessary packages.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;installation-list&quot;&gt;Installation List&lt;/h2&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Ubuntu Restricted Extras&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install ubuntu-restricted-extras
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Chrome&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install google-chrome-beta
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;And following extensions are useful:&lt;/p&gt;
    &lt;ul&gt;
      &lt;li&gt;Hangouts&lt;/li&gt;
      &lt;li&gt;Unblock Youku&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Git&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;LaTeX and Texmaker&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install texlive-full
sudo apt-get install texmaker
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Vim&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install vim
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;vimrc&lt;/code&gt; file can be found &lt;a href=&quot;/download_file/File/vimrc&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Dropbox&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install nautilus-dropbox
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;Thunderbird
Thunderbird is installed by default and only upgrading is required.
And following add-ons are useful:
    &lt;ul&gt;
      &lt;li&gt;Grammar Checker&lt;/li&gt;
      &lt;li&gt;LaTeX It!&lt;/li&gt;
      &lt;li&gt;MinimizeToTray revived&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Openssh Server&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install openssh-server
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Kerberos&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install krb5-user
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;Configure the kerberos. Here is an example for &lt;a href=&quot;http://farmshare.stanford.edu&quot;&gt;corn&lt;/a&gt; machines
at Stanford.&lt;/p&gt;

    &lt;ol&gt;
      &lt;li&gt;
        &lt;p&gt;Create a folder for Control ticket.&lt;/p&gt;

        &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mkdir ~/.krblog
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
      &lt;/li&gt;
      &lt;li&gt;
        &lt;p&gt;Set up configuration for ssh. Copy the following lines into
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.ssh/config&lt;/code&gt; file.&lt;/p&gt;

        &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Host corn corn?? corn.stanford.edu corn??.stanford.edu
GSSAPIKeyExchange yes
GSSAPIAuthentication yes
GSSAPIDelegateCredentials yes
ControlMaster auto
ControlPath ~/.krblog/.%r@%h:%p
ControlPersist yes
ServerAliveInterval 60
ServerAliveCountMax 3
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;        &lt;/div&gt;
      &lt;/li&gt;
    &lt;/ol&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;MPICH&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install mpich
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;R and RStudio&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install r-base
sudo apt-get install r-base-dev
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Python, numpy, scipy, matplotlib, ipython and ipython-notebook&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Jekyll&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install ruby-dev
sudo gem install jekyll
sudo gem install jekyll-sitemap
sudo apt-get install nodejs
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install ruby-dev
sudo gem install jekyll
sudo gem install jekyll-sitemap
sudo apt-get install nodejs
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Julia&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install julia
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;CMake&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install cmake
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Valgrind&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install valgrind
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Pinyin Input&lt;/p&gt;

    &lt;p&gt;Install &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ibus-pinyin&lt;/code&gt; for Ubuntu 10-14.&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install ibus-pinyin
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;Install &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fcitx&lt;/code&gt; for Ubuntu 15.&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install fcitx
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;With the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ibus-pinyin&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fcitx&lt;/code&gt; installed,
we follow the following steps:&lt;/p&gt;

    &lt;ol&gt;
      &lt;li&gt;Click &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;System Settings/Language Support&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;Click &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Install/Remove Languages...&lt;/code&gt; and add &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Chinese&lt;/code&gt;&lt;/li&gt;
      &lt;li&gt;Click &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;System Settings/Language Support&lt;/code&gt;
and select &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;IBus&lt;/code&gt; (Ubuntu 10-14) or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fcitx&lt;/code&gt; (Ubuntu 15) as the
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Keyboard input method system&lt;/code&gt;.&lt;/li&gt;
      &lt;li&gt;Logout and Re-Login.&lt;/li&gt;
      &lt;li&gt;Configure pinyin input based on different systems.
Here we only show an example for Ubuntu 15,
        &lt;ul&gt;
          &lt;li&gt;Click keyboard button on the status bar,
and select &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Configure&lt;/code&gt;.&lt;/li&gt;
          &lt;li&gt;Add Chinese pinyin ( uncheck &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Only Show Current Language&lt;/code&gt; ).
The instructions for Ubuntu 10-14 are detailed &lt;a href=&quot;http://www.pinyinjoe.com/linux/ubuntu-10-chinese-input-pinyin-chewing.htm&quot;&gt;here&lt;/a&gt;.&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ol&gt;

    &lt;p&gt;For detailed instructions, readers are referred
to &lt;a href=&quot;http://www.pinyinjoe.com&quot;&gt;Pinyin Joe’s&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Dput, Uploading packages to PPA&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install dput
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Exfat related packages&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install exfat-utils
sudo apt-get install exfat-fuse
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;hr /&gt;

&lt;p&gt;Updating List:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;2015-09-25: Added the first version of the Ubuntu package
 installation instructions.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;2015-09-28: Added instructions for Chinese pinyin input.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;2015-09-30: Added instructions for dput to upload packages to PPA.
 And updated the instruction order to avoid the usage of
 the not installed package.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;2015-10-03: Added instructions for Ubuntu restricted extras.
 This installation includes many useful plug-ins.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;2015-10-24: Added instructions for Exfat format related packages.
 Such that any Exfat format UBS can be read.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;hr /&gt;
&lt;p&gt;Please let me know if any of these packages are not updated
via the repositories.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Yingzhou Li&lt;/p&gt;

</content>
   </entry>
   
 
   
   <entry>
     <title>Vim Setting</title>
     <link href="/posts/2015-07/vim.html"/>
     <updated>2015-07-22T00:00:00+00:00</updated>
     <id>/posts/2015-07/vim</id>
     <content type="html">&lt;p&gt;My Vim setting (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.vimrc&lt;/code&gt;) is reorganized today.
Most of these settings are referred from &lt;a href=&quot;http://vim.wikia.com/wiki/Vim_Tips_Wiki&quot;&gt;Vim Wiki&lt;/a&gt;
Mainly, it supports basic auto read, line number, ruler
(specifically for Vim on Mac, this is not necessary for Linux).
Also it enables auto spell check with underline highlight for spell
bad words and others,
and the functionality of returning to the last edit position for
opening files is added to it.
The last line of basic setting part adds a user defined command
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Clean&lt;/code&gt; for removing spaces at the end of each line.&lt;/p&gt;

&lt;p&gt;Another parts of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.vimrc&lt;/code&gt; file enables &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim&quot;&gt;Vundle&lt;/a&gt;
with plugins &lt;a href=&quot;https://github.com/JuliaLang/julia-vim&quot;&gt;julia-vim&lt;/a&gt;, &lt;a href=&quot;https://github.com/godlygeek/tabular&quot;&gt;tabular&lt;/a&gt;
and &lt;a href=&quot;https://github.com/plasticboy/vim-markdown&quot;&gt;vim-markdown&lt;/a&gt;. A few settings of
&lt;a href=&quot;https://github.com/plasticboy/vim-markdown&quot;&gt;vim-markdown&lt;/a&gt;
are also presented next to &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim&quot;&gt;Vundle&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The detailed &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.vimrc&lt;/code&gt; file is attached as follows.
And an updating list and a TODO list are added at the end of this post.
Hopefully, it will be helpful for others.&lt;/p&gt;

&lt;div class=&quot;language-vim highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;&quot; Configuration file for vim&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;&quot; Edited by Yingzhou Li&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;&quot;=================================================================&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;&quot; Basic setting for vim&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;history&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;20&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;autoread&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;number&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;ruler&lt;/span&gt;                           &quot; status bar setting &lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; Mac

&lt;span class=&quot;c&quot;&gt;&quot; Setting for spell check&lt;/span&gt;
autocmd &lt;span class=&quot;nb&quot;&gt;BufRead&lt;/span&gt; *&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;txt&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;*&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;tex&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;*&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;md&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;*&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;markdown &lt;span class=&quot;k&quot;&gt;setlocal&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;spell&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;spelllang&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;en_us

&lt;span class=&quot;c&quot;&gt;&quot; Setting for indent&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;tabstop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;4&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;shiftwidth&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;4&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;softtabstop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;4&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;autoindent&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;expandtab&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;viminfo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;%&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;'&lt;span class=&quot;m&quot;&gt;500&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;\&quot;&lt;span class=&quot;m&quot;&gt;500&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;~&lt;/span&gt;/&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;viminfo&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;&quot; Setting for highlight&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;syntax&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;on&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;highlight&lt;/span&gt; Comment ctermfg&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;Yellow
&lt;span class=&quot;nb&quot;&gt;highlight&lt;/span&gt; clear SpellBad
&lt;span class=&quot;nb&quot;&gt;highlight&lt;/span&gt; SpellBad &lt;span class=&quot;nb&quot;&gt;term&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;standout ctermfg&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;term&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;underline&lt;/span&gt; cterm&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;underline&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;highlight&lt;/span&gt; clear SpellCap
&lt;span class=&quot;nb&quot;&gt;highlight&lt;/span&gt; SpellCap &lt;span class=&quot;nb&quot;&gt;term&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;underline&lt;/span&gt; cterm&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;underline&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;highlight&lt;/span&gt; clear SpellRare
&lt;span class=&quot;nb&quot;&gt;highlight&lt;/span&gt; SpellRare &lt;span class=&quot;nb&quot;&gt;term&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;underline&lt;/span&gt; cterm&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;underline&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;highlight&lt;/span&gt; clear SpellLocal
&lt;span class=&quot;nb&quot;&gt;highlight&lt;/span&gt; SpellLocal &lt;span class=&quot;nb&quot;&gt;term&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;underline&lt;/span&gt; cterm&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;underline&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;&quot; Return to last edit position when opening files&lt;/span&gt;
autocmd &lt;span class=&quot;nb&quot;&gt;BufReadPost&lt;/span&gt; *
&lt;span class=&quot;se&quot;&gt;	\&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;'\&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;0&lt;/span&gt; &amp;amp;&amp;amp; &lt;span class=&quot;nb&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;'\&quot;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;$&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;|&lt;/span&gt;
&lt;span class=&quot;se&quot;&gt;	\&lt;/span&gt;   exe &lt;span class=&quot;s2&quot;&gt;&quot;normal! g`\&quot;&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;|&lt;/span&gt;
&lt;span class=&quot;se&quot;&gt;	\&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;endif&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;&quot; Remove space at the end of each line&lt;/span&gt;
command Clean &lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;%s&lt;span class=&quot;sr&quot;&gt;/\s\+$/&lt;/span&gt;/&lt;span class=&quot;k&quot;&gt;e&lt;/span&gt;


&lt;span class=&quot;c&quot;&gt;&quot;=================================================================&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;&quot; Setting for Vundle, julia-vim&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;filetype&lt;/span&gt; off
&lt;span class=&quot;k&quot;&gt;set&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;rtp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;+=~&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/.vim/&lt;/span&gt;bundle/Vundle&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;vim&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;call&lt;/span&gt; vundle#begin&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
Plugin &lt;span class=&quot;s1&quot;&gt;'gmarik/Vundle.vim'&lt;/span&gt;
Plugin &lt;span class=&quot;s1&quot;&gt;'JuliaLang/julia-vim'&lt;/span&gt;
Plugin &lt;span class=&quot;s1&quot;&gt;'godlygeek/tabular'&lt;/span&gt;
Plugin &lt;span class=&quot;s1&quot;&gt;'plasticboy/vim-markdown'&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;call&lt;/span&gt; vundle#end&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;filetype&lt;/span&gt; plugin &lt;span class=&quot;nb&quot;&gt;indent&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;on&lt;/span&gt;


&lt;span class=&quot;c&quot;&gt;&quot;=================================================================&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;&quot; Setting for Markdown+LaTeX&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;g:vim_markdown_folding_disabled&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;g:vim_markdown_math&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;let&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;g:vim_markdown_frontmatter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;
&lt;p&gt;Installation:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Vim installation&lt;/p&gt;

    &lt;p&gt;The &lt;a href=&quot;/download_file/File/vimrc&quot;&gt;vimrc&lt;/a&gt; file here only support self-installed &lt;a href=&quot;http://www.vim.org/&quot;&gt;vim&lt;/a&gt;.
The installation instructions for different platforms are different.
Here is an example for Ubuntu:&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo apt-get install vim
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Vundle&lt;/p&gt;

    &lt;p&gt;The installation of Vundle is available
   &lt;a href=&quot;https://github.com/VundleVim/Vundle.vim&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Download the &lt;a href=&quot;/download_file/File/vimrc&quot;&gt;vimrc&lt;/a&gt; file.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Copy &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.vimrc&lt;/code&gt; to your user folder.&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;cp /path/to/vimrc ~/.vimrc
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Install plugins.&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;vim ~/.vimrc
:PluginInstall
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;hr /&gt;

&lt;p&gt;Updating List:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;2015-07-22: Added new &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.vimrc&lt;/code&gt; file.&lt;/li&gt;
  &lt;li&gt;2015-08-24: Specified spell check for *.txt, *.tex, *.md, *.markdown
 files only.&lt;/li&gt;
  &lt;li&gt;2015-09-23: Updated this page and added vim installation step
 in the installation instruction.&lt;/li&gt;
&lt;/ol&gt;

&lt;hr /&gt;
&lt;p&gt;TODO List:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Add ‘‘SMART” hard wrap for text files, especially for .tex files.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Yingzhou Li&lt;/p&gt;

</content>
   </entry>
   
 
   
   <entry>
     <title>MATLAB Random Seed</title>
     <link href="/posts/2015-07/randseed.html"/>
     <updated>2015-07-07T00:00:00+00:00</updated>
     <id>/posts/2015-07/randseed</id>
     <content type="html">&lt;p&gt;A shocking thing about random seed in MATLAB is that the random seed is
initialized by the same value every time we start MATLAB.&lt;/p&gt;

&lt;p&gt;The story is as follows.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;We were trying to run numerical results on &lt;a href=&quot;http://sherlock.stanford.edu/&quot;&gt;Sherlock&lt;/a&gt;
for our new paper “Multidimensional Butterfly Factorization”
which is collaborating with &lt;a target=&quot;_blank&quot; href=&quot;https://haizhaoyang.github.io/&quot;&gt;
Haizhao Yang&lt;/a&gt; and
&lt;a target=&quot;_blank&quot; href=&quot;https://web.stanford.edu/~lexing/&quot;&gt;
Lexing Ying&lt;/a&gt;.  As been pointed out in previous
papers [&lt;a href=&quot;/download_file/Paper/bf.pdf#page=15&quot;&gt;1&lt;/a&gt;,&lt;a href=&quot;/download_file/Paper/mba.pdf#page=14&quot;&gt;2&lt;/a&gt;], an evaluation of true relative
error is too expansive to compute.  Hence, the relative error was
evaluated in a subsampled set of points, i.e.,&lt;/p&gt;

\[\epsilon = \sqrt{\frac{\sum_{x\in S}\lvert u^d(x)-u^a(x) \rvert^2}
    {\sum\_{x\in S}\lvert u^d(x) \rvert^2}}\]

&lt;p&gt;where $u^d$ is the result of direct evaluation, $u^a$ is the result of
the fast algorithm, and $S$ is a point set of size 256.&lt;/p&gt;

&lt;p&gt;On &lt;a href=&quot;http://sherlock.stanford.edu/&quot;&gt;Sherlock&lt;/a&gt;, all jobs have to be submitted via sbatch files.
In each sbatch file, we will start MATLAB and run the script.
However, we found that the evaluated relative error is constant over several
runs. At the beginning, we thought there was a bug in the code, especially,
in the relative error evaluation part. After a careful debugging and double
checking the relative error, we finally came to this finding.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;We start a new MATLAB, and the following lines are always true on my Mac Pro.&lt;/p&gt;

&lt;div class=&quot;language-matlab highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;rand&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;ans&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;

    &lt;span class=&quot;mf&quot;&gt;0.8147&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;randn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;ans&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;

    &lt;span class=&quot;mf&quot;&gt;1.8339&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;A nice way to have true random values every run, we could suggest to initialize
the random seed with current computer time. And as been pointed out in the help
file of &lt;a href=&quot;http://www.mathworks.com/help/matlab/ref/rng.html&quot;&gt;&lt;strong&gt;rng&lt;/strong&gt;&lt;/a&gt;, we could put the following line at the beginning of
the code:&lt;/p&gt;

&lt;div class=&quot;language-matlab highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;rng&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'shuffle'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;such that it seeds the random number generator based on the current time.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Yingzhou Li&lt;/p&gt;

</content>
   </entry>
   
 
   
   <entry>
     <title>New Homepage</title>
     <link href="/posts/2015-06/newpage.html"/>
     <updated>2015-06-24T00:00:00+00:00</updated>
     <id>/posts/2015-06/newpage</id>
     <content type="html">&lt;p&gt;My new homepage was posted yesterday. The key reason to post a new
homepage is to have Posts section in it. Another reason is that the
theme in previous homepage is too dark. Hence I spent two days to
code this new homepage and added the post feature to it.&lt;/p&gt;

&lt;p&gt;&lt;a target=&quot;_blank&quot; href=&quot;https://hodgestar.com/jack.html&quot;&gt;
Jack Poulson&lt;/a&gt; is the first one suggested me to
write post daily or weekly to improve my writing skill and he also
recommended me &lt;a href=&quot;https://github.com/mojombo/jekyll&quot;&gt;Jekyll&lt;/a&gt; which is supper useful for blog-style web
designing. It was a long time ago, I downloaded this template called
&lt;a href=&quot;https://github.com/holman/left#readme&quot;&gt;Left&lt;/a&gt;, where the post section is naturely embeded.  Finally, until
this week, I moved my previous homepage to this template and started
posting.  As metioned earlier, the main purpose of my posting is to
improve my academic writing skill. At the same time, I will share my
understandings of papers, algorithms, or theorems. The frequency of
posts is not guaranteed. But I will try my best to post at least one
each week.&lt;/p&gt;

&lt;p&gt;Hopefully, you will enjoy my posts.  Clicking the red figure below or
the email link, an auto prepared email would pop out. You are welcome
to send me any discussion and suggestion.  Our email might be posted
below the related post with your permission.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Yingzhou Li&lt;/p&gt;

</content>
   </entry>
   
 
   
   <entry>
     <title>Left</title>
     <link href="/posts/2015-06/left.html"/>
     <updated>2015-06-23T00:00:00+00:00</updated>
     <id>/posts/2015-06/left</id>
     <content type="html">&lt;p&gt;Left is a clean, whitespace-happy layout for &lt;a href=&quot;https://github.com/mojombo/jekyll&quot;&gt;Jekyll&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This is designed to be an easy layout to modify for your own blog. It was
extracted from &lt;a href=&quot;http://zachholman.com&quot;&gt;zachholman.com&lt;/a&gt;, which means it was battle-hardened from
years of posting serious blog posts about emoji and swear words.&lt;/p&gt;

&lt;p&gt;You’re actually reading an example post right now. See how cool it is? Oh, be
quiet, you’re making me blush.&lt;/p&gt;

&lt;p&gt;You’ll want to &lt;a href=&quot;https://github.com/holman/left#readme&quot;&gt;get the code&lt;/a&gt; and read the README to learn how to
install and set up Left for your own purposes.&lt;/p&gt;

&lt;p&gt;If you have any questions about this Jekyll template,
follow and ping Holman on Twitter &lt;a href=&quot;https://twitter.com/holman&quot;&gt;@holman&lt;/a&gt;.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;I personally like the layout of Left. I modified the blog style template to
a personal homepage style.
Email me if you happen to share the same flavor as me.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Yingzhou Li&lt;/p&gt;

</content>
   </entry>
   
 
 
</feed>
