User:Justin545

{{userpage}}

Subpages

Links

  1. List of XML and HTML character entity references
  2. Wikipedia:WikiProject User scripts/Scripts
  3. [http://fedoraforum.org/forum/archive/index.php/t-64964.html How to mount LVM volumes, help!] (keyword="mount LVM fedora")
  4. Template:AD
  5. [http://hellobmw.com/archives/install-jre-on-ubuntu.html Ubuntu 下安装 JRE (Java Runtime Environment)]
  6. [http://gauss.ececs.uc.edu/RedBlack/redblack.html Red/Black Tree Demonstration]
  7. [http://docs.google.com/gview?a=v&q=cache:6sX0fkTwQbQJ:https://atlserver.pv.infn.it/atlas/EventFilter/NoteMT.pdf+multithread+programming&hl=zh-TW&gl=tw Multi Thread Programming]
  8. [http://www.lslnet.com/linux/f/docs1/i09/big5151390.htm epoll()簡單介紹(轉貼)]
  9. [http://discuss.fogcreek.com/joelonsoftware/default.asp?cmd=show&ixPost=22948 AVL Trees vs. Red-Black Trees?]
  10. [http://www.kernel.org/doc/Documentation/rbtree.txt Virtual memory areas (VMAs) are tracked with red-black trees, as are epoll file descriptors]
  11. [http://lists.openwall.net/linux-kernel/2008/02/10/305 Epoll calls rb_set_parent(n, n) to initialize the rb-tree node]
  12. [http://blog.csdn.net/adcxf/archive/2009/02/09/3871470.aspx reentrant,thread-safe 和 async-signal-safe]
  13. [http://tldp.org/LDP/lpg/node7.html Linux Interprocess Communications]
  14. [http://osdir.com/ml/kernel.aio.general/2003-05/msg00000.html Comparing the aio and epoll event frameworks]
  15. [http://jchuang1977.wordpress.com/2008/12/08/linux-kernel-ipc-%E7%9A%84%E4%BB%8B%E7%B4%B9/ Linux Kernel IPC 的介紹]
  16. [http://blog.csdn.net/ldong2007/archive/2009/06/15/4271685.aspx 可重入性 线程安全 Async-Signal-Safe]
  17. [http://forum.icst.org.tw/phpbb/viewtopic.php?f=44&t=12819 Bash Shell Script可以做到光棒上下移動選單的功能嗎 ?]
  18. ANSI escape code
  19. [http://books.google.com.tw/books?id=cbbMrRNiC4cC&dq=understanding+linux+kernel&printsec=frontcover&source=bl&ots=TvXa8Unc1g&sig=3ArZVMBbzm-ss6e1jSe-M-GnJhw&hl=zh-TW&ei=N5mjSv2fKoeCkAWqy72BBA&sa=X&oi=book_result&ct=result&resnum=11#v=onepage&q=&f=false Understanding the Linux Kernel]
  20. [http://www.opengroup.org/onlinepubs/009695399/utilities/make.html (IEEE make manual) The Open Group Base Specifications Issue 6 IEEE Std 1003.1, 2004 Edition manual]
  21. [http://translate.google.com.tw/translate?hl=zh-TW&sl=zh-CN&u=http://lifegoo.pluskid.org/wiki/EmacsCscope.html&ei=wij5SuX3INiJkQXBx6SrCw&sa=X&oi=translate&ct=result&resnum=2&ved=0CAwQ7gEwAQ&prev=/search%3Fq%3Dcscope%2Bemacs%26hl%3Dzh-TW%26client%3Dfirefox-a%26rls%3Dcom.ubuntu:zh-TW:unofficial%26hs%3DvCS%26sa%3DG 在Emacs裡面使用Cscope]
  22. [http://wiki.ubuntu-tw.org/index.php?title=IEs4Linux IEs4Linux]
  23. [http://alexchuo.blogspot.com/2004/09/ntfs.html 將隨身碟格式化成 NTFS]
  24. [http://www.parashift.com/c++-faq-lite/exceptions.html [17] Exceptions and error handling]
  25. [http://developer.apple.com/performance/ Performance (Apple Developer Connection)]
  26. [http://lwn.net/Articles/250967/ What every programmer should know about memory]
  27. Polymorphic Inline Cache
  28. [http://portal.acm.org/citation.cfm?id=1048973 Context Threading: A Flexible and Efficient Dispatch Technique for Virtual Machine Interpreters]
  29. Branch prediction
  30. [http://www.open-std.org/jtc1/sc22/wg21/docs/papers/1997/N1124.pdf http://www.open-std.org/jtc1/sc22/wg...1997/N1124.pdf]
  31. [http://www.linuxprogrammingblog.com/all-about-linux-signals?page=4 All about Linux signals]
  32. [http://garrys-brain.blogspot.com/2007/07/llvm-low-level-virtual-machine.html LLVM - Low-Level Virtual Machine]
  33. [http://cpp.comsci.us/etymology/literals.html C++ Literal Constants]
  34. [http://fred-zone.blogspot.com/2009/08/mips-mipsel.html mips 和 mipsel 的差異]
  35. [http://www.dcs.gla.ac.uk/~tony/teaching/dbis4/dbis4-lecture7.ps Garbage Collection]
  36. [http://www.mail-archive.com/bug-gdb@gnu.org/msg00920.html Re: Problems with glibc-2.2.2 and threads (realtime signal)]
  37. [http://stenlyho.blogspot.com/2009/04/llvm.html 搭建LLVM實驗環境(轉貼)]
  38. [http://blog.fallingsnow.net/2008/05/23/simple-vm-jit-with-llvm/ Simple VM JIT with LLVM]
  39. Communicating sequential processes (CSP) mentioned in Go language
  40. [http://basen.oru.se/kurser/koi/2008-2009-p1/texter/gc/index.html The Very Basics of Garbage Collection] (see 'Myths' section)
  41. Ch interpreter (an embeddable C/C++ interpreter)
  42. JDownloader
  43. [http://android.modaco.com/content/htc-hero-hero-modaco-com/293381/log-out-of-google-account/#entry1080078 Log-Out of Google Account]
  44. [http://www.ubuntu-tw.org/modules/newbb/viewtopic.php?viewmode=thread&topic_id=15005&forum=12 在 Ubuntu 9.04 設置 Android 開發環境]
  45. [http://support.appcelerator.net/faqs/android-dev/java-not-found-java-is-required-for-android Java not found. Java is required for Android]
  46. [http://androidandme.com/2009/10/news/how-to-install-android-sdk-and-play-with-android-2-0-in-the-emulator/ How to install Android SDK and play with Android 2.0 in the emulator]
  47. [http://www.anddev.org/viewtopic.php?p=28991 Access Android Market from Android Emulator]
  48. [http://groups.google.com/group/android-platform/browse_thread/thread/ecefc295092e1921/f1685e8ab2cea737?lnk=gst&q=garbage#f1685e8ab2cea737 Dalvik spends 7.4% of its time garbage collecting => Android UI spends 7.4% of its time unresponsive]
  49. [http://kerneltrap.org/node/4705 Kernel : likely/unlikely macros] (gcc branch prediction information `__builtin_expect()')
  50. [http://hllvm.group.javaeye.com/group/topic/17798 [資料] Dalvik VM的JIT編譯器的資料堆積(dumping...work in progress)]
  51. [http://chaoticjava.com/posts/how-does-garbage-collection-work/ How does garbage collection work?] (generational garbage collector)
  52. [http://research.microsoft.com/en-us/um/people/trishulc/papers/ismm98_distr.ps Using Generational Garbage Collection To Implement Cache-Conscious Data Placement]
  53. [http://jyhshin.pixnet.net/blog/post/26588145 gcc 預先定義的巨集] (__func__, __FUNCTION__, __PRETTY_FUNCTION__)
  54. [http://gcc.gnu.org/ml/gcc-help/2008-05/msg00090.html Re: Force GCC to unroll a loop?] (loop unrolling could consume instruction cache and reduce performance)

=On-line Linux manual=

  1. [http://www.kernel.org/doc/man-pages/index.html Linux man]
  2. [http://www.opengroup.org/onlinepubs/9699919799/ POSIX:2008]
  3. [http://phpunixman.sourceforge.net/ phpMan]
  4. [http://manpages.ubuntu.com/ Ubuntu Manpage]
  5. [http://www.die.net/ die.net]
  6. [http://www.about.com/ About.com]

{{clear}}

Notes

=C++=

  • Try-catch makes the code tidy and readable, without try-catch the code becomes ugly as you need to check the result and handle exceptions after each function call. However, it is performed in run-time and have overhead each time a function is called?

=Firefox=

  • [https://addons.mozilla.org/zh-TW/firefox/addon/1320 Gmail Manager]: A Gmail notifier which allows you to receive new mail notifications.

=Do not feed [[Software bug|bug]]=

==Interactions==

  • Signals
  • File system
  • Out of memory (heap)

==Timing, race conditions, [[program counter]] and execution==

  • Add/remove code usually changes the execution speed of the program. Which could affects the timing between different tasks, such as timeout mechanism or time restrictions in real-time systems. In the extreme case, the execution could be blocked and causes starvations/deadlocks. Add/remove code actually affects the program counter.
  • It should be helpful to prevent deadlock by checking each statement one by one in the locked area and make sure each one will not block the execution.

==Power loss==

=[[Network File System (protocol)|NFS]]=

  1. Sharing folder
  1. Modify '/etc/exports', for example:
  2. /nfstmp *(rw,sync)

sudo /etc/init.d/nfs-kernel-server restart

=Emacs=

  • Ask community if it's a bug: Emacs seems to hang when some of SCIM are killed or closed.

;; You can also use `M-x customize-variable x-select-enable-clipboard ' to change the variable by Emacs UI.

(setq-default x-select-enable-clipboard t)

;;(defun x-clipboard-edit-key()

;; (global-set-key [(shift delete)] 'clipboard-kill-region)

;; (global-set-key [(control insert)] 'clipboard-kill-ring-save)

;; (global-set-key [(shift insert)] 'x-clipboard-yank))

Emacs for MS Windows:

runs the command kill-region

runs the command kill-ring-save

runs the command yank

=SVN tips=

svnadmin cteate /tmp/tstprj

mkdir /tmp/workdir

cd /tmp/workdir

svn co file:///tmp/tstprj

cd tstprj

cp /etc/fstab .

svn add fstab

svn ci --username=justin

cat << 'EOF' > /tmp/PrintPos.sh

  1. !/bin/bash

c=$#

i=1

while [ $i -le $c ]; do

echo "\$$i='$1'"

shift

i=$(($i + 1))

done

EOF

chmod a+x /tmp/PrintPos.sh

cat << 'EOF' > /tmp/ConcurDiffWrap.sh

  1. !/bin/bash
  1. !! There is interval between @a1@ and @a2@ such that other process would
  2. interfere the execution within the interval.

NewTmpDir()

{

local Node

while :; do

Node=$RANDOM

if [ ! -e /tmp/${Node} ]; then # @a1@

mkdir /tmp/${Node} # @a2@

eval "${1}=/tmp/${Node}"

return

fi

done

}

NewTmpDir Dir

mv "$6" "${Dir}/Old" || echo 'Cannot move $6'

echo '' > "$6"

mv "$7" "${Dir}/New" || echo 'Cannot move $7'

echo '' > "$7"

meld "$1" "$2" "$3" "$4" "$5" "${Dir}/Old" "${Dir}/New" &

  1. Print positional parameters.
  2. Put this segment at positions where positional parameter are no longer used,
  3. becasue there are `shift' in this segment.

c=$#

i=1

while [ $i -le $c ]; do

echo "\$$i='$1'"

shift

i=$(($i + 1))

done

echo '==================================================================='

EOF

chmod a+x /tmp/ConcurDiffWrap.sh

svn di -r 2:3 --diff-cmd /tmp/ConcurDiffWrap.sh

=minicom=

  • minicom in English UI

$ LANG=en_US.UTF-8 sudo minicom

  • Ctrl-A Z T and change terminal setting from VT102 to ANSI

=RAM disk=

mkdir /tmp/ramdisk

sudo mount -t tmpfs -o size=16 tmpfs /tmp/ramdisk

sudo umount /tmp/ramdisk

=Bra-ket notation=

==Column vector & row vector==

"The scalar product or action is written as

:\langle\phi{\mid}\psi\rangle.

The right part is called the ket {{IPAc-en|k|ɛ|t}}; it is a vector, typically represented as a column vector, and written |\psi\rangle.

The left part is called the bra, {{IPAc-en|b|r|ɑː}}; it is the Hermitian conjugate of the ket with the same label, typically represented as a row vector, and written \langle\phi|." - [https://en.wikipedia.org/w/index.php?title=Bra%E2%80%93ket_notation&oldid=902061330 Bra–ket notation]

==Tensor product in bra-ket notation and vector form==

:| 0 \rangle = \begin{bmatrix} 1 \\ 0 \end{bmatrix} and | 1 \rangle = \begin{bmatrix} 0 \\ 1 \end{bmatrix}

:| \psi_1 \rangle = a | 0 \rangle + b | 1 \rangle = a\begin{bmatrix} 1 \\ 0 \end{bmatrix} + b\begin{bmatrix} 0 \\ 1 \end{bmatrix} = \begin{bmatrix} a \\ 0 \end{bmatrix} + \begin{bmatrix} 0 \\ b \end{bmatrix} = \begin{bmatrix} a \\ b \end{bmatrix}

:| \psi_2 \rangle = c | 0 \rangle + d | 1 \rangle = \begin{bmatrix} c \\ d \end{bmatrix}

:| 0 0 \rangle = | 0 \rangle \otimes | 0 \rangle = \begin{bmatrix} 1 \\ 0 \end{bmatrix} \otimes \begin{bmatrix} 1 \\ 0 \end{bmatrix} = \begin{bmatrix} 1 \\ 0 \\ 0 \\ 0 \end{bmatrix}

:| 0 1 \rangle = | 0 \rangle \otimes | 1 \rangle = \begin{bmatrix} 1 \\ 0 \end{bmatrix} \otimes \begin{bmatrix} 0 \\ 1 \end{bmatrix} = \begin{bmatrix} 0 \\ 1 \\ 0 \\ 0 \end{bmatrix}

:| 1 0 \rangle = | 1 \rangle \otimes | 0 \rangle = \begin{bmatrix} 0 \\ 1 \end{bmatrix} \otimes \begin{bmatrix} 1 \\ 0 \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ 1 \\ 0 \end{bmatrix}

:| 1 1 \rangle = | 1 \rangle \otimes | 1 \rangle = \begin{bmatrix} 0 \\ 1 \end{bmatrix} \otimes \begin{bmatrix} 0 \\ 1 \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ 0 \\ 1 \end{bmatrix}

:| \psi_1 \psi_2 \rangle = | \psi_1 \rangle \otimes | \psi_2 \rangle = (a | 0 \rangle + b | 1 \rangle) \otimes (c | 0 \rangle + d | 1 \rangle) = ac| 0 \rangle \otimes | 0 \rangle + ad| 0 \rangle \otimes | 1 \rangle + bc| 1 \rangle \otimes | 0 \rangle + bd| 1 \rangle \otimes | 1 \rangle = ac| 0 0 \rangle + ad| 0 1 \rangle + bc| 1 0 \rangle + bd| 1 1 \rangle = ac \begin{bmatrix} 1 \\ 0 \\ 0 \\ 0 \end{bmatrix} + ad \begin{bmatrix} 0 \\ 1 \\ 0 \\ 0 \end{bmatrix} + bc \begin{bmatrix} 0 \\ 0 \\ 1 \\ 0 \end{bmatrix} + bd \begin{bmatrix} 0 \\ 0 \\ 0 \\ 1 \end{bmatrix} = \begin{bmatrix} ac \\ ad \\ bc \\ bd \end{bmatrix}

:| \psi_1 \psi_2 \rangle = | \psi_1 \rangle \otimes | \psi_2 \rangle = \begin{bmatrix} a \\ b \end{bmatrix} \otimes \begin{bmatrix} c \\ d \end{bmatrix} = \begin{bmatrix} ac \\ ad \\ bc \\ bd \end{bmatrix}

=Quantum computer=

  1. "Any quantum circuit can be simulated to an arbitrary degree of accuracy using a combination of CNOT gates and single qubit rotations." - [https://en.wikipedia.org/w/index.php?title=Controlled_NOT_gate&oldid=829202356 Controlled NOT gate]
  2. "The first implementation scheme for a controlled-NOT quantum gate was proposed by Ignacio Cirac and Peter Zoller in 1995" - [https://en.wikipedia.org/w/index.php?title=Trapped_ion_quantum_computer&oldid=822476820#History_of_trapped_ion_quantum_computing Trapped_ion_quantum_computer#History_of_trapped_ion_quantum_computing]
  3. "Because the number of elements in the matrices is 2^{2x}, where x is the number of qubits the gates act on, it is intractable to simulate large quantum systems using classical computers." - [https://en.wikipedia.org/w/index.php?title=Quantum_gate&oldid=829643224#Circuit_composition_and_entangled_states Quantum_gate#Circuit_composition_and_entangled_states]

==Quantum gate - Square root of NOT gate ({{math|{{radic|NOT}}}})==

: X = NOT = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}.

:\sqrt{X} = \sqrt{NOT} = \frac{1}{2} \begin{bmatrix} 1+i & 1-i \\ 1-i & 1+i \end{bmatrix}

:\sqrt{NOT} \, \sqrt{NOT} = \left( \frac{1}{2} \begin{bmatrix} 1+i & 1-i \\ 1-i & 1+i \end{bmatrix} \right) \left( \frac{1}{2} \begin{bmatrix} 1+i & 1-i \\ 1-i & 1+i \end{bmatrix} \right)

:= \begin{bmatrix} \frac{1}{2} (1+i) & \frac{1}{2} (1-i) \\ \frac{1}{2} (1-i) & \frac{1}{2} (1+i) \end{bmatrix} \begin{bmatrix} \frac{1}{2} (1+i) & \frac{1}{2} (1-i) \\ \frac{1}{2} (1-i) & \frac{1}{2} (1+i) \end{bmatrix}

:= \begin{bmatrix} \frac{1}{2} (1+i) \frac{1}{2} (1+i) + \frac{1}{2} (1-i) \frac{1}{2} (1-i) & \frac{1}{2} (1+i) \frac{1}{2} (1-i) + \frac{1}{2} (1-i) \frac{1}{2} (1+i) \\ \frac{1}{2} (1-i) \frac{1}{2} (1+i) + \frac{1}{2} (1+i)\frac{1}{2} (1-i) & \frac{1}{2} (1-i) \frac{1}{2} (1-i) + \frac{1}{2} (1+i) \frac{1}{2} (1+i) \end{bmatrix}

:= \begin{bmatrix} \frac{1}{2} (1+i) \frac{1}{2} (1+i) + \frac{1}{2} (1-i) \frac{1}{2} (1-i) & \frac{1}{2} (1+i) \frac{1}{2} (1-i) + \frac{1}{2} (1-i) \frac{1}{2} (1+i) \\ \frac{1}{2} (1+i) \frac{1}{2} (1-i) + \frac{1}{2} (1-i) \frac{1}{2} (1+i) & \frac{1}{2} (1+i) \frac{1}{2} (1+i) + \frac{1}{2} (1-i) \frac{1}{2} (1-i) \end{bmatrix}

:= \begin{bmatrix} \frac{1}{2} \frac{1}{2} (1+i)(1+i) + \frac{1}{2} \frac{1}{2} (1-i)(1-i) & \frac{1}{2} \frac{1}{2} (1+i)(1-i) + \frac{1}{2} \frac{1}{2} (1-i)(1+i) \\ \frac{1}{2} \frac{1}{2} (1+i)(1-i) + \frac{1}{2} \frac{1}{2} (1-i)(1+i) & \frac{1}{2} \frac{1}{2} (1+i)(1+i) + \frac{1}{2} \frac{1}{2} (1-i)(1-i) \end{bmatrix}

:= \begin{bmatrix} \frac{1}{4} (1+i)(1+i) + \frac{1}{4} (1-i)(1-i) & \frac{1}{4} (1+i)(1-i) + \frac{1}{4} (1-i)(1+i) \\ \frac{1}{4} (1+i)(1-i) + \frac{1}{4} (1-i)(1+i) & \frac{1}{4} (1+i)(1+i) + \frac{1}{4} (1-i)(1-i) \end{bmatrix}

:= \begin{bmatrix} \frac{1}{4} [(1+i)(1+i) + (1-i)(1-i)] & \frac{1}{4} [(1+i)(1-i) + (1-i)(1+i)] \\ \frac{1}{4} [(1+i)(1-i) + (1-i)(1+i)] & \frac{1}{4} [(1+i)(1+i) + (1-i)(1-i)] \end{bmatrix}

:= \frac{1}{4} \begin{bmatrix} (1+i)(1+i) + (1-i)(1-i) & (1+i)(1-i) + (1-i)(1+i) \\ (1+i)(1-i) + (1-i)(1+i) & (1+i)(1+i) + (1-i)(1-i) \end{bmatrix}

:= \frac{1}{4} \begin{bmatrix} (1+i+i+i^2) + (1-i-i+i^2) & (1-i+i-i^2) + (1+i-i-i^2) \\ (1-i+i-i^2) + (1+i-i-i^2) & (1+i+i+i^2) + (1-i-i+i^2) \end{bmatrix}

:= \frac{1}{4} \begin{bmatrix} (1+2i-1) + (1-2i-1) & (1-(-1)) + (1-(-1)) \\ (1-(-1)) + (1-(-1)) & (1+2i-1) + (1-2i-1) \end{bmatrix}

:= \frac{1}{4} \begin{bmatrix} 2i + (-2i) & 2 + 2 \\ 2 + 2 & 2i + (-2i) \end{bmatrix}

:= \frac{1}{4} \begin{bmatrix} 0 & 4 \\ 4 & 0 \end{bmatrix}

:= \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} = NOT = X

In fact, you can use the service of online symbolic mathematics to do the above work for you. Related links:

  1. [http://www.mathics.net Mathics]
  2. [https://math.stackexchange.com/questions/44428/online-tools-for-doing-symbolic-mathematics Online tools for doing symbolic mathematics - Mathematics Stack Exchange]

==Quantum gate - Example of operation parallelism==

p_{00}: \, \, | 0 0 \rangle \mapsto | 0 0 \rangle

p_{01}: \, \, | 0 1 \rangle \mapsto | 0 1 \rangle

p_{10}: \, \, | 1 0 \rangle \mapsto | 1 1 \rangle

p_{11}: \, \, | 1 1 \rangle \mapsto | 1 0 \rangle

The meaning of notation above:

:For example, state | 0 1 \rangle means that the first qubit is 0 and the second qubit is 1. If, for example, p_{01}=0.7, it means that state | 0 1 \rangle appears with probability 0.7 after measurements.

The above map is the result of a series of quntum program executions which applying CNOT gate on the system. But you can not know the map beforehand, so how to know the value of the second qubit after applying the quantum gate operation above? Here is what you may do:

:You should be able to encode the system so that each state appears with the probability according to your design. Suppose that you encode the system so that the probability distribution is

::p_{00}=0.4

::p_{01}=0.3

::p_{10}=0.2

::p_{11}=0.1

:(note that p_{00} + p_{01} + p_{10} + p_{11} = 1)

:Suppose that you want to know the second qubit's value of state | 1 0 \rangle after the quantum operation. Because the corresponding probability you have encoded is p_{10}=0.2, you should be able to find one of 4 after-operation states | 0 0 \rangle, | 0 1 \rangle, | 1 0 \rangle and | 1 1 \rangle appears with probability 0.2 as you repeat the quantum program over and over several times. And you will finally realize that state | 1 1 \rangle appears with probability 0.2 after you repeat enough the quantum program, so it means the state transition is from | 1 0 \rangle to | 1 1 \rangle and therefore the second qubit's value changes from 0 to 1 after the quantum operation.

==Applying a 2-qubit CNOT gate to 3 qubits==

\mbox{CNOT}=\left(\begin{array}{cccc} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 0 & 1\\ 0 & 0 & 1 & 0\end{array}\right)

I \otimes \mbox{CNOT} =

\left(\begin{array}{cc} 1 & 0 \\ 0 & 1\end{array}\right) \otimes \left(\begin{array}{cccc} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 0 & 1\\ 0 & 0 & 1 & 0\end{array}\right) =

\left(\begin{array}{cccccccc} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0\\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1\\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0\end{array}\right)

| \psi \rangle = \left(\begin{array}{c} a\\ b\\ c\\ d\\ e\\ f\\ g\\ h\end{array}\right)

(I \otimes \mbox{CNOT}) | \psi \rangle =

\left(\begin{array}{cccccccc} 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0\\ 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0\\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1\\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0\end{array}\right)

\left(\begin{array}{c} a\\ b\\ c\\ d\\ e\\ f\\ g\\ h\end{array}\right) =

\left(\begin{array}{c} a\\ b\\ d\\ c\\ e\\ f\\ h\\ g\end{array}\right)

\, \, \, \begin{array}{c} \text{qubits 000}\\ \text{qubits 001}\\ \text{qubits 010}\\ \text{qubits 011}\\ \text{qubits 100}\\ \text{qubits 101}\\ \text{qubits 110}\\ \text{qubits 111}\end{array}

=Reinforcement learning=

  1. "If the discount factor meets or exceeds 1, the Q values may diverge." - [https://en.wikipedia.org/w/index.php?title=State%E2%80%93action%E2%80%93reward%E2%80%93state%E2%80%93action&oldid=829903292#Discount_factor_(gamma) State–action–reward–state–action#Discount_factor_(gamma)]

==Deterministic and simplified Q functions of reinforcement learning==

Simplify by letting \alpha = \gamma = 1. The result should be more close to dynamic programming.

Q-learning

:Q(s_{t},a_{t}) \leftarrow (1-\alpha) \cdot \underbrace{Q(s_{t},a_{t})}_{\rm old~value} + \underbrace{\alpha}_{\rm learning~rate} \cdot \overbrace{\bigg( \underbrace{r_{t}}_{\rm reward} + \underbrace{\gamma}_{\rm discount~factor} \cdot \underbrace{\max_{a}Q(s_{t+1}, a)}_{\rm estimate~of~optimal~future~value} \bigg) }^{\rm learned~value}

:Q(s_{t},a_{t}) \leftarrow (1-\alpha) \cdot Q(s_{t},a_{t}) + \alpha \cdot \overbrace{\bigg( r_{t} + \gamma \cdot \max_{a}Q(s_{t+1}, a) \bigg) }^{\rm learned~value}

:Q(s_{t},a_{t}) \leftarrow (1-\alpha) \cdot Q(s_{t},a_{t}) + \alpha \cdot \bigg( r_{t} + \gamma \cdot \max_{a}Q(s_{t+1}, a) \bigg)

:Q(s_{t},a_{t}) \leftarrow r_{t} + \max_{a}Q(s_{t+1}, a)

SARSA

:Q(s_t,a_t) \leftarrow Q(s_t,a_t) + \alpha [r_{t} + \gamma Q(s_{t+1}, a_{t+1})-Q(s_t,a_t)]

:Q(s_t,a_t) \leftarrow Q(s_t,a_t) + [r_{t} + \gamma Q(s_{t+1}, a_{t+1})-Q(s_t,a_t)]

:Q(s_t,a_t) \leftarrow Q(s_t,a_t) + r_{t} + \gamma Q(s_{t+1}, a_{t+1})-Q(s_t,a_t)

:Q(s_t,a_t) \leftarrow r_{t} + Q(s_{t+1}, a_{t+1})

Self-pipe trick

int pipefd[2];

void handler(int signum)

{

char ch = 0;

write(pipefd[1], &ch, sizeof(ch));

}

void startRoutine(SIMP_SOCK_Arg_T *arg)

{

// ...

pipe(pipefd);

fcntl(pipefd[0], F_SETFL, fcntl(pipefd[0], F_GETFL) | O_NONBLOCK);

fcntl(pipefd[1], F_SETFL, fcntl(pipefd[1], F_GETFL) | O_NONBLOCK);

signal(SIGTERM, handler);

FD_ZERO(&rfds);

FD_SET(arg->mSock.mSocket, &rfds);

FD_SET(pipefd[0], &rfds);

// ...

while (1)

{

_rfds = rfds;

// ...

if (select(maxfd + 1, &_rfds, &_wfds, NULL, NULL) == -1)

{

if (errno == EINTR) continue;

break;

}

// ... read()/write() socket and process data ...

// There could be resource allocation somewhere

void *p = malloc(...);

// ... do something about *p ...

free(p);

if (FD_ISSET(pipefd[0], &_rfds))

{

char ch;

read(pipefd[0], &ch, sizeof(ch));

break;

}

}

// ...

}

Raw Watchlist

Adiabatic quantum computation

BKL singularity

BadVista

Bing

Bing (Search)

Bing (search engine)

Bing (web search engine)

Cavity quantum electrodynamics

Classical test theory

Cluster state

Coherence (physics)

Convolution

Criticism of Google

Criticism of Microsoft

Criticism of Wikipedia

Criticism of Windows 7

Device driver

Dirac delta function

Direct Rendering Manager

Euler's theorem (differential geometry)

Evolute

Fourier series

Freedesktop.org

Git (software)

Google

Google platform

Graphics Execution Manager

Guievict

Internet Explorer 8

Jordan curve theorem

Keith Packard

LOCC

Lagrange's identity

Library (computing)

List of unsolved problems in physics

Loadable kernel module

MeeGo

MeeGo (operating system)

Method of characteristics

Metric tensor

MicroXwin

Microsoft

Microsoft Office 2007

Möbius transformation

Nitrogen-vacancy center

O(1) scheduler

Office Open XML

One-way quantum computer

OpenDocument

OpenDocument software

Optical lattice

Optical pumping

Overlap-add method

Overlap–add method

Phasor

Phasor (sine waves)

Pseudo-differential operator

Pythagorean triple

Qt (framework)

Quantum channel

Quantum cryptography

Quantum error correction

Quantum gate

Quantum information

Quantum key distribution

Quantum mechanical Bell test prediction

Quantum programming

Quantum teleportation

Quasiconformal mapping

Qubit

Ratio test

Riesz transform

Selection rule

Separable state

Separable states

Squashed entanglement

Standardization of Office Open XML

Sturm-Liouville theory

Sturm–Liouville theory

Superconducting quantum computing

Topological computing

Topological quantum computer

Trapped ion quantum computer

Universal quantum simulator

Unsolved problems in physics

Wayland (display server)

Wayland (display server protocol)

Wayland display server

Windowing system

Windows 7

Windows 7/Archive 7

X Window System

Xmove

Xpra

User:HAl

User:Justin545/Blog comments

User:Justin545/Blogger

User:Justin545/IRC

User:Justin545/Private Note

User:Silly rabbit

Template:NumBlk

Template:NumBlk/doc

template:NumBlk & lists

  • xyz

  • abc

{{NumBlk|Border=.||f(x) = a x + b|77}}

{{NumBlk|Border=.||f(x) = a x + b|37}}

  • {{NumBlk|Border=.||f(x) = a x + b|17}}

  • {{NumBlk|Border=.||f(x) = a x + b|57}}

{{NumBlk|Border=.||f(x) = a x + b|97}}

{{NumBlk|Border=.||f(x) = a x + b|67}}

=Pages may be with issues=