Skip to content

Instantly share code, notes, and snippets.

@HajimeKawahara
Last active January 4, 2016 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HajimeKawahara/c46a63640b8ae397249a to your computer and use it in GitHub Desktop.
Save HajimeKawahara/c46a63640b8ae397249a to your computer and use it in GitHub Desktop.
complex array
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Julia 複素行列について"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 参考1 https://en.wikibooks.org/wiki/Introducing_Julia/Arrays_and_tuples\n",
"## 参考2 http://docs.julialang.org/en/release-0.4/stdlib/linalg/"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1. row vectorと1 x N matrixは異なる"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"3-element Array{Complex{Int64},1}:\n",
" 1+1im\n",
" 1-2im\n",
" 0+0im"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a = [1+1im,1-2im,0]"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"1x3 Array{Complex{Int64},2}:\n",
" 1+1im 1-2im 0+0im"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"b = [1+1im 1-2im 0]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 上記のようにcommaをつけて定義すると、row vectorに、spaceで定義すると1 x N matrixとなる\n",
"## 1 x N matrixを row vectorに変換したいとき"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"1x3 Array{Complex{Int64},2}:\n",
" 1+1im 1-2im 0+0im"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"b[1,:]"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### 上ではだめで"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"3-element Array{Complex{Int64},1}:\n",
" 1+1im\n",
" 1-2im\n",
" 0+0im"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"c = transpose(b)[:,1]"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"true"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a == c"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### のようにしないとならない"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 2. 転置について\n",
"### 転置には、単なる転置(transpose)と複素共役転置がある"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"1x3 Array{Complex{Int64},2}:\n",
" 1+1im 1-2im 0+0im"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"transpose(a)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"1x3 Array{Complex{Int64},2}:\n",
" 1-1im 1+2im 0+0im"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ctranspose(a)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 紛らわしいのは省略記号がそれぞれ(.')と(')であることである"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"1x3 Array{Complex{Int64},2}:\n",
" 1+1im 1-2im 0+0im"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a.'"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"1x3 Array{Complex{Int64},2}:\n",
" 1-1im 1+2im 0+0im"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a'"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 特に(')は実数行列では単なる転置なのでそれに慣れてしまうと、\n",
"## 複素行列の時に複素共役をとる操作がはいっていることを忘れてしまうことである"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 0.4.2",
"language": "julia",
"name": "julia-0.4"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "0.4.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment